Browse Source

新增自动发布文件

yunxing 4 years ago
parent
commit
38feabd2d3
4 changed files with 54 additions and 8482 deletions
  1. 8 0
      README.md
  2. 13 4
      package.json
  3. 33 0
      publish.js
  4. 0 8478
      yarn.lock

+ 8 - 0
README.md

@@ -15,9 +15,11 @@ yarn serve 或 npm run serve
 ### 打包
 
 ``` shell
+
 1. yarn build_aly  或 npm run build_aly     # 阿里云环境
 2. yarn build_test 或 npm run build_test    # 测试环境
 3. yarn build_prod 或 npm run build_prod    # 生产环境
+
 ```
 
 ### 分析打包
@@ -26,6 +28,12 @@ yarn serve 或 npm run serve
 yarn build --report 或 npm run build --report 
 ```
 
+### 发布版本
+
+``` shell
+npm run publish # 只能发布到阿里云环境(需要外网支持)
+```
+
 ### 目录结构
 
 ``` shell

+ 13 - 4
package.json

@@ -2,11 +2,19 @@
   "name": "wanda-bm-guide-h5",
   "version": "0.1.0",
   "private": true,
+  "remote": {
+    "host": "60.205.177.43",
+    "path": "/root/apps/web/wandaBmGuideH5",
+    "user": "root",
+    "password": "WWW.sagacloud.mail@2020",
+    "local": "wandaBmGuideH5"
+  },
   "scripts": {
     "serve": "vue-cli-service serve",
-    "build_aly":"vue-cli-service build --mode aly", 
-    "build_test":"vue-cli-service build --mode test",
-    "build_prod": "vue-cli-service build --mode production"
+    "build_aly": "vue-cli-service build --mode aly",
+    "build_test": "vue-cli-service build --mode test",
+    "build_prod": "vue-cli-service build --mode production",
+    "publish": "node publish.js"
   },
   "dependencies": {
     "@saga-web/base": "2.1.27",
@@ -42,6 +50,7 @@
     "vue-template-compiler": "^2.6.11",
     "webpack-bundle-analyzer": "^3.8.0",
     "fengmap": "^2.5.3",
-    "polybooljs": "^1.2.0"
+    "polybooljs": "^1.2.0",
+    "node-ssh": "^6.0.0"
   }
 }

+ 33 - 0
publish.js

@@ -0,0 +1,33 @@
+
+const Client = require("node-ssh");
+const ssh = new Client(); 
+
+ssh.connect({
+  host: process.env.npm_package_remote_host,
+  port: "22",
+  username: process.env.npm_package_remote_user,
+  password: process.env.npm_package_remote_password
+}).then(() => {
+  const failedList = [];
+  ssh.putDirectory(
+    process.env.npm_package_remote_local,
+    process.env.npm_package_remote_path,
+    {
+      recursive: true,
+      concurrency: 1,
+      tick: function(localPath, remotePath, error) {
+        if (error) {
+          failedList.push(localPath);
+        }
+      }
+    }
+  ).then(status => {
+    if (failedList.length > 0) {
+      console.log("发布失败");
+      console.log("failed transfers", failedList.join(", "));
+    } else {
+      console.log(status ? "发布成功" : "发布失败");
+    }
+    ssh.dispose();
+  });
+});

File diff suppressed because it is too large
+ 0 - 8478
yarn.lock