summaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorKasra Bigdeli <[email protected]>2020-08-16 08:43:27 -0400
committerKasra Bigdeli <[email protected]>2020-08-16 08:43:27 -0400
commitb643e1709a296c137832408d459abe36bbb8ca20 (patch)
treeee83fb2409b374e6105f669b3982d4e7773f9448 /scripts
parentb67f5f8aa1e79fc6fcdd3b4e2e75b5d06daa1bb4 (diff)
downloadcaprover-one-click-apps-b643e1709a296c137832408d459abe36bbb8ca20.tar.gz
caprover-one-click-apps-b643e1709a296c137832408d459abe36bbb8ca20.zip
Added placeholder for validating v4
Diffstat (limited to 'scripts')
-rw-r--r--scripts/validate_json.js55
1 files changed, 48 insertions, 7 deletions
diff --git a/scripts/validate_json.js b/scripts/validate_json.js
index 6e71702..3e58338 100644
--- a/scripts/validate_json.js
+++ b/scripts/validate_json.js
@@ -6,8 +6,52 @@
const pathOfPublic = path.join(__dirname, '..', PUBLIC);
+ // validating version 4
+ // function validateV4() {
+
+ // const version = '2';
+ // const pathOfVersion = path.join(pathOfPublic, 'v' + version);
+ // const pathOfApps = path.join(pathOfVersion, 'apps');
+
+ // return fs.readdir(pathOfApps)
+ // .then(function (items) {
+
+ // const apps = items.filter(v => v.includes('.json'));
+
+ // for (var i = 0; i < apps.length; i++) {
+ // const contentString = fs.readFileSync(path.join(pathOfApps, apps[i]));
+ // const content = JSON.parse(contentString);
+ // const captainVersion = (content.captainVersion + '');
+ // const versionString = (version + '');
+ // if (versionString !== captainVersion)
+ // throw new Error(`unmatched versions ${versionString} ${captainVersion} for ${apps[i]}`);
+
+ // apps[i] = apps[i].replace('.json', '');
+
+ // if (!content.description){
+ // throw new Error(`Cannot find description for ${apps[i]}`);
+ // }
+
+ // const logoFileName = apps[i] + '.png';
+
+ // const logoFullPath = path.join(pathOfVersion, 'logos', logoFileName);
+
+ // if (!fs.existsSync(logoFullPath) ||
+ // !fs.statSync(logoFullPath).isFile()) {
+ // let printablePath = logoFullPath;
+ // printablePath = printablePath.substr(printablePath.indexOf(`/${PUBLIC}`));
+ // throw new Error(`Cannot find logo for ${apps[i]} ${printablePath}`);
+ // }
+
+ // console.log(`Validated ${apps[i]}`);
+
+ // }
+
+ // });
+ // }
+
// validating version 2
- function validate() {
+ function validateV2() {
const version = '2';
const pathOfVersion = path.join(pathOfPublic, 'v' + version);
@@ -28,11 +72,9 @@
apps[i] = apps[i].replace('.json', '');
- if (!content.displayName) {
- content.displayName = apps[i];
- content.displayName = content.displayName.substr(0, 1).toUpperCase() + content.displayName.substring(1, content.displayName.length);
+ if (!content.description) {
+ throw new Error(`Cannot find description for ${apps[i]}`);
}
- if (!content.description) content.description = '';
const logoFileName = apps[i] + '.png';
@@ -52,10 +94,9 @@
});
}
-
Promise.resolve()
.then(function () {
- return validate();
+ return validateV2();
})
.catch(function (err) {
console.error(err);