This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from strukturart/package_script
add a build and a package script
- Loading branch information
Showing
10 changed files
with
212 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Build and upload artifact | ||
on: push | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set Node.js 12.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12.x | ||
|
||
- name: npm install | ||
run: npm install | ||
|
||
- name: build | ||
run: npm run package | ||
|
||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: App | ||
path: build/bhacker-store.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build | ||
tmp | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,72 @@ | ||
var path; | ||
|
||
|
||
var sdcard = navigator.getDeviceStorage('sdcard'); | ||
|
||
sdcard.addEventListener("change", function(event) { | ||
|
||
var reason = event.reason; | ||
path = event.path; | ||
install(path) | ||
|
||
}); | ||
|
||
function install(param) { | ||
const { install, installPkg } = (_ => { | ||
var path, sdcard; | ||
var initialized = false; | ||
|
||
try { | ||
var sdcard = navigator.getDeviceStorage("sdcard"); | ||
sdcard.addEventListener("change", function(event) { | ||
// var reason = event.reason; | ||
path = event.path; | ||
install(path); | ||
}); | ||
var initialized = true; | ||
} catch (error) { | ||
console.error("initialisation of sdcard failed:", error); | ||
} | ||
|
||
function install(param) { | ||
if (!initialized) throw new Error("install module is not initialized yet"); | ||
|
||
var request = sdcard.get(param); | ||
|
||
request.onsuccess = function() { | ||
var file = this.result; | ||
installPkg(file) | ||
} | ||
var file = this.result; | ||
installPkg(file); | ||
}; | ||
|
||
request.onerror = function() { | ||
alert("Unable to get the file: " + this.error); | ||
} | ||
} | ||
|
||
alert("Unable to get the file: " + this.error); | ||
}; | ||
} | ||
|
||
function installPkg(packageFile) { | ||
navigator.mozApps.mgmt.import(packageFile).then(function() { | ||
function installPkg(packageFile) { | ||
if (!initialized) throw new Error("install module is not initialized yet"); | ||
navigator.mozApps.mgmt | ||
.import(packageFile) | ||
.then(function() { | ||
download_counter(); | ||
toaster("<br><br><br><br>THANK YOU<br> for installing the app.<br><br> If you like it I would be happy about a donation, press the option button.<br><br><br><br><br><br>", 6000); | ||
|
||
}).catch(e => { | ||
alert('Installation error: ' + e.name + ' ' + e.message) | ||
}) | ||
let appGetter = navigator.mozApps.mgmt.getAll() | ||
toaster( | ||
"<br><br><br><br>THANK YOU<br> for installing the app.<br><br> If you like it I would be happy about a donation, press the option button.<br><br><br><br><br><br>", | ||
6000 | ||
); | ||
}) | ||
.catch(e => { | ||
alert("Installation error: " + e.name + " " + e.message); | ||
}); | ||
let appGetter = navigator.mozApps.mgmt.getAll(); | ||
appGetter.onsuccess = function() { | ||
let apps = appGetter.result | ||
|
||
|
||
} | ||
appGetter.onerror = function(e) {} | ||
} | ||
let apps = appGetter.result; | ||
}; | ||
appGetter.onerror = function(e) {}; | ||
} | ||
|
||
function download_counter() { | ||
const url = "https://bhackers.uber.space/srs/v1/download_counter/count/" + app_slug | ||
function download_counter() { | ||
const url = | ||
"https://bhackers.uber.space/srs/v1/download_counter/count/" + app_slug; | ||
let xhttp = new XMLHttpRequest({ mozSystem: true }); | ||
|
||
xhttp.open('GET', url, true) | ||
xhttp.open("GET", url, true); | ||
xhttp.withCredentials = true; | ||
xhttp.timeout = 2000; | ||
|
||
xhttp.responseType = 'json'; | ||
xhttp.responseType = "json"; | ||
|
||
xhttp.send(null); | ||
|
||
xhttp.onload = function() { | ||
|
||
if (xhttp.readyState === xhttp.DONE && xhttp.status === 200) { | ||
|
||
let data = xhttp.response; | ||
|
||
} | ||
if (xhttp.readyState === xhttp.DONE && xhttp.status === 200) { | ||
let data = xhttp.response; | ||
} | ||
}; | ||
|
||
} | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "bhackers-store", | ||
"version": "1.0.0", | ||
"description": "An client for https://gitlab.com/banana-hackers/store-db", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"package": "./tools/build.sh && ./tools/package.sh" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/strukturart/kaiOs-alt-app-store.git" | ||
}, | ||
"author": "strukturart <https://github.com/strukturart>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/strukturart/kaiOs-alt-app-store/issues" | ||
}, | ||
"devDependencies": { | ||
"prettier": "2.1.1", | ||
"terser": "^5.3.0" | ||
}, | ||
"homepage": "https://github.com/strukturart/kaiOs-alt-app-store#readme" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -e #fail on error | ||
mkdir -p ./build/app | ||
rm -rf ./build/app/* || true | ||
|
||
# copy folders | ||
mkdir -p ./build/app/assets | ||
cp -r ./application/assets/css ./build/app/assets/css | ||
cp -r ./application/icons ./build/app/icons | ||
# copy metadata file | ||
cp ./application/manifest.webapp ./build/app/manifest.webapp | ||
|
||
# minify js | ||
# documentation under https://terser.org/docs/cli-usage | ||
npx terser ./application/assets/js/*.js ./application/app.js \ | ||
-o ./build/app/bundle.min.js \ | ||
--source-map "url='bundle.min.js.map',root='application/',includeSources=true"\ | ||
--ecma 5 | ||
|
||
# copy index file | ||
cp ./application/index.html ./build/app/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
set -e #fail on error | ||
|
||
mkdir -p ./build/tmp | ||
|
||
rm ./build/tmp/application.zip || true | ||
rm ./build/bhacker-store.zip || true | ||
|
||
echo "{\"version\": 1,\"manifestURL\":\"app://bHacker-Store.org/manifest.webapp\"}" > ./build/tmp/metadata.json | ||
|
||
cd build/tmp | ||
|
||
zip -jqr application.zip ../app | ||
|
||
cd .. | ||
|
||
zip -jqr bhacker-store.zip tmp | ||
|
||
echo "Created bhacker-store.zip" |