diff --git a/packages/server/.gitignore b/packages/server/.gitignore index c737d00466..e8589f631d 100644 --- a/packages/server/.gitignore +++ b/packages/server/.gitignore @@ -2,6 +2,7 @@ node_modules/ myapps/ .env builder/* +client/* public/ db/dev.db/ dist diff --git a/packages/server/package.json b/packages/server/package.json index ace5fe693f..d3d99a5b16 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -13,7 +13,8 @@ "postbuild": "copyfiles -u 1 src/**/*.svelte dist/ && copyfiles -u 1 src/**/*.hbs dist/ && copyfiles -u 1 src/**/*.json dist/", "test": "jest --coverage --maxWorkers=2", "test:watch": "jest --watch", - "build:docker": "docker build . -t app-service", + "predocker": "copyfiles -f ../client/dist/budibase-client.js ../standard-components/manifest.json client", + "build:docker": "yarn run predocker && docker build . -t app-service", "run:docker": "node dist/index.js", "dev:stack:up": "node scripts/dev/manage.js up", "dev:stack:down": "node scripts/dev/manage.js down", diff --git a/packages/server/src/utilities/fileSystem/clientLibrary.js b/packages/server/src/utilities/fileSystem/clientLibrary.js index 6b7e8d837d..0b57bbc3b2 100644 --- a/packages/server/src/utilities/fileSystem/clientLibrary.js +++ b/packages/server/src/utilities/fileSystem/clientLibrary.js @@ -2,6 +2,9 @@ const { join } = require("path") const { ObjectStoreBuckets } = require("../../constants") const fs = require("fs") const { upload, retrieveToTmp, streamUpload } = require("./utilities") +const { resolve } = require("../centralPath") +const env = require("../../environment") +const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..") /** * Client library paths in the object store: @@ -86,13 +89,26 @@ exports.backupClientLibrary = async appId => { * @returns {Promise} */ exports.updateClientLibrary = async appId => { + let manifest, client + + if (false && env.isDev()) { + // Load the symlinked version in dev which is always the newest + manifest = require.resolve("@budibase/standard-components/manifest.json") + client = require.resolve("@budibase/client") + } else { + // Load the bundled version in prod + manifest = resolve(TOP_LEVEL_PATH, "client", "manifest.json") + client = resolve(TOP_LEVEL_PATH, "client", "budibase-client.js") + + console.log(manifest) + console.log(client) + } + // Upload latest component manifest await streamUpload( ObjectStoreBuckets.APPS, join(appId, "manifest.json"), - fs.createReadStream( - require.resolve("@budibase/standard-components/manifest.json") - ), + fs.createReadStream(manifest), { ContentType: "application/json", } @@ -102,7 +118,7 @@ exports.updateClientLibrary = async appId => { await streamUpload( ObjectStoreBuckets.APPS, join(appId, "budibase-client.js"), - fs.createReadStream(require.resolve("@budibase/client")), + fs.createReadStream(client), { ContentType: "application/javascript", }