
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
deploy-plus
Advanced tools
前端一键自动化部署脚手架服务,支持开发、测试、生产多环境配置。配置好后一键即可自动完成部署。
https://github.com/chenchenwuai/deploy-plus
全局安装 deploy-plus
npm install deploy-plus -g
本地安装 deploy-plus
npm install deploy-plus --save-dev
查看版本,表示安装成功
deploy-plus -v
注:本地安装的需要在调用前加 npx
npx deploy-plus -v
deploy-plus -h
init 初始化配置文件(在项目目录下)deploy-plus init -fy
# 或者使用简写
deploy-plus i -fy
执行
deploy-plus i -h获取使用帮助
参数
-f --force 强制重新生成配置文件-y --yes 全部设置为默认值, 如果后面跟字符串会被当作默认密码,例如: deploy-plus i -y my-password根据提示填写内容,会在项目根目录下生成 deploy.config.js 文件,初始化可根据选择的需要部署的环境生成 dev (开发环境)、test (测试环境)、prod (生产环境) 三个配置,再有其他配置可参考模板自行配置。
提示:交互输入密码时会自动使用私钥加密,无需手动加密。
如果生成文件时没有输入密码,或者没有默认密码,而后面又想设置密码时,请参考 2.3节 生成密码的加密字符串
encrypt 加解密密码操作# 加密原始密码
deploy-plus encrypt 123456
# 或者使用简写
deploy-plus e 123456
加密成功后,控制台会打印出结果,请将结果填写到配置的password字段
# 解密
deploy-plus e decrypt xxxxx
# 或者使用简写
deploy-plus e -d xxxxx
xxxxx 为加密密码生成的字符串
执行
deploy-plus e -h获取使用帮助
deploy 部署文件到服务器deploy-plus deploy
# 或者使用简写
deploy-plus d
deploy-plus d -by -m prod
执行
deploy-plus d -h获取使用帮助
参数
-m --mode <mode> 设置部署模式,不设置此参数,则默认 dev,例如:deploy-plus d -m prod-c --cluster 部署集群,设置此参数后会忽略 -m 参数-b --build 设置此参数,会执行打包命令(需保证已填写打包命令配置)-y --yes 跳过是否确定部署提示如需手动配置,只需要在项目根目录下手动创建
.deploy.config.js文件,复制以下代码按情况修改即可。
// 配置字段解析
module.exports = {
projectName: 'myProject', // 项目名称
privateKey: '/Users/username/.ssh/id_rsa', // id_rsa文件路径
passphrase: '',
cluster: ['dev','test'], // 集群部署配置,要同时部署多台配置此属性如: ['dev', 'test', 'prod']
dev: {
// 环境对象
name: '开发环境', // 环境名称
script: 'npm run build', // 打包命令
host: '192.168.0.1', // 服务器地址
port: 22, // 服务器端口号
username: 'root', // 服务器登录用户名
password: '', // 服务器登录密码
distPath: 'dist', // 本地打包生成目录
webDir: '/usr/local/nginx/html', // 服务器部署路径(不可为空或'/'或'/aaa',至少三级目录)
isBackupRemoteFile: true, // 是否备份远程文件(默认true)
isCompressBackup: true // 是否压缩备份文件(默认true)
},
test: {
name: '测试环境',
script: 'npm run build:test',
host: '192.168.0.1',
port: 22,
username: 'root',
password: '',
distPath: 'dist',
webDir: '/usr/local/nginx/html',
isBackupRemoteFile: true,
isCompressBackup: true
},
prod: {
name: '生产环境',
script: 'npm run build:prod',
host: '192.168.0.1',
port: 22,
username: 'root',
password: '',
distPath: 'dist',
webDir: '/usr/local/nginx/html',
isBackupRemoteFile: true,
isCompressBackup: true
}
}
如果使用本地安装命令的话,可以在项目根目录下的 package.json 文件中 scripts 脚本中添加如下代码
"scripts": {
"deploy": "deploy-plus d",
"deploy:dev": "deploy-plus d -b",
"deploy:test": "deploy-plus d -b -m test",
"deploy:prod": "deploy-plus d -b -m prod"
}
然后使用下面代码也可以完成部署操作
npm run deploy:dev
假设你有一个 Vue 项目,需要部署到开发服务器和生产服务器。
第一步:安装并初始化
# 在项目根目录下
npm install deploy-plus --save-dev
# 初始化配置文件(使用默认密码 123456)
npx deploy-plus init -fy 123456
第二步:修改配置文件 .deploy.config.js
module.exports = {
projectName: 'my-vue-app',
privateKey: '/Users/yourname/.ssh/id_rsa',
passphrase: '',
cluster: [],
dev: {
name: '开发环境',
script: 'npm run build:dev',
host: '192.168.1.100',
port: 22,
username: 'root',
password: 'xxxxxx', // 使用 deploy-plus e 123456 生成的加密字符串
distPath: 'dist',
webDir: '/var/www/my-vue-app',
isBackupRemoteFile: true,
isCompressBackup: true
},
prod: {
name: '生产环境',
script: 'npm run build:prod',
host: '10.0.0.50',
port: 22,
username: 'deploy',
password: 'xxxxxx',
distPath: 'dist',
webDir: '/var/www/my-vue-app',
isBackupRemoteFile: true,
isCompressBackup: true
}
}
第三步:执行部署
# 部署到开发环境(不执行打包,适合已打包的情况)
npx deploy-plus d
# 部署到开发环境(先打包再部署)
npx deploy-plus d -b
# 部署到生产环境(先打包再部署,跳过确认提示)
npx deploy-plus d -by -m prod
同时部署到多台服务器:
// .deploy.config.js
module.exports = {
projectName: 'my-app',
privateKey: '/Users/yourname/.ssh/id_rsa',
cluster: ['dev', 'test'], // 指定要同时部署的环境
dev: {
name: '开发服务器1',
host: '192.168.1.101',
// ... 其他配置
},
test: {
name: '开发服务器2',
host: '192.168.1.102',
// ... 其他配置
}
}
# 执行集群部署(会依次部署到 dev 和 test)
npx deploy-plus d -c -b
如果服务器已配置 SSH 密钥认证,可以不设置密码:
module.exports = {
projectName: 'my-app',
privateKey: '/Users/yourname/.ssh/id_rsa', // 确保此私钥已添加到服务器
passphrase: '', // 私钥密码,没有则留空
dev: {
name: '开发环境',
host: '192.168.1.100',
port: 22,
username: 'root',
password: '', // 留空,使用密钥认证
distPath: 'dist',
webDir: '/var/www/html',
isBackupRemoteFile: false, // 不备份远程文件
isCompressBackup: false
}
}
# 1. 初始化配置
deploy-plus init
# 2. 加密密码并填入配置
deploy-plus encrypt your-server-password
# 3. 部署前先测试配置(不打包,手动确认)
deploy-plus d -m dev
# 4. 正式部署(打包 + 部署 + 跳过确认)
deploy-plus d -by -m prod
webDir 必须是至少三级的绝对路径,如 /var/www/html/ 或 /var 这样的少于三级的目录(安全限制)deploy-plus e -d 加密字符串
isCompressBackup: true 会将备份压缩为 .tar.gz 文件isBackupRemoteFile: false 可以关闭备份功能webDir 的同级目录,命名格式为 {webDir}_backup_{YYYYMMDD_HHmmss}.tar.gz最后如果大家觉得还不错挺好用的话,麻烦给个 Star 😜😜😜。
FAQs
The npm package deploy-plus receives a total of 10 weekly downloads. As such, deploy-plus popularity was classified as not popular.
We found that deploy-plus demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.