crabatool 1.0.230 → 1.0.249
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server.js +9 -2
- package/lib/utils.js +13 -8
- package/package.json +1 -1
- package/test/craba.js +17 -7
- package/tool/compress.js +5 -1
- package/tool/crabapublish.js +4 -1
- package/tool/upgrade.js +16 -8
package/lib/server.js
CHANGED
|
@@ -5,6 +5,7 @@ var path = require('path');
|
|
|
5
5
|
var config = require('./config.js');
|
|
6
6
|
var utils = require('./utils.js');
|
|
7
7
|
var compression = require('compression');
|
|
8
|
+
const { off } = require('process');
|
|
8
9
|
var app = new express();
|
|
9
10
|
//app.use(express.json({ limit: '50mb' })); // post数据包大小限制
|
|
10
11
|
app.use(compression()); // 开启压缩
|
|
@@ -36,8 +37,14 @@ app.use(express.static(config.webPath))
|
|
|
36
37
|
// 业务ap的代理转发
|
|
37
38
|
if (config.proxy) {
|
|
38
39
|
var { createProxyMiddleware } = require('http-proxy-middleware');
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
if (Array.isArray(config.proxy)) { // 兼容代理配置是数组
|
|
41
|
+
for (const item of config.proxy) {
|
|
42
|
+
app.use(createProxyMiddleware(item))
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
for (let key in config.proxy) {
|
|
46
|
+
app.use(key, createProxyMiddleware(config.proxy[key]));
|
|
47
|
+
}
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
|
package/lib/utils.js
CHANGED
|
@@ -645,14 +645,19 @@ class Utils {
|
|
|
645
645
|
return ips.join(',');
|
|
646
646
|
}
|
|
647
647
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
648
|
+
gitpush(branchName, msg) {
|
|
649
|
+
const execSync = require('child_process').execSync;
|
|
650
|
+
console.log('git add --all'); // 暂存
|
|
651
|
+
execSync('git add --all'); // 暂存
|
|
652
|
+
|
|
653
|
+
console.log('git commit -m \"' + msg + '\"'); // 提交日志
|
|
654
|
+
execSync('git commit -m \"' + msg + '\"'); // 提交日志
|
|
655
|
+
|
|
656
|
+
console.log('git pull --rebase origin ' + branchName); // 拉取分支
|
|
657
|
+
execSync('git pull --rebase origin ' + branchName); // 拉取分支
|
|
658
|
+
|
|
659
|
+
console.log('git push origin ' + branchName); // 推送
|
|
660
|
+
execSync('git push origin ' + branchName); // 推送
|
|
656
661
|
}
|
|
657
662
|
|
|
658
663
|
addPackageVersion(packagePath, v1, v2) {
|
package/package.json
CHANGED
package/test/craba.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* 项目环境使用工具包
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
var crabaTool = require('
|
|
5
|
+
var crabaTool = require('../index'); // 引入craba脚手架工具包
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
// 当前项目相关配置,注意必填项和非必填项哦
|
|
@@ -10,7 +10,7 @@ var config = {
|
|
|
10
10
|
//【必填】
|
|
11
11
|
// 告诉工具当前项目的端路径地址,填绝对路径哦
|
|
12
12
|
//webPath: "F:/shell_master/web/src/main/resources/static/shell",
|
|
13
|
-
webPath: "
|
|
13
|
+
webPath: "/Users/yangyj/Desktop/test-craba/www",
|
|
14
14
|
|
|
15
15
|
//【必填】
|
|
16
16
|
// 告诉工具当前项目前端服务器端口地址
|
|
@@ -18,7 +18,7 @@ var config = {
|
|
|
18
18
|
|
|
19
19
|
//【ngp必填】【非ngp项目不是必填】
|
|
20
20
|
// 当前项目模块名称,各组按需修改
|
|
21
|
-
modName: "
|
|
21
|
+
modName: "", // 如:modName:"jxc"
|
|
22
22
|
|
|
23
23
|
// 【不是必填】
|
|
24
24
|
// 告诉工具当webPath目录下面的js、css、gspx文件发生改变就自动刷新网页
|
|
@@ -35,12 +35,22 @@ var config = {
|
|
|
35
35
|
ignoreCompress: true,
|
|
36
36
|
|
|
37
37
|
proxy: {
|
|
38
|
-
'/
|
|
39
|
-
target:
|
|
40
|
-
|
|
38
|
+
'/www': {
|
|
39
|
+
target: "http://127.0.0.1:3001",
|
|
40
|
+
pathRewrite: {
|
|
41
|
+
'^/www': ''
|
|
42
|
+
},
|
|
43
|
+
router: function (req) {
|
|
44
|
+
if (req.url.includes('.gspx')) {
|
|
45
|
+
return 'http://127.0.0.1:3000'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
changeOrigin: false, //是否重写请求头中的host
|
|
49
|
+
},
|
|
50
|
+
'/api': {
|
|
51
|
+
target: "http://127.0.0.1:3000"
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
|
-
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
crabaTool.run(config); // 传入配置参数,启动工具
|
package/tool/compress.js
CHANGED
|
@@ -20,7 +20,7 @@ module.exports.run = function() {
|
|
|
20
20
|
_zipName = path.join(config.targetPath, 'craba.zip');
|
|
21
21
|
_tempJsPath = path.join(_tempPath, 'js');
|
|
22
22
|
_tempSkinPath = path.join(_tempPath, 'skins');
|
|
23
|
-
_pkgPath =
|
|
23
|
+
_pkgPath = path.join(_jsPath, 'package.json');
|
|
24
24
|
|
|
25
25
|
if (fs.existsSync(_zipName)) {
|
|
26
26
|
fs.unlinkSync(_zipName);
|
|
@@ -28,6 +28,10 @@ module.exports.run = function() {
|
|
|
28
28
|
|
|
29
29
|
utils.addPackageVersion(_pkgPath); // 版本号+1
|
|
30
30
|
|
|
31
|
+
|
|
32
|
+
var branchName = config.branchName || config.version;
|
|
33
|
+
utils.gitpush(branchName, '版本号+1');
|
|
34
|
+
|
|
31
35
|
doCompress(); // 打包、压缩、合并js和css到临时目录下
|
|
32
36
|
}
|
|
33
37
|
|
package/tool/crabapublish.js
CHANGED
|
@@ -9,7 +9,7 @@ const FormData = require('form-data');
|
|
|
9
9
|
var _tempPath = path.join(config.targetPath, '__build');
|
|
10
10
|
var _zipName = path.join(config.targetPath, 'craba.zip');
|
|
11
11
|
var _jsPath = path.join(config.targetPath, 'src/Carpa.Web/js');
|
|
12
|
-
var _pkgPath =
|
|
12
|
+
var _pkgPath = path.join(_jsPath, 'package.json');
|
|
13
13
|
var pkg = utils.readPackage(_pkgPath);
|
|
14
14
|
|
|
15
15
|
module.exports.upload = function() {
|
|
@@ -107,7 +107,10 @@ function doAutoTest() {
|
|
|
107
107
|
if (version == 'master') {
|
|
108
108
|
version = 'NewCraba';
|
|
109
109
|
}
|
|
110
|
+
|
|
110
111
|
var url = 'http://jci.ca.com/job/craba-uitest/buildWithParameters?token=remoteBuild&remoteBuild=yes&version=' + version;
|
|
112
|
+
console.log('自动化测试Jenkins:', url);
|
|
113
|
+
|
|
111
114
|
axios({
|
|
112
115
|
method: 'GET',
|
|
113
116
|
url: url
|
package/tool/upgrade.js
CHANGED
|
@@ -87,7 +87,6 @@ class Upgrade {
|
|
|
87
87
|
//console.log(data.remark);
|
|
88
88
|
that.gitLogs = data.remark; // 先记录日志列表
|
|
89
89
|
that.updateCraba(); // 需要更新平台
|
|
90
|
-
that.clearLog(); // 每次更新后都要清除标记,避免下次又去更新;
|
|
91
90
|
} else {
|
|
92
91
|
console.log('没有检测到更新标记,无需更新平台资源');
|
|
93
92
|
}
|
|
@@ -137,6 +136,9 @@ class Upgrade {
|
|
|
137
136
|
|
|
138
137
|
if (localData.version == newData.version) {
|
|
139
138
|
console.log(':::本地已经是最新版本,不需要更新:::');
|
|
139
|
+
if (this.hasLogs()) {
|
|
140
|
+
this.clearLog();
|
|
141
|
+
}
|
|
140
142
|
if (cb) cb();
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
@@ -170,24 +172,30 @@ class Upgrade {
|
|
|
170
172
|
this.downloadCraba()
|
|
171
173
|
}
|
|
172
174
|
|
|
175
|
+
hasLogs() {
|
|
176
|
+
if (!this.gitLogs || this.gitLogs.length < 1) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
|
|
173
182
|
// 更新完成后推送平台并提交日志
|
|
174
183
|
pushGitLog() {
|
|
175
|
-
if (!this.
|
|
184
|
+
if (!this.hasLogs()) {
|
|
176
185
|
return;
|
|
177
186
|
}
|
|
178
187
|
|
|
179
|
-
const execSync = require('child_process').execSync;
|
|
180
188
|
|
|
181
189
|
var logs = [];
|
|
182
190
|
this.gitLogs.forEach(function(log, index) {
|
|
183
|
-
logs.push((index + 1) + '
|
|
191
|
+
logs.push('【日志' + (index + 1) + '】' + log.branch_log + ',时间:' + log.create_time);
|
|
184
192
|
});
|
|
193
|
+
var msg = logs.join(';\t');
|
|
185
194
|
|
|
186
|
-
|
|
195
|
+
var branchName = config.branchName || config.version;
|
|
196
|
+
utils.gitpush(branchName, msg);
|
|
187
197
|
|
|
188
|
-
|
|
189
|
-
execSync('git commit -m \"' + logs.join(';\t') + '\"');
|
|
190
|
-
execSync('git push -u origin ' + (config.branchName || config.version));
|
|
198
|
+
this.clearLog(); // 每次更新后都要清除标记,避免下次又去更新;
|
|
191
199
|
}
|
|
192
200
|
|
|
193
201
|
_updateDone() {
|