budibase/packages/server/initialise/initialiseRuntimePackages.js

55 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-06-25 23:48:22 +02:00
const { ncp } = require('ncp');
const { masterAppPackage } = require("../utilities/createAppPackage");
2019-06-28 23:59:27 +02:00
const { mkdir, rimraf, exists } = require("../utilities/fsawait");
const { runtimePackagesDirectory } = require("../utilities/runtimePackages");
2019-06-25 23:48:22 +02:00
const copyfolder = (source, destination) =>
new Promise((resolve, reject) => {
ncp(source, destination, function (err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
2019-06-28 23:59:27 +02:00
2019-06-25 23:48:22 +02:00
module.exports = async (config, bbMaster, latestAppsFolder) => {
// create runtime folder
// copy master into /master/latest
2019-06-28 23:59:27 +02:00
if(await exists(runtimePackagesDirectory)) {
2019-06-25 23:48:22 +02:00
try {
2019-06-28 23:59:27 +02:00
await rimraf(runtimePackagesDirectory);
2019-06-25 23:48:22 +02:00
} catch(err) {
console.log(err);
}
}
2019-06-28 23:59:27 +02:00
await mkdir(runtimePackagesDirectory);
2019-06-25 23:48:22 +02:00
/*
const allApps = await bbMaster
.indexApi
.listItems("/all_applications");
for(let app of allApps) {
app.
}
*/
const apps = {
"_master": masterAppPackage(config)
}
return ((appName, versionId) => {
if(appName === "_master") {
return apps[appName];
}
return apps[appName][versionId];
});
}