diff --git a/.gitignore b/.gitignore index 7091e6f..2cabec8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ -appero/node_modules/* -appero/package-lock.json -appero/yarn.lock -appero/MACOSX* - -.DS_Store - -appero/.installed +installation/baseapp/node_modules +installation/baseapp/package-lock.json +installation/baseapp/yarn.lock +installation/baseapp/tmp +.trunk +.DS_Store \ No newline at end of file diff --git a/Appero! b/Appero! deleted file mode 100755 index cdfe3a2..0000000 --- a/Appero! +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/zsh -mydir=${0:a:h} -cd $mydir -echo $mydir -cd appero - - -# Check for installed file -if [ ! -f .installed ]; then - echo "Installing appero..." - # Install Homebrew - if [ ! -f /opt/homebrew/bin/brew ]; then - echo "Installing Homebrew..." - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - else - echo "Homebrew already installed" - fi - - if which node > /dev/null - then - echo "node is installed, skipping..." - else - echo "Installing node..." - # Install Homebrew packages - brew install node - fi - - # Install npm packages - echo "Installing npm packages..." - npm install - - touch .installed -fi - -echo "Starting appero..." - -# Run -node appero.js - diff --git a/README.md b/README.md index a5d6b96..8fd720c 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,4 @@ -# Appero +# Appetite (was Appero'!) +The simplest and lightest way to transform websites into native apps -![icon](https://user-images.githubusercontent.com/67682496/210121840-20aef54e-41e9-4b9a-87ac-a065eac8ded7.png) - - -## The easiest way to create a native application from any website - -### Installation and usage - -Download the release and double click on Appero! or: - - git clone https://github.com/thecookingsenpai/appero && cd appero - ./Appero! - - -At the first launch Appero might have to download and install node.js, brew and the required packages. This will happens only once. - -Once finished, the application will be available in the appero/apps folder. +## Work in Progress \ No newline at end of file diff --git a/appero/appero.js b/appero/appero.js deleted file mode 100644 index c6a8944..0000000 --- a/appero/appero.js +++ /dev/null @@ -1,68 +0,0 @@ -const fse = require('fs-extra'); -var request = require("request"); -const decompress = require("decompress"); -const prompt = require("prompt-sync")({ sigint: true }); - -var url = prompt("URL: "); -var name = prompt("Name: "); - -decompress("baseapp.zip", "./") - .then(() => { - main(); - }) - -function main() { - - // Arguments parsing - console.log(url) - // Safety check - if(!url) { - console.error('No URL specified'); - process.exit(1); - } else if ( (!url.startsWith('http://')) && (!url.startsWith('https://')) ) { - console.error('URL must start with http:// or https://'); - process.exit(1); - } - // Trying to get favicon - try { - var stream = request(url + "/favicon.ico").pipe(fse.createWriteStream('favicon.ico')) - stream.on('finish', function () { - if (fse.existsSync("favicon.ico")) { - finalWrap(true) - } - }) - } catch (err) { - console.log("No favicon") - finalWrap(false) - } - - -} - - -function finalWrap(fav) { - // Wrapping with random id - var folder_name - if (name==="") { - var rid = Math.floor(Math.random() * 8192); - folder_name = "./apps/app_" + rid - } else { - folder_name = name; - } - fse.copySync("./baseapp.app", folder_name) - // Writing location - fse.writeFileSync(folder_name + "/Contents/MacOS/location.config", url, "utf8") - // Changing name - var plist = fse.readFileSync(folder_name + "/Contents/Info.plist", "utf8") - var newPlist = plist.replace("Appero Native App", folder_name) - fse.writeFileSync(folder_name + "/Contents/Info.plist", newPlist, "utf8") - // Icon - if (fav) { - fse.removeSync(folder_name + "/Contents/Resources/electron.icns") - fse.moveSync("favicon.ico", folder_name + "/Contents/Resources/electron.icns") - } - // Packing - fse.moveSync(folder_name, folder_name + ".app") - fse.removeSync("baseapp.app") - console.log('Done'); -} \ No newline at end of file diff --git a/appero/baseapp.zip b/appero/baseapp.zip deleted file mode 100644 index d4c187e..0000000 Binary files a/appero/baseapp.zip and /dev/null differ diff --git a/appero/package.json b/appero/package.json deleted file mode 100644 index 47a371d..0000000 --- a/appero/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "appero", - "version": "1.0.0", - "description": "URLs to native apps", - "main": "appero.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "TCSenpai", - "license": "ISC", - "devDependencies": { - "fs-extra": "^11.1.0", - "prompt-sync": "^4.2.0", - "request": "^2.88.2", - "decompress": "^4.2.1" - } -} diff --git a/installation/.github/CODEOWNERS b/installation/.github/CODEOWNERS new file mode 100644 index 0000000..7639191 --- /dev/null +++ b/installation/.github/CODEOWNERS @@ -0,0 +1 @@ +* @electron/wg-ecosystem diff --git a/installation/.github/dependabot.yml b/installation/.github/dependabot.yml new file mode 100644 index 0000000..3a1f0c4 --- /dev/null +++ b/installation/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: +- package-ecosystem: npm + directory: "/" + schedule: + interval: daily + time: "13:00" + open-pull-requests-limit: 99 + versioning-strategy: increase diff --git a/installation/.github/workflows/add-to-project.yml b/installation/.github/workflows/add-to-project.yml new file mode 100644 index 0000000..60b1cb7 --- /dev/null +++ b/installation/.github/workflows/add-to-project.yml @@ -0,0 +1,29 @@ +name: Add to Ecosystem WG Project + +on: + issues: + types: + - opened + pull_request_target: + types: + - opened + +permissions: {} + +jobs: + add-to-project: + runs-on: ubuntu-latest + steps: + - name: Generate GitHub App token + uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1 + id: generate-token + with: + creds: ${{ secrets.ECOSYSTEM_ISSUE_TRIAGE_GH_APP_CREDS }} + org: electron + - name: Add to Project + uses: dsanders11/project-actions/add-item@3a81985616963f32fae17d1d1b406c631f3201a1 # v1.1.0 + with: + field: Opened + field-value: ${{ github.event.pull_request.created_at || github.event.issue.created_at }} + project-number: 89 + token: ${{ steps.generate-token.outputs.token }} diff --git a/installation/baseapp/baselauncher b/installation/baseapp/baselauncher new file mode 100644 index 0000000..89d51f9 --- /dev/null +++ b/installation/baseapp/baselauncher @@ -0,0 +1,2 @@ + +echo { \"target_url\": \"$URL\" } > $HOME/.config/appetite/config.json && yarn start . diff --git a/installation/baseapp/index.html b/installation/baseapp/index.html new file mode 100644 index 0000000..4ec7052 --- /dev/null +++ b/installation/baseapp/index.html @@ -0,0 +1,12 @@ + + + + + + + Appetite Control Center + + +

Please use a proper Appetite app

+ + diff --git a/installation/baseapp/main.js b/installation/baseapp/main.js new file mode 100644 index 0000000..79f020f --- /dev/null +++ b/installation/baseapp/main.js @@ -0,0 +1,73 @@ +// Modules to control application life and create native browser window +const { app, BrowserWindow } = require('electron') +const path = require('node:path') + + +const Store = require('electron-store'); +const { url } = require('node:inspector'); +const store = new Store(); + +// /home/user/.config/appname +console.log(app.getPath('userData')); + +store.set('unicorn', '🦄'); +console.log(store.get('unicorn')); +//=> '🦄' + +let target_url = undefined +try { + // (if any) We load the URLs + let url_list = store.get('url_list') + url_list = JSON.parse(url_list) + // (if any) We load the index + let index_url = store.get('index_url') + // (if possible) We load the indexed URL + target_url = url_list[index_url] +} catch (error) { + //console.log(error) + target_url = store.get('target_url') +} +console.log(target_url); + +function createWindow () { + // Create the browser window. + const mainWindow = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + } + }) + + // and load the index.html of the app. + if (target_url || target_url === "base") { + mainWindow.loadURL(target_url) + } else { + mainWindow.loadFile('index.html') + } + + // Open the DevTools. + // mainWindow.webContents.openDevTools() +} + +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +// Some APIs can only be used after this event occurs. +app.whenReady().then(() => { + createWindow() + + app.on('activate', function () { + // On macOS it's common to re-create a window in the app when the + // dock icon is clicked and there are no other windows open. + if (BrowserWindow.getAllWindows().length === 0) createWindow() + }) +}) + +// Quit when all windows are closed, except on macOS. There, it's common +// for applications and their menu bar to stay active until the user quits +// explicitly with Cmd + Q. +app.on('window-all-closed', function () { + if (process.platform !== 'darwin') app.quit() +}) + +// In this file you can include the rest of your app's specific main process +// code. You can also put them in separate files and require them here. diff --git a/installation/baseapp/package.json b/installation/baseapp/package.json new file mode 100644 index 0000000..5d29703 --- /dev/null +++ b/installation/baseapp/package.json @@ -0,0 +1,22 @@ +{ + "name": "appetite", + "version": "2.0.0", + "description": "Websites to Linux native apps!", + "main": "main.js", + "scripts": { + "start": "electron ." + }, + "repository": "https://github.com/tcsenpai/appetite", + "keywords": [ + ], + "author": "tcsenpai", + "license": "CC0-1.0", + "devDependencies": { + "electron": "^28.1.4", + "electron-builder": "^24.9.1" + }, + "dependencies": { + "electron-store": "^8.1.0", + "fs": "^0.0.1-security" + } +} diff --git a/installation/bin/appetite b/installation/bin/appetite new file mode 100755 index 0000000..a5395f4 --- /dev/null +++ b/installation/bin/appetite @@ -0,0 +1,23 @@ +#!/bin/bash +cd ../baseapp + +# Input an url from the user +echo "Enter the url of the website you want to save as a native app: " +read url +echo $url +echo "Enter the app name:" +read appname +echo $appname created successfully. + +cp baselauncher tmp +SCRIPT=$(cat tmp) +HEADER="#!/bin/bash" +CHDIR="cd ../baseapp/" +PRESCRIPT="URL=$url" + +echo -e $HEADER "\n" $CHDIR "\n" $PRESCRIPT "\n" $SCRIPT > $appname +chmod +x $appname + +mv $appname ../bin/ +cd ../bin/ +ls \ No newline at end of file diff --git a/installation/bin/google b/installation/bin/google new file mode 100755 index 0000000..645e4ff --- /dev/null +++ b/installation/bin/google @@ -0,0 +1,4 @@ +#!/bin/bash + cd ../baseapp/ + URL=https://google.it + echo { \"target_url\": \"$URL\" } > $HOME/.config/appetite/config.json && yarn start . diff --git a/installation/bin/youtube b/installation/bin/youtube new file mode 100755 index 0000000..07a6a26 --- /dev/null +++ b/installation/bin/youtube @@ -0,0 +1,4 @@ +#!/bin/bash + cd ../baseapp/ + URL=https://youtube.com + echo { \"target_url\": \"$URL\" } > $HOME/.config/appetite/config.json && yarn start . diff --git a/installation/install b/installation/install new file mode 100755 index 0000000..e2955e9 --- /dev/null +++ b/installation/install @@ -0,0 +1,22 @@ +#!/bin/bash + +# Ensuring we have nodejs +if ! [ -x "$(command -v node)" ]; then + echo 'Error: node is not installed.' >&2 + echo 'Please install nodejs and try again.' + exit 1 +fi + +# Collecting dependencies +cd "baseapp" && npm install + +cd .. +echo "You should be able to run bin/appetite now" +echo "" +echo "> Quickstart: you can create native apps by executing:" +echo "cd bin && ./appetite" +echo "> Follow the instructions and you will have the app ready in bin/appname" +echo "> To launch the app, simply run the following command:" +echo "cd bin/ && ./appname" +echo "" +echo "Enjoy!" \ No newline at end of file