From bdfd80fc030c7c7c93becde0f5691e6ca4029ec2 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 5 Nov 2020 13:41:16 +0000 Subject: [PATCH] rename buildPage --- packages/server/src/api/controllers/application.js | 8 ++++---- packages/server/src/api/controllers/page.js | 9 ++++++--- packages/server/src/api/routes/pages.old.js | 8 ++++++-- packages/server/src/utilities/builder/index.js | 6 +++--- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index b10b8d82c0..5a494d4734 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -1,5 +1,5 @@ const CouchDB = require("../../db") -const { buildPage } = require("../../utilities/builder") +const { compileStaticAssetsForPage } = require("../../utilities/builder") const env = require("../../environment") const { copy, existsSync, readFile, writeFile } = require("fs-extra") const { budibaseAppsDir } = require("../../utilities/budibaseDir") @@ -230,13 +230,13 @@ const createEmptyAppPackage = async (ctx, app) => { unauthPage.props._children[0]._children.title = `Log in to ${app.name}` const homeScreen = cloneDeep(HOME_SCREEN) homeScreen._id = generateScreenID(mainPage._id) - const response = await db.bulkDocs([mainPage, unauthPage, homeScreen]) + await db.bulkDocs([mainPage, unauthPage, homeScreen]) - await buildPage(app._id, "main", { + await compileStaticAssetsForPage(app._id, "main", { page: mainPage, screens: [homeScreen], }) - await buildPage(app._id, "unauthenticated", { + await compileStaticAssetsForPage(app._id, "unauthenticated", { page: unauthPage, screens: [], }) diff --git a/packages/server/src/api/controllers/page.js b/packages/server/src/api/controllers/page.js index 06d427f546..0455a4cf45 100644 --- a/packages/server/src/api/controllers/page.js +++ b/packages/server/src/api/controllers/page.js @@ -1,14 +1,17 @@ const CouchDB = require("../../db/client") const { generatePageID } = require("../../db/utils") -const { buildPage } = require("../../utilities/builder") +const { compileStaticAssetsForPage } = require("../../utilities/builder") exports.save = async function(ctx) { const db = new CouchDB(ctx.user.appId) const appPackage = ctx.request.body - // TODO: rename to something more descriptive - await buildPage(ctx.user.appId, ctx.params.pageId, ctx.request.body) + await compileStaticAssetsForPage( + ctx.user.appId, + ctx.params.pageId, + ctx.request.body + ) // remove special doc props which couch will complain about delete appPackage.page._css diff --git a/packages/server/src/api/routes/pages.old.js b/packages/server/src/api/routes/pages.old.js index 2cd0b5ed66..5d23264c10 100644 --- a/packages/server/src/api/routes/pages.old.js +++ b/packages/server/src/api/routes/pages.old.js @@ -5,7 +5,7 @@ const Joi = require("joi") const { listScreens, saveScreen, - buildPage, + compileStaticAssetsForPage, deleteScreen, } = require("../../utilities/builder") const authorized = require("../../middleware/authorized") @@ -44,7 +44,11 @@ router.post( "/_builder/api/:appId/pages/:pageName", authorized(BUILDER), async ctx => { - await buildPage(ctx.params.appId, ctx.params.pageName, ctx.request.body) + await compileStaticAssetsForPage( + ctx.params.appId, + ctx.params.pageName, + ctx.request.body + ) ctx.response.status = StatusCodes.OK } ) diff --git a/packages/server/src/utilities/builder/index.js b/packages/server/src/utilities/builder/index.js index 155ad5b197..015e40244e 100644 --- a/packages/server/src/utilities/builder/index.js +++ b/packages/server/src/utilities/builder/index.js @@ -11,13 +11,13 @@ // const { join } = require("../centralPath") // const { dirname } = require("path") -const buildPage = require("./buildPage") +const compileStaticAssetsForPage = require("./compileStaticAssetsForPage") // const getPages = require("./getPages") // const listScreens = require("./listScreens") // const { budibaseAppsDir } = require("../budibaseDir") // const { budibaseAppsDir } = require("../budibaseDir") -module.exports.buildPage = buildPage +module.exports.compileStaticAssetsForPage = compileStaticAssetsForPage // module.exports.listScreens = listScreens // const getAppDefinition = async appPath => @@ -76,5 +76,5 @@ module.exports.buildPage = buildPage // space: 2, // }) // const appDefinition = await getAppDefinition(appPath) -// await buildPage(appId, appDefinition, pagename, page) +// await compileStaticAssetsForPage(appId, appDefinition, pagename, page) // }