- 引入依赖
npm i @quincyx/deploy-toolkit -D
- 创建脚本
在项目根目录下创建文件 deploy.js
const path = require('path')
const deployTool = require('@quincyx/deploy-toolkit')
const option = {
server: {
host: '0.0.0.0',
port: '22',
username: '',
password: '',
privateKey:'',
remotePath: '/www/web',
localPath: path.resolve(__dirname, './dist'),
},
project: {
name: config.name,
version: config.version,
url: 'https://www.null.com'
},
git: {
enable: true,
version: 'patch'
},
webhook: {
enable: true,
type: 'work_wx',
key: 'work_wx_bot_key'
}
}
deployTool.start(option)
- 添加到 npm script
在 package.json 中添加部署脚本
"scripts": {
"build:test": "vue-cli-service build --mode test",
"deploy:test": "vue-cli-service build --mode test && node deploy.js"
}