budibase/packages/server/initialise/initialiseRuntimePackages.js

54 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-06-25 23:48:22 +02:00
const { masterAppPackage } = require("../utilities/createAppPackage");
2019-07-26 18:08:59 +02:00
const { mkdir, remove, pathExists, copy } = require("fs-extra");
2019-06-28 23:59:27 +02:00
const { runtimePackagesDirectory } = require("../utilities/runtimePackages");
2019-06-25 23:48:22 +02:00
const copyfolder = (source, destination) =>
new Promise((resolve, reject) => {
2019-07-26 18:08:59 +02:00
copy(source, destination, function (err) {
2019-06-25 23:48:22 +02:00
if (err) {
reject(err);
} else {
resolve();
}
});
});
2019-06-28 23:59:27 +02:00
2019-07-09 08:29:50 +02:00
module.exports = async (context, bbMaster, latestAppsFolder) => {
2019-06-25 23:48:22 +02:00
// create runtime folder
// copy master into /master/latest
2019-07-26 18:08:59 +02:00
if(await pathExists(runtimePackagesDirectory)) {
2019-06-25 23:48:22 +02:00
try {
2019-07-26 18:08:59 +02:00
await remove(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 = {
2019-07-09 08:29:50 +02:00
"_master": masterAppPackage(context)
2019-06-25 23:48:22 +02:00
}
return ((appName, versionId) => {
if(appName === "_master") {
return apps[appName];
}
return apps[appName][versionId];
});
}