From 541bb5c302eab43df911f2912860ac702cbda7c6 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sat, 11 Sep 2021 09:06:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=B7=E8=B4=9D=20url=20=E5=88=B0=20connecti?= =?UTF-8?q?on=20=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/deploy.js b/deploy.js index a4799b3..7f3c42e 100644 --- a/deploy.js +++ b/deploy.js @@ -50,7 +50,6 @@ try { } catch (err) { console.error('Loading config files failed: ' + err.message) } -wo.envi.deploy.connection = wo.envi.deploy[wo.envi.deploy.gotoTarget] // 读取命令行参数 commander @@ -76,8 +75,8 @@ commander .parse(process.argv) wo.envi.deploy.fromPath = commander.fromPath || wo.envi.deploy.fromPath - wo.envi.deploy.connection = wo.envi.deploy[commander.gotoTarget || wo.envi.deploy.gotoTarget] // 使用用户指定的连接 + // 可以用命令行参数覆盖掉配置文件 const connection = { targetType: commander.targetType || wo.envi.deploy.connection.targetType, @@ -94,7 +93,7 @@ const connection = { gitemail: commander.gitemail || wo.envi.deploy.connection.gitemail, // common username: commander.user || wo.envi.deploy.connection.user, - privateKey: fs.existsSync(commander.key || wo.envi.deploy.key) ? (commander.key || wo.envi.deploy.key) : undefined, + privateKey: fs.existsSync(commander.key || wo.envi.deploy.connection.key) ? (commander.key || wo.envi.deploy.connection.key) : undefined, password: commander.password || wo.envi.deploy.connection.password, tryKeyboard: true, onKeyboardInteractive: (name, instructions, lang, prompts, finish) => { // 不起作用 @@ -102,6 +101,7 @@ const connection = { finish([password]) } }, + url: wo.envi.deploy.connection.url } console.log(` deploy from ${wo.envi.deploy.fromPath} to ${JSON.stringify(connection)}`) @@ -164,10 +164,10 @@ function deployToSsh(connection){ }) ssh.dispose() if (err) { - console.error(`🙁️🙁️🙁️ Failed deploy ${connection.fromPath} to ${connection.targetPath}/${connection.targetDir} 🙁️🙁️🙁️`) + console.error(`🙁️🙁️🙁️ Failed deploy ${wo.envi.deploy.fromPath} to ${connection.targetPath}/${connection.targetDir} 🙁️🙁️🙁️`) process.exit(1) } else { - console.info(`😊😊😊 Successfully deployed ${connection.fromPath} to ${connection.targetPath}/${connection.targetDir} 😊😊😊`) + console.info(`😊😊😊 Successfully deployed [${wo.envi.deploy.fromPath}] to [${connection.targetPath}/${connection.targetDir}] 😊😊😊`) if (connection.url){ console.info(`*** ${connection.url} ***`) } @@ -176,7 +176,7 @@ function deployToSsh(connection){ }).catch(err => { console.error(err) ssh.dispose() - console.error(`🙁️🙁️🙁️ Failed deploy ${connection.fromPath} to ${connection.targetPath}/${connection.targetDir} 🙁️🙁️🙁️`) + console.error(`🙁️🙁️🙁️ Failed deploy [${wo.envi.deploy.fromPath}] to [${connection.targetPath}/${connection.targetDir}] 🙁️🙁️🙁️`) process.exit(1) }) } @@ -300,12 +300,12 @@ function deployToGit(connection){ }).then(() => { return git('push', '-u', repo.url, 'HEAD:' + repo.branch, '--force') }).then(()=>{ - console.info(`😊😊😊 Successfully deployed ${connection.fromPath} to ${connection.repo}#${connection.branch} 😊😊😊`) + console.info(`😊😊😊 Successfully deployed [${wo.envi.deploy.fromPath}] to [${connection.repo}#${connection.branch}] 😊😊😊`) if (connection.url){ console.info(`*** ${connection.url} ***`) } }).catch((err)=>{ - console.error(`🙁️🙁️🙁️ Failed deploy ${connection.fromPath} to ${connection.targetPath}/${connection.targetDir} 🙁️🙁️🙁️`) + console.error(`🙁️🙁️🙁️ Failed deploy [${wo.envi.deploy.fromPath}] to [${connection.targetPath}/${connection.targetDir}] 🙁️🙁️🙁️`) process.exit(1) }) }