Merge pull request #1323 from adamschmalhofer/jekyll-apps.json

Jekyll apps.json changes
master
Gordon Williams 2022-01-20 08:16:13 +00:00 committed by GitHub
commit 3faec602a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 23 deletions

View File

@ -1,25 +1,35 @@
--- ---
# =================================================================
# 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 %} {%- if page.restricted == nil -%}
================================================================= {%- assign apps = site.static_files | where: "name", "metadata.json" | map: "path" -%}
ALL THE INFORMATION INSIDE APPS.JSON HAS NOW BEEN MOVED {%- else -%}
{%- capture temp -%}
You'll find it inside a file called apps/yourapp/metadata.json {%- for app in page.restricted %} /apps/{{app}}/metadata.json {%- endfor -%}
{%- endcapture -%}
Otherwise nothing has changed. GitHub Pages will automatically {%- assign apps = temp | strip | split: " " -%}
create apps.json as your site is hosted, or if you're hosting {%- endif -%}
yourself you can run bin/create_apps_json.sh
=================================================================
{% endcomment %}
{%- assign apps = site.static_files | where: "name", "metadata.json" -%}
[ [
{%- include_relative {{ apps.first.path }} -%} {%- include_relative {{ apps.first }} -%}
{%- for app in apps offset:1 -%} {%- for app in apps offset:1 -%}
,{%- include_relative {{ app.path }} -%} ,{%- include_relative {{ app }} -%}
{%- endfor -%} {%- endfor -%}
] ]

View File

@ -10,7 +10,6 @@ var SETTINGS = {
var path = require('path'); var path = require('path');
var ROOTDIR = path.join(__dirname, '..'); var ROOTDIR = path.join(__dirname, '..');
var APPDIR = ROOTDIR+'/apps'; var APPDIR = ROOTDIR+'/apps';
var APPJSON = ROOTDIR+'/apps.json';
var OUTFILE = ROOTDIR+'/firmware.js'; var OUTFILE = ROOTDIR+'/firmware.js';
var DEVICE = "BANGLEJS"; var DEVICE = "BANGLEJS";
var APPS = [ // IDs of apps to install var APPS = [ // IDs of apps to install
@ -28,7 +27,6 @@ global.Const = {
}; };
var AppInfo = require(ROOTDIR+"/core/js/appinfo.js"); var AppInfo = require(ROOTDIR+"/core/js/appinfo.js");
var appjson = JSON.parse(fs.readFileSync(APPJSON).toString());
var appfiles = []; var appfiles = [];
function fileGetter(url) { function fileGetter(url) {
@ -58,8 +56,11 @@ function fileGetter(url) {
} }
Promise.all(APPS.map(appid => { Promise.all(APPS.map(appid => {
var app = appjson.find(app=>app.id==appid); try {
if (app===undefined) throw new Error(`App ${appid} not found`); var app = JSON.parse(fs.readFileSync(APPDIR + "/" + appid + "metadata.json").toString());
} catch (e) {
throw new Error(`App ${appid} not found`);
}
return AppInfo.getFiles(app, { return AppInfo.getFiles(app, {
fileGetter : fileGetter, fileGetter : fileGetter,
settings : SETTINGS, settings : SETTINGS,

View File

@ -16,7 +16,6 @@ var DEVICE = process.argv[2];
var path = require('path'); var path = require('path');
var ROOTDIR = path.join(__dirname, '..'); var ROOTDIR = path.join(__dirname, '..');
var APPDIR = ROOTDIR+'/apps'; var APPDIR = ROOTDIR+'/apps';
var APPJSON = ROOTDIR+'/apps.json';
var MINIFY = true; var MINIFY = true;
var OUTFILE, APPS; var OUTFILE, APPS;
@ -86,7 +85,6 @@ function atob(input) {
} }
var AppInfo = require(ROOTDIR+"/core/js/appinfo.js"); var AppInfo = require(ROOTDIR+"/core/js/appinfo.js");
var appjson = JSON.parse(fs.readFileSync(APPJSON).toString());
var appfiles = []; var appfiles = [];
function fileGetter(url) { function fileGetter(url) {
@ -134,8 +132,11 @@ function evaluateFile(file) {
} }
Promise.all(APPS.map(appid => { Promise.all(APPS.map(appid => {
var app = appjson.find(app=>app.id==appid); try {
if (app===undefined) throw new Error(`App ${appid} not found`); var app = JSON.parse(fs.readFileSync(APPDIR + "/" + appid + "metadata.json").toString());
} catch (e) {
throw new Error(`App ${appid} not found`);
}
return AppInfo.getFiles(app, { return AppInfo.getFiles(app, {
fileGetter : fileGetter, fileGetter : fileGetter,
settings : SETTINGS, settings : SETTINGS,