commit 4ed9de4bd80ef4a65790e48616bfd9984c4a1149 Author: thecookingsenpai Date: Mon Dec 25 13:24:49 2023 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7091e6f --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +appero/node_modules/* +appero/package-lock.json +appero/yarn.lock +appero/MACOSX* + +.DS_Store + +appero/.installed diff --git a/Appero! b/Appero! new file mode 100755 index 0000000..cdfe3a2 --- /dev/null +++ b/Appero! @@ -0,0 +1,39 @@ +#!/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 new file mode 100644 index 0000000..a5d6b96 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# Appero + +![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. diff --git a/appero/appero.js b/appero/appero.js new file mode 100644 index 0000000..c6a8944 --- /dev/null +++ b/appero/appero.js @@ -0,0 +1,68 @@ +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 new file mode 100644 index 0000000..d4c187e Binary files /dev/null and b/appero/baseapp.zip differ diff --git a/appero/package.json b/appero/package.json new file mode 100644 index 0000000..47a371d --- /dev/null +++ b/appero/package.json @@ -0,0 +1,17 @@ +{ + "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" + } +}