seimin hace 3 años
padre
commit
6094f57491
Se han modificado 4 ficheros con 329 adiciones y 7 borrados
  1. 239 6
      package-lock.json
  2. 4 1
      package.json
  3. 43 0
      upload/development.js
  4. 43 0
      upload/production.js

+ 239 - 6
package-lock.json

@@ -47,6 +47,7 @@
47 47
         "rimraf": "^2.6.0",
48 48
         "semver": "^5.3.0",
49 49
         "shelljs": "^0.7.6",
50
+        "ssh2-sftp-client": "^7.2.0",
50 51
         "stylus": "^0.54.5",
51 52
         "stylus-loader": "^2.1.1",
52 53
         "uglifyjs-webpack-plugin": "^1.1.1",
@@ -314,6 +315,16 @@
314 315
         "node": ">=0.10.0"
315 316
       }
316 317
     },
318
+    "node_modules/asn1": {
319
+      "version": "0.2.6",
320
+      "resolved": "https://registry.npmmirror.com/asn1/download/asn1-0.2.6.tgz?cache=0&sync_timestamp=1635986760581&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fasn1%2Fdownload%2Fasn1-0.2.6.tgz",
321
+      "integrity": "sha1-DTp7tuZOAqkMAwOzHykoaOoJoI0=",
322
+      "dev": true,
323
+      "license": "MIT",
324
+      "dependencies": {
325
+        "safer-buffer": "~2.1.0"
326
+      }
327
+    },
317 328
     "node_modules/asn1.js": {
318 329
       "version": "4.10.1",
319 330
       "resolved": "https://registry.npm.taobao.org/asn1.js/download/asn1.js-4.10.1.tgz",
@@ -1398,6 +1409,15 @@
1398 1409
       "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=",
1399 1410
       "dev": true
1400 1411
     },
1412
+    "node_modules/bcrypt-pbkdf": {
1413
+      "version": "1.0.2",
1414
+      "resolved": "https://registry.npmmirror.com/bcrypt-pbkdf/download/bcrypt-pbkdf-1.0.2.tgz",
1415
+      "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
1416
+      "dev": true,
1417
+      "dependencies": {
1418
+        "tweetnacl": "^0.14.3"
1419
+      }
1420
+    },
1401 1421
     "node_modules/better-scroll": {
1402 1422
       "version": "1.12.6",
1403 1423
       "resolved": "https://registry.npm.taobao.org/better-scroll/download/better-scroll-1.12.6.tgz",
@@ -2403,6 +2423,20 @@
2403 2423
         "js-yaml": "bin/js-yaml.js"
2404 2424
       }
2405 2425
     },
2426
+    "node_modules/cpu-features": {
2427
+      "version": "0.0.2",
2428
+      "resolved": "https://registry.npmmirror.com/cpu-features/download/cpu-features-0.0.2.tgz",
2429
+      "integrity": "sha1-n2NhVvEVX9BL26oCi7PC++886no=",
2430
+      "dev": true,
2431
+      "hasInstallScript": true,
2432
+      "optional": true,
2433
+      "dependencies": {
2434
+        "nan": "^2.14.1"
2435
+      },
2436
+      "engines": {
2437
+        "node": ">=8.0.0"
2438
+      }
2439
+    },
2406 2440
     "node_modules/create-ecdh": {
2407 2441
       "version": "4.0.3",
2408 2442
       "resolved": "https://registry.npm.taobao.org/create-ecdh/download/create-ecdh-4.0.3.tgz",
@@ -4034,6 +4068,12 @@
4034 4068
       "integrity": "sha1-aNYITKsbB5dnVA2A5Wo5tCPkq/Q=",
4035 4069
       "dev": true
4036 4070
     },
4071
+    "node_modules/err-code": {
4072
+      "version": "2.0.3",
4073
+      "resolved": "https://registry.npmmirror.com/err-code/download/err-code-2.0.3.tgz",
4074
+      "integrity": "sha1-I8Lzt1b/38YI0w4nyalBAkgH5/k=",
4075
+      "dev": true
4076
+    },
4037 4077
     "node_modules/errno": {
4038 4078
       "version": "0.1.7",
4039 4079
       "resolved": "https://registry.npm.taobao.org/errno/download/errno-0.1.7.tgz",
@@ -7505,9 +7545,9 @@
7505 7545
       "dev": true
7506 7546
     },
7507 7547
     "node_modules/nan": {
7508
-      "version": "2.14.0",
7509
-      "resolved": "https://registry.npm.taobao.org/nan/download/nan-2.14.0.tgz",
7510
-      "integrity": "sha1-eBj3IgJ7JFmobwKV1DTR/CM2xSw=",
7548
+      "version": "2.15.0",
7549
+      "resolved": "https://registry.npmmirror.com/nan/download/nan-2.15.0.tgz",
7550
+      "integrity": "sha1-PzSkc/8Y4VwbVia2KQO1rW5mX+4=",
7511 7551
       "dev": true,
7512 7552
       "optional": true
7513 7553
     },
@@ -11352,6 +11392,19 @@
11352 11392
       "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=",
11353 11393
       "dev": true
11354 11394
     },
11395
+    "node_modules/promise-retry": {
11396
+      "version": "2.0.1",
11397
+      "resolved": "https://registry.npmmirror.com/promise-retry/download/promise-retry-2.0.1.tgz",
11398
+      "integrity": "sha1-/3R6E2IKtXumiPX8Z4VUEMNw2iI=",
11399
+      "dev": true,
11400
+      "dependencies": {
11401
+        "err-code": "^2.0.2",
11402
+        "retry": "^0.12.0"
11403
+      },
11404
+      "engines": {
11405
+        "node": ">=10"
11406
+      }
11407
+    },
11355 11408
     "node_modules/proxy-addr": {
11356 11409
       "version": "2.0.5",
11357 11410
       "resolved": "https://registry.npm.taobao.org/proxy-addr/download/proxy-addr-2.0.5.tgz",
@@ -12011,6 +12064,15 @@
12011 12064
         "node": ">=0.12"
12012 12065
       }
12013 12066
     },
12067
+    "node_modules/retry": {
12068
+      "version": "0.12.0",
12069
+      "resolved": "https://registry.npmmirror.com/retry/download/retry-0.12.0.tgz",
12070
+      "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=",
12071
+      "dev": true,
12072
+      "engines": {
12073
+        "node": ">= 4"
12074
+      }
12075
+    },
12014 12076
     "node_modules/rgb-regex": {
12015 12077
       "version": "1.0.1",
12016 12078
       "resolved": "https://registry.npm.taobao.org/rgb-regex/download/rgb-regex-1.0.1.tgz",
@@ -12763,6 +12825,67 @@
12763 12825
       "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
12764 12826
       "dev": true
12765 12827
     },
12828
+    "node_modules/ssh2": {
12829
+      "version": "1.5.0",
12830
+      "resolved": "https://registry.npmmirror.com/ssh2/download/ssh2-1.5.0.tgz",
12831
+      "integrity": "sha1-TcVZupihy7Qg6NQpmN/jXQ7akrw=",
12832
+      "dev": true,
12833
+      "hasInstallScript": true,
12834
+      "dependencies": {
12835
+        "asn1": "^0.2.4",
12836
+        "bcrypt-pbkdf": "^1.0.2"
12837
+      },
12838
+      "engines": {
12839
+        "node": ">=10.16.0"
12840
+      },
12841
+      "optionalDependencies": {
12842
+        "cpu-features": "0.0.2",
12843
+        "nan": "^2.15.0"
12844
+      }
12845
+    },
12846
+    "node_modules/ssh2-sftp-client": {
12847
+      "version": "7.2.0",
12848
+      "resolved": "https://registry.npmmirror.com/ssh2-sftp-client/download/ssh2-sftp-client-7.2.0.tgz",
12849
+      "integrity": "sha512-h850dHBeLuKfL9uTQ7y11p8QA687Sr057+Q1paB7dMuO4GDtNwxj/CPwJmvIM5BCzEuNrWf9CnMnIdC23TxzcA==",
12850
+      "dev": true,
12851
+      "dependencies": {
12852
+        "concat-stream": "^2.0.0",
12853
+        "promise-retry": "^2.0.1",
12854
+        "ssh2": "^1.5.0"
12855
+      },
12856
+      "engines": {
12857
+        "node": ">=10.24.1"
12858
+      }
12859
+    },
12860
+    "node_modules/ssh2-sftp-client/node_modules/concat-stream": {
12861
+      "version": "2.0.0",
12862
+      "resolved": "https://registry.npmmirror.com/concat-stream/download/concat-stream-2.0.0.tgz",
12863
+      "integrity": "sha1-QUz1r3kKSMYKub5FJ9VtXkETPLE=",
12864
+      "dev": true,
12865
+      "engines": [
12866
+        "node >= 6.0"
12867
+      ],
12868
+      "dependencies": {
12869
+        "buffer-from": "^1.0.0",
12870
+        "inherits": "^2.0.3",
12871
+        "readable-stream": "^3.0.2",
12872
+        "typedarray": "^0.0.6"
12873
+      }
12874
+    },
12875
+    "node_modules/ssh2-sftp-client/node_modules/readable-stream": {
12876
+      "version": "3.6.0",
12877
+      "resolved": "https://registry.npmmirror.com/readable-stream/download/readable-stream-3.6.0.tgz?cache=0&sync_timestamp=1632380409088&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Freadable-stream%2Fdownload%2Freadable-stream-3.6.0.tgz",
12878
+      "integrity": "sha1-M3u9o63AcGvT4CRCaihtS0sskZg=",
12879
+      "dev": true,
12880
+      "dependencies": {
12881
+        "inherits": "^2.0.3",
12882
+        "string_decoder": "^1.1.1",
12883
+        "util-deprecate": "^1.0.1"
12884
+      },
12885
+      "engines": {
12886
+        "node": ">= 6"
12887
+      }
12888
+    },
12766 12889
     "node_modules/ssri": {
12767 12890
       "version": "5.3.0",
12768 12891
       "resolved": "https://registry.npm.taobao.org/ssri/download/ssri-5.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fssri%2Fdownload%2Fssri-5.3.0.tgz",
@@ -13309,6 +13432,12 @@
13309 13432
       "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=",
13310 13433
       "dev": true
13311 13434
     },
13435
+    "node_modules/tweetnacl": {
13436
+      "version": "0.14.5",
13437
+      "resolved": "https://registry.npmmirror.com/tweetnacl/download/tweetnacl-0.14.5.tgz",
13438
+      "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
13439
+      "dev": true
13440
+    },
13312 13441
     "node_modules/type": {
13313 13442
       "version": "1.2.0",
13314 13443
       "resolved": "https://registry.npm.taobao.org/type/download/type-1.2.0.tgz?cache=0&sync_timestamp=1570722938806&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftype%2Fdownload%2Ftype-1.2.0.tgz",
@@ -14813,6 +14942,15 @@
14813 14942
       "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=",
14814 14943
       "dev": true
14815 14944
     },
14945
+    "asn1": {
14946
+      "version": "0.2.6",
14947
+      "resolved": "https://registry.npmmirror.com/asn1/download/asn1-0.2.6.tgz?cache=0&sync_timestamp=1635986760581&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fasn1%2Fdownload%2Fasn1-0.2.6.tgz",
14948
+      "integrity": "sha1-DTp7tuZOAqkMAwOzHykoaOoJoI0=",
14949
+      "dev": true,
14950
+      "requires": {
14951
+        "safer-buffer": "~2.1.0"
14952
+      }
14953
+    },
14816 14954
     "asn1.js": {
14817 14955
       "version": "4.10.1",
14818 14956
       "resolved": "https://registry.npm.taobao.org/asn1.js/download/asn1.js-4.10.1.tgz",
@@ -15849,6 +15987,15 @@
15849 15987
       "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=",
15850 15988
       "dev": true
15851 15989
     },
15990
+    "bcrypt-pbkdf": {
15991
+      "version": "1.0.2",
15992
+      "resolved": "https://registry.npmmirror.com/bcrypt-pbkdf/download/bcrypt-pbkdf-1.0.2.tgz",
15993
+      "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
15994
+      "dev": true,
15995
+      "requires": {
15996
+        "tweetnacl": "^0.14.3"
15997
+      }
15998
+    },
15852 15999
     "better-scroll": {
15853 16000
       "version": "1.12.6",
15854 16001
       "resolved": "https://registry.npm.taobao.org/better-scroll/download/better-scroll-1.12.6.tgz",
@@ -16721,6 +16868,16 @@
16721 16868
         }
16722 16869
       }
16723 16870
     },
16871
+    "cpu-features": {
16872
+      "version": "0.0.2",
16873
+      "resolved": "https://registry.npmmirror.com/cpu-features/download/cpu-features-0.0.2.tgz",
16874
+      "integrity": "sha1-n2NhVvEVX9BL26oCi7PC++886no=",
16875
+      "dev": true,
16876
+      "optional": true,
16877
+      "requires": {
16878
+        "nan": "^2.14.1"
16879
+      }
16880
+    },
16724 16881
     "create-ecdh": {
16725 16882
       "version": "4.0.3",
16726 16883
       "resolved": "https://registry.npm.taobao.org/create-ecdh/download/create-ecdh-4.0.3.tgz",
@@ -18098,6 +18255,12 @@
18098 18255
       "integrity": "sha1-aNYITKsbB5dnVA2A5Wo5tCPkq/Q=",
18099 18256
       "dev": true
18100 18257
     },
18258
+    "err-code": {
18259
+      "version": "2.0.3",
18260
+      "resolved": "https://registry.npmmirror.com/err-code/download/err-code-2.0.3.tgz",
18261
+      "integrity": "sha1-I8Lzt1b/38YI0w4nyalBAkgH5/k=",
18262
+      "dev": true
18263
+    },
18101 18264
     "errno": {
18102 18265
       "version": "0.1.7",
18103 18266
       "resolved": "https://registry.npm.taobao.org/errno/download/errno-0.1.7.tgz",
@@ -21009,9 +21172,9 @@
21009 21172
       "dev": true
21010 21173
     },
21011 21174
     "nan": {
21012
-      "version": "2.14.0",
21013
-      "resolved": "https://registry.npm.taobao.org/nan/download/nan-2.14.0.tgz",
21014
-      "integrity": "sha1-eBj3IgJ7JFmobwKV1DTR/CM2xSw=",
21175
+      "version": "2.15.0",
21176
+      "resolved": "https://registry.npmmirror.com/nan/download/nan-2.15.0.tgz",
21177
+      "integrity": "sha1-PzSkc/8Y4VwbVia2KQO1rW5mX+4=",
21015 21178
       "dev": true,
21016 21179
       "optional": true
21017 21180
     },
@@ -24243,6 +24406,16 @@
24243 24406
       "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=",
24244 24407
       "dev": true
24245 24408
     },
24409
+    "promise-retry": {
24410
+      "version": "2.0.1",
24411
+      "resolved": "https://registry.npmmirror.com/promise-retry/download/promise-retry-2.0.1.tgz",
24412
+      "integrity": "sha1-/3R6E2IKtXumiPX8Z4VUEMNw2iI=",
24413
+      "dev": true,
24414
+      "requires": {
24415
+        "err-code": "^2.0.2",
24416
+        "retry": "^0.12.0"
24417
+      }
24418
+    },
24246 24419
     "proxy-addr": {
24247 24420
       "version": "2.0.5",
24248 24421
       "resolved": "https://registry.npm.taobao.org/proxy-addr/download/proxy-addr-2.0.5.tgz",
@@ -24783,6 +24956,12 @@
24783 24956
       "integrity": "sha1-uKSCXVvbH8P29Twrwz+BOIaBx7w=",
24784 24957
       "dev": true
24785 24958
     },
24959
+    "retry": {
24960
+      "version": "0.12.0",
24961
+      "resolved": "https://registry.npmmirror.com/retry/download/retry-0.12.0.tgz",
24962
+      "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=",
24963
+      "dev": true
24964
+    },
24786 24965
     "rgb-regex": {
24787 24966
       "version": "1.0.1",
24788 24967
       "resolved": "https://registry.npm.taobao.org/rgb-regex/download/rgb-regex-1.0.1.tgz",
@@ -25452,6 +25631,54 @@
25452 25631
       "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
25453 25632
       "dev": true
25454 25633
     },
25634
+    "ssh2": {
25635
+      "version": "1.5.0",
25636
+      "resolved": "https://registry.npmmirror.com/ssh2/download/ssh2-1.5.0.tgz",
25637
+      "integrity": "sha1-TcVZupihy7Qg6NQpmN/jXQ7akrw=",
25638
+      "dev": true,
25639
+      "requires": {
25640
+        "asn1": "^0.2.4",
25641
+        "bcrypt-pbkdf": "^1.0.2",
25642
+        "cpu-features": "0.0.2",
25643
+        "nan": "^2.15.0"
25644
+      }
25645
+    },
25646
+    "ssh2-sftp-client": {
25647
+      "version": "7.2.0",
25648
+      "resolved": "https://registry.npmmirror.com/ssh2-sftp-client/download/ssh2-sftp-client-7.2.0.tgz",
25649
+      "integrity": "sha512-h850dHBeLuKfL9uTQ7y11p8QA687Sr057+Q1paB7dMuO4GDtNwxj/CPwJmvIM5BCzEuNrWf9CnMnIdC23TxzcA==",
25650
+      "dev": true,
25651
+      "requires": {
25652
+        "concat-stream": "^2.0.0",
25653
+        "promise-retry": "^2.0.1",
25654
+        "ssh2": "^1.5.0"
25655
+      },
25656
+      "dependencies": {
25657
+        "concat-stream": {
25658
+          "version": "2.0.0",
25659
+          "resolved": "https://registry.npmmirror.com/concat-stream/download/concat-stream-2.0.0.tgz",
25660
+          "integrity": "sha1-QUz1r3kKSMYKub5FJ9VtXkETPLE=",
25661
+          "dev": true,
25662
+          "requires": {
25663
+            "buffer-from": "^1.0.0",
25664
+            "inherits": "^2.0.3",
25665
+            "readable-stream": "^3.0.2",
25666
+            "typedarray": "^0.0.6"
25667
+          }
25668
+        },
25669
+        "readable-stream": {
25670
+          "version": "3.6.0",
25671
+          "resolved": "https://registry.npmmirror.com/readable-stream/download/readable-stream-3.6.0.tgz?cache=0&sync_timestamp=1632380409088&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Freadable-stream%2Fdownload%2Freadable-stream-3.6.0.tgz",
25672
+          "integrity": "sha1-M3u9o63AcGvT4CRCaihtS0sskZg=",
25673
+          "dev": true,
25674
+          "requires": {
25675
+            "inherits": "^2.0.3",
25676
+            "string_decoder": "^1.1.1",
25677
+            "util-deprecate": "^1.0.1"
25678
+          }
25679
+        }
25680
+      }
25681
+    },
25455 25682
     "ssri": {
25456 25683
       "version": "5.3.0",
25457 25684
       "resolved": "https://registry.npm.taobao.org/ssri/download/ssri-5.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fssri%2Fdownload%2Fssri-5.3.0.tgz",
@@ -25893,6 +26120,12 @@
25893 26120
       "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=",
25894 26121
       "dev": true
25895 26122
     },
26123
+    "tweetnacl": {
26124
+      "version": "0.14.5",
26125
+      "resolved": "https://registry.npmmirror.com/tweetnacl/download/tweetnacl-0.14.5.tgz",
26126
+      "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
26127
+      "dev": true
26128
+    },
25896 26129
     "type": {
25897 26130
       "version": "1.2.0",
25898 26131
       "resolved": "https://registry.npm.taobao.org/type/download/type-1.2.0.tgz?cache=0&sync_timestamp=1570722938806&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftype%2Fdownload%2Ftype-1.2.0.tgz",

+ 4 - 1
package.json

@@ -7,7 +7,9 @@
7 7
   "scripts": {
8 8
     "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
9 9
     "start": "npm run dev",
10
-    "build": "node build/build.js"
10
+    "build": "node build/build.js",
11
+    "development": "node ./upload/development.js",
12
+    "production": "node ./upload/production.js"
11 13
   },
12 14
   "dependencies": {
13 15
     "axios": "^0.18.0",
@@ -52,6 +54,7 @@
52 54
     "rimraf": "^2.6.0",
53 55
     "semver": "^5.3.0",
54 56
     "shelljs": "^0.7.6",
57
+    "ssh2-sftp-client": "^7.2.0",
55 58
     "stylus": "^0.54.5",
56 59
     "stylus-loader": "^2.1.1",
57 60
     "uglifyjs-webpack-plugin": "^1.1.1",

+ 43 - 0
upload/development.js

@@ -0,0 +1,43 @@
1
+const shell = require('shelljs')
2
+const path = require('path');
3
+const config = {
4
+  ip: "192.168.3.109", // ssh地址
5
+  username: "root", // ssh 用户名
6
+  port: 22,      //端口
7
+  password: "DStech@123", // ssh 密码
8
+  path: '/home/itsm/project/web/reqApp', // 上传地址,删除地址
9
+  buildPath: '../dist' // 本地打包后文件地址
10
+}
11
+let Client = require('ssh2-sftp-client');
12
+
13
+function connectSSh() {
14
+  let sftp = new Client();
15
+  sftp.connect({
16
+    host: config.ip,
17
+    port: config.port,
18
+    username: config.username,
19
+    password: config.password
20
+  }).then(() => {
21
+    console.log("-----先执行删除服务器文件-----")
22
+    return sftp.rmdir(config.path, true);
23
+  }).then(() => {
24
+    // 上传文件
25
+    console.log("-----开始上传-----")
26
+    return sftp.uploadDir(path.resolve(__dirname, config.buildPath), config.path);
27
+  }).then((data) => {
28
+    console.log("-----上传完成-----");
29
+    sftp.end();
30
+  }).catch((err) => {
31
+    console.log(err, '-----失败-----');
32
+    sftp.end();
33
+  });
34
+}
35
+function runTask() {
36
+  //打包完成
37
+  if (shell.exec(`npm run build`).code == 0) {
38
+    console.log("-----打包成功-----");
39
+    //提交上传
40
+    connectSSh();
41
+  }
42
+}
43
+runTask()

+ 43 - 0
upload/production.js

@@ -0,0 +1,43 @@
1
+const shell = require('shelljs')
2
+const path = require('path');
3
+const config = {
4
+  ip: "139.129.255.139", // ssh地址
5
+  username: "root", // ssh 用户名
6
+  port: 22,      //端口
7
+  password: "DStech@123", // ssh 密码
8
+  path: '/home/md2/newweb/reqApp', // 上传地址,删除地址
9
+  buildPath: '../dist' // 本地打包后文件地址
10
+}
11
+let Client = require('ssh2-sftp-client');
12
+
13
+function connectSSh() {
14
+  let sftp = new Client();
15
+  sftp.connect({
16
+    host: config.ip,
17
+    port: config.port,
18
+    username: config.username,
19
+    password: config.password
20
+  }).then(() => {
21
+    console.log("-----先执行删除服务器文件-----")
22
+    return sftp.rmdir(config.path, true);
23
+  }).then(() => {
24
+    // 上传文件
25
+    console.log("-----开始上传-----")
26
+    return sftp.uploadDir(path.resolve(__dirname, config.buildPath), config.path);
27
+  }).then((data) => {
28
+    console.log("-----上传完成-----");
29
+    sftp.end();
30
+  }).catch((err) => {
31
+    console.log(err, '-----失败-----');
32
+    sftp.end();
33
+  });
34
+}
35
+function runTask() {
36
+  //打包完成
37
+  if (shell.exec(`npm run build`).code == 0) {
38
+    console.log("-----打包成功-----");
39
+    //提交上传
40
+    connectSSh();
41
+  }
42
+}
43
+runTask()