2020-02-22 23:24:19 +01:00
|
|
|
const { readdir, stat, copyFile, ensureDir } = require("fs-extra")
|
2020-02-03 10:24:25 +01:00
|
|
|
const { constants } = require("fs")
|
|
|
|
const { join, basename } = require("path")
|
2020-02-12 13:45:24 +01:00
|
|
|
const serverConfig = require("../../server/config")()
|
2020-02-03 10:24:25 +01:00
|
|
|
|
|
|
|
const packagesFolder = ".."
|
|
|
|
|
|
|
|
const jsFile = dir => join(dir, "budibase-client.js")
|
|
|
|
const jsMapFile = dir => join(dir, "budibase-client.js.map")
|
|
|
|
const sourceJs = jsFile("dist")
|
|
|
|
const sourceJsMap = jsMapFile("dist")
|
|
|
|
|
2020-02-12 13:45:24 +01:00
|
|
|
const appPackages = join(
|
|
|
|
packagesFolder,
|
|
|
|
"server",
|
|
|
|
serverConfig.latestPackagesFolder
|
|
|
|
)
|
2020-02-03 10:24:25 +01:00
|
|
|
|
|
|
|
const publicMain = appName => join(appPackages, appName, "public", "main")
|
|
|
|
const publicUnauth = appName =>
|
|
|
|
join(appPackages, appName, "public", "unauthenticated")
|
|
|
|
|
|
|
|
;(async () => {
|
|
|
|
const apps = await readdir(appPackages)
|
|
|
|
|
|
|
|
const copySource = file => async toDir => {
|
2020-02-22 23:24:19 +01:00
|
|
|
await ensureDir(toDir)
|
2020-02-03 10:24:25 +01:00
|
|
|
const dest = join(toDir, basename(file))
|
|
|
|
try {
|
|
|
|
await copyFile(file, dest, constants.COPYFILE_FICLONE)
|
|
|
|
console.log(`COPIED ${file} to ${dest}`)
|
|
|
|
} catch (e) {
|
|
|
|
console.log(`COPY FAILED ${file} to ${dest}: ${e}`)
|
2019-09-12 16:04:07 +02:00
|
|
|
}
|
2020-02-03 10:24:25 +01:00
|
|
|
}
|
2019-09-12 16:04:07 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
const copySourceJs = copySource(sourceJs)
|
|
|
|
const copySourceJsMap = copySource(sourceJsMap)
|
2019-09-12 16:04:07 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
for (let app of apps) {
|
2020-02-12 13:45:24 +01:00
|
|
|
if (app === ".data") continue
|
2020-02-03 10:24:25 +01:00
|
|
|
if (!(await stat(join(appPackages, app))).isDirectory()) continue
|
2019-09-12 16:04:07 +02:00
|
|
|
|
2020-02-12 13:45:24 +01:00
|
|
|
//await copySourceJs(nodeModules(app))
|
|
|
|
//await copySourceJsMap(nodeModules(app))
|
2019-09-12 16:04:07 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
await copySourceJs(publicMain(app))
|
|
|
|
await copySourceJsMap(publicMain(app))
|
2019-09-12 16:04:07 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
await copySourceJs(publicUnauth(app))
|
|
|
|
await copySourceJsMap(publicUnauth(app))
|
2019-09-12 16:04:07 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
await copySource(join("dist", "budibase-client.esm.mjs"))(
|
|
|
|
join(packagesFolder, "server", "builder")
|
|
|
|
)
|
|
|
|
}
|
|
|
|
})()
|