From bc883c7805104968b41910880ce07712cf0ee50b Mon Sep 17 00:00:00 2001 From: Kasra Bigdeli Date: Tue, 24 Dec 2019 16:38:35 -0500 Subject: updated --- build_one_click_apps.js | 69 +++++++++++++++++++++++++++++++++++++++++++ npm_run_puplish.js | 78 ------------------------------------------------- package.json | 3 +- 3 files changed, 71 insertions(+), 79 deletions(-) create mode 100644 build_one_click_apps.js delete mode 100644 npm_run_puplish.js diff --git a/build_one_click_apps.js b/build_one_click_apps.js new file mode 100644 index 0000000..48c8594 --- /dev/null +++ b/build_one_click_apps.js @@ -0,0 +1,69 @@ + /*jshint esversion: 6 */ + const path = require('path'); + const fs = require('fs-extra') + + const pathOfPublic = path.join(__dirname, 'public'); + + + function copyVersion(version) { + + const pathOfVersion = path.join(pathOfPublic, 'v' + version); + const pathOfApps = path.join(pathOfVersion, 'apps'); + const pathOfList = path.join(pathOfVersion, 'autoGeneratedList.json'); + + return fs.readdir(pathOfApps) + .then(function (items) { + + const apps = items.filter(v => v.includes('.json')); + const appDetails = []; + + 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]}`) + if (captainVersion === "1") { + if (contentString.includes("$$cap_root_domain")) + throw new Error('V1 should not have root domain') + } + + apps[i] = apps[i].replace('.json', ''); + + if (captainVersion + '' === '2') { + 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) content.description = '' + + appDetails[i] = { + name: apps[i], + displayName: content.displayName, + description: content.description, + logoUrl: apps[i] + '.png' + } + } + + } + + fs.outputJsonSync(pathOfList, { + appList: apps, + appDetails: appDetails + }); + + }) + } + + + Promise.resolve() + .then(function () { + return copyVersion(1) + }) + .then(function () { + return copyVersion(2) + }) + .catch(function (err) { + console.error(err) + }) \ No newline at end of file diff --git a/npm_run_puplish.js b/npm_run_puplish.js deleted file mode 100644 index 0fbd4fb..0000000 --- a/npm_run_puplish.js +++ /dev/null @@ -1,78 +0,0 @@ - /*jshint esversion: 6 */ - const ghPages = require('gh-pages'); - const path = require('path'); - const fs = require('fs-extra') - - const pathOfPublic = path.join(__dirname, 'public'); - - - function copyVersion(version) { - - const pathOfVersion = path.join(pathOfPublic, 'v' + version); - const pathOfApps = path.join(pathOfVersion, 'apps'); - const pathOfList = path.join(pathOfVersion, 'autoGeneratedList.json'); - - return fs.readdir(pathOfApps) - .then(function (items) { - - const apps = items.filter(v => v.includes('.json')); - const appDetails = []; - - 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]}`) - if (captainVersion === "1") { - if (contentString.includes("$$cap_root_domain")) - throw new Error('V1 should not have root domain') - } - - apps[i] = apps[i].replace('.json', ''); - - if (captainVersion + '' === '2') { - 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) content.description = '' - - appDetails[i] = { - name: apps[i], - displayName: content.displayName, - description: content.description, - logoUrl: apps[i] + '.png' - } - } - - } - - fs.outputJsonSync(pathOfList, { - appList: apps, - appDetails: appDetails - }); - - }) - } - - - Promise.resolve() - .then(function () { - return copyVersion(1) - }) - .then(function () { - return copyVersion(2) - }) - .then(function () { - ghPages.publish('public', function (err) { - if (err) - console.log(err); - else - console.log('Built and deployed successfully'); - }); - }) - .catch(function (err) { - console.error(err) - }) \ No newline at end of file diff --git a/package.json b/package.json index a0872bf..8d6ec3b 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "One Click App Repository for CapRover", "main": "build_and_publish_to_github_pages.js", "scripts": { - "publish": "node ./npm_run_puplish.js" + "build": "node ./build_one_click_apps.js", + "publish": "npm run build && ./publish-from-actions.sh" }, "repository": { "type": "git", -- cgit v1.2.3