forked from FOSS/BangleApps
Get rid of "b2" and "bno2" tags and add "supports" array.
Use the opportunity to refactor apps.json so everything looks prettymaster
parent
54a0b89fe7
commit
a94790391a
|
@ -217,8 +217,9 @@ and which gives information about the app for the Launcher.
|
|||
{ "id": "appid", // 7 character app id
|
||||
"name": "Readable name", // readable name
|
||||
"shortName": "Short name", // short name for launcher
|
||||
"icon": "icon.png", // icon in apps/
|
||||
"version": "0v01", // the version of this app
|
||||
"description": "...", // long description (can contain markdown)
|
||||
"icon": "icon.png", // icon in apps/
|
||||
"type":"...", // optional(if app) -
|
||||
// 'app' - an application
|
||||
// 'widget' - a widget
|
||||
|
@ -226,6 +227,7 @@ and which gives information about the app for the Launcher.
|
|||
// 'bootloader' - code that runs at startup only
|
||||
// 'RAM' - code that runs and doesn't upload anything to storage
|
||||
"tags": "", // comma separated tag list for searching
|
||||
"supports": ["BANGLEJS2"], // List of device IDs supported, either BANGLEJS or BANGLEJS2
|
||||
"dependencies" : { "notify":"type" } // optional, app 'types' we depend on
|
||||
// for instance this will use notify/notifyfs is they exist, or will pull in 'notify'
|
||||
"readme": "README.md", // if supplied, a link to a markdown-style text file
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
{ "id": "7chname",
|
||||
"name": "My app's human readable name",
|
||||
"shortName":"Short Name",
|
||||
"icon": "app.png",
|
||||
"version":"0.01",
|
||||
"description": "A detailed description of my great app",
|
||||
"icon": "app.png",
|
||||
"tags": "",
|
||||
"supports" : ["BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"7chname.app.js","url":"app.js"},
|
||||
{"name":"7chname.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
{ "id": "7chname",
|
||||
"name": "My widget's human readable name",
|
||||
"shortName":"Short Name",
|
||||
"icon": "widget.png",
|
||||
"version":"0.01",
|
||||
"description": "A detailed description of my great widget",
|
||||
"tags": "widget",
|
||||
"icon": "widget.png",
|
||||
"type": "widget",
|
||||
"tags": "widget",
|
||||
"supports" : ["BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"7chname.wid.js","url":"widget.js"}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/nodejs
|
||||
/* Quick hack to add proper 'supports' field to apps.json
|
||||
*/
|
||||
|
||||
var fs = require("fs");
|
||||
|
||||
var BASEDIR = __dirname+"/../";
|
||||
|
||||
var appsFile, apps;
|
||||
try {
|
||||
appsFile = fs.readFileSync(BASEDIR+"apps.json").toString();
|
||||
} catch (e) {
|
||||
ERROR("apps.json not found");
|
||||
}
|
||||
try{
|
||||
apps = JSON.parse(appsFile);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
var m = e.toString().match(/in JSON at position (\d+)/);
|
||||
if (m) {
|
||||
var char = parseInt(m[1]);
|
||||
console.log("===============================================");
|
||||
console.log("LINE "+appsFile.substr(0,char).split("\n").length);
|
||||
console.log("===============================================");
|
||||
console.log(appsFile.substr(char-10, 20));
|
||||
console.log("===============================================");
|
||||
}
|
||||
console.log(m);
|
||||
ERROR("apps.json not valid JSON");
|
||||
|
||||
}
|
||||
|
||||
apps = apps.map((app,appIdx) => {
|
||||
var tags = [];
|
||||
if (app.tags) tags = app.tags.split(",").map(t=>t.trim());
|
||||
var supportsB1 = true;
|
||||
var supportsB2 = false;
|
||||
if (tags.includes("b2")) {
|
||||
tags = tags.filter(x=>x!="b2");
|
||||
supportsB2 = true;
|
||||
}
|
||||
if (tags.includes("bno2")) {
|
||||
tags = tags.filter(x=>x!="bno2");
|
||||
supportsB2 = false;
|
||||
}
|
||||
if (tags.includes("bno1")) {
|
||||
tags = tags.filter(x=>x!="bno1");
|
||||
supportsB1 = false;
|
||||
}
|
||||
app.tags = tags.join(",");
|
||||
app.supports = [];
|
||||
if (supportsB1) app.supports.push("BANGLEJS");
|
||||
if (supportsB2) app.supports.push("BANGLEJS2");
|
||||
return app;
|
||||
});
|
||||
|
||||
var KEY_ORDER = [
|
||||
"id","name","shortName","version","description","icon","type","tags","supports",
|
||||
"dependencies", "readme", "custom", "customConnect", "interface",
|
||||
"allow_emulator", "storage", "data", "sortorder"
|
||||
];
|
||||
|
||||
var JS = JSON.stringify;
|
||||
var json = "[\n "+apps.map(app=>{
|
||||
var keys = KEY_ORDER.filter(k=>k in app);
|
||||
Object.keys(app).forEach(k=>{
|
||||
if (!KEY_ORDER.includes(k))
|
||||
throw new Error(`Key named ${k} not known!`);
|
||||
});
|
||||
|
||||
|
||||
return "{\n "+keys.map(k=>{
|
||||
var js = JS(app[k]);
|
||||
if (k=="storage")
|
||||
js = "[\n "+app.storage.map(s=>JS(s)).join(",\n ")+"\n ]";
|
||||
return JS(k)+": "+js;
|
||||
}).join(",\n ")+"\n }";
|
||||
}).join(",\n ")+"\n]\n";
|
||||
|
||||
//console.log(json);
|
||||
|
||||
console.log("new apps.json written");
|
||||
fs.writeFileSync(BASEDIR+"apps.json", json);
|
|
@ -51,7 +51,8 @@ try{
|
|||
|
||||
const APP_KEYS = [
|
||||
'id', 'name', 'shortName', 'version', 'icon', 'description', 'tags', 'type',
|
||||
'sortorder', 'readme', 'custom', 'customConnect', 'interface', 'storage', 'data', 'allow_emulator',
|
||||
'sortorder', 'readme', 'custom', 'customConnect', 'interface', 'storage', 'data',
|
||||
'supports', 'allow_emulator',
|
||||
'dependencies'
|
||||
];
|
||||
const STORAGE_KEYS = ['name', 'url', 'content', 'evaluate', 'noOverwite'];
|
||||
|
@ -81,6 +82,14 @@ apps.forEach((app,appIdx) => {
|
|||
if (!app.name) ERROR(`App ${app.id} has no name`);
|
||||
var isApp = !app.type || app.type=="app";
|
||||
if (app.name.length>20 && !app.shortName && isApp) ERROR(`App ${app.id} has a long name, but no shortName`);
|
||||
if (!Array.isArray(app.supports)) ERROR(`App ${app.id} has no 'supports' field or it's not an array`);
|
||||
else {
|
||||
app.supports.forEach(dev => {
|
||||
if (!["BANGLEJS","BANGLEJS2"].includes(dev))
|
||||
ERROR(`App ${app.id} has unknown device in 'supports' field - ${dev}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (!app.version) WARN(`App ${app.id} has no version`);
|
||||
else {
|
||||
if (!fs.existsSync(appDir+"ChangeLog")) {
|
||||
|
|
Loading…
Reference in New Issue