1
0
Fork 0
mirror of synced 2024-07-04 14:01:27 +12:00
budibase/packages/server/utilities/runtimePackages.js

42 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-06-29 09:59:27 +12:00
const { join } = require("path");
2019-10-12 05:14:23 +13:00
const { isString, last } = require("lodash/fp");
const { common } = require("@budibase/core");
2019-06-29 09:59:27 +12:00
const runtimePackagesDirectory = "./runtime_apps";
2019-10-12 05:14:23 +13:00
const LATEST_VERSIONID = "##LATEST##";
const { $, splitKey } = common;
2019-06-29 09:59:27 +12:00
2019-07-02 09:49:13 +12:00
const getRuntimeAppsDirectory = (appName) =>
join(runtimePackagesDirectory, appName);
2019-10-12 05:14:23 +13:00
const getLatestDirectory = (appContext, appname) =>
join(appContext.config.latestPackagesFolder, appname);
module.exports.LATEST_VERSIONID = LATEST_VERSIONID;
2019-06-29 09:59:27 +12:00
module.exports.runtimePackagesDirectory = runtimePackagesDirectory;
2019-10-12 05:14:23 +13:00
module.exports.getRuntimePackageDirectory = (appContext, appName, versionId) =>
versionId === LATEST_VERSIONID
? getLatestDirectory(appContext, appName)
: join(getRuntimeAppsDirectory(appName), versionId);
2019-07-02 09:49:13 +12:00
module.exports.getRuntimeAppsDirectory = getRuntimeAppsDirectory;
2019-10-12 05:14:23 +13:00
// the point of this in mainly to support running in dev
// i.e. if no "versions" are in use, then it will route
// to the latest package
module.exports.determineVersionId = (version) => {
let versionKey = isString(version)
? version
: null;
if(!versionKey && version && version.key)
versionKey = version.key;
return versionKey
? $(versionKey, [
splitKey,
last])
: LATEST_VERSIONID;
}