summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/deploy.yml (renamed from .github/workflows/main.yml)0
-rw-r--r--.github/workflows/validate_json.yml17
-rw-r--r--build_one_click_apps.js1
-rw-r--r--package.json1
-rw-r--r--validate_json.js69
5 files changed, 88 insertions, 0 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/deploy.yml
index aeba7c2..aeba7c2 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/deploy.yml
diff --git a/.github/workflows/validate_json.yml b/.github/workflows/validate_json.yml
new file mode 100644
index 0000000..df41c87
--- /dev/null
+++ b/.github/workflows/validate_json.yml
@@ -0,0 +1,17 @@
+name: Publish One Click Apps
+
+on:
+ push:
+ branches: [something]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v1
+ - uses: actions/setup-node@v1
+ with:
+ node-version: 10
+ - run: npm ci && npm run validate_json
+ env:
+ GITHUB_PERSONAL_TOKEN: ${{secrets.GITHUB_PERSONAL_TOKEN}}
diff --git a/build_one_click_apps.js b/build_one_click_apps.js
index 48c8594..775e87e 100644
--- a/build_one_click_apps.js
+++ b/build_one_click_apps.js
@@ -66,4 +66,5 @@
})
.catch(function (err) {
console.error(err)
+ process.exit(127)
}) \ No newline at end of file
diff --git a/package.json b/package.json
index 8d6ec3b..9cc2ea1 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,7 @@
"main": "build_and_publish_to_github_pages.js",
"scripts": {
"build": "node ./build_one_click_apps.js",
+ "validate_json": "node./validate_json.js",
"publish": "npm run build && ./publish-from-actions.sh"
},
"repository": {
diff --git a/validate_json.js b/validate_json.js
new file mode 100644
index 0000000..19b639c
--- /dev/null
+++ b/validate_json.js
@@ -0,0 +1,69 @@
+ /*jshint esversion: 6 */
+ const path = require('path');
+ const fs = require('fs-extra')
+
+ const PUBLIC = `public`
+ const pathOfPublic = path.join(__dirname, PUBLIC);
+
+
+ // validating version 2
+ function validate() {
+
+ const version = '2'
+ const pathOfVersion = path.join(pathOfPublic, 'v' + version);
+ const pathOfApps = path.join(pathOfVersion, 'apps');
+
+ return fs.readdir(pathOfApps)
+ .then(function (items) {
+
+ const apps = items.filter(v => v.includes('.json'));
+ const appDetails = [];
+
+ for (var i = 0; i < apps.length; i++) {
+ const contentString = fs.readFileSync(path.join(pathOfApps, apps[i]));
+ const content = JSON.parse(contentString)
+ const captainVersion = (content.captainVersion + '');
+ const versionString = (version + '');
+ if (versionString !== captainVersion)
+ throw new Error(`unmatched versions ${versionString} ${captainVersion} for ${apps[i]}`)
+
+ apps[i] = apps[i].replace('.json', '');
+
+ if (!content.displayName) {
+ content.displayName = apps[i];
+ content.displayName = content.displayName.substr(0, 1).toUpperCase() + content.displayName.substring(1, content.displayName.length);
+ }
+ if (!content.description) content.description = '';
+
+ const logoFileName = apps[i] + '.png';
+
+ appDetails[i] = {
+ name: apps[i],
+ displayName: content.displayName,
+ description: content.description,
+ logoUrl: logoFileName
+ }
+
+ const logoFullPath = path.join(pathOfVersion, 'logos', logoFileName);
+
+ if (!fs.existsSync(logoFullPath) ||
+ !fs.statSync(logoFullPath).isFile()) {
+ let printablePath = logoFullPath;
+ printablePath = printablePath.substr(printablePath.indexOf(`/${PUBLIC}`))
+ throw new Error(`Cannot find logo for ${apps[i]} ${printablePath}`);
+ }
+
+ }
+
+ })
+ }
+
+
+ Promise.resolve()
+ .then(function () {
+ return validate()
+ })
+ .catch(function (err) {
+ console.error(err)
+ process.exit(127)
+ }) \ No newline at end of file