Added v2
This commit is contained in:
@@ -1,26 +1,60 @@
|
||||
const ghpages = require('gh-pages');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra')
|
||||
/*jshint esversion: 6 */
|
||||
const ghpages = require('gh-pages');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra')
|
||||
|
||||
const pathOfPublic = path.join(__dirname, 'public');
|
||||
const pathOfV1 = path.join(pathOfPublic, 'v1');
|
||||
const pathOfApps = path.join(pathOfV1, 'apps');
|
||||
const pathOfList = path.join(pathOfV1, 'autoGeneratedList.json');
|
||||
const pathOfPublic = path.join(__dirname, 'public');
|
||||
|
||||
fs.readdir(pathOfApps, function (err, items) {
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
items[i] = items[i].replace('.json', '');
|
||||
}
|
||||
|
||||
fs.outputJsonSync(pathOfList, {
|
||||
appList: items
|
||||
});
|
||||
function copyVersion(version) {
|
||||
|
||||
ghpages.publish('public', function (err) {
|
||||
if (err)
|
||||
console.log(err);
|
||||
else
|
||||
console.log('Built and deployed successfully');
|
||||
});
|
||||
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'));
|
||||
|
||||
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', '');
|
||||
}
|
||||
|
||||
fs.outputJsonSync(pathOfList, {
|
||||
appList: apps
|
||||
});
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
})
|
||||
Reference in New Issue
Block a user