Initial commit

This commit is contained in:
thecookingsenpai 2023-12-25 13:24:49 +01:00
commit 4ed9de4bd8
6 changed files with 150 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
appero/node_modules/*
appero/package-lock.json
appero/yarn.lock
appero/MACOSX*
.DS_Store
appero/.installed

39
Appero! Executable file
View File

@ -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

18
README.md Normal file
View File

@ -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.

68
appero/appero.js Normal file
View File

@ -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');
}

BIN
appero/baseapp.zip Normal file

Binary file not shown.

17
appero/package.json Normal file
View File

@ -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"
}
}