budi new not handling custom directories

This commit is contained in:
Michael Shanks 2020-05-18 10:45:07 +01:00
parent 3ee1d6670b
commit 37a46883e5
1 changed files with 12 additions and 5 deletions

View File

@ -11,9 +11,7 @@ module.exports = opts => {
const run = async opts => { const run = async opts => {
try { try {
opts.dir = xPlatHomeDir(opts.dir) setup(opts)
const bbconfig = dotenv.config({ path: resolve(opts.dir, ".env") })
console.log(bbconfig)
await createAppInstance(opts) await createAppInstance(opts)
await createEmptyAppPackage(opts) await createEmptyAppPackage(opts)
exec(`cd ${join(opts.dir, opts.applicationId)} && npm install`) 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 createAppInstance = async opts => {
const createAppCtx = { const createAppCtx = {
params: { clientId: process.env.CLIENT_ID }, 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 // this cannot be a top level require as it will cause
// the environment module to be loaded prematurely // the environment module to be loaded prematurely
const instanceController = require("@budibase/server/src/api/controllers/instance") const instanceController = require("@budibase/server/src/api/controllers/instance")
await instanceController.create({ const createInstCtx = {
params: { params: {
clientId: process.env.CLIENT_ID, clientId: process.env.CLIENT_ID,
applicationId: opts.applicationId, applicationId: opts.applicationId,
@ -53,9 +58,11 @@ const createAppInstance = async opts => {
request: { request: {
body: { name: `dev-${process.env.CLIENT_ID}` }, body: { name: `dev-${process.env.CLIENT_ID}` },
}, },
}) }
await instanceController.create(createInstCtx)
console.log(chalk.green(`Default Instance Created`)) console.log(chalk.green(`Default Instance Created`))
console.log(JSON.stringify(createInstCtx.body))
} }
const createEmptyAppPackage = async opts => { const createEmptyAppPackage = async opts => {