seimin 3 years ago
parent
commit
104ac12ca4
7 changed files with 8776 additions and 0 deletions
  1. BIN
      --favicon-32x32.png
  2. BIN
      favicon-32x32.png
  3. 27 0
      gulpfile.js
  4. 8639 0
      package-lock.json
  5. 24 0
      package.json
  6. 43 0
      upload/development.js
  7. 43 0
      upload/production.js

BIN
--favicon-32x32.png


BIN
favicon-32x32.png


+ 27 - 0
gulpfile.js

@@ -0,0 +1,27 @@
1
+const { src, dest, series } = require('gulp');
2
+const del = require('del');
3
+const from = {
4
+  path: [
5
+    './css/**/*',
6
+    './imgs/**/*',
7
+    './js/**/*',
8
+    './libs/**/*',
9
+    './backgroundsize.min.htc',
10
+    './index.html',
11
+    './login.html',
12
+    './PIE.htc',
13
+  ]
14
+};
15
+// 清理dist文件夹
16
+const cleanDist = async (cb) => {
17
+  await del(['dist/**']);
18
+  cb();
19
+}
20
+// 移动assets文件夹的内容到dist
21
+const moveAssets = (cb) => {
22
+  src(from.path,{base:'./'})
23
+    .pipe(dest('dist'));
24
+  cb();
25
+}
26
+
27
+exports.build = series(cleanDist, moveAssets);

File diff suppressed because it is too large
+ 8639 - 0
package-lock.json


+ 24 - 0
package.json

@@ -0,0 +1,24 @@
1
+{
2
+  "name": "pc-repair",
3
+  "version": "1.0.0",
4
+  "description": "",
5
+  "main": "index.js",
6
+  "scripts": {
7
+    "development": "node ./upload/development.js",
8
+    "production": "node ./upload/production.js",
9
+    "build": "npx gulp build"
10
+  },
11
+  "repository": {
12
+    "type": "git",
13
+    "url": "http://git.dashitech.com/seimin/zuel-itsm-3.0.2.git"
14
+  },
15
+  "keywords": [],
16
+  "author": "",
17
+  "license": "ISC",
18
+  "devDependencies": {
19
+    "del": "^6.0.0",
20
+    "gulp": "^4.0.2",
21
+    "shelljs": "^0.8.5",
22
+    "ssh2-sftp-client": "^7.2.0"
23
+  }
24
+}

+ 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/pcReq', // 上传地址,删除地址
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/pcReq', // 上传地址,删除地址
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()