From 38170905ca012ddd2d8e1cbaaeea3f50078840ec Mon Sep 17 00:00:00 2001 From: Adam Schmalhofer Date: Wed, 19 Jan 2022 16:52:52 +0100 Subject: [PATCH 1/3] Port firmwaremake*.js to metadata.json --- bin/firmwaremaker.js | 9 +++++---- bin/firmwaremaker_c.js | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/firmwaremaker.js b/bin/firmwaremaker.js index 4bc2a70b2..9f7758ee5 100755 --- a/bin/firmwaremaker.js +++ b/bin/firmwaremaker.js @@ -10,7 +10,6 @@ var SETTINGS = { var path = require('path'); var ROOTDIR = path.join(__dirname, '..'); var APPDIR = ROOTDIR+'/apps'; -var APPJSON = ROOTDIR+'/apps.json'; var OUTFILE = ROOTDIR+'/firmware.js'; var DEVICE = "BANGLEJS"; var APPS = [ // IDs of apps to install @@ -28,7 +27,6 @@ global.Const = { }; var AppInfo = require(ROOTDIR+"/core/js/appinfo.js"); -var appjson = JSON.parse(fs.readFileSync(APPJSON).toString()); var appfiles = []; function fileGetter(url) { @@ -58,8 +56,11 @@ function fileGetter(url) { } Promise.all(APPS.map(appid => { - var app = appjson.find(app=>app.id==appid); - if (app===undefined) throw new Error(`App ${appid} not found`); + try { + var app = JSON.parse(fs.readFileSync(APPDIR + "/" + appid + "metadata.json").toString()); + } catch (e) { + throw new Error(`App ${appid} not found`); + } return AppInfo.getFiles(app, { fileGetter : fileGetter, settings : SETTINGS, diff --git a/bin/firmwaremaker_c.js b/bin/firmwaremaker_c.js index 14ced9ef8..e7042d2c3 100755 --- a/bin/firmwaremaker_c.js +++ b/bin/firmwaremaker_c.js @@ -16,7 +16,6 @@ var DEVICE = process.argv[2]; var path = require('path'); var ROOTDIR = path.join(__dirname, '..'); var APPDIR = ROOTDIR+'/apps'; -var APPJSON = ROOTDIR+'/apps.json'; var MINIFY = true; var OUTFILE, APPS; @@ -86,7 +85,6 @@ function atob(input) { } var AppInfo = require(ROOTDIR+"/core/js/appinfo.js"); -var appjson = JSON.parse(fs.readFileSync(APPJSON).toString()); var appfiles = []; function fileGetter(url) { @@ -134,8 +132,11 @@ function evaluateFile(file) { } Promise.all(APPS.map(appid => { - var app = appjson.find(app=>app.id==appid); - if (app===undefined) throw new Error(`App ${appid} not found`); + try { + var app = JSON.parse(fs.readFileSync(APPDIR + "/" + appid + "metadata.json").toString()); + } catch (e) { + throw new Error(`App ${appid} not found`); + } return AppInfo.getFiles(app, { fileGetter : fileGetter, settings : SETTINGS, From 03f8642f77920fad8262f76f67f5b074a5363452 Mon Sep 17 00:00:00 2001 From: Adam Schmalhofer Date: Wed, 19 Jan 2022 18:25:39 +0100 Subject: [PATCH 2/3] Offer an easy way to only have a restricted apps --- apps.json | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps.json b/apps.json index 1455a2b13..4efd5318a 100644 --- a/apps.json +++ b/apps.json @@ -1,4 +1,8 @@ --- +# uncomment the following line if you only want explicitly listed +# apps to be available on your site + +# restricted: ["boot", "launch", "antonclk", "health", "setting", "about", "widbat", "widbt", "widlock", "widid"] --- {% comment %} ================================================================= @@ -12,14 +16,21 @@ ================================================================= {% endcomment %} -{%- assign apps = site.static_files | where: "name", "metadata.json" -%} +{%- if page.restricted == nil -%} + {%- assign apps = site.static_files | where: "name", "metadata.json" | map: "path" -%} +{%- else -%} + {%- capture temp -%} + {%- for app in page.restricted %} /apps/{{app}}/metadata.json {%- endfor -%} + {%- endcapture -%} + {%- assign apps = temp | strip | split: " " -%} +{%- endif -%} [ -{%- include_relative {{ apps.first.path }} -%} +{%- include_relative {{ apps.first }} -%} {%- for app in apps offset:1 -%} -,{%- include_relative {{ app.path }} -%} +,{%- include_relative {{ app }} -%} {%- endfor -%} ] From 057ca686263ff6d797e40a61c1c3177a8ea68651 Mon Sep 17 00:00:00 2001 From: Adam Schmalhofer Date: Wed, 19 Jan 2022 18:30:01 +0100 Subject: [PATCH 3/3] Moved apps.json banner to top of file --- apps.json | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/apps.json b/apps.json index 4efd5318a..822af47f2 100644 --- a/apps.json +++ b/apps.json @@ -1,21 +1,20 @@ --- -# uncomment the following line if you only want explicitly listed +# ================================================================= +# ALL THE INFORMATION INSIDE APPS.JSON HAS NOW BEEN MOVED +# +# You'll find it inside a file called apps/yourapp/metadata.json +# +# Otherwise nothing has changed. GitHub Pages will automatically +# create apps.json as your site is hosted, or if you're hosting +# yourself you can run bin/create_apps_json.sh +# +# ================================================================= + +# Uncomment the following line if you only want explicitly listed # apps to be available on your site # restricted: ["boot", "launch", "antonclk", "health", "setting", "about", "widbat", "widbt", "widlock", "widid"] --- -{% comment %} -================================================================= - ALL THE INFORMATION INSIDE APPS.JSON HAS NOW BEEN MOVED - - You'll find it inside a file called apps/yourapp/metadata.json - - Otherwise nothing has changed. GitHub Pages will automatically - create apps.json as your site is hosted, or if you're hosting - yourself you can run bin/create_apps_json.sh - -================================================================= -{% endcomment %} {%- if page.restricted == nil -%} {%- assign apps = site.static_files | where: "name", "metadata.json" | map: "path" -%} {%- else -%}