UNPKG

yw-auto-deploy-tool

Version:

一个自动打包、上传并部署的脚本工具

32 lines (27 loc) 902 B
#!/usr/bin/env node const fs = require('fs'); const path = require('path'); const configPath = path.resolve(process.cwd(), 'deploy.config.js'); const defaultConfig = ` // deploy.config.js module.exports = { sshConfig: { host: 'your.server.com', port: 22, username: 'your-username', password: 'your-password', }, paths: { localDistDir: './dist', // 本地构建目录 localZipPath: './dist.zip', // 本地打包后的 zip 路径 remoteZipPath: '/data/soft/server/yw_label/yw_label-ui/html/dist.zip', // 远程 zip 文件路径 remoteUnzipDir: '/data/soft/server/yw_label/yw_label-ui/html', // 远程解压路径 }, }; `; if (fs.existsSync(configPath)) { console.log('⚠️ deploy.config.js 已存在,未覆盖。'); } else { fs.writeFileSync(configPath, defaultConfig.trimStart()); console.log('✅ 已生成 deploy.config.js 模板文件'); }