File tree 1 file changed +72
-0
lines changed 1 file changed +72
-0
lines changed Original file line number Diff line number Diff line change
1
+ const scpClient = require ( 'scp2' ) ;
2
+ const ora = require ( 'ora' ) ;
3
+ const chalk = require ( 'chalk' ) ;
4
+
5
+ const server = {
6
+ // 你的服务器ip
7
+ host : 'xxx' ,
8
+ // 服务器ssh端口
9
+ port : 22 ,
10
+ // 服务器用户名
11
+ username : 'xxx' ,
12
+ // 服务器密码
13
+ password : 'xxx' ,
14
+ // 项目上传的目录
15
+ path : '/www/wwwroot/navigation.zcbing.cn/'
16
+ }
17
+
18
+ const spinner = ora ( '正在发布到生产服务器...' ) ;
19
+ spinner . start ( ) ;
20
+ deployDist ( )
21
+
22
+ function deployDist ( ) {
23
+
24
+ scpClient . scp (
25
+ 'package.json' ,
26
+ server ,
27
+ function ( err ) {
28
+ if ( ! err ) {
29
+ console . log ( '发布package' )
30
+ }
31
+ }
32
+ )
33
+ scpClient . scp (
34
+ 'nuxt.config.js' ,
35
+ server ,
36
+ function ( err ) {
37
+ if ( ! err ) {
38
+ console . log ( '发布nuxt.config.js' )
39
+ }
40
+ }
41
+ )
42
+
43
+ scpClient . scp (
44
+ 'server/' ,
45
+ {
46
+ ...server ,
47
+ path : `${ server . path } server/`
48
+ } ,
49
+ function ( err ) {
50
+ if ( ! err ) {
51
+ console . log ( '发布server' )
52
+ }
53
+ }
54
+ )
55
+
56
+ scpClient . scp (
57
+ '.nuxt/' ,
58
+ {
59
+ ...server ,
60
+ path : `${ server . path } .nuxt/`
61
+ } ,
62
+ function ( err ) {
63
+ spinner . stop ( ) ;
64
+ if ( err ) {
65
+ console . log ( chalk . red ( '发布失败.\n' ) ) ;
66
+ throw err ;
67
+ } else {
68
+ console . log ( chalk . green ( 'Success! 成功发布到服务器!' ) ) ;
69
+ }
70
+ }
71
+ ) ;
72
+ }
You can’t perform that action at this time.
0 commit comments