From c9b35508d98f84bc6a5752024ffcbd503ac24ddd Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Mon, 22 Jun 2020 21:16:51 +0100 Subject: [PATCH] #363 bugfix: page not built until prop changed --- .../server/src/api/controllers/application.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index ab4820794f..43463fc4fd 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -1,6 +1,6 @@ const CouchDB = require("../../db") const ClientDb = require("../../db/clientDb") -const { getPackageForBuilder } = require("../../utilities/builder") +const { getPackageForBuilder, buildPage } = require("../../utilities/builder") const newid = require("../../db/newid") const env = require("../../environment") const instanceController = require("./instance") @@ -111,15 +111,23 @@ const createEmptyAppPackage = async (ctx, app) => { await updateJsonFile(join(appsFolder, app._id, "package.json"), { name: npmFriendlyAppName(app.name), }) - await updateJsonFile( + + const mainJson = await updateJsonFile( join(appsFolder, app._id, "pages", "main", "page.json"), app ) - await updateJsonFile( + + await buildPage(ctx.config, app._id, "main", { page: mainJson }) + + const unauthenticatedJson = await updateJsonFile( join(appsFolder, app._id, "pages", "unauthenticated", "page.json"), app ) + await buildPage(ctx.config, app._id, "unauthenticated", { + page: unauthenticatedJson, + }) + return newAppFolder } @@ -145,6 +153,7 @@ const updateJsonFile = async (filePath, app) => { const json = await readFile(filePath, "utf8") const newJson = sqrl.Render(json, app) await writeFile(filePath, newJson, "utf8") + return JSON.parse(newJson) } const runNpmInstall = async newAppFolder => {