mirror of https://github.com/Budibase/budibase.git
15 changed files with 255 additions and 29 deletions
@ -1 +1 @@ |
|||
Subproject commit b372ad7403fa12f92670ef38e7576bc5795006e9 |
|||
Subproject commit feb2f3412a0e3748d6509a3693b1f38c448bd743 |
|||
@ -0,0 +1 @@ |
|||
{} |
|||
@ -0,0 +1,69 @@ |
|||
const util = require("util"); |
|||
const fs = require("fs"); |
|||
const { join } = require("path"); |
|||
const { ncp } = require('ncp'); |
|||
const { masterAppPackage } = require("../utilities/createAppPackage"); |
|||
const rimraf = util.promisify(require("rimraf")); |
|||
const mkdir = util.promisify(fs.mkdir); |
|||
|
|||
const exists = root => async (path) => { |
|||
try { |
|||
await util.promisify(fs.access)( |
|||
join(root,path) |
|||
); |
|||
} catch (e) { |
|||
return false; |
|||
} |
|||
return true; |
|||
}; |
|||
|
|||
const copyfolder = (source, destination) => |
|||
new Promise((resolve, reject) => { |
|||
ncp(source, destination, function (err) { |
|||
if (err) { |
|||
reject(err); |
|||
} else { |
|||
resolve(); |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
module.exports = async (config, bbMaster, latestAppsFolder) => { |
|||
|
|||
const appsRuntimeFolder = "./runtime_apps"; |
|||
// create runtime folder
|
|||
// copy master into /master/latest
|
|||
if(await exists(appsRuntimeFolder)) { |
|||
try { |
|||
await rimraf(appsRuntimeFolder); |
|||
} catch(err) { |
|||
console.log(err); |
|||
} |
|||
} |
|||
|
|||
await mkdir(appsRuntimeFolder); |
|||
|
|||
|
|||
/* |
|||
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]; |
|||
}); |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
const { join } = require("path"); |
|||
|
|||
const createAppPackage = (appPath) => ({ |
|||
appDefinition: require(join(appPath, "appDefinition.json")), |
|||
behaviourSources: require(join(appPath, "plugins.json")), |
|||
appPath |
|||
}); |
|||
|
|||
module.exports.masterAppPackage = (config) => { |
|||
const standardPackage = createAppPackage("../appPackages/master"); |
|||
|
|||
const customizeMaster = config && config.customizeMaster |
|||
? config.customizeMaster |
|||
: a => a; |
|||
|
|||
const appDefinition = customizeMaster( |
|||
standardPackage.appDefinition); |
|||
|
|||
return ({ |
|||
appDefinition, |
|||
behaviourSources: config && config.masterPlugins |
|||
? config.masterPlugins |
|||
: standardPackage.behaviourSources, |
|||
appPath: standardPackage.appPath |
|||
}); |
|||
} |
|||
|
|||
module.exports.applictionVersionPackage = (appname, versionId) => |
|||
createAppPackage(`../runtimePackages/${appname}/${versionId}`); |
|||
|
|||
|
|||
Loading…
Reference in new issue