crabatool 1.0.65 → 1.0.69

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crabatool",
3
- "version": "1.0.65",
3
+ "version": "1.0.69",
4
4
  "description": "crabatool",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/tool/checkgspx.js CHANGED
@@ -3,7 +3,7 @@ var config = require('../lib/config.js');
3
3
  var fs = require('fs');
4
4
  var path = require('path');
5
5
  var htmlparser2 = require('htmlparser2');
6
- var warnTags = ['VPanel', 'HPanel', 'HiddenColumn', 'Hblock', 'Vblock']; // 'div', 'table', 'tr', 'td', 'br','HiddenField', 'CloseButton', 'CancelButton'];
6
+ var warnTags = ['VPanel', 'HPanel', 'HiddenColumn', 'Hblock', 'Vblock', 'div', 'table', 'tr', 'td', 'br', 'iframe', 'HiddenField', 'CloseButton', 'CancelButton'];
7
7
 
8
8
  module.exports.getResults = function() {
9
9
  var data = {
package/tool/checkjs.js CHANGED
@@ -14,6 +14,24 @@ var sizeBlackList = ['craba.min.js', 'crabaEx.min.js', 'crabaNgp.js', 'echarts-a
14
14
  // 语法规则,不能包含这些关键词
15
15
  var dangerousJs = ['\\slet\\s', '\\sconst\\s', '\=\>\\s?\\(?\\{', '\\sasync\\s', '\\sawait\\s', '\\.then\\(', '\\sdebugger\\s'];
16
16
 
17
+ // gspx无用标签的修改建议
18
+ var warnTagsInfo = {
19
+ 'VPanel': '建议更改为`FlexColumn`或`FlowPanel LayoutDirection="Vert"`',
20
+ 'HPanel': '建议更改为`HBlock`或`FlowPanel`',
21
+ 'HiddenColumn': '写错了,没有这个标签',
22
+ 'Hblock': '写错了,没有这个标签',
23
+ 'Vblock': '写错了,没有这个标签',
24
+ 'div': '平台的Block标签等效于div标签`<Block CssClass="styleA"/>`等于`<div class="styleA"></div>`',
25
+ 'table': '建议更换为`FlowPane`l或`FlexColumn和HBlock的组合`',
26
+ 'tr': '建议更换为`FlowPanel`或`FlexColumn和HBlock的组合`',
27
+ 'td': '建议更换为`FlowPanel`或`FlexColumn和HBlock的组合`',
28
+ 'br': '建议使用`CssStyle="margin:10px 0;"`增加间距或`VSPacer`',
29
+ 'HiddenField': '新平台里面99%的这个标签都没意义,`<HiddenField ID="hd" Value="${hd}"/>`取代方法,不用gspx解析一遍,改为js直接读取变量:`var hd =this.get_context("hd");`',
30
+ 'CloseButton': '如果是`<CloseButton Visible=false/>`这种建议直接去掉,新平台不用加这个标签都可以`Esc`关闭页面,每个页面默认支持Esc关闭',
31
+ 'CancelButton': '如果是`<CancelButton Visible=false/>`这种建议直接去掉,新平台不用加这个标签都可以`Esc`关闭页面,每个页面默认支持Esc关闭',
32
+ 'iframe': '建议使用IFrame'
33
+ }
34
+
17
35
 
18
36
  module.exports.start = function() {
19
37
  var jsFiles = utils.getFiles({ source: config.webPath, exts: '.js', ignores: config.ignoreCheck });
@@ -101,7 +119,7 @@ module.exports.start = function() {
101
119
  info.push(`| 共检查 | ${gspxData.count}个gspx文件 |`);
102
120
  info.push(`| 忽略目录和文件 | ${config.ignoreCheck ? config.ignoreCheck.join('、') : '无' + ' |'}`);
103
121
 
104
- info.push("# 检测报表");
122
+ info.push("# 检测结果汇总");
105
123
  info.push("| 类型 | 数量 |");
106
124
  info.push("| ------ | ------ |");
107
125
  info.push(`| 语法异常文件数 | ${errList.length}个 |`);
@@ -132,10 +150,10 @@ module.exports.start = function() {
132
150
  var detail = [];
133
151
  if (errList.length > 0) {
134
152
  detail.push("");
135
- detail.push('# js语法异常文件清单如下');
153
+ detail.push('# js语法异常清单如下');
136
154
  errList.forEach((s, index) => {
137
155
 
138
- detail.push(`## ${index + 1}. ${s}`);
156
+ detail.push(`${index + 1}. ${s}`);
139
157
 
140
158
  var err = errRegList[index];
141
159
  detail.push("| 异常字符 | 位置 |");
@@ -149,9 +167,9 @@ module.exports.start = function() {
149
167
 
150
168
  if (notUtf8List.length > 0) {
151
169
  detail.push("");
152
- detail.push('# 非utf8文件清单如下');
170
+ detail.push('# 非utf8清单如下');
153
171
  notUtf8List.forEach((s, index) => {
154
- detail.push(`## ${index + 1}. ${s}`);
172
+ detail.push(`${index + 1}. ${s}`);
155
173
 
156
174
  sonar.issues.push(getSonarEntity('非utf8', modName, '', s, -1, -1));
157
175
  });
@@ -159,9 +177,9 @@ module.exports.start = function() {
159
177
 
160
178
  if (bigList.length > 0) {
161
179
  detail.push("");
162
- detail.push(`# 超过${fileSize}kb的文件清单如下`);
180
+ detail.push(`# 超过${fileSize}kb清单如下`);
163
181
  bigList.forEach((s, index) => {
164
- detail.push(`## ${index + 1}. ${s}`);
182
+ detail.push(`${index + 1}. ${s}`);
165
183
  var arr = s.split(' ');
166
184
  sonar.issues.push(getSonarEntity(`超${fileSize}kb文件`, modName, arr[1], arr[0], -1, -1));
167
185
  });
@@ -170,27 +188,37 @@ module.exports.start = function() {
170
188
  if (gspxData.errorList.length > 0) {
171
189
  detail.push(`# 出错误页面清单如下`);
172
190
  gspxData.errorList.forEach((info, index) => {
173
- detail.push(`## ${index + 1}. ${info.name}`);
191
+ detail.push(`${index + 1}. ${info.name}`);
174
192
  detail.push(`> 错误标签: ${info.tag}`);
175
193
  detail.push(`> 错误描述:${info.error}`);
176
194
  });
177
195
  }
178
196
 
179
197
  if (warnPages > 0) {
180
- detail.push(`# 建议优化gspx页面清单如下`);
198
+ detail.push(`# 建议优化gspx清单如下`);
181
199
  Object.keys(gspxData.warnList).forEach((key, index) => {
182
200
  var tags = gspxData.warnList[key];
183
201
 
184
- detail.push(`## ${index + 1}. ${key}`); 4
185
- detail.push(`> 此页面建议优化标签明细: ${tags.join('')}`);
202
+ detail.push(`**${index + 1}. ${key}**`);
203
+ detail.push(`>建议优化标签明细: \`${tags.join('`、`')}\``);
204
+ detail.push("");
205
+ detail.push("| 标签名称 | 优化建议 |");
206
+ detail.push("| ----- | ------ |");
207
+ var oks = [];
208
+ tags.forEach((tag) => {
209
+ if (oks.includes(tag)) return;
210
+ oks.push(tag);
211
+
212
+ detail.push(`| ${tag} | ${warnTagsInfo[tag] || '-'} |`);
213
+ });
186
214
  });
187
215
  }
188
216
 
189
- detail.push('# 本项目标签使用情况汇总');
190
- detail.push("| 标签名称 | 使用次数 |");
191
- detail.push("| ----- | ------ |");
217
+ detail.push('# 项目标签汇总');
218
+ detail.push("| 标签名称 | 使用次数 | 标签使用建议");
219
+ detail.push("| ----- | ------ | ---- |");
192
220
  gspxData.tagList.forEach((item, index) => {
193
- detail.push(`| ${item.name} | ${item.count} |`);
221
+ detail.push(`| ${item.name} | ${item.count} | ${warnTagsInfo[item.name] || '-'} |`);
194
222
  });
195
223
 
196
224
 
@@ -202,7 +230,7 @@ module.exports.start = function() {
202
230
 
203
231
  // 推送到钉钉
204
232
  if (status != '无异常') { // 检查结果检查就不发到钉钉了; ps:健康也发到钉钉,鼓励开发继续保持;
205
- postWebhooks(id, reportUrl, webhookList);
233
+ //postWebhooks(id, reportUrl, webhookList);
206
234
  }
207
235
  }
208
236