oops - fix sanity check
parent
8ec7878ede
commit
8c230be70a
|
|
@ -52,6 +52,7 @@ try{
|
||||||
const APP_KEYS = [
|
const APP_KEYS = [
|
||||||
'id', 'name', 'shortName', 'version', 'icon', 'description', 'tags', 'type',
|
'id', 'name', 'shortName', 'version', 'icon', 'description', 'tags', 'type',
|
||||||
'sortorder', 'readme', 'custom', 'interface', 'storage', 'data', 'allow_emulator',
|
'sortorder', 'readme', 'custom', 'interface', 'storage', 'data', 'allow_emulator',
|
||||||
|
'dependencies'
|
||||||
];
|
];
|
||||||
const STORAGE_KEYS = ['name', 'url', 'content', 'evaluate'];
|
const STORAGE_KEYS = ['name', 'url', 'content', 'evaluate'];
|
||||||
const DATA_KEYS = ['name', 'wildcard', 'storageFile'];
|
const DATA_KEYS = ['name', 'wildcard', 'storageFile'];
|
||||||
|
|
@ -100,6 +101,15 @@ apps.forEach((app,appIdx) => {
|
||||||
if (app.readme && !fs.existsSync(appDir+app.readme)) ERROR(`App ${app.id} README file doesn't exist`);
|
if (app.readme && !fs.existsSync(appDir+app.readme)) ERROR(`App ${app.id} README file doesn't exist`);
|
||||||
if (app.custom && !fs.existsSync(appDir+app.custom)) ERROR(`App ${app.id} custom HTML doesn't exist`);
|
if (app.custom && !fs.existsSync(appDir+app.custom)) ERROR(`App ${app.id} custom HTML doesn't exist`);
|
||||||
if (app.interface && !fs.existsSync(appDir+app.interface)) ERROR(`App ${app.id} interface HTML doesn't exist`);
|
if (app.interface && !fs.existsSync(appDir+app.interface)) ERROR(`App ${app.id} interface HTML doesn't exist`);
|
||||||
|
if (app.dependencies) {
|
||||||
|
if (("object"==typeof app.dependencies) && !Array.isArray(app.dependencies)) {
|
||||||
|
Object.keys(app.dependencies).forEach(dependency => {
|
||||||
|
if (app.dependencies[dependency]!="type")
|
||||||
|
ERROR(`App ${app.id} 'dependencies' must all be tagged 'type' right now`);
|
||||||
|
});
|
||||||
|
} else
|
||||||
|
ERROR(`App ${app.id} 'dependencies' must be an object`);
|
||||||
|
}
|
||||||
var fileNames = [];
|
var fileNames = [];
|
||||||
app.storage.forEach((file) => {
|
app.storage.forEach((file) => {
|
||||||
if (!file.name) ERROR(`App ${app.id} has a file with no name`);
|
if (!file.name) ERROR(`App ${app.id} has a file with no name`);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ Puck.debug=3;
|
||||||
// FIXME: use UART lib so that we handle errors properly
|
// FIXME: use UART lib so that we handle errors properly
|
||||||
const Comms = {
|
const Comms = {
|
||||||
reset : (opt) => new Promise((resolve,reject) => {
|
reset : (opt) => new Promise((resolve,reject) => {
|
||||||
var tries = 5;
|
let tries = 5;
|
||||||
Puck.write(`\x03\x10reset(${opt=="wipe"?"1":""});\n`,function rstHandler(result) {
|
Puck.write(`\x03\x10reset(${opt=="wipe"?"1":""});\n`,function rstHandler(result) {
|
||||||
console.log("<COMMS> reset: got "+JSON.stringify(result));
|
console.log("<COMMS> reset: got "+JSON.stringify(result));
|
||||||
if (result===null) return reject("Connection failed");
|
if (result===null) return reject("Connection failed");
|
||||||
|
|
@ -148,7 +148,7 @@ const Comms = {
|
||||||
console.log("<COMMS> removeAllApps start");
|
console.log("<COMMS> removeAllApps start");
|
||||||
Progress.show({title:"Removing all apps",percent:"animate",sticky:true});
|
Progress.show({title:"Removing all apps",percent:"animate",sticky:true});
|
||||||
return new Promise((resolve,reject) => {
|
return new Promise((resolve,reject) => {
|
||||||
var timeout = 5;
|
let timeout = 5;
|
||||||
function handleResult(result,err) {
|
function handleResult(result,err) {
|
||||||
console.log("<COMMS> removeAllApps: received "+JSON.stringify(result));
|
console.log("<COMMS> removeAllApps: received "+JSON.stringify(result));
|
||||||
if (result=="" && (timeout--)) {
|
if (result=="" && (timeout--)) {
|
||||||
|
|
@ -165,7 +165,7 @@ const Comms = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Use write with newline here so we wait for it to finish
|
// Use write with newline here so we wait for it to finish
|
||||||
var cmd = '\x10E.showMessage("Erasing...");require("Storage").eraseAll();Bluetooth.println("OK");reset()\n';
|
let cmd = '\x10E.showMessage("Erasing...");require("Storage").eraseAll();Bluetooth.println("OK");reset()\n';
|
||||||
Puck.write(cmd, handleResult, true /* wait for newline */);
|
Puck.write(cmd, handleResult, true /* wait for newline */);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -394,13 +394,13 @@ function customApp(app) {
|
||||||
|
|
||||||
/// check for dependencies the app needs and install them if required
|
/// check for dependencies the app needs and install them if required
|
||||||
function checkDependencies(app, uploadOptions) {
|
function checkDependencies(app, uploadOptions) {
|
||||||
var promise = Promise.resolve();
|
let promise = Promise.resolve();
|
||||||
if (app.dependencies) {
|
if (app.dependencies) {
|
||||||
Object.keys(app.dependencies).forEach(dependency=>{
|
Object.keys(app.dependencies).forEach(dependency=>{
|
||||||
if (app.dependencies[dependency]!="type")
|
if (app.dependencies[dependency]!="type")
|
||||||
throw new Error("Only supporting dependencies on app types right now");
|
throw new Error("Only supporting dependencies on app types right now");
|
||||||
console.log(`Searching for dependency on app type '${dependency}'`);
|
console.log(`Searching for dependency on app type '${dependency}'`);
|
||||||
var found = appsInstalled.find(app=>app.type==dependency);
|
let found = appsInstalled.find(app=>app.type==dependency);
|
||||||
if (found)
|
if (found)
|
||||||
console.log(`Found dependency in installed app '${found.id}'`);
|
console.log(`Found dependency in installed app '${found.id}'`);
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue