crabatool 1.0.198 → 1.0.203

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/index.js CHANGED
@@ -52,6 +52,7 @@ function checkFast(args) {
52
52
  // crabatool -update -webPath 项目路径 -version可选参数
53
53
  if (args.includes('-update')) {
54
54
  start.bindAndCheckConfig('-webPath');
55
+ start.checkCraba();
55
56
  require('./tool/upgrade.js').updateCraba();
56
57
  return false;
57
58
  }
@@ -59,6 +60,7 @@ function checkFast(args) {
59
60
  // crabatool -checkUpdate -version master -webPath F:\\crabaevery\\www
60
61
  if (args.includes('-checkUpdate')) {
61
62
  start.bindAndCheckConfig('-webPath');
63
+ start.checkCraba();
62
64
  require('./tool/upgrade.js').checkUpdateCraba();
63
65
  return false;
64
66
  }
package/lib/utils.js CHANGED
@@ -431,7 +431,9 @@ class Utils {
431
431
  });
432
432
  }
433
433
 
434
- if (!fileList) fileList = [];
434
+ if (!fileList) {
435
+ fileList = [];
436
+ }
435
437
 
436
438
  if (!fs.existsSync(source)) {
437
439
  return fileList;
@@ -440,7 +442,8 @@ class Utils {
440
442
  var files = fs.readdirSync(source);
441
443
  files.forEach(function(fileName) {
442
444
  var filePath = utils.join(source, fileName);
443
- if (options.ignores && options.ignores.includes(filePath)) {
445
+ // 包含路径或文件名,都忽略掉
446
+ if (options.ignores && (options.ignores.includes(filePath) || options.ignores.includes(fileName))) {
444
447
  return;
445
448
  }
446
449
 
@@ -631,13 +634,16 @@ class Utils {
631
634
  return temppath;
632
635
  }
633
636
 
634
- addPackageVersion(packagePath) {
637
+ addPackageVersion(packagePath, v1, v2) {
635
638
  if (!fs.existsSync(packagePath)) {
636
639
  return false;
637
640
  }
638
641
 
642
+ if (!v1) v1 = 'version';
643
+ if (!v2) v2 = 'updateTime';
644
+
639
645
  var pkg = JSON.parse(fs.readFileSync(packagePath));
640
- var version = pkg.version;
646
+ var version = pkg[v1];
641
647
  if (!version) return false;
642
648
 
643
649
  var vs = version.split('.');
@@ -651,10 +657,10 @@ class Utils {
651
657
  }
652
658
 
653
659
  var dt = new Date();
654
- pkg.updateTime = dt.toString();
660
+ pkg[v2] = dt.toString();
655
661
 
656
662
  var versionOk = vs.join(".");
657
- pkg.version = versionOk;
663
+ pkg[v1] = versionOk;
658
664
  console.log("date:" + dt.toString() + "--old:" + version + "-----new:" + versionOk);
659
665
 
660
666
  var content = JSON.stringify(pkg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crabatool",
3
- "version": "1.0.198",
3
+ "version": "1.0.203",
4
4
  "description": "crabatool",
5
5
  "main": "index.js",
6
6
  "bin": {
package/tool/checkjs.js CHANGED
@@ -275,7 +275,7 @@ module.exports.start = async function() {
275
275
  detail.push("| ----- | ------ | ---- | ---- |");
276
276
  infoList.forEach((item) => {
277
277
  detail.push(`| ${item.char.trim()} | ${item.line || '-'} | ${item.column || '-'} | ${item.msg || '-'} |`);
278
- sonar.issues.push(getSonarEntity('语法异常', modName, item.char.trim(), fileName, -1, item.line, item.column, item.endLine));
278
+ sonar.issues.push(getSonarEntity('语法异常', modName, item.char.trim(), fileName, item.line, item.column, item.endLine));
279
279
  });
280
280
  });
281
281
  //}
@@ -292,7 +292,7 @@ module.exports.start = async function() {
292
292
  detail.push("| ----- | ------ | ---- | ---- |");
293
293
  infoList.forEach((item) => {
294
294
  detail.push(`| ${item.char.trim()} | ${item.line || '-'} | ${item.column || '-'} | ${item.msg || '-'} |`);
295
- sonar.issues.push(getSonarEntity('语法警告', modName, item.char.trim(), fileName, -1, item.line, item.column, item.endLine));
295
+ sonar.issues.push(getSonarEntity('语法警告', modName, item.char.trim(), fileName, item.line, item.column, item.endLine));
296
296
  });
297
297
  });
298
298
  //}
@@ -310,7 +310,7 @@ module.exports.start = async function() {
310
310
  detail.push("| ----- | ------ | ---- | ---- |");
311
311
  infoList.forEach((item) => {
312
312
  detail.push(`| ${item.char.trim()} | ${item.line || '-'} | ${item.column || '-'} | ${item.msg || '-'} |`);
313
- sonar.issues.push(getSonarEntity('语法提示', modName, item.char.trim(), fileName, -1, item.line, item.column, item.endLine));
313
+ sonar.issues.push(getSonarEntity('语法提示', modName, item.char.trim(), fileName, item.line, item.column, item.endLine));
314
314
  });
315
315
  });
316
316
  //}
@@ -321,7 +321,7 @@ module.exports.start = async function() {
321
321
  notUtf8List.forEach((s, index) => {
322
322
  detail.push(`${index + 1}. ${s}`);
323
323
 
324
- sonar.issues.push(getSonarEntity('非utf8', modName, '', s, -1, -1));
324
+ sonar.issues.push(getSonarEntity('非utf8', modName, '', s, -1, -1,-1));
325
325
  });
326
326
  }
327
327
 
@@ -480,7 +480,10 @@ function getSonarEntity(type, modName, message, filePath, line, column, endLine)
480
480
  }
481
481
 
482
482
  function getReportUrl(id, anchor) {
483
- if (!config.reportHost) return '';
483
+ if (!config.reportHost) {
484
+ return '';
485
+ }
486
+
484
487
  var href = config.reportHost + "/index.html#%2FPages%2FReport%2FJsReport.gspx?id=" + id;
485
488
  if (anchor) {
486
489
  href += "&toc=anchor-" + anchor;
@@ -538,7 +541,10 @@ function postWebhooks(id, reportUrl, webhookList) {
538
541
  return;
539
542
  }
540
543
 
541
- if (reportUrl) webhookList.push(`[报告详情](${reportUrl})`);
544
+ if (reportUrl) {
545
+ webhookList.push(`[报告详情](${reportUrl})`);
546
+ webhookList.push("[导出excel](" + config.reportHost + "/apis/downloadReport?id=" + id + ")");
547
+ }
542
548
  var content = webhookList.join(' \n');// 推送到钉钉只推送详情
543
549
 
544
550
  var data = {
@@ -13,18 +13,17 @@ var _pkgPath = utils.getCrabaPackgePath(path.join(_jsPath, 'package.json'));
13
13
  var pkg = utils.readPackage(_pkgPath);
14
14
 
15
15
  module.exports.upload = function() {
16
- doUploadPkg(); // 先上传package版本信息文件,然后上传craba.zip资源包,再然后调用自动化测试
16
+ doUploadPkg(config.version, _pkgPath, doZipCraba); // 先上传package版本信息文件,然后上传craba.zip资源包,再然后调用自动化测试
17
17
  }
18
18
 
19
- function doUploadPkg() {
20
- var version = config.version; // 默认临时目录下
19
+ function doUploadPkg(version, pkgPath, cb) {
21
20
  var host = config.host || config.SourceHost;
22
21
  var apis = utils.joinPath(host, '/apis/publish/save');
23
22
 
24
23
 
25
24
  const formData = new FormData();
26
25
  formData.append('my_field', 'my value');
27
- formData.append('my_file', fs.createReadStream(_pkgPath));
26
+ formData.append('my_file', fs.createReadStream(pkgPath));
28
27
  var headers = formData.getHeaders();
29
28
 
30
29
  axios({
@@ -37,27 +36,26 @@ function doUploadPkg() {
37
36
  token: 'wssf2021' // 临时授权码
38
37
  }
39
38
  }).then(function(response) {
40
- console.log(response.data);
41
- doZipCraba();
39
+ //console.log(response.data);
40
+ if (cb) cb(version);
42
41
  }).catch(function(err) {
43
42
  console.log(err);
44
43
  });
45
44
  }
46
45
 
47
- function doZipCraba() {
46
+ function doZipCraba(version) {
48
47
  // 将demo文件一起打包
49
48
  utils.copyFiles(path.join(_jsPath, 'demo'), _tempPath);
50
49
 
51
50
  // 打包平台资源
52
51
  utils.zip(_tempPath, _zipName, function() {
53
52
  console.log('压缩完成');
54
- doUploadCraba(); // 根据配置上传到服务端指定路径(分支)下
53
+ doUploadCraba(version); // 根据配置上传到服务端指定路径(分支)下
55
54
  }, { ignoreBase: true }); // 忽略跟路径
56
55
  }
57
56
 
58
- function doUploadCraba() {
57
+ function doUploadCraba(version) {
59
58
  console.log('上传资源');
60
- var version = config.version; // 默认临时目录下
61
59
  var host = config.host || config.SourceHost;
62
60
  var apis = utils.joinPath(host, '/apis/publish/save');
63
61
 
@@ -76,12 +74,13 @@ function doUploadCraba() {
76
74
  data: formData,
77
75
  headers: {
78
76
  ...headers,
77
+ craba: 1,
79
78
  version: version,
80
79
  token: 'wssf2021' // 临时授权码
81
80
  }
82
81
  }).then(function(response) {
83
- console.log(response.data);
84
- doAutoTest();
82
+ //console.log(response.data);
83
+ if (version) doAutoTest();
85
84
  }).catch(function(err) {
86
85
  utils.postWeebhooks(config.modName + '上传资源失败');
87
86
  console.log(err);
@@ -91,15 +90,15 @@ function doUploadCraba() {
91
90
  function doAutoTest() {
92
91
  var type = process.env.REMOTE_BUILD != 'no' ? '正式环境' : '临时环境';
93
92
 
94
- var msg = new Date().toString() + " " + config.modName + type + '发版完成。';
95
- msg += '对应分支:' + config.version + ',对应版本:' + pkg.version;
93
+ var msg = new Date().toString() + "\r\n" + config.modName + type + '发版完成。';
94
+ msg += '\r\n对应分支:' + config.version + '\r\n对应版本:' + pkg.version;
96
95
 
97
96
  if (process.env.REMOTE_BUILD != 'no') {
98
97
  utils.postWeebhooks(msg);
99
98
  return;
100
99
  }
101
100
 
102
- utils.postWeebhooks(msg + ',开始触发自动化测试');
101
+ utils.postWeebhooks(msg + '\r\n开始触发自动化测试');
103
102
 
104
103
  var url = 'http://jci.ca.com/job/craba-uitest/buildWithParameters?token=remoteBuild&remoteBuild=yes&version';
105
104
  axios({
package/tool/start.js CHANGED
@@ -162,7 +162,7 @@ class Start {
162
162
  checkCraba() {
163
163
  var crabaJs = utils.join(config.webPath, 'js/craba.min.js');
164
164
  if (!fs.existsSync(crabaJs)) {
165
- throw new Error('请检查craba.js,平台前端组件不存在,请检查指定的webPath路径是否为craba前端框架的根目录。' + crabaJs);
165
+ throw new Error('平台前端组件不存在,请检查指定的webPath路径是否为craba前端框架的根目录。' + crabaJs);
166
166
  }
167
167
  }
168
168
 
package/tool/upgrade.js CHANGED
@@ -82,7 +82,7 @@ class Upgrade {
82
82
 
83
83
  // 如果没有手工记录更新日志,就不需要更新平台,即便是补丁也要手动标记
84
84
  var data = response.data;
85
- if (data.success && data.data.remark) {
85
+ if (data.success && data.remark) {
86
86
  updateCraba(); // 需要更新平台
87
87
  }
88
88
  }).catch(function(err) {