const execa = require("execa"); const path = require("path"); const fs = require("fs-extra"); async function cleanDist() { const distPath = path.resolve(__dirname, "../dist"); console.log(" -------- cleaning dist directory -------- "); await fs.remove(distPath); console.log(" -------- dist directory cleaned -------- "); } async function build() { const entryPath = path.resolve(__dirname, "../packages/rcs_5.0"); const toolPath = path.resolve(__dirname, "../tool/app/web"); const themePath = path.resolve(__dirname, "../tool/theme/web"); const paths = [entryPath, toolPath, themePath]; for await (const curPath of paths) { if (!(await fs.exists(path.resolve(curPath, "node_modules")))) { try { console.log(` -------- ${curPath} dependencies installing -------- `); const dependencyProcess = execa( "yarn install --registry=http://192.168.10.78:7001/", { cwd: curPath, shell: true, } ); dependencyProcess.stdout.pipe(process.stdout); dependencyProcess.stderr.pipe(process.stderr); await dependencyProcess; console.log(` -------- ${curPath} dependencies installed -------- `); } catch (error) { throw new Error(error); } } console.log(` -------- ${curPath} build start -------- `); const buildProcess = execa("yarn build", { cwd: curPath, shell: true, }); buildProcess.stdout.pipe(process.stdout); buildProcess.stderr.pipe(process.stderr); await buildProcess; console.log(` -------- ${curPath} build end -------- `); } } async function generateHtml() { const destPath = path.resolve(__dirname, "../dist/static/index.html"); const content = `