BangleApps/bin/firmwaremaker.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
2019-11-10 10:22:33 +00:00
/*
Mashes together a bunch of different apps to make
a single firmware JS file which can be uploaded.
*/
var path = require('path');
var ROOTDIR = path.join(__dirname, '..');
var OUTFILE = ROOTDIR+'/firmware.js';
var DEVICEID = "BANGLEJS";
2019-11-10 10:22:33 +00:00
var APPS = [ // IDs of apps to install
2020-03-09 17:06:13 +00:00
"boot","launch","mclock","setting",
"about","alarm","widbat","widbt","welcome"
2019-11-10 10:22:33 +00:00
];
2020-03-09 17:06:13 +00:00
var MINIFY = true;
2019-11-10 10:22:33 +00:00
var fs = require("fs");
var apploader = require("./lib/apploader.js");
apploader.init({
DEVICEID : DEVICEID
});
2020-09-22 14:33:55 +00:00
2019-11-10 10:22:33 +00:00
var appfiles = [];
Promise.all(APPS.map(appid => {
var app = apploader.apps.find(a => a.id==appid);
if (!app) throw new Error(`App ${appid} not found`);
return apploader.getAppFiles(app).then(files => {
2019-11-10 10:22:33 +00:00
appfiles = appfiles.concat(files);
});
})).then(() => {
//console.log(appfiles);
2020-03-11 16:30:36 +00:00
var js = "// Generated by BangleApps/bin/firmwaremaker.js\n";
2019-11-10 10:22:33 +00:00
appfiles.forEach((file) => {
js += file.cmd+"\n";
2020-03-10 15:33:41 +00:00
/*if (file.crc && file.evaluate!==true) {
js += `\x10if (E.CRC32(require('Storage').read(${JSON.stringify(file.name)}))!=${file.crc}){console.log("${file.name} invalid");FAIL++}\n`;
}*/
2019-11-10 10:22:33 +00:00
});
// js = js.replace(/\x10/g,""); // remove the echo-off characters (for testing only)
2019-11-10 10:22:33 +00:00
fs.writeFileSync(OUTFILE, js);
console.log("Output written to "+OUTFILE);
});