1
0
Fork 0
mirror of synced 2024-06-27 18:40:42 +12:00

rename buildPage

This commit is contained in:
Martin McKeaveney 2020-11-05 13:41:16 +00:00
parent 76cc7d897c
commit 3847c058dc
4 changed files with 19 additions and 12 deletions

View file

@ -1,5 +1,5 @@
const CouchDB = require("../../db") const CouchDB = require("../../db")
const { buildPage } = require("../../utilities/builder") const { compileStaticAssetsForPage } = require("../../utilities/builder")
const env = require("../../environment") const env = require("../../environment")
const { copy, existsSync, readFile, writeFile } = require("fs-extra") const { copy, existsSync, readFile, writeFile } = require("fs-extra")
const { budibaseAppsDir } = require("../../utilities/budibaseDir") 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}` unauthPage.props._children[0]._children.title = `Log in to ${app.name}`
const homeScreen = cloneDeep(HOME_SCREEN) const homeScreen = cloneDeep(HOME_SCREEN)
homeScreen._id = generateScreenID(mainPage._id) 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, page: mainPage,
screens: [homeScreen], screens: [homeScreen],
}) })
await buildPage(app._id, "unauthenticated", { await compileStaticAssetsForPage(app._id, "unauthenticated", {
page: unauthPage, page: unauthPage,
screens: [], screens: [],
}) })

View file

@ -1,14 +1,17 @@
const CouchDB = require("../../db/client") const CouchDB = require("../../db/client")
const { generatePageID } = require("../../db/utils") const { generatePageID } = require("../../db/utils")
const { buildPage } = require("../../utilities/builder") const { compileStaticAssetsForPage } = require("../../utilities/builder")
exports.save = async function(ctx) { exports.save = async function(ctx) {
const db = new CouchDB(ctx.user.appId) const db = new CouchDB(ctx.user.appId)
const appPackage = ctx.request.body const appPackage = ctx.request.body
// TODO: rename to something more descriptive await compileStaticAssetsForPage(
await buildPage(ctx.user.appId, ctx.params.pageId, ctx.request.body) ctx.user.appId,
ctx.params.pageId,
ctx.request.body
)
// remove special doc props which couch will complain about // remove special doc props which couch will complain about
delete appPackage.page._css delete appPackage.page._css

View file

@ -5,7 +5,7 @@ const Joi = require("joi")
const { const {
listScreens, listScreens,
saveScreen, saveScreen,
buildPage, compileStaticAssetsForPage,
deleteScreen, deleteScreen,
} = require("../../utilities/builder") } = require("../../utilities/builder")
const authorized = require("../../middleware/authorized") const authorized = require("../../middleware/authorized")
@ -44,7 +44,11 @@ router.post(
"/_builder/api/:appId/pages/:pageName", "/_builder/api/:appId/pages/:pageName",
authorized(BUILDER), authorized(BUILDER),
async ctx => { 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 ctx.response.status = StatusCodes.OK
} }
) )

View file

@ -11,13 +11,13 @@
// const { join } = require("../centralPath") // const { join } = require("../centralPath")
// const { dirname } = require("path") // const { dirname } = require("path")
const buildPage = require("./buildPage") const compileStaticAssetsForPage = require("./compileStaticAssetsForPage")
// const getPages = require("./getPages") // const getPages = require("./getPages")
// const listScreens = require("./listScreens") // const listScreens = require("./listScreens")
// const { budibaseAppsDir } = require("../budibaseDir") // const { budibaseAppsDir } = require("../budibaseDir")
// const { budibaseAppsDir } = require("../budibaseDir") // const { budibaseAppsDir } = require("../budibaseDir")
module.exports.buildPage = buildPage module.exports.compileStaticAssetsForPage = compileStaticAssetsForPage
// module.exports.listScreens = listScreens // module.exports.listScreens = listScreens
// const getAppDefinition = async appPath => // const getAppDefinition = async appPath =>
@ -76,5 +76,5 @@ module.exports.buildPage = buildPage
// space: 2, // space: 2,
// }) // })
// const appDefinition = await getAppDefinition(appPath) // const appDefinition = await getAppDefinition(appPath)
// await buildPage(appId, appDefinition, pagename, page) // await compileStaticAssetsForPage(appId, appDefinition, pagename, page)
// } // }