diff --git a/lib/commands/deploy.js b/lib/commands/deploy.js index a1d49e7..aaea193 100644 --- a/lib/commands/deploy.js +++ b/lib/commands/deploy.js @@ -36,7 +36,6 @@ const checkEnvCorrect = (config, env) => { 'script', 'host', 'port', - 'username', 'distPath', 'webDir' ] @@ -44,12 +43,10 @@ const checkEnvCorrect = (config, env) => { if ( config && (function () { - const { privateKey, password } = config - if (!privateKey && !password) { + const { privateKey } = config + if (!privateKey) { error( - `配置错误: 请配置 ${underline('privateKey')} 或 ${underline( - 'passwrod' - )}` + `配置错误: 请配置 ${underline('privateKey')}}` ) process.exit(1) } @@ -72,6 +69,25 @@ const checkEnvCorrect = (config, env) => { } } +// 输入SSH密码 +const inputSSHPwd = async (config, any) => { + const pwd = await inquirer.prompt([ + { + type: 'input', + name: 'username', + message: '请输入服务器登录用户名', + default: 'root', + }, + { + type: 'password', + name: 'password', + message: '请输入服务器登录密码', + default: '' + } + ]) + Object.assign(config, pwd) +} + // 执行打包脚本 const execBuild = async (config, index) => { try { @@ -201,6 +217,7 @@ const createTaskList = (config) => { const { isRemoveRemoteFile = true } = config taskList = [] + taskList.push(inputSSHPwd) taskList.push(execBuild) taskList.push(connectSSH) taskList.push(uploadLocalFile) diff --git a/lib/config/index.js b/lib/config/index.js index 6438187..5750c36 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -30,19 +30,6 @@ const devConfig = [ default: 22, when: (answers) => answers.deployEnvList.includes('dev') }, - { - type: 'input', - name: 'devUsername', - message: '用户名', - default: 'root', - when: (answers) => answers.deployEnvList.includes('dev') - }, - { - type: 'password', - name: 'devPassword', - message: '密码', - when: (answers) => answers.deployEnvList.includes('dev') - }, { type: 'input', name: 'devDistPath', @@ -93,19 +80,6 @@ const testConfig = [ default: 22, when: (answers) => answers.deployEnvList.includes('test') }, - { - type: 'input', - name: 'testUsername', - message: '用户名', - default: 'root', - when: (answers) => answers.deployEnvList.includes('test') - }, - { - type: 'password', - name: 'testPassword', - message: '密码', - when: (answers) => answers.deployEnvList.includes('test') - }, { type: 'input', name: 'testDistPath', @@ -156,19 +130,6 @@ const prodConfig = [ default: 22, when: (answers) => answers.deployEnvList.includes('prod') }, - { - type: 'input', - name: 'prodUsername', - message: '用户名', - default: 'root', - when: (answers) => answers.deployEnvList.includes('prod') - }, - { - type: 'password', - name: 'prodPassword', - message: '密码', - when: (answers) => answers.deployEnvList.includes('prod') - }, { type: 'input', name: 'prodDistPath',