Port sanitychess.js to metadata.json

pull/1221/head
Adam Schmalhofer 2022-01-07 01:14:18 +01:00
parent d8d0dae4b5
commit 6f9cd73425
1 changed files with 27 additions and 22 deletions

View File

@ -26,14 +26,19 @@ function WARN(s) {
console.log("Warning: "+s); console.log("Warning: "+s);
} }
var appsFile, apps; var apps = [];
var dirs = fs.readdirSync(APPSDIR, {withFileTypes: true});
dirs.forEach(dir => {
var appsFile;
if (dir.name.startsWith("_example"))
return;
try { try {
appsFile = fs.readFileSync(BASEDIR+"apps.json").toString(); appsFile = fs.readFileSync(APPSDIR+dir.name+"/metadata.json").toString();
} catch (e) { } catch (e) {
ERROR("apps.json not found"); return;
} }
try{ try{
apps = JSON.parse(appsFile); apps.push(JSON.parse(appsFile));
} catch (e) { } catch (e) {
console.log(e); console.log(e);
var m = e.toString().match(/in JSON at position (\d+)/); var m = e.toString().match(/in JSON at position (\d+)/);
@ -46,9 +51,9 @@ try{
console.log("==============================================="); console.log("===============================================");
} }
console.log(m); console.log(m);
ERROR("apps.json not valid JSON"); ERROR(dir.name+"/metadata.json not valid JSON");
} }
});
const APP_KEYS = [ const APP_KEYS = [
'id', 'name', 'shortName', 'version', 'icon', 'screenshots', 'description', 'tags', 'type', 'id', 'name', 'shortName', 'version', 'icon', 'screenshots', 'description', 'tags', 'type',