cli - new handler respects latestPackagesFolder
This commit is contained in:
parent
b64c57bbfb
commit
d14d297d25
|
@ -2,17 +2,18 @@ const { getAppContext } = require("../../common");
|
||||||
const {
|
const {
|
||||||
getMasterApisWithFullAccess
|
getMasterApisWithFullAccess
|
||||||
} = require("@budibase/server/utilities/budibaseApi");
|
} = require("@budibase/server/utilities/budibaseApi");
|
||||||
const { copy, readJSON, writeJSON, remove } = require("fs-extra");
|
const { copy, readJSON, writeJSON, remove, exists } = require("fs-extra");
|
||||||
const { resolve, join } = require("path");
|
const { resolve, join } = require("path");
|
||||||
const thisPackageJson = require("../../../package.json");
|
const thisPackageJson = require("../../../package.json");
|
||||||
const {exec} = require('child_process');
|
const {exec} = require('child_process');
|
||||||
|
|
||||||
module.exports = ({name}) => {
|
module.exports = (opts) => {
|
||||||
run({name});
|
run(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
const run = async (opts) => {
|
const run = async (opts) => {
|
||||||
const context = await getAppContext({configName:opts.config, masterIsCreated:true});
|
const context = await getAppContext({configName:opts.config, masterIsCreated:true});
|
||||||
|
opts.config = context.config;
|
||||||
const bb = await getMasterApisWithFullAccess(context);
|
const bb = await getMasterApisWithFullAccess(context);
|
||||||
|
|
||||||
const app = bb.recordApi.getNew("/applications", "application");
|
const app = bb.recordApi.getNew("/applications", "application");
|
||||||
|
@ -28,11 +29,14 @@ const createEmtpyAppPackage = async (opts) => {
|
||||||
const templateFolder = resolve(
|
const templateFolder = resolve(
|
||||||
__dirname, "appPackageTemplate");
|
__dirname, "appPackageTemplate");
|
||||||
|
|
||||||
const destinationFolder = resolve(".", opts.name);
|
const appsFolder = opts.config.latestPackagesFolder || ".";
|
||||||
|
const destinationFolder = resolve(appsFolder, opts.name);
|
||||||
|
|
||||||
|
if(await exists(destinationFolder)) return;
|
||||||
|
|
||||||
await copy(templateFolder, destinationFolder);
|
await copy(templateFolder, destinationFolder);
|
||||||
|
|
||||||
const packageJsonPath = join(opts.name, "package.json");
|
const packageJsonPath = join(appsFolder, opts.name, "package.json");
|
||||||
const packageJson = await readJSON(packageJsonPath);
|
const packageJson = await readJSON(packageJsonPath);
|
||||||
|
|
||||||
packageJson.name = opts.name;
|
packageJson.name = opts.name;
|
||||||
|
|
|
@ -20,6 +20,6 @@ module.exports.getAppContext = async ({configName, masterIsCreated}) => {
|
||||||
configName = "config.js";
|
configName = "config.js";
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = require(join(cwd(), configName))();
|
const config = require(resolve(cwd(), configName))();
|
||||||
return await buildAppContext(config, masterIsCreated);
|
return await buildAppContext(config, masterIsCreated);
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"build": "cd appPackages/_master && yarn && cd ../testApp && yarn && cd ../testApp2 && yarn",
|
"build": "cd appPackages/_master && yarn && cd ../testApp && yarn && cd ../testApp2 && yarn",
|
||||||
"initialise": "node initialise/initialiseBudibase --datastore local --username admin --password admin --rootPath .data --cleanDev",
|
"initialise": "node initialise/initialiseBudibase --datastore local --username admin --password admin --rootPath .data --cleanDev && node ../cli/bin/budi new testApp2",
|
||||||
"dev:builder": "node index"
|
"dev:builder": "node index"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
Loading…
Reference in New Issue