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 => {