追加跟踪细粒度

This commit is contained in:
aixianling
2023-01-18 14:25:00 +08:00
parent 02001e78c2
commit ae8bf19957
2 changed files with 10 additions and 7 deletions

View File

@@ -1,9 +1,10 @@
const {exec} = require("child_process");
class Process {
constructor(cmd) {
constructor(cmd, cb) {
this.cmd = cmd
this.pid = exec(cmd, {windowsHide: true, encoding: "utf8"});
this.callback = cb
}
static new(cmd) {
@@ -28,6 +29,7 @@ class Process {
})
this.pid.stdout.on('data', data => {
console.log(data)
this.callback?.()
})
})
}

View File

@@ -15,17 +15,18 @@ const handleZip = (id, ws) => {
wxwork: 'base-wxcp',
mp: 'dvcp_v2_wxmp'
}[info.type] || {}
let path = `../${buildPath}`, {dist} = info
let path = `../${buildPath}`, {dist} = info, progress
dist = dist || `../zips/${info.name}v${info.version || "1.0.0"}`
Promise.all([
db.query(`update node_custom_config set download=null,error=null,zipTime='${dayjs().format("YYYY-MM-DD HH:mm:ss")}' where ${uniCon}`),
process.new(`./shell/update.sh ${info.name} ${path}`)])
.then(() => sendMessage({code: 0, progress: 30}))
.then(() => pid = new process(`cd ${path}&&npm run apps&&node bin/pages.js ${id}&&npm run build`)).then(() => pid.ins())
.then(() => progress = 30, sendMessage({code: 0, progress}))
.then(() => pid = new process(`cd ${path}&&npm run apps&&node bin/pages.js ${id}&&npm run build`), () => sendMessage({code: 0, progress: ++progress}))
.then(() => pid.ins())
.then(() => fse.emptyDir(dist))
.then(() => sendMessage({code: 0, progress: 70}))
.then(() => pid = new process(`./shell/move.sh ${info.type} ${path} ${dist}`)).then(() => pid.ins())
.then(() => sendMessage({code: 0, progress: 90}))
.then(() => progress = 70, sendMessage({code: 0, progress}))
.then(() => pid = new process(`./shell/move.sh ${info.type} ${path} ${dist}`), () => sendMessage({code: 0, progress: ++progress})).then(() => pid.ins())
.then(() => progress = 90, sendMessage({code: 0, progress}))
.then(() => db.query(`update node_custom_config set download='${dayjs().format("YYYY-MM-DD HH:mm:ss")}',error='' where ${uniCon}`))
.then(() => db.detail({table: "node_custom_config", id}))
.then(row => sendMessage({code: 0, progress: 100, row}))