From e0e983cec1e34b4c4abc3c8adfd277501768982b Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Mon, 18 May 2020 10:45:07 +0100 Subject: [PATCH] budi new not handling custom directories --- packages/cli/src/commands/new/newHandler.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/new/newHandler.js b/packages/cli/src/commands/new/newHandler.js index e020c5f9da..44007acde7 100644 --- a/packages/cli/src/commands/new/newHandler.js +++ b/packages/cli/src/commands/new/newHandler.js @@ -11,9 +11,7 @@ module.exports = opts => { const run = async opts => { try { - opts.dir = xPlatHomeDir(opts.dir) - const bbconfig = dotenv.config({ path: resolve(opts.dir, ".env") }) - console.log(bbconfig) + setup(opts) await createAppInstance(opts) await createEmptyAppPackage(opts) exec(`cd ${join(opts.dir, opts.applicationId)} && npm install`) @@ -25,6 +23,13 @@ const run = async opts => { } } +const setup = opts => { + opts.dir = xPlatHomeDir(opts.dir) + process.env.BUDIBASE_DIR = opts.dir + const bbconfig = dotenv.config({ path: resolve(opts.dir, ".env") }) + console.log(JSON.stringify(bbconfig)) +} + const createAppInstance = async opts => { const createAppCtx = { params: { clientId: process.env.CLIENT_ID }, @@ -45,7 +50,7 @@ const createAppInstance = async opts => { // this cannot be a top level require as it will cause // the environment module to be loaded prematurely const instanceController = require("@budibase/server/src/api/controllers/instance") - await instanceController.create({ + const createInstCtx = { params: { clientId: process.env.CLIENT_ID, applicationId: opts.applicationId, @@ -53,9 +58,11 @@ const createAppInstance = async opts => { request: { body: { name: `dev-${process.env.CLIENT_ID}` }, }, - }) + } + await instanceController.create(createInstCtx) console.log(chalk.green(`Default Instance Created`)) + console.log(JSON.stringify(createInstCtx.body)) } const createEmptyAppPackage = async opts => {