-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.js
43 lines (40 loc) · 1.23 KB
/
upload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict'
// 引入scp2
import client from 'scp2'
// 下面三个插件是部署的时候控制台美化所用 可有可无
import ora from 'ora'
import chalk from 'chalk'
const spinner = ora(chalk.green('正在发布到服务器...'))
spinner.start()
const ENV = process.argv.splice(2)[0] // 获取对应环境参数
const serve = {
dev: {
// 测试服务器
host: '', // 服务器的IP地址
port: '22', // 服务器端口, 一般为 22
username: '', // 用户名
password: '', // 密码
// privateKey: require('fs').readFileSync('D:\\key.ppk'),
passphrase: 'private_key_password',
path: '' // 项目部署的服务器目标位置
},
pro: {
// 正式服务器
host: '', // 服务器的IP地址
port: '22', // 服务器端口, 一般为 22
username: '', // 用户名
password: '', // 密码
// privateKey: require('fs').readFileSync('D:\\key.ppk'),
passphrase: 'private_key_password',
path: '' // 项目部署的服务器目标位置
}
}
client.scp('./dist/build/h5', serve[ENV], err => {
spinner.stop()
if (!err) {
console.log(chalk.green(`项目发布${ENV}环境完毕!`))
} else {
console.log('err', err)
console.log(chalk.green('发布失败!'))
}
})