Updating standard components to make use of the development version in node_modules.
This commit is contained in:
parent
0b7502ba7e
commit
751607f72e
|
@ -10,13 +10,14 @@ const { budibaseTempDir } = require("../../../utilities/budibaseDir")
|
||||||
const { getDeployedApps } = require("../../../utilities/builder/hosting")
|
const { getDeployedApps } = require("../../../utilities/builder/hosting")
|
||||||
const CouchDB = require("../../../db")
|
const CouchDB = require("../../../db")
|
||||||
const setBuilderToken = require("../../../utilities/builder/setBuilderToken")
|
const setBuilderToken = require("../../../utilities/builder/setBuilderToken")
|
||||||
const { loadHandlebarsFile } = require("../../../utilities/fileSystem")
|
const {
|
||||||
|
loadHandlebarsFile,
|
||||||
|
NODE_MODULES_PATH,
|
||||||
|
} = require("../../../utilities/fileSystem")
|
||||||
const env = require("../../../environment")
|
const env = require("../../../environment")
|
||||||
const fileProcessor = require("../../../utilities/fileSystem/processor")
|
const fileProcessor = require("../../../utilities/fileSystem/processor")
|
||||||
const { objectStoreUrl, clientLibraryPath } = require("../../../utilities")
|
const { objectStoreUrl, clientLibraryPath } = require("../../../utilities")
|
||||||
|
|
||||||
const TOP_LEVEL = join(__dirname, "..", "..", "..", "..")
|
|
||||||
|
|
||||||
async function checkForSelfHostedURL(ctx) {
|
async function checkForSelfHostedURL(ctx) {
|
||||||
// the "appId" component of the URL may actually be a specific self hosted URL
|
// the "appId" component of the URL may actually be a specific self hosted URL
|
||||||
let possibleAppUrl = `/${encodeURI(ctx.params.appId).toLowerCase()}`
|
let possibleAppUrl = `/${encodeURI(ctx.params.appId).toLowerCase()}`
|
||||||
|
@ -32,7 +33,7 @@ async function checkForSelfHostedURL(ctx) {
|
||||||
const COMP_LIB_BASE_APP_VERSION = "0.2.5"
|
const COMP_LIB_BASE_APP_VERSION = "0.2.5"
|
||||||
|
|
||||||
exports.serveBuilder = async function(ctx) {
|
exports.serveBuilder = async function(ctx) {
|
||||||
let builderPath = resolve(TOP_LEVEL, "builder")
|
let builderPath = resolve(NODE_MODULES_PATH, "builder")
|
||||||
if (ctx.file === "index.html") {
|
if (ctx.file === "index.html") {
|
||||||
await setBuilderToken(ctx)
|
await setBuilderToken(ctx)
|
||||||
}
|
}
|
||||||
|
@ -93,7 +94,13 @@ exports.serveApp = async function(ctx) {
|
||||||
|
|
||||||
exports.serveClientLibrary = async function(ctx) {
|
exports.serveClientLibrary = async function(ctx) {
|
||||||
return send(ctx, "budibase-client.js", {
|
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"
|
||||||
|
),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ const fetch = require("node-fetch")
|
||||||
const DEFAULT_AUTOMATION_BUCKET =
|
const DEFAULT_AUTOMATION_BUCKET =
|
||||||
"https://prod-budi-automations.s3-eu-west-1.amazonaws.com"
|
"https://prod-budi-automations.s3-eu-west-1.amazonaws.com"
|
||||||
const DEFAULT_AUTOMATION_DIRECTORY = ".budibase-automations"
|
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,
|
* 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 lib = library.split("/")[1]
|
||||||
const path = require.resolve(library).split(lib)[0]
|
const path = require.resolve(library).split(lib)[0]
|
||||||
return require(join(path, lib, filename))
|
return require(join(path, lib, filename))
|
||||||
}
|
} else if (env.isDev()) {
|
||||||
const devPath = join(budibaseTempDir(), library, filename)
|
return require(join(
|
||||||
if (env.isDev() && fs.existsSync(devPath)) {
|
NODE_MODULES_PATH,
|
||||||
return require(devPath)
|
"@budibase",
|
||||||
|
"standard-components",
|
||||||
|
filename
|
||||||
|
))
|
||||||
}
|
}
|
||||||
const path = join(appId, "node_modules", library, "package", filename)
|
const path = join(appId, "node_modules", library, "package", filename)
|
||||||
let resp = await retrieve(ObjectStoreBuckets.APPS, path)
|
let resp = await retrieve(ObjectStoreBuckets.APPS, path)
|
||||||
|
@ -230,3 +234,4 @@ exports.cleanup = appIds => {
|
||||||
exports.upload = upload
|
exports.upload = upload
|
||||||
exports.retrieve = retrieve
|
exports.retrieve = retrieve
|
||||||
exports.retrieveToTmp = retrieveToTmp
|
exports.retrieveToTmp = retrieveToTmp
|
||||||
|
exports.NODE_MODULES_PATH = NODE_MODULES_PATH
|
||||||
|
|
Loading…
Reference in New Issue