打包脚本集中管理

This commit is contained in:
2022-12-21 08:43:58 +08:00
parent 1f1cac75f1
commit 6ae2164d52
3 changed files with 38 additions and 3 deletions

22
shell/move.sh Normal file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
Type=$1
Prj=$2
Deploy=$3
case "$Type" in
web)
cp -r $Prj/dist/* $Deploy
;;
web)
cp -r $Prj/dist/build/h5/* $Deploy
;;
web)
cp -r $Prj/dist/build/mp-weixin/* $Deploy
;;
*)
echo $"Usage: $0 (web|wxwork|mp)"
exit 1
esac
exit $?
exit $RETVAL

13
shell/update.sh Normal file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/expect
set Name [lindex $argv 0]
set Prj [lindex $argv 1]
puts "更新$Name"
cd $Prj
spawn git pull
expect "Username"
send "aixianling\r"
expect "Password"
send "axl123.0\r"
interact
cd ..

View File

@@ -16,17 +16,17 @@ module.exports = {
wxwork: 'base-wxcp', wxwork: 'base-wxcp',
mp: 'dvcp_v2_wxmp' mp: 'dvcp_v2_wxmp'
}[info.type] || {} }[info.type] || {}
const path = `/home/deploy/node-service/${buildPath}`, const path = `/home/deploy/node_deploy/${buildPath}`,
{dist} = info {dist} = info
Promise.all([ Promise.all([
execute(`/root/node-service/update.sh ${info.name} ${path}`), execute(`./shell/update.sh ${info.name} ${path}`),
db.query(sql) db.query(sql)
]).then(() => setTimeout(() => { ]).then(() => setTimeout(() => {
response.send({code: 0}) response.send({code: 0})
}, 1000)) }, 1000))
execute(`cd ${path}&&npm run apps&&node bin/pages.js ${id}&&npm run build`) execute(`cd ${path}&&npm run apps&&node bin/pages.js ${id}&&npm run build`)
.then(() => fse.emptyDir(dist)) .then(() => fse.emptyDir(dist))
.then(() => execute(`/root/node-service/move.sh ${info.type} ${path} ${dist}`)) .then(() => execute(`./shell/move.sh ${info.type} ${path} ${dist}`))
.then(() => { .then(() => {
return db.query(`update node_custom_config set download='${dayjs().format("YYYY-MM-DD HH:mm:ss")}',error='' where ${uniCon}`) return db.query(`update node_custom_config set download='${dayjs().format("YYYY-MM-DD HH:mm:ss")}',error='' where ${uniCon}`)
}).catch(err => { }).catch(err => {