budibase/packages/server/utilities/createAppPackage.js

57 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-06-25 23:48:22 +02:00
const { join } = require("path");
2019-06-28 23:59:27 +02:00
const constructHierarchy = require("./constructHierarchy");
const { common } = require("budibase-core");
const { getRuntimePackageDirectory } = require("../utilities/runtimePackages");
const createAppPackage = (config, appPath) => {
const appDefModule = require(
join(appPath, "appDefinition.json"));
const pluginsModule = require(
join(appPath, "plugins.js"));
2019-07-07 10:03:37 +02:00
const accessLevels = require(
join(appPath, "access_levels.json")
);
return ({
appDefinition: appDefModule,
behaviourSources: pluginsModule(config),
2019-07-07 10:03:37 +02:00
appPath,
accessLevels
})
}
2019-06-25 23:48:22 +02:00
module.exports.masterAppPackage = (config) => {
const standardPackage = createAppPackage(config, "../appPackages/master");
2019-06-25 23:48:22 +02:00
const customizeMaster = config && config.customizeMaster
? config.customizeMaster
: a => a;
2019-06-28 23:59:27 +02:00
const appDefinition = common.$(standardPackage.appDefinition, [
customizeMaster,
constructHierarchy
]);
const plugins = require("../appPackages/master/plugins.js")
(config);
2019-06-25 23:48:22 +02:00
return ({
appDefinition,
2019-06-28 23:59:27 +02:00
behaviourSources: config && config.extraMasterPlugins
? {...plugins, ...config.extraMasterPlugins}
: plugins,
2019-06-25 23:48:22 +02:00
appPath: standardPackage.appPath
});
}
module.exports.applictionVersionPackage = (config, appname, versionId) => {
const pkg = createAppPackage(
config,
join("..", getRuntimePackageDirectory(appname, versionId))
);
pkg.appDefinition = constructHierarchy(pkg.appDefinition);
2019-06-28 23:59:27 +02:00
return pkg;
}