change deploy type 'web' to 'ssh'

This commit is contained in:
陆柯 2020-02-23 11:06:16 +08:00
parent 43073a9350
commit b5223ae17c
2 changed files with 7 additions and 6 deletions

1
.deploy_git Submodule

@ -0,0 +1 @@
Subproject commit 53affcafdaefb4873c9975ed65952af630e989ca

View File

@ -29,7 +29,7 @@ try {
commander commander
.version('1.0', '-v, --version') // 默认是 -V。如果要 -v就要加 '-v --version' .version('1.0', '-v, --version') // 默认是 -V。如果要 -v就要加 '-v --version'
.option('-f, --from <from>', `from path to copy from. Default to ${Config.deploy.from}`) .option('-f, --from <from>', `from path to copy from. Default to ${Config.deploy.from}`)
.option('-t, --type <type>', `Deploy to server type, web or git. Default to ${Config.deploy.type}`) .option('-t, --type <type>', `Deploy to server type, ssh or git. Default to ${Config.deploy.type}`)
.option('-H, --host <host>', `Host IP or domain name of the target server. Default to ${Config.deploy.host}`) .option('-H, --host <host>', `Host IP or domain name of the target server. Default to ${Config.deploy.host}`)
.option('-P, --port <port>', `Ssh port number of the target server. Default to ${Config.deploy.port}`) .option('-P, --port <port>', `Ssh port number of the target server. Default to ${Config.deploy.port}`)
.option('-D, --dir <dir>', `Destination path to deploy on the target server. Default to ${Config.deploy.dir}`) .option('-D, --dir <dir>', `Destination path to deploy on the target server. Default to ${Config.deploy.dir}`)
@ -47,7 +47,7 @@ const privateKeyFile = commander.key || Config.deploy.key || `${process.env.HOME
const connection = { const connection = {
from: commander.from || Config.deploy.from || './dist', from: commander.from || Config.deploy.from || './dist',
type: commander.type || Config.deploy.type || 'web', type: commander.type || Config.deploy.type || 'ssh',
host: commander.host || Config.deploy.host, host: commander.host || Config.deploy.host,
port: commander.port || Config.deploy.port || 22, port: commander.port || Config.deploy.port || 22,
dir: commander.dir || Config.deploy.dir, // 目标服务器上的目录。似乎该目录必须已经存在于服务器上 dir: commander.dir || Config.deploy.dir, // 目标服务器上的目录。似乎该目录必须已经存在于服务器上
@ -68,14 +68,14 @@ const connection = {
} }
console.log(` connection = ${JSON.stringify(connection)}`) console.log(` connection = ${JSON.stringify(connection)}`)
if (connection.type==='web') { if (connection.type==='ssh') {
deployToWeb() deployToSsh()
}else if (connection.type==='git'){ }else if (connection.type==='git'){
deployToGit() deployToGit()
} }
/** ********************** 连接到 Web主机,拷贝文件到指定路径 ************* **/ /** ********************** 连接到 Ssh主机,拷贝文件到指定路径 ************* **/
function deployToWeb(){ function deployToSsh(){
const ssh = new (require('node-ssh'))() const ssh = new (require('node-ssh'))()
function subDirs (path) { function subDirs (path) {