crabatool 1.0.123 → 1.0.125

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/utils.js CHANGED
@@ -54,6 +54,25 @@ class Utils {
54
54
  return "";
55
55
  }
56
56
 
57
+ searchRootFolter(name, source) {
58
+ if (!path.basename(source)) return null;
59
+ if (fs.existsSync(source)) {
60
+ var files = fs.readdirSync(source);
61
+ //console.log(files);
62
+ for (var i = 0; i < files.length; i++) {
63
+ var fileName = files[i];
64
+ var filePath = utils.join(source, fileName);
65
+ //console.log(filePath);
66
+ var stat = fs.statSync(filePath);
67
+ if (stat.isDirectory()) {
68
+ var basename = path.basename(fileName);
69
+ if (basename == name) return filePath;
70
+ }
71
+ }
72
+ }
73
+ return utils.searchRootFolter(name, utils.join(source, '../'));
74
+ }
75
+
57
76
  format() {
58
77
  // 字符串参数化
59
78
  var args = new Array(arguments.length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crabatool",
3
- "version": "1.0.123",
3
+ "version": "1.0.125",
4
4
  "description": "crabatool",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -40,4 +40,4 @@
40
40
  ],
41
41
  "license": "UNLICENSED",
42
42
  "devDependencies": {}
43
- }
43
+ }
@@ -0,0 +1,66 @@
1
+ {
2
+ "env": {
3
+ "browser": true
4
+ },
5
+ "extends": [
6
+ "eslint:recommended",
7
+ "plugin:native-ie/ie11",
8
+ "plugin:native-ie/ie10"
9
+ ],
10
+ "parserOptions": {
11
+ "ecmaVersion": "latest",
12
+ "sourceType": "script"
13
+ },
14
+ "rules": {
15
+ "semi": "off",
16
+ "no-redeclare": "off",
17
+ //"no-unused-vars": "off",
18
+ "missingSemi": "off"
19
+ },
20
+ "globals": {
21
+ "Sys": "readonly",
22
+ "Craba": "readonly",
23
+ "Type": "readonly",
24
+ "$app": "readonly",
25
+ "$common": "readonly",
26
+ "$settings": "readonly",
27
+ "$craba": "readonly",
28
+ "$msg": "readonly",
29
+ "$print": "readonly",
30
+ "$notify": "readonly",
31
+ "$cache": "readonly",
32
+ "$user": "readonly",
33
+ "$userCache": "readonly",
34
+ "$dom": "readonly",
35
+ "$Dom": "readonly",
36
+ "$export": "readonly",
37
+ "$skin": "readonly",
38
+ "$step": "readonly",
39
+ "$ms": "readonly",
40
+ "$createDelegate": "readonly",
41
+ "$createControl": "readonly",
42
+ "$uploader": "readonly",
43
+ "$debug": "readonly",
44
+ "$skinUtils": "readonly",
45
+ "$scriptLoader": "readonly",
46
+ "$Message": "readonly",
47
+ "$removeNode": "readonly",
48
+ "$get": "readonly",
49
+ "$agency": "readonly",
50
+ "$createControlFromGspx": "readonly",
51
+ "handleError": "readonly",
52
+ "$jsLoader": "readonly",
53
+ "$create": "readonly",
54
+ "$addHandler": "readonly",
55
+ "$searchUtils": "readonly",
56
+ "$crabaJSON": "readonly",
57
+ "asyncCall": "readonly",
58
+ "$clearHandlers": "readonly",
59
+ "$removeHandler": "readonly",
60
+ "getClientBounds": "readonly",
61
+ "echarts": "readonly",
62
+ "SysConsts": "readonly",
63
+ "math": "readonly",
64
+ "createIterator": "readonly"
65
+ }
66
+ }
package/test/test.js CHANGED
@@ -9,10 +9,11 @@ var crabaTool = require('../index.js'); // 引入craba脚手架工具包
9
9
  var config = {
10
10
  //【必填】
11
11
  // 告诉工具当前项目的端路径地址,填绝对路径哦
12
- webPath: "F:\\jxc\\jxc-web\\src\\main\\resources\\static\\jxc",
12
+ //webPath: "F:\\jxc\\jxc-web\\src\\main\\resources\\static\\jxc",
13
13
  //webPath: "F:/shell_master/web/src/main/resources/static/shell",
14
14
  //webPath: "F:\\newcrabadoc\\www",
15
15
  //webPath: "F:\\CarpaNET_NEW\\src\\Carpa.Web\\js\\",
16
+ webPath: "F:/crabaevery/www",
16
17
 
17
18
  //【必填】
18
19
  // 告诉工具当前项目前端服务器端口地址
@@ -20,7 +21,7 @@ var config = {
20
21
 
21
22
  //【ngp必填】【非ngp项目不是必填】
22
23
  // 当前项目模块名称,各组按需修改
23
- modName: "jxc", // 如:modName:"jxc"
24
+ modName: "shell", // 如:modName:"jxc"
24
25
 
25
26
  defaultPage: 'index.html',
26
27
 
@@ -32,7 +33,7 @@ var config = {
32
33
  // 1. 当前模块是由哪些过去的模块合并来的,各组按需修改
33
34
  // 2. 如果配置了子模块清单,工具会自动将所有子模块下的init.js和当前模块的jxc/js/jxc.js,合并打包到:jxc/js/init.js,实际运行过程中只加载:jxc/js/init.js,不会加载子模块下面的init.js,这样就可以大大减少http请求
34
35
  // 3. 同2,biz.js也是相同思路进行合并打包
35
- childModList: ['recordsheet', 'baseinfo', 'accounting', 'analysiscloud', 'finance'],
36
+ //childModList: ['recordsheet', 'baseinfo', 'accounting', 'analysiscloud', 'finance'],
36
37
 
37
38
  // 【不是必填】
38
39
  // 上一步中打包后的文件是否压缩, true为忽略【不压缩】,false为【要压缩】,各组按需修改
@@ -47,7 +48,16 @@ var config = {
47
48
  globals: ['crabadoc', 'Type', 'CrabaMarkdown', '$doc', 'www', 'crabaJs'],
48
49
 
49
50
  // 告诉助手项目有哪些js忽略语法检查,可以填目录
50
- ignoreCheck: ['js/lib/highlight.min.js', 'js/lib/markdown-it.min.js', 'Pages/Component.min.js'],
51
+ ignoreCheck: [
52
+ 'js/lib/highlight.min.js',
53
+ 'js/lib/markdown-it.min.js',
54
+ 'Pages/Component.min.js',
55
+ '/js/es6-promise.auto.min.js',
56
+ 'iconfont/iconfont.js',
57
+ 'biconfont/iconfont.js',
58
+ 'ueditor',
59
+ 'js'
60
+ ],
51
61
 
52
62
  // 配置js语法检测报告推送地址
53
63
  webhooks: ''
package/tool/checkjs.js CHANGED
@@ -153,6 +153,7 @@ module.exports.start = async function() {
153
153
  status = '有异常';
154
154
  }
155
155
 
156
+ var branchName = getBranchName();
156
157
  var modName = getModName();
157
158
  var id = modName + '_' + new Date().getTime();
158
159
  var webhookList = [];
@@ -169,6 +170,7 @@ module.exports.start = async function() {
169
170
  info.push(`| 平台日期 | ${localVersion.date} |`);
170
171
  }
171
172
  info.push(`| 生成报告时间 | ${new Date().toString()} |`);
173
+ info.push(`| 分支名 | ${branchName} |`);
172
174
  info.push(`| 网站路径 | ${config.webPath} |`);
173
175
  info.push(`| 共检查 | ${jsFiles.length}个js文件 |`);
174
176
  info.push(`| 共检查 | ${gspxData.count}个gspx文件 |`);
@@ -191,6 +193,7 @@ module.exports.start = async function() {
191
193
  webhookList.push(`1. 平台版本:${localVersion.version}`);
192
194
  webhookList.push(`1. 平台日期:${localVersion.date}`);
193
195
  }
196
+ webhookList.push(`1. 分支名:${branchName}`);
194
197
  webhookList.push(`1. 共检测 ${jsFiles.length}个 js文件 `);
195
198
  webhookList.push(`1. 共检测 ${gspxData.count}个 gspx文件 `);
196
199
 
@@ -431,6 +434,10 @@ function getReportUrl(id, anchor) {
431
434
  return href;
432
435
  }
433
436
 
437
+ function getBranchName() {
438
+ return config.branchName || 'null'
439
+ }
440
+
434
441
  function getModName() {
435
442
  return config.modName || 'noname';
436
443
  }
package/tool/start.js CHANGED
@@ -84,6 +84,7 @@ class Start {
84
84
  bindConfigByArgv('-ignoreCompress', 'boolean');
85
85
  bindConfigByArgv('-Debug', 'boolean');
86
86
  bindConfigByArgv('-checkgspx', 'boolean');
87
+ //bindConfigByArgv('-branchName');
87
88
  }
88
89
 
89
90
  checkPath() {
@@ -106,6 +107,8 @@ class Start {
106
107
  throw new Error(`请检查craba.js,配置的webPath路径不存在,支持相对路径,路径中用\\双斜杠或单反斜杠/;请检查拼写是否正确:${config.webPath}`);;
107
108
  }
108
109
 
110
+ bindBranchName();
111
+
109
112
  start.checkCraba();
110
113
  }
111
114
 
@@ -188,6 +191,16 @@ var start = new Start();
188
191
  module.exports = start;
189
192
 
190
193
 
194
+ function bindBranchName() {
195
+ var gitPath = utils.searchRootFolter('.git', config.webPath);
196
+ if (!gitPath) return;
197
+ var headPath = utils.join(gitPath, 'HEAD');
198
+ if (!fs.existsSync(headPath)) return;
199
+
200
+ var content = fs.readFileSync(headPath).toString().trim();
201
+ var arr = content.split('/');
202
+ config.branchName = arr[arr.length - 1]; // 分支名称
203
+ }
191
204
 
192
205
 
193
206
  /*内部私有方法*/