2020-02-03 10:24:25 +01:00
|
|
|
const { masterAppPackage } = require("../utilities/createAppPackage")
|
|
|
|
const { mkdir, remove, pathExists, copy } = require("fs-extra")
|
|
|
|
const { runtimePackagesDirectory } = require("../utilities/runtimePackages")
|
2019-06-25 23:48:22 +02:00
|
|
|
|
|
|
|
const copyfolder = (source, destination) =>
|
2020-02-03 10:24:25 +01:00
|
|
|
new Promise((resolve, reject) => {
|
|
|
|
copy(source, destination, function(err) {
|
|
|
|
if (err) {
|
|
|
|
reject(err)
|
|
|
|
} else {
|
|
|
|
resolve()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2019-06-28 23:59:27 +02:00
|
|
|
|
2020-02-25 16:21:23 +01:00
|
|
|
exports.copyfolder = copyfolder
|
|
|
|
|
|
|
|
module.exports = async context => {
|
2020-02-03 10:24:25 +01:00
|
|
|
// create runtime folder
|
|
|
|
// copy master into /master/latest
|
|
|
|
if (await pathExists(runtimePackagesDirectory)) {
|
|
|
|
try {
|
|
|
|
await remove(runtimePackagesDirectory)
|
|
|
|
} catch (err) {
|
|
|
|
console.log(err)
|
2019-06-25 23:48:22 +02:00
|
|
|
}
|
2020-02-03 10:24:25 +01:00
|
|
|
}
|
2019-06-25 23:48:22 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
await mkdir(runtimePackagesDirectory)
|
|
|
|
|
|
|
|
const apps = {
|
|
|
|
_master: masterAppPackage(context),
|
|
|
|
}
|
2019-06-25 23:48:22 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
return (appName, versionId) => {
|
|
|
|
if (appName === "_master") {
|
|
|
|
return apps[appName]
|
|
|
|
}
|
2019-06-25 23:48:22 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
return apps[appName][versionId]
|
|
|
|
}
|
|
|
|
}
|