Bundle latest client library with the server and use it when updating apps in production
This commit is contained in:
parent
bd27aa0caf
commit
ef4a0f8c79
|
@ -2,6 +2,7 @@ node_modules/
|
||||||
myapps/
|
myapps/
|
||||||
.env
|
.env
|
||||||
builder/*
|
builder/*
|
||||||
|
client/*
|
||||||
public/
|
public/
|
||||||
db/dev.db/
|
db/dev.db/
|
||||||
dist
|
dist
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
"postbuild": "copyfiles -u 1 src/**/*.svelte dist/ && copyfiles -u 1 src/**/*.hbs dist/ && copyfiles -u 1 src/**/*.json dist/",
|
"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": "jest --coverage --maxWorkers=2",
|
||||||
"test:watch": "jest --watch",
|
"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",
|
"run:docker": "node dist/index.js",
|
||||||
"dev:stack:up": "node scripts/dev/manage.js up",
|
"dev:stack:up": "node scripts/dev/manage.js up",
|
||||||
"dev:stack:down": "node scripts/dev/manage.js down",
|
"dev:stack:down": "node scripts/dev/manage.js down",
|
||||||
|
|
|
@ -2,6 +2,9 @@ const { join } = require("path")
|
||||||
const { ObjectStoreBuckets } = require("../../constants")
|
const { ObjectStoreBuckets } = require("../../constants")
|
||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const { upload, retrieveToTmp, streamUpload } = require("./utilities")
|
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:
|
* Client library paths in the object store:
|
||||||
|
@ -86,13 +89,26 @@ exports.backupClientLibrary = async appId => {
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
exports.updateClientLibrary = async appId => {
|
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
|
// Upload latest component manifest
|
||||||
await streamUpload(
|
await streamUpload(
|
||||||
ObjectStoreBuckets.APPS,
|
ObjectStoreBuckets.APPS,
|
||||||
join(appId, "manifest.json"),
|
join(appId, "manifest.json"),
|
||||||
fs.createReadStream(
|
fs.createReadStream(manifest),
|
||||||
require.resolve("@budibase/standard-components/manifest.json")
|
|
||||||
),
|
|
||||||
{
|
{
|
||||||
ContentType: "application/json",
|
ContentType: "application/json",
|
||||||
}
|
}
|
||||||
|
@ -102,7 +118,7 @@ exports.updateClientLibrary = async appId => {
|
||||||
await streamUpload(
|
await streamUpload(
|
||||||
ObjectStoreBuckets.APPS,
|
ObjectStoreBuckets.APPS,
|
||||||
join(appId, "budibase-client.js"),
|
join(appId, "budibase-client.js"),
|
||||||
fs.createReadStream(require.resolve("@budibase/client")),
|
fs.createReadStream(client),
|
||||||
{
|
{
|
||||||
ContentType: "application/javascript",
|
ContentType: "application/javascript",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue