Changed build chain
This commit is contained in:
parent
9ee75a559f
commit
a0e1fb0ac8
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
autoGeneratedList.json
|
dist/*
|
||||||
node_modules
|
node_modules
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "One Click App Repository for CapRover",
|
"description": "One Click App Repository for CapRover",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node ./scripts/build_one_click_apps.js",
|
"build": "rm -rf ./dist/ && mkdir -p dist && node ./scripts/build_one_click_apps.js",
|
||||||
"validate_json": "node ./scripts/validate_json.js",
|
"validate_json": "node ./scripts/validate_json.js",
|
||||||
"publish": "npm run build && ./scripts/publish-from-actions.sh"
|
"publish": "npm run build && ./scripts/publish-from-actions.sh"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
# V1 is no longer being updated.
|
|
||||||
|
|
||||||
We use v2, which has an additional parameter of `$$cap_root_domain`
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
{
|
|
||||||
"captainVersion": "1",
|
|
||||||
"documentation": "Just a placeholder for upgrade message",
|
|
||||||
"dockerCompose": {
|
|
||||||
"services": {
|
|
||||||
"$$cap_appname": {
|
|
||||||
"image": "this-is-not-a-real-app:$$cap_adminer_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"instructions": {
|
|
||||||
"start": "You CapRover is not supported anymore. Navigate to SETTINGS and update your CapRover.",
|
|
||||||
"end": ""
|
|
||||||
},
|
|
||||||
"variables": [{
|
|
||||||
"id": "$$cap_adminer_version",
|
|
||||||
"label": "Update CapRover",
|
|
||||||
"description": "",
|
|
||||||
"defaultValue": "NOT SUPPORTED",
|
|
||||||
"validRegex": "/.{100,}/"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,76 +1,83 @@
|
||||||
/*jshint esversion: 6 */
|
/*jshint esversion: 6 */
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs-extra')
|
const fs = require('fs-extra');
|
||||||
|
|
||||||
const PUBLIC = `public`
|
const pathOfPublic = path.join(__dirname, '..', `public`);
|
||||||
const pathOfPublic = path.join(__dirname, '..', PUBLIC);
|
|
||||||
|
const pathOfDist = path.join(__dirname, '..', `dist`);
|
||||||
|
// const pathOfDistV1 = path.join(pathOfDist, 'v1');
|
||||||
|
const pathOfDistV2 = path.join(pathOfDist, 'v2');
|
||||||
|
const pathOfDistV3 = path.join(pathOfDist, 'v3');
|
||||||
|
|
||||||
|
const pathOfSourceDirectory = path.join(pathOfPublic, 'v2');
|
||||||
|
const pathOfSourceDirectoryApps = path.join(pathOfSourceDirectory, 'apps');
|
||||||
|
const pathOfSourceDirectoryLogos = path.join(pathOfSourceDirectory, 'logos');
|
||||||
|
|
||||||
|
|
||||||
function copyVersion(version) {
|
function createAppList(appsList, pathOfApps) {
|
||||||
|
const apps = appsList.filter(v => v.includes('.json'));
|
||||||
|
const appDetails = [];
|
||||||
|
|
||||||
const pathOfVersion = path.join(pathOfPublic, 'v' + version);
|
for (var i = 0; i < apps.length; i++) {
|
||||||
const pathOfApps = path.join(pathOfVersion, 'apps');
|
const contentString = fs.readFileSync(path.join(pathOfApps, apps[i]));
|
||||||
const pathOfList = path.join(pathOfVersion, 'autoGeneratedList.json'); //kept for backward compat
|
const content = JSON.parse(contentString);
|
||||||
const pathOfList2 = path.join(pathOfVersion, 'list');
|
const captainVersion = (content.captainVersion + '');
|
||||||
|
|
||||||
return fs.readdir(pathOfApps)
|
apps[i] = apps[i].replace('.json', '');
|
||||||
.then(function (items) {
|
|
||||||
|
|
||||||
const apps = items.filter(v => v.includes('.json'));
|
if (captainVersion + '' === '2') {
|
||||||
const appDetails = [];
|
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 = '';
|
||||||
|
|
||||||
for (var i = 0; i < apps.length; i++) {
|
appDetails[i] = {
|
||||||
const contentString = fs.readFileSync(path.join(pathOfApps, apps[i]));
|
name: apps[i],
|
||||||
const content = JSON.parse(contentString)
|
displayName: content.displayName,
|
||||||
const captainVersion = (content.captainVersion + '');
|
description: content.description,
|
||||||
const versionString = (version + '');
|
logoUrl: apps[i] + '.png'
|
||||||
if (versionString !== captainVersion)
|
};
|
||||||
throw new Error(`unmatched versions ${versionString} ${captainVersion} for ${apps[i]}`)
|
} else {
|
||||||
if (captainVersion === "1") {
|
throw new Error('Unknown captain-version: ' + captainVersion);
|
||||||
if (contentString.includes("$$cap_root_domain"))
|
}
|
||||||
throw new Error('V1 should not have root domain')
|
|
||||||
}
|
|
||||||
|
|
||||||
apps[i] = apps[i].replace('.json', '');
|
}
|
||||||
|
|
||||||
if (captainVersion + '' === '2') {
|
return {
|
||||||
if (!content.displayName) {
|
appList: apps,
|
||||||
content.displayName = apps[i]
|
appDetails: appDetails
|
||||||
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
|
|
||||||
});
|
|
||||||
|
|
||||||
fs.outputJsonSync(pathOfList2, {
|
|
||||||
oneClickApps: appDetails
|
|
||||||
});
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Promise.resolve()
|
function buildDist() {
|
||||||
.then(function () {
|
return fs.readdir(pathOfSourceDirectoryApps)
|
||||||
return copyVersion(1)
|
.then(function (appsFileNames) { // [ app1.json app2.json .... ]
|
||||||
})
|
|
||||||
.then(function () {
|
appsFileNames.forEach(appFileName => {
|
||||||
return copyVersion(2)
|
fs.copySync(path.join(pathOfSourceDirectoryApps, appFileName), path.join(pathOfDistV2, `apps`, appFileName));
|
||||||
})
|
fs.copySync(path.join(pathOfSourceDirectoryApps, appFileName), path.join(pathOfDistV3, `apps`, appFileName.split('.')[0]));
|
||||||
.catch(function (err) {
|
});
|
||||||
console.error(err)
|
|
||||||
process.exit(127)
|
fs.copySync(pathOfSourceDirectoryLogos, path.join(pathOfDistV2, `logos`));
|
||||||
})
|
fs.copySync(pathOfSourceDirectoryLogos, path.join(pathOfDistV3, `logos`));
|
||||||
|
|
||||||
|
fs.outputJsonSync(path.join(pathOfDistV2, 'autoGeneratedList.json'), createAppList(appsFileNames, pathOfSourceDirectoryApps));
|
||||||
|
fs.outputJsonSync(path.join(pathOfDistV2, 'list'), createAppList(appsFileNames, pathOfSourceDirectoryApps)); // TODO delete
|
||||||
|
fs.outputJsonSync(path.join(pathOfDistV3, 'list'), createAppList(appsFileNames, pathOfSourceDirectoryApps));
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
return fs.copySync(path.join(pathOfPublic, 'CNAME'), path.join(pathOfDist, 'CNAME'))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Promise.resolve()
|
||||||
|
.then(function () {
|
||||||
|
return buildDist();
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(127);
|
||||||
|
});
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
BUILD_DIR=public
|
BUILD_DIR=dist
|
||||||
SOURCE_DIRECTORY_DEPLOY_GH=~/temp-gh-deploy-src
|
SOURCE_DIRECTORY_DEPLOY_GH=~/temp-gh-deploy-src
|
||||||
CLONED_DIRECTORY_DEPLOY_GH=~/temp-gh-deploy-cloned
|
CLONED_DIRECTORY_DEPLOY_GH=~/temp-gh-deploy-cloned
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue