diff --git a/packages/server/src/api/controllers/static/index.js b/packages/server/src/api/controllers/static/index.js index ec3db6bbd3..fb9c16683c 100644 --- a/packages/server/src/api/controllers/static/index.js +++ b/packages/server/src/api/controllers/static/index.js @@ -10,13 +10,14 @@ const { budibaseTempDir } = require("../../../utilities/budibaseDir") const { getDeployedApps } = require("../../../utilities/builder/hosting") const CouchDB = require("../../../db") const setBuilderToken = require("../../../utilities/builder/setBuilderToken") -const { loadHandlebarsFile } = require("../../../utilities/fileSystem") +const { + loadHandlebarsFile, + NODE_MODULES_PATH, +} = require("../../../utilities/fileSystem") const env = require("../../../environment") const fileProcessor = require("../../../utilities/fileSystem/processor") const { objectStoreUrl, clientLibraryPath } = require("../../../utilities") -const TOP_LEVEL = join(__dirname, "..", "..", "..", "..") - async function checkForSelfHostedURL(ctx) { // the "appId" component of the URL may actually be a specific self hosted URL let possibleAppUrl = `/${encodeURI(ctx.params.appId).toLowerCase()}` @@ -32,7 +33,7 @@ async function checkForSelfHostedURL(ctx) { const COMP_LIB_BASE_APP_VERSION = "0.2.5" exports.serveBuilder = async function(ctx) { - let builderPath = resolve(TOP_LEVEL, "builder") + let builderPath = resolve(NODE_MODULES_PATH, "builder") if (ctx.file === "index.html") { await setBuilderToken(ctx) } @@ -93,7 +94,13 @@ exports.serveApp = async function(ctx) { exports.serveClientLibrary = async function(ctx) { return send(ctx, "budibase-client.js", { - root: join(TOP_LEVEL, "node_modules", "@budibase", "client", "dist"), + root: join( + NODE_MODULES_PATH, + "node_modules", + "@budibase", + "client", + "dist" + ), }) } diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index 7ef99eda41..632c22f40b 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -22,6 +22,7 @@ const fetch = require("node-fetch") const DEFAULT_AUTOMATION_BUCKET = "https://prod-budi-automations.s3-eu-west-1.amazonaws.com" const DEFAULT_AUTOMATION_DIRECTORY = ".budibase-automations" +const NODE_MODULES_PATH = join(__dirname, "..", "..", "..", "..", "node_modules") /** * The single stack system (Cloud and Builder) should not make use of the file system where possible, @@ -170,10 +171,13 @@ exports.getComponentLibraryManifest = async (appId, library) => { const lib = library.split("/")[1] const path = require.resolve(library).split(lib)[0] return require(join(path, lib, filename)) - } - const devPath = join(budibaseTempDir(), library, filename) - if (env.isDev() && fs.existsSync(devPath)) { - return require(devPath) + } else if (env.isDev()) { + return require(join( + NODE_MODULES_PATH, + "@budibase", + "standard-components", + filename + )) } const path = join(appId, "node_modules", library, "package", filename) let resp = await retrieve(ObjectStoreBuckets.APPS, path) @@ -230,3 +234,4 @@ exports.cleanup = appIds => { exports.upload = upload exports.retrieve = retrieve exports.retrieveToTmp = retrieveToTmp +exports.NODE_MODULES_PATH = NODE_MODULES_PATH