拷贝 url 到 connection 中

This commit is contained in:
陆柯 2021-09-11 09:06:33 +08:00
parent 3e9680a295
commit 541bb5c302

View File

@ -50,7 +50,6 @@ try {
} catch (err) { } catch (err) {
console.error('Loading config files failed: ' + err.message) console.error('Loading config files failed: ' + err.message)
} }
wo.envi.deploy.connection = wo.envi.deploy[wo.envi.deploy.gotoTarget]
// 读取命令行参数 // 读取命令行参数
commander commander
@ -76,8 +75,8 @@ commander
.parse(process.argv) .parse(process.argv)
wo.envi.deploy.fromPath = commander.fromPath || wo.envi.deploy.fromPath wo.envi.deploy.fromPath = commander.fromPath || wo.envi.deploy.fromPath
wo.envi.deploy.connection = wo.envi.deploy[commander.gotoTarget || wo.envi.deploy.gotoTarget] // 使用用户指定的连接 wo.envi.deploy.connection = wo.envi.deploy[commander.gotoTarget || wo.envi.deploy.gotoTarget] // 使用用户指定的连接
// 可以用命令行参数覆盖掉配置文件 // 可以用命令行参数覆盖掉配置文件
const connection = { const connection = {
targetType: commander.targetType || wo.envi.deploy.connection.targetType, targetType: commander.targetType || wo.envi.deploy.connection.targetType,
@ -94,7 +93,7 @@ const connection = {
gitemail: commander.gitemail || wo.envi.deploy.connection.gitemail, gitemail: commander.gitemail || wo.envi.deploy.connection.gitemail,
// common // common
username: commander.user || wo.envi.deploy.connection.user, 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, password: commander.password || wo.envi.deploy.connection.password,
tryKeyboard: true, tryKeyboard: true,
onKeyboardInteractive: (name, instructions, lang, prompts, finish) => { // 不起作用 onKeyboardInteractive: (name, instructions, lang, prompts, finish) => { // 不起作用
@ -102,6 +101,7 @@ const connection = {
finish([password]) finish([password])
} }
}, },
url: wo.envi.deploy.connection.url
} }
console.log(` deploy from ${wo.envi.deploy.fromPath} to ${JSON.stringify(connection)}`) console.log(` deploy from ${wo.envi.deploy.fromPath} to ${JSON.stringify(connection)}`)
@ -164,10 +164,10 @@ function deployToSsh(connection){
}) })
ssh.dispose() ssh.dispose()
if (err) { 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) process.exit(1)
} else { } 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){ if (connection.url){
console.info(`*** ${connection.url} ***`) console.info(`*** ${connection.url} ***`)
} }
@ -176,7 +176,7 @@ function deployToSsh(connection){
}).catch(err => { }).catch(err => {
console.error(err) console.error(err)
ssh.dispose() 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) process.exit(1)
}) })
} }
@ -300,12 +300,12 @@ function deployToGit(connection){
}).then(() => { }).then(() => {
return git('push', '-u', repo.url, 'HEAD:' + repo.branch, '--force') return git('push', '-u', repo.url, 'HEAD:' + repo.branch, '--force')
}).then(()=>{ }).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){ if (connection.url){
console.info(`*** ${connection.url} ***`) console.info(`*** ${connection.url} ***`)
} }
}).catch((err)=>{ }).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) process.exit(1)
}) })
} }