crabatool 1.0.151 → 1.0.153

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.151",
3
+ "version": "1.0.153",
4
4
  "description": "crabatool",
5
5
  "main": "index.js",
6
6
  "bin": {
package/tool/checkjs.js CHANGED
@@ -64,15 +64,17 @@ module.exports.start = async function() {
64
64
  var eslintResults = await eslintCheck(content);
65
65
 
66
66
  // 检查编码
67
- var ret = jschardet.detect(byte);
68
- if (utils.isUtf8(byte, ret.encoding) || ret.encoding == 'UTF-8') {
69
- utf8List.push(filePath);
70
- } else {
71
- var reg = /[\u4e00-\u9FA5]+/;
72
- if (!reg.test(content)) { // 不包含中文的情况,jschardet把utf-8也认为是gbk了
67
+ if (config.checkutf8) {
68
+ var ret = jschardet.detect(byte);
69
+ if (utils.isUtf8(byte, ret.encoding) || ret.encoding == 'UTF-8') {
73
70
  utf8List.push(filePath);
74
71
  } else {
75
- notUtf8List.push(`路径:${filePath} 编码:${ret.encoding}`);
72
+ var reg = /[\u4e00-\u9FA5]+/;
73
+ if (!reg.test(content)) { // 不包含中文的情况,jschardet把utf-8也认为是gbk了
74
+ utf8List.push(filePath);
75
+ } else {
76
+ notUtf8List.push(`路径:${filePath} 编码:${ret.encoding}`);
77
+ }
76
78
  }
77
79
  }
78
80
  pb.value++;
@@ -184,7 +186,11 @@ module.exports.start = async function() {
184
186
  info.push(`| 语法异常文件数Error | ${errKeys.length}个 |${calc(errKeys.length, jsFiles.length)}|`);
185
187
  info.push(`| 语法警告文件数Warn | ${warnKeys.length}个 |${calc(warnKeys.length, jsFiles.length)}|`);
186
188
  info.push(`| 语法提示文件数Info | ${infoKeys.length}个 |${calc(infoKeys.length, jsFiles.length)}|`);
187
- info.push(`| 非utf8文件数 | ${notUtf8List.length}个 |${calc(notUtf8List.length, jsFiles.length)}|`);
189
+
190
+ if (config.checkutf8) {
191
+ info.push(`| 非utf8文件数 | ${notUtf8List.length}个 |${calc(notUtf8List.length, jsFiles.length)}|`);
192
+ }
193
+
188
194
  info.push(`| 超过${fileSize}kb的文件数 | ${bigList.length}个 |${calc(bigList.length, jsFiles.length)}|`);
189
195
  info.push(`| gspx建议优化数 | ${warnGspxCount}个 |${calc(warnGspxCount, gspxData.count)}|`);
190
196
  info.push(`| gspx语法错误数 | ${gspxData.errorList.length}个 |${calc(gspxData.errorList.length, gspxData.count)}|`);
@@ -227,9 +233,11 @@ module.exports.start = async function() {
227
233
  webhookList.push(`7. 语法警告文件数Warn:${warnKeys.length}个,占比${calc(warnKeys.length, jsFiles.length)}`);
228
234
  //}
229
235
  webhookList.push(`8. 语法提示文件数Info:${infoKeys.length}个,占比${calc(infoKeys.length, jsFiles.length)}`);
230
- if (notUtf8List.length > 0) {
236
+
237
+ if (config.checkutf8 && notUtf8List.length > 0) {
231
238
  webhookList.push(`1. 非utf8文件数:${notUtf8List.length}个,占比${calc(notUtf8List.length, jsFiles.length)}`);
232
239
  }
240
+
233
241
  if (bigList.length > 0) {
234
242
  webhookList.push(`1. 超过${fileSize}kb的文件数:${bigList.length}个,占比${calc(bigList.length, jsFiles.length)}`);
235
243
  }
@@ -298,7 +306,7 @@ module.exports.start = async function() {
298
306
  });
299
307
  //}
300
308
 
301
- if (notUtf8List.length > 0) {
309
+ if (config.checkutf8 && notUtf8List.length > 0) {
302
310
  detail.push("");
303
311
  detail.push('# 非utf8清单如下');
304
312
  notUtf8List.forEach((s, index) => {
package/tool/start.js CHANGED
@@ -56,7 +56,7 @@ class Start {
56
56
  start.installvscode();
57
57
  } else if (num == 8) {
58
58
  var options = {};
59
- options.type = await question('选择项目类型:1. 普通craba项目; 2. ngp微前端项目; 输入编号:');
59
+ options.type = await question('选择项目类型:1. 普通craba纯前端项目; 2. ngp微前端项目;输入编号:');
60
60
  if (options.type != 1 && options.type != 2) options.type = 1;
61
61
  if (options.type == 2) {
62
62
  options.modName = await question('请输入微服务的模块名称:');
@@ -85,6 +85,7 @@ class Start {
85
85
  bindConfigByArgv('-ignoreCompress', 'boolean');
86
86
  bindConfigByArgv('-Debug', 'boolean');
87
87
  bindConfigByArgv('-checkgspx', 'boolean');
88
+ bindConfigByArgv('-checkutf8', 'boolean');
88
89
  //bindConfigByArgv('-branchName');
89
90
  }
90
91
 
@@ -261,7 +262,7 @@ async function waitFolder(question) {
261
262
  if (fs.existsSync(projectPath)) {
262
263
  if (fs.readdirSync(projectPath).length > 0) {
263
264
  var result = await question('输入的路径下有其他文件,避免文件覆盖或冲突,请确认是否在此路径下创建项目(Y/N):');
264
- if (result && result.toLowerCace() == 'y') {
265
+ if (result && result.toLowerCase() == 'y') {
265
266
  return projectPath;
266
267
  }
267
268
  return waitFolder(question);
package/tool/upgrade.js CHANGED
@@ -82,15 +82,15 @@ class Upgrade {
82
82
 
83
83
  createProject(options) {
84
84
  var projectPath = "";
85
- if (options.type == 1) {
85
+ if (options.type == 1) { // 普通前端项目
86
86
  projectPath = utils.join(options.projectPath, 'www');
87
- } else if (options.type == 2) {
88
- projectPath = `/web/src/main/resources/static/`;
89
- if (!options.projectPath.includes(options.modName)) {
90
- projectPath = utils.join(options.projectPath, options.modName, projectPath, options.modName);
91
- } else {
92
- projectPath = utils.join(options.projectPath, projectPath, options.modName);
87
+ } else if (options.type == 2) { // ngp微前端
88
+ var name1 = options.modName;
89
+ if (options.projectPath.includes(options.modName)) { // 输入的路径已经包含模块名了
90
+ name1 = '';
93
91
  }
92
+ projectPath = `${name1}/web/src/main/resources/static/${options.modName}`;
93
+ projectPath = utils.join(options.projectPath, projectPath);
94
94
  }
95
95
 
96
96
  this.done = this._createDone;