UNPKG

server-deploy-cli

Version:

connect server with ssh2-sftp-client, and publish local files to remote server or delete some files from the remote server or other operations you wanna do

55 lines (53 loc) 3.11 kB
/* * @Author: famous * @Date: 2022-08-31 16:15:14 * @Last Modified by: famous * @Last Modified time: 2023-07-11 10:49:33 * * 注: * 1、server: 多个服务器时,server 配置数组即可 * * 2、链接服务器的 password 和 privateKey 配置一项即可, * 都不配置时,将通过命令行交互工具输入密码或私钥文件路径, * 此时也可不配置用户名 username ,配置了则作为命令行中用户名的默认值 * * 3、@fileUploadMode 字段为 delete 时需注意是否存在 @deploySectionList 字段, * 若存在,则按对应值删除服务器文件或目录 */ export default { server: { connectConfig: { // host: "", // 主机 ip ,无默认值 // easyToUnderstandHostName: "", //通俗易懂的主机名称,无默认值 port: 22, // 端口号,默认为 22 username: "root", // 服务器登录用户名,默认为 root // password: '', // 服务器登录密码,无默认值 // privateKey: fs.readFileSync('C:/Users/a/.ssh/id_rsa'), // ssh私钥路径, Buffer 可以,无默认值 // privateKey: fs.readFileSync('C:/Users/a/.ssh/id_rsa').toString(), // ssh私钥路径, String 也可以,无默认值 }, localBuildDir: "./dist", // 本地打包目录,默认为 ./dist // deploySectionList: // 只发布打包目录中的部分文件或文件夹,无默认值,即默认整个localBuildDir目录全量部署 // [ // { // type: 'file', //类型 file: 文件 dir: 目录 // name: 'index.html', //文件名或目录名 // } // ] autoBuild: true, // 是否自动打包,默认为 true buildCommander: "npm run build", // 打包命令,默认为 npm run build needBackup: false, // 是否在部署上传前将服务器当前版本备份至本地,默认为 false backupDir: "./backup", // 当 needBackup 为 true 时,本地备份存储目录,默认为 ./backup fileUploadMode: "delete", // delete(默认): 先删除服务器文件再上传 cover: 上传覆盖服务器文件 // remoteRootDir: "", // 服务器部署目录,无默认值,必传 }, execGitShellBeforeBuild: false, // 是否执行 git 命令文件,若启用自动打包,将在打包前执行,默认为 false /** * @execShellOriginFilePath * windows 中默认的 cmd 或 powershell 终端无法正常执行 sh 文件中的命令,故使用 Git Bash 执行 * windows 中请传入 Git Bash 的 sh.exe 或 bash.exe 文件在安装目录中的路径 * 默认值: process.env.SHELL || 'C:\\Program Files\\Git\\bin\\sh.exe' * Mac 、 Linux 无需配置此项,默认支持 sh 命令 */ execShellOriginFilePath: process.env.SHELL || "C:\\Program Files\\Git\\bin\\sh.exe", // 默认为 C:\\Program Files\\Git\\bin\\sh.exe gitShellFile: "deploy-git.sh", // git 命令执行文件,默认为 deploy-git.sh }