mirror of
https://github.com/tcsenpai/appetite.git
synced 2025-06-06 01:05:20 +00:00
Rewritten for linux / mac compatibility
This commit is contained in:
parent
4ed9de4bd8
commit
43e2b3f5fe
12
.gitignore
vendored
12
.gitignore
vendored
@ -1,8 +1,6 @@
|
|||||||
appero/node_modules/*
|
installation/baseapp/node_modules
|
||||||
appero/package-lock.json
|
installation/baseapp/package-lock.json
|
||||||
appero/yarn.lock
|
installation/baseapp/yarn.lock
|
||||||
appero/MACOSX*
|
installation/baseapp/tmp
|
||||||
|
.trunk
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
appero/.installed
|
|
||||||
|
39
Appero!
39
Appero!
@ -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
|
|
||||||
|
|
20
README.md
20
README.md
@ -1,18 +1,4 @@
|
|||||||
# Appero
|
# Appetite (was Appero'!)
|
||||||
|
The simplest and lightest way to transform websites into native apps
|
||||||
|
|
||||||

|
## Work in Progress
|
||||||
|
|
||||||
|
|
||||||
## 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.
|
|
@ -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');
|
|
||||||
}
|
|
Binary file not shown.
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
1
installation/.github/CODEOWNERS
vendored
Normal file
1
installation/.github/CODEOWNERS
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
* @electron/wg-ecosystem
|
9
installation/.github/dependabot.yml
vendored
Normal file
9
installation/.github/dependabot.yml
vendored
Normal file
@ -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
|
29
installation/.github/workflows/add-to-project.yml
vendored
Normal file
29
installation/.github/workflows/add-to-project.yml
vendored
Normal file
@ -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 }}
|
2
installation/baseapp/baselauncher
Normal file
2
installation/baseapp/baselauncher
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
echo { \"target_url\": \"$URL\" } > $HOME/.config/appetite/config.json && yarn start .
|
12
installation/baseapp/index.html
Normal file
12
installation/baseapp/index.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||||
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
|
||||||
|
<title>Appetite Control Center</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Please use a proper Appetite app</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
73
installation/baseapp/main.js
Normal file
73
installation/baseapp/main.js
Normal file
@ -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.
|
22
installation/baseapp/package.json
Normal file
22
installation/baseapp/package.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
23
installation/bin/appetite
Executable file
23
installation/bin/appetite
Executable file
@ -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
|
4
installation/bin/google
Executable file
4
installation/bin/google
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd ../baseapp/
|
||||||
|
URL=https://google.it
|
||||||
|
echo { \"target_url\": \"$URL\" } > $HOME/.config/appetite/config.json && yarn start .
|
4
installation/bin/youtube
Executable file
4
installation/bin/youtube
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd ../baseapp/
|
||||||
|
URL=https://youtube.com
|
||||||
|
echo { \"target_url\": \"$URL\" } > $HOME/.config/appetite/config.json && yarn start .
|
22
installation/install
Executable file
22
installation/install
Executable file
@ -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!"
|
Loading…
x
Reference in New Issue
Block a user