diff --git a/packages/cli/src/commands/init/initHandler.js b/packages/cli/src/commands/init/initHandler.js index 543923376d..7cef940a1f 100644 --- a/packages/cli/src/commands/init/initHandler.js +++ b/packages/cli/src/commands/init/initHandler.js @@ -64,7 +64,7 @@ const createDevConfig = async (opts) => { const initialiseDatabase = async (opts) => { - const appContext = await getAppContext(); + const appContext = await getAppContext({masterIsCreated:false}); await createMasterDb( appContext, diff --git a/packages/cli/src/commands/new/newHandler.js b/packages/cli/src/commands/new/newHandler.js index f18a1c16f7..4a8db0e2eb 100644 --- a/packages/cli/src/commands/new/newHandler.js +++ b/packages/cli/src/commands/new/newHandler.js @@ -12,7 +12,7 @@ module.exports = ({name}) => { } const run = async (opts) => { - const context = await getAppContext(opts.config); + const context = await getAppContext({configName:opts.config, masterIsCreated:true}); const bb = await getMasterApisWithFullAccess(context); const app = bb.recordApi.getNew("/applications", "application"); diff --git a/packages/cli/src/commands/run/runHandler.js b/packages/cli/src/commands/run/runHandler.js index 12a4567379..913c80e462 100644 --- a/packages/cli/src/commands/run/runHandler.js +++ b/packages/cli/src/commands/run/runHandler.js @@ -2,8 +2,9 @@ const { getAppContext } = require("../../common"); const app = require("@budibase/server/app"); module.exports = ({config}) => { - getAppContext(config).then(context => { - app(context) + getAppContext({configName:config, masterIsCreated:true}) + .then(context => { + app(context); }); } diff --git a/packages/cli/src/common.js b/packages/cli/src/common.js index c7a3fd1a96..1bd4e852c9 100644 --- a/packages/cli/src/common.js +++ b/packages/cli/src/common.js @@ -10,7 +10,7 @@ module.exports.serverFileName = relativePath => "server", relativePath); -module.exports.getAppContext = async (configName) => { +module.exports.getAppContext = async ({configName, masterIsCreated}) => { if(configName) { if(!configName.endsWith(".js")) { @@ -21,5 +21,5 @@ module.exports.getAppContext = async (configName) => { } const config = require(join(cwd(), configName))(); - return await buildAppContext(config, false); + return await buildAppContext(config, masterIsCreated); } \ No newline at end of file diff --git a/packages/server/utilities/masterAppInternal.js b/packages/server/utilities/masterAppInternal.js index 6359c8ca0e..41f779b069 100644 --- a/packages/server/utilities/masterAppInternal.js +++ b/packages/server/utilities/masterAppInternal.js @@ -6,7 +6,7 @@ const { const getDatastore = require("./datastore"); const getDatabaseManager = require("./databaseManager"); const {$, splitKey} = require("@budibase/core").common; -const { keyBy, last, filter } = require("lodash/fp"); +const { keyBy, values } = require("lodash/fp"); const { masterAppPackage, applictionVersionPackage, @@ -34,7 +34,6 @@ module.exports = async (context) => { const loadApplications = async () => { const apps = await bb.indexApi.listItems("/all_applications"); applications = $(apps, [ - filter(a => !!a.defaultVersion.key), keyBy("name") ]); } @@ -286,7 +285,7 @@ module.exports = async (context) => { await bb.recordApi.save(userInMaster); } - const listApplications = () => applications; + const listApplications = () => values(applications); return ({