publish:dev script to help client development

This commit is contained in:
Michael Shanks 2019-09-12 15:04:07 +01:00
parent dda4517cb0
commit 4cd2de5df3
3 changed files with 66 additions and 1 deletions

14
packages/client/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Publish Dev",
"program": "${workspaceFolder}/scripts/publishDev.js"
}
]
}

View File

@ -6,7 +6,8 @@
"module": "dist/budibase-client.js", "module": "dist/budibase-client.js",
"scripts": { "scripts": {
"build": "rollup -c", "build": "rollup -c",
"test": "jest" "test": "jest",
"publish:dev": "yarn build && node ./scripts/publishDev.js"
}, },
"jest": { "jest": {
"globals": { "globals": {
@ -46,6 +47,7 @@
"@babel/preset-env": "^7.5.5", "@babel/preset-env": "^7.5.5",
"@babel/runtime": "^7.5.5", "@babel/runtime": "^7.5.5",
"babel-jest": "^24.8.0", "babel-jest": "^24.8.0",
"fs-extra": "^8.1.0",
"jest": "^24.8.0", "jest": "^24.8.0",
"rollup": "^1.12.0", "rollup": "^1.12.0",
"rollup-plugin-commonjs": "^10.0.0", "rollup-plugin-commonjs": "^10.0.0",

View File

@ -0,0 +1,49 @@
const { readdir, stat, copyFile } = require("fs-extra");
const { constants } = require("fs");
const { join } = require("path");
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");
const appPackages = join(packagesFolder, "server", "appPackages");
const publicMain = appName => join(appPackages, appName, "public", "main");
const publicUnauth = appName => join(appPackages, appName, "public", "unauthenticated");
const nodeModules = appName => join(appPackages, appName, "node_modules", "@budibase", "client", "dist");
(async () => {
const apps = await readdir(appPackages);
const copySource = file => async toDir => {
const dest = jsFile(toDir);
try {
await copyFile(file, dest, constants.COPYFILE_FICLONE);
console.log(`COPIED ${file} to ${dest}`);
} catch(e) {
console.log(`COPY FAILED ${file} to ${dest}: ${e}`);
}
}
const copySourceJs = copySource(sourceJs);
const copySourceJsMap = copySource(sourceJsMap);
for(let app of apps) {
if(!(await stat(join(appPackages, app))).isDirectory()) continue;
await copySourceJs(nodeModules(app));
await copySourceJsMap(nodeModules(app));
await copySourceJs(publicMain(app));
await copySourceJsMap(publicMain(app));
await copySourceJs(publicUnauth(app));
await copySourceJsMap(publicUnauth(app));
}
})();