added post-deploy script

This commit is contained in:
SrGooglo 2023-06-02 02:24:17 +00:00
parent aef7680498
commit 8dcf0b2850
2 changed files with 47 additions and 1 deletions

View File

@ -12,7 +12,8 @@
"dev:chat_server": "cd packages/chat_server && yarn dev",
"dev:marketplace_server": "cd packages/marketplace_server && yarn dev",
"dev:server": "cd packages/server && yarn dev",
"dev:client": "cd packages/app && yarn dev"
"dev:client": "cd packages/app && yarn dev",
"post:deploy": "node ./scripts/post-deploy.js"
},
"workspaces": [
"packages/**"

45
scripts/post-deploy.js Normal file
View File

@ -0,0 +1,45 @@
const path = require("path")
const fs = require("fs")
const child_process = require("child_process")
const sharedRootPath = path.resolve(process.cwd(), "shared")
const rootPath = process.cwd()
const packagesPath = path.resolve(rootPath, "packages")
const getPackages = require("./utils/getPackages")
async function main() {
const packages = await getPackages({
ignore: ["shared", "app", "wrapper"]
})
for await (const packageName of packages) {
const packagePath = path.resolve(packagesPath, packageName)
// copy shared
const sharedPath = path.resolve(packagePath, "src", "_shared")
if (fs.existsSync(sharedPath)) {
// remove old shared folder
fs.rmdirSync(sharedPath, { recursive: true })
}
// copy entire shared folder
// shared/* => /_shared/*
fs.mkdirSync(sharedPath, { recursive: true })
await child_process.execSync(`cp -r ${sharedRootPath}/* ${sharedPath} && echo Shared lib copied`, {
cwd: packagePath,
stdio: "inherit"
})
// run yarn build
await child_process.execSync("yarn build", {
cwd: packagePath,
stdio: "inherit"
})
}
}
main().catch(console.error)