crabatool 1.0.307 → 1.0.318

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/config.js CHANGED
@@ -5,6 +5,7 @@ var pg = require('../package.json');
5
5
  class Config {
6
6
  constructor() {
7
7
  this.reportHost = "http://crabadoc.ca.com"; // 用于接收检测报告的服务器,可配置的。由于产品没有提供服务,目前统一放到平台的文档服务器
8
+ //this.reportHost = "http://127.0.0.1:9998";
8
9
  this.webhooks = "https://oapi.dingtalk.com/robot/send?access_token=ce27b1b1540881540d44c0bd05ba738d865363758892ede137dc1020bd36bd5a";
9
10
  this.crabaHooks = "https://oapi.dingtalk.com/robot/send?access_token=ce27b1b1540881540d44c0bd05ba738d865363758892ede137dc1020bd36bd5a";
10
11
  //this.webhooks = "https://oapi.dingtalk.com/robot/send?access_token=37279df60e03ebf25e8eb71230ddb93fe74de99951a8d635d0458e60bfcd44d8";
package/lib/utils.js CHANGED
@@ -289,7 +289,9 @@ class Utils {
289
289
 
290
290
  // 删除文件夹,清空文件夹,删除目录,清空目录,清空整个目录,包括子目录和文件
291
291
  cleardirsSync(dirname) {
292
- if (!fs.existsSync(dirname)) return;
292
+ if (!fs.existsSync(dirname)) {
293
+ return;
294
+ }
293
295
 
294
296
  fs.readdirSync(dirname).forEach(function(file) {
295
297
  var filePath = utils.join(dirname, file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crabatool",
3
- "version": "1.0.307",
3
+ "version": "1.0.318",
4
4
  "description": "crabatool",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -16,7 +16,7 @@
16
16
  "checkUpdate": "node run.js -checkUpdate -version master -webPath F:\\crabaevery\\www",
17
17
  "upload": "node run.js -upload -version master -Debug true -host http://127.0.0.1:9998 -hidejspath true -targetPath F:\\CarpaNET_NEW",
18
18
  "crabaNgp": "node run.js -mergejs -hidejspath true -targetPath F:\\CarpaNET_NEW\\src\\Carpa.Web\\js\\crabaNgp -inNames initMs.js,businessControl.js -outName F:\\CarpaMS\\src\\js\\crabaNgp.js",
19
- "webPath": "node ./test/test.js -checkjs -webhooks 0 -webPath F:\\crabaevery\\www -modName crabaevery",
19
+ "webPath": "node ./test/test.js -checkjs -webPath F:\\crabaevery\\www -modName crabaevery",
20
20
  "biconfont": "node ./test/test.js -iconfont -zipPath F:\\crabaevery\\www\\biconfont -fontPath F:\\crabaevery\\www\\skins\\bicon -prefix .bicon- -fontName biconfont",
21
21
  "aiconfont": "node ./test/test.js -iconfont -zipPath F:\\crabaevery\\www\\iconfont -fontPath F:\\CarpaNET_NEW\\src\\Carpa.Web\\skins -prefix .aicon- -fontName iconfont",
22
22
  "makeHash": "node run.js -makeHash -webPath ./test/ -modName craba -files http://crabadoc.ca.com/js/utils/utils.js,F:/newcrabadoc/www/js/utils/utils.js,./test/test.js,./test/beefun.js,https://s5.vip.wpscdn.cn/web-libs/2t/js/userinfo-collect/1.0.3/vas2t-userinfo-collect.min.js?a=1 -outJson ./hash.json -hashName sha384",
package/test/test.js CHANGED
@@ -40,7 +40,7 @@ var config = {
40
40
  ignoreCompress: true,
41
41
 
42
42
  // 用于保存检查报告的api
43
- reportHost: 'http://crabadoc.ca.com',
43
+ //reportHost: 'http://crabadoc.ca.com',
44
44
 
45
45
  Debug: false,
46
46
 
package/tool/checkjs.js CHANGED
@@ -52,6 +52,7 @@ module.exports.start = async function() {
52
52
  }
53
53
 
54
54
  var errDatas = {};
55
+ var trimErrDatas = {};
55
56
  var warnDatas = {};
56
57
  var infoDatas = {};
57
58
  var bigList = [];
@@ -147,12 +148,28 @@ module.exports.start = async function() {
147
148
  // 二次检查
148
149
  if (reg.test(noComment)) {
149
150
  var nreg = new RegExp(dangerousJs.join('|'), 'ig');
150
- var infoList = getMathReuslts(noComment, nreg);
151
+ var infoList = getMathReuslts(noComment, nreg, null, '兼容性字符,不推荐使用');
151
152
  var list = errDatas[filePath];
152
153
  if (list) errDatas[filePath] = list.concat(infoList); // 记录该js有异常
153
154
  else errDatas[filePath] = infoList;
154
155
  }
155
156
  }
157
+
158
+ // trimEnd检查
159
+ var tstr = `\.trimEnd\(([^,)]+)\)|\.trimEnd\(['"],['"]\)`;
160
+ var reg1 = new RegExp(tstr);
161
+ if (reg1.test(content)) {
162
+ var noComment = utils.clearComment(content);// 去掉注释的代码再查一遍;因为js里面有些危险字符是被注释了的
163
+
164
+ // 二次检查
165
+ if (reg1.test(noComment)) {
166
+ var nreg = new RegExp(tstr);
167
+ var infoList = getMathReuslts(noComment, nreg, null, 'trimEnd(xx)使用不规范,不支持参数替换;请调整为trimEndChar(xx)');
168
+ var list = trimErrDatas[filePath];
169
+ if (list) trimErrDatas[filePath] = list.concat(infoList); // 记录该js有异常
170
+ else trimErrDatas[filePath] = infoList;
171
+ }
172
+ }
156
173
  }
157
174
  pb.clear('检验完成');
158
175
 
@@ -162,6 +179,7 @@ module.exports.start = async function() {
162
179
  // 生成检测报告 markdown语法
163
180
  var warnGspxCount = Object.keys(gspxData.warnList).length;
164
181
  var status = '无异常';
182
+ var trimErrKeys = Object.keys(trimErrDatas);
165
183
  var errKeys = Object.keys(errDatas);
166
184
  var warnKeys = Object.keys(warnDatas);
167
185
  var infoKeys = Object.keys(infoDatas);
@@ -169,7 +187,7 @@ module.exports.start = async function() {
169
187
  projectName: getModName(),
170
188
  branchName: getBranchName(),
171
189
  }
172
- if (errKeys.length > 0 || warnKeys.length > 0 || notUtf8List.length > 0 || warnGspxCount > 0 || gspxData.errorList.length > 0) {
190
+ if (errKeys.length > 0 || trimErrKeys.length > 0 || warnKeys.length > 0 || notUtf8List.length > 0 || warnGspxCount > 0 || gspxData.errorList.length > 0) {
173
191
  status = '有异常';
174
192
  }
175
193
 
@@ -203,6 +221,7 @@ module.exports.start = async function() {
203
221
  info.push("| 类型 | 数量 | 占比 |");
204
222
  info.push("| ------ | ------ | ----- |");
205
223
  info.push(`| 语法异常文件数Error | ${errKeys.length}个 |${calc(errKeys.length, jsFiles.length)}|`);
224
+ info.push(`| trimEnd异常数 | ${trimErrKeys.length}个 |${calc(trimErrKeys.length, jsFiles.length)}|`);
206
225
  info.push(`| 语法警告文件数Warn | ${warnKeys.length}个 |${calc(warnKeys.length, jsFiles.length)}|`);
207
226
  info.push(`| 语法提示文件数Info | ${infoKeys.length}个 |${calc(infoKeys.length, jsFiles.length)}|`);
208
227
 
@@ -221,8 +240,8 @@ module.exports.start = async function() {
221
240
 
222
241
  reportData.data = {
223
242
  errorCount: errKeys.length,
224
- warnCount: errKeys.length,
225
- tipCount: errKeys.length,
243
+ warnCount: warnKeys.length,
244
+ tipCount: infoKeys.length,
226
245
  fileSize: fileSize,
227
246
  fileSizeCount: bigList.length,
228
247
  gspxWarnCount: warnGspxCount.length,
@@ -266,7 +285,7 @@ module.exports.start = async function() {
266
285
  webhookList.push(`[更多异常...](${reportUrl1})`);
267
286
  }
268
287
  }
269
-
288
+ webhookList.push(`7. trimEnd(xx)使用数:${trimErrKeys.length}个,占比${calc(trimErrKeys.length, jsFiles.length)}`);
270
289
  //}
271
290
  //if (warnKeys.length > 0) {
272
291
  webhookList.push(`7. js语法警告数Warn:${warnKeys.length}个,占比${calc(warnKeys.length, jsFiles.length)}`);
@@ -303,11 +322,28 @@ module.exports.start = async function() {
303
322
  detail.push("| ----- | ------ | ---- | ---- |");
304
323
  infoList.forEach((item) => {
305
324
  detail.push(`| ${item.char.trim()} | ${item.line || '-'} | ${item.column || '-'} | ${item.msg || '-'} |`);
306
- sonar.issues.push(getSonarEntity('语法异常', modName, item.char.trim(), item.msg, fileName, item.line, item.column, item.endLine));
325
+ //sonar.issues.push(getSonarEntity('语法异常', modName, item.char.trim(), item.msg, fileName, item.line, item.column, item.endLine));
307
326
  });
308
327
  });
309
328
  //}
310
329
 
330
+ if (trimErrKeys.length > 0) {
331
+ detail.push("");
332
+ detail.push(`# ${trimErrKeys.length}个必须修复trimEnd清单`);
333
+ trimErrKeys.forEach((fileName, index) => {
334
+
335
+ detail.push(`${index + 1}. ${fileName}`);
336
+
337
+ var infoList = trimErrDatas[fileName];
338
+ detail.push("| 类型 | 行号 | 列号 | 说明 |");
339
+ detail.push("| ----- | ------ | ---- | ---- |");
340
+ infoList.forEach((item) => {
341
+ detail.push(`| ${item.char.trim()} | ${item.line || '-'} | ${item.column || '-'} | ${item.msg || '-'} |`);
342
+ //sonar.issues.push(getSonarEntity('trimEnd异常', modName, item.char.trim(), item.msg, fileName, item.line, item.column, item.endLine));
343
+ });
344
+ });
345
+ }
346
+
311
347
  //if (warnKeys.length > 0) {
312
348
  detail.push("");
313
349
  detail.push(`# ${warnKeys.length}个建议修复警告清单`);
@@ -320,7 +356,7 @@ module.exports.start = async function() {
320
356
  detail.push("| ----- | ------ | ---- | ---- |");
321
357
  infoList.forEach((item) => {
322
358
  detail.push(`| ${item.char.trim()} | ${item.line || '-'} | ${item.column || '-'} | ${item.msg || '-'} |`);
323
- sonar.issues.push(getSonarEntity('语法警告', modName, item.char.trim(), item.msg, fileName, item.line, item.column, item.endLine));
359
+ //sonar.issues.push(getSonarEntity('语法警告', modName, item.char.trim(), item.msg, fileName, item.line, item.column, item.endLine));
324
360
  });
325
361
  });
326
362
  //}
@@ -338,7 +374,7 @@ module.exports.start = async function() {
338
374
  detail.push("| ----- | ------ | ---- | ---- |");
339
375
  infoList.forEach((item) => {
340
376
  detail.push(`| ${item.char.trim()} | ${item.line || '-'} | ${item.column || '-'} | ${item.msg || '-'} |`);
341
- sonar.issues.push(getSonarEntity('语法提示', modName, item.char.trim(), item.msg, fileName, item.line, item.column, item.endLine));
377
+ //sonar.issues.push(getSonarEntity('语法提示', modName, item.char.trim(), item.msg, fileName, item.line, item.column, item.endLine));
342
378
  });
343
379
  });
344
380
  //}
@@ -349,7 +385,7 @@ module.exports.start = async function() {
349
385
  notUtf8List.forEach((s, index) => {
350
386
  detail.push(`${index + 1}. ${s}`);
351
387
 
352
- sonar.issues.push(getSonarEntity('非utf8', modName, '', '', s, -1, -1, -1));
388
+ //sonar.issues.push(getSonarEntity('非utf8', modName, '', '', s, -1, -1, -1));
353
389
  });
354
390
  }
355
391
 
@@ -359,7 +395,7 @@ module.exports.start = async function() {
359
395
  bigList.forEach((s, index) => {
360
396
  detail.push(`${index + 1}. ${s}`);
361
397
  var arr = s.split(' ');
362
- sonar.issues.push(getSonarEntity(`超${fileSize}kb文件`, modName, arr[1], '', arr[0], -1, -1));
398
+ //sonar.issues.push(getSonarEntity(`超${fileSize}kb文件`, modName, arr[1], '', arr[0], -1, -1));
363
399
  });
364
400
  }
365
401
 
@@ -475,20 +511,20 @@ function calc(a, b) {
475
511
  return Math.ceil(a / b * 100) + '%';
476
512
  }
477
513
 
478
- function getMathReuslts(content, nreg, filterFun) {
514
+ function getMathReuslts(content, nreg, filterFun, msg) {
479
515
  var all = content.matchAll(nreg);
480
516
  var list = [];
481
517
  var v = all.next()
482
518
  while (!v.done) {
483
519
  var value = v.value[0];
484
520
  if (!filterFun || filterFun(value)) {
485
- list.push({ "char": value, "column": v.value.index, 'msg': '兼容性字符,不推荐使用' });
521
+ list.push({ "char": value, "column": v.value.index, 'msg': msg });
486
522
  }
487
523
  v = all.next();
488
524
  }
489
525
  return list;
490
526
  }
491
-
527
+ /*
492
528
  function getSonarEntity(type, modName, ruleId, message, filePath, line, column, endLine) {
493
529
  var entity = {
494
530
  "engineId": modName,
@@ -507,7 +543,7 @@ function getSonarEntity(type, modName, ruleId, message, filePath, line, column,
507
543
  }
508
544
  return entity;
509
545
  }
510
-
546
+ */
511
547
  function getReportUrl(id, anchor) {
512
548
  if (!config.reportHost) {
513
549
  return '';
@@ -538,8 +574,8 @@ function postReport(id, reportUrl, content, sonar) {
538
574
  "title": getModName() + " 代码检测报告",
539
575
  "id": id,
540
576
  "text": content
541
- },
542
- sonar: sonar // 代码质量管理系统需要,一起提交到文档保存到文档服务器
577
+ }
578
+ //sonar: sonar // 代码质量管理系统需要,一起提交到文档保存到文档服务器
543
579
  };
544
580
 
545
581
  axios({
package/tool/compress.js CHANGED
@@ -72,7 +72,7 @@ function doCompress() {
72
72
  compressCrabaJs(inNames, 'agency.js', updateAgencyVersion);
73
73
 
74
74
  // craba.min.js
75
- inNames = ['type.js', 'craba.js', 'common.js', 'es6.js', 'controls.js', 'required.js', 'drag.js', 'listView.js', 'crabaEx.js', 'crabaFC.js', 'crabaMS.js'];
75
+ inNames = ['type.js', 'craba.js', 'common.js', 'es6.js', 'controls.js', 'required.js', 'drag.js', 'listView.js', 'crabaEx.js', 'crabaFC.js', 'crabaMS.js', 'biz.js'];
76
76
  compressCrabaJs(inNames, 'craba.min.js', updateCrabaVersion);
77
77
 
78
78
  // crabaEx.min.js
package/tool/iconfont.js CHANGED
@@ -73,7 +73,7 @@ function zipOk(zipUrl) {
73
73
  utils.cleardirsSync(target);
74
74
  fs.unlinkSync(zipUrl);
75
75
 
76
- var ignores = ["run.bat", "读我.txt", "font.zip", "iconfont.css", "demo_index.html", "demo.css", "iconfont.json", "iconfont.woff2", "iconfont.js"];
76
+ var ignores = ["run.bat", "readme.txt", "font.zip", "iconfont.css", "demo_index.html", "demo.css", "iconfont.json", "iconfont.woff2", "iconfont.js"];
77
77
  // 从bicon下面拷贝文件到skins\bicon下面
78
78
  utils.copyFiles(config.zipPath, config.fontPath, ignores, utils.createDelegate(this, function(fileName) {
79
79
  utils.debug('拷贝文件', fileName);
package/tool/upgrade.js CHANGED
@@ -64,6 +64,7 @@ class Upgrade {
64
64
  var host = config.host || config.SourceHost;
65
65
  var apis = utils.joinPath(host, '/apis/publish/checkUpdate');
66
66
  var that = this;
67
+ console.log(version + '检测标记:' + apis);
67
68
 
68
69
  var data = {
69
70
  version: version
@@ -287,6 +288,12 @@ class Upgrade {
287
288
  this.pb.render({ value: ++this.pb.value, text: fileName });
288
289
  }));
289
290
 
291
+ // 新结构
292
+ var eotPath = path.join(source, 'skins', 'iconfont.eot');
293
+ if (fs.existsSync(eotPath)) {
294
+ utils.cleardirsSync(path.join(dest, 'skins', 'font'));
295
+ }
296
+
290
297
  if (this.done) {
291
298
  this.done();
292
299
  }