Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions lib/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,17 @@ const checkEnvCorrect = (config, env) => {
'script',
'host',
'port',
'username',
'distPath',
'webDir'
]

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)
}
Expand All @@ -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 {
Expand Down Expand Up @@ -201,6 +217,7 @@ const createTaskList = (config) => {
const { isRemoveRemoteFile = true } = config

taskList = []
taskList.push(inputSSHPwd)
taskList.push(execBuild)
taskList.push(connectSSH)
taskList.push(uploadLocalFile)
Expand Down
39 changes: 0 additions & 39 deletions lib/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down