crabatool 1.0.831 → 1.0.834

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
@@ -78,6 +78,15 @@ exports.run = async function(options) {
78
78
  }
79
79
 
80
80
  async function checkFast(args) {
81
+ // 配置文件方式启用自动生成 ID(优先于长度判断,避免被提前 return 掉)
82
+ if (!args.includes('-autoId') && config.autoId === true) {
83
+ start.checkWebPath();
84
+ start.bindConfigByArgv('-ignoreAutoId', 'array');
85
+ start.bindConfigByArgv('-ignoreFiles', 'array');
86
+ require('./tool/addNodeId.js').start();
87
+ return false;
88
+ }
89
+
81
90
  // 1. 服务端构建环境,自动化,根据命令行参数,直接调用脚手架功能
82
91
  if (args.length < 3) {
83
92
  return true;
package/lib/config.js CHANGED
@@ -25,6 +25,7 @@ class Config {
25
25
  this.ignoreCheck = [];
26
26
  this.ignoreFiles = [];
27
27
  this.ignoreAutoId = [];
28
+ this.autoId = false; // 是否在启动时自动生成 ID
28
29
  this.Version = pg.version;
29
30
  this.Debug = false;
30
31
  this.version = 'master';
package/lib/server.js CHANGED
@@ -171,7 +171,7 @@ function createServer(app, options) {
171
171
  res.setHeader('Content-Type', 'text/html; charset=utf-8'); // 当做文本输出,才能显示到iframe中
172
172
  }
173
173
  var name = path.basename(pathname);
174
- if (name == 'index.html' || name == 'login.html') {
174
+ if (name == 'index.html' || name == 'login.html') { // 入口文件:首页和登录页面不能被缓存
175
175
  res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
176
176
  res.setHeader('Pragma', 'no-cache');
177
177
  res.setHeader('Expires', '0');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crabatool",
3
- "version": "1.0.831",
3
+ "version": "1.0.834",
4
4
  "description": "crabatool",
5
5
  "main": "index.js",
6
6
  "bin": {
package/tool/checkgspx.js CHANGED
@@ -9,6 +9,7 @@ module.exports.getResults = function() {
9
9
  var data = {
10
10
  count: 0,
11
11
  tags: {},
12
+ labelList: {},
12
13
  bizList: {},
13
14
  tagList: [],
14
15
  customs1: {},
@@ -96,6 +97,20 @@ function readGspxToJSON(fileName, data) {
96
97
  }
97
98
  }
98
99
  }
100
+
101
+ if (name == 'Label') {
102
+ for (var key in attrs) {
103
+ if (key == 'ReadOnly') {
104
+ if (!data.labelList[fileName]) {
105
+ data.labelList[fileName] = [];
106
+ }
107
+ var id = attrs.ID || attrs.Label || attrs.Text;
108
+ data.labelList[fileName].push(id);
109
+ break;
110
+ }
111
+ }
112
+ }
113
+
99
114
  // 建议优化页面汇总
100
115
  if (warnTags.includes(name)) {
101
116
  if (name == 'CancelButton' || name == 'CloseButton') {
package/tool/checkjs.js CHANGED
@@ -198,6 +198,7 @@ module.exports.start = async function() {
198
198
 
199
199
  // 生成检测报告 markdown语法
200
200
  var warnGspxCount = Object.keys(gspxData.warnList).length;
201
+ var readLabelCount = Object.keys(gspxData.labelList).length;
201
202
  var trimErrKeys = Object.keys(trimErrDatas);
202
203
  var errKeys = Object.keys(errDatas);
203
204
  var undefKeys = Object.keys(undefDatas);
@@ -211,7 +212,7 @@ module.exports.start = async function() {
211
212
 
212
213
  var branchName = getBranchName();
213
214
  var modName = getModName();
214
- var id = modName + '_' + new Date().getTime();
215
+ var id = modName + '_' + branchName + '_' + new Date().getTime();
215
216
  var webhookList = [];
216
217
  var info = [];
217
218
  var localVersion = upgrade.getLocalVersion();
@@ -251,7 +252,9 @@ module.exports.start = async function() {
251
252
  }
252
253
 
253
254
  info.push(`| 超过${fileSize}kb的文件数 | ${bigList.length}个 |${calc(bigList.length, jsFiles.length)}|`);
254
-
255
+ if (readLabelCount > 0) {
256
+ info.push(`| 只读Label优化数 | ${readLabelCount}个 |${calc(readLabelCount, gspxData.count)}|`);
257
+ }
255
258
  if (warnGspxCount > 0) {
256
259
  info.push(`| gspx建议优化数 | ${warnGspxCount}个 |${calc(warnGspxCount, gspxData.count)}|`);
257
260
  }
@@ -267,7 +270,8 @@ module.exports.start = async function() {
267
270
  tipCount: infoKeys.length,
268
271
  fileSize: fileSize,
269
272
  fileSizeCount: bigList.length,
270
- gspxWarnCount: warnGspxCount.length,
273
+ gspxWarnCount: warnGspxCount,
274
+ readLabelCount: readLabelCount,
271
275
  gspxErrorCount: gspxData.errorList.length,
272
276
  jsTotal: jsFiles.length,
273
277
  gspxTotal: gspxData.count
@@ -323,7 +327,9 @@ module.exports.start = async function() {
323
327
  if (config.checkutf8 && notUtf8List.length > 0) {
324
328
  webhookList.push(`1. 非utf8文件数:${notUtf8List.length}个,占比${calc(notUtf8List.length, jsFiles.length)}`);
325
329
  }
326
-
330
+ if (readLabelCount > 0) {
331
+ webhookList.push(`1. 只读Label优化数:${readLabelCount}个,占比${calc(readLabelCount, gspxData.count)}`);
332
+ }
327
333
  if (bigList.length > 0) {
328
334
  webhookList.push(`1. 超过${fileSize}kb的文件数:${bigList.length}个,占比${calc(bigList.length, jsFiles.length)}`);
329
335
  }
@@ -486,6 +492,22 @@ module.exports.start = async function() {
486
492
  });
487
493
  }
488
494
 
495
+ if (readLabelCount > 0) {
496
+ detail.push(`# 只读Label清单如下`);
497
+ Object.keys(gspxData.labelList).forEach((key, index) => {
498
+ var ids = gspxData.labelList[key];
499
+
500
+ detail.push(`**${index + 1}. ${key}**`);
501
+ detail.push(`>建议优化Label明细: \`${ids.join('`、`')}\``);
502
+ detail.push("");
503
+ detail.push("| Label特性 | 优化建议 |");
504
+ detail.push("| ----- | ------ |");
505
+ ids.forEach((sid) => {
506
+ detail.push(`| ${sid} | 去掉ReadOnly |`);
507
+ });
508
+ });
509
+ }
510
+
489
511
  if (warnGspxCount > 0) {
490
512
  detail.push(`# 建议优化gspx清单如下`);
491
513
  Object.keys(gspxData.warnList).forEach((key, index) => {
package/tool/start.js CHANGED
@@ -134,6 +134,7 @@ class Start {
134
134
 
135
135
  { name: '-ignoreCheck', type: 'array' },
136
136
  { name: '-ignoreAutoId', type: 'array' },
137
+ { name: '-autoId', type: 'boolean' },
137
138
  { name: '-childModList', type: 'array' },
138
139
  { name: '-globals', type: 'array' },
139
140