crabatool 1.0.210 → 1.0.221

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/.eslintrc.json CHANGED
@@ -20,6 +20,7 @@
20
20
  "globals": {
21
21
  "Sys": "readonly",
22
22
  "Craba": "readonly",
23
+ "Carpa": "readonly",
23
24
  "Type": "readonly",
24
25
  "$app": "readonly",
25
26
  "$common": "readonly",
@@ -80,6 +81,7 @@
80
81
  "convertGridData": "readonly",
81
82
  "__pathMapName": "readonly",
82
83
  "CrabaLanguage": "readonly",
84
+ "CarpaLanguage": "readonly",
83
85
  "NGPLanguage": "readonly"
84
86
  }
85
87
  }
package/index.js CHANGED
@@ -8,10 +8,6 @@ module.exports.run = function(options) {
8
8
 
9
9
  start.initArgs(); // 检查注册参数
10
10
 
11
- if (options) {
12
- console.log('运行参数:', options);
13
- }
14
-
15
11
  if (!checkFast(process.argv)) {
16
12
  return;
17
13
  }
package/lib/utils.js CHANGED
@@ -56,7 +56,15 @@ class Utils {
56
56
  }
57
57
 
58
58
  searchRootFolter(name, source) {
59
- if (!path.basename(source)) return null;
59
+ var basename = path.basename(source);
60
+ if (!basename) {
61
+ return null;
62
+ }
63
+
64
+ if (basename == 'node_modules' || basename.startsWith('.')) {
65
+ return null;
66
+ }
67
+
60
68
  if (fs.existsSync(source)) {
61
69
  var files = fs.readdirSync(source);
62
70
  //console.log(files);
@@ -66,8 +74,14 @@ class Utils {
66
74
  //console.log(filePath);
67
75
  var stat = fs.statSync(filePath);
68
76
  if (stat.isDirectory()) {
69
- var basename = path.basename(fileName);
70
- if (basename == name) return filePath;
77
+ basename = path.basename(fileName);
78
+ if (basename == name) {
79
+ return filePath;
80
+ }
81
+
82
+ if (basename == 'node_modules' || basename.startsWith('.')) {
83
+ continue;
84
+ }
71
85
  }
72
86
  }
73
87
  }
@@ -446,7 +460,7 @@ class Utils {
446
460
  files.forEach(function(fileName) {
447
461
  var filePath = utils.join(source, fileName);
448
462
  // 包含路径或文件名,都忽略掉
449
- if (options.ignores && (options.ignores.includes(filePath) || options.ignores.includes(fileName))) {
463
+ if (options.ignores && (options.ignores.includes(filePath))) {
450
464
  return;
451
465
  }
452
466
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crabatool",
3
- "version": "1.0.210",
3
+ "version": "1.0.221",
4
4
  "description": "crabatool",
5
5
  "main": "index.js",
6
6
  "bin": {
package/tool/checkjs.js CHANGED
@@ -492,7 +492,7 @@ function getReportUrl(id, anchor) {
492
492
  }
493
493
 
494
494
  function getBranchName() {
495
- return config.branchName || 'null'
495
+ return config.branchName || 'null';
496
496
  }
497
497
 
498
498
  function getModName() {
package/tool/compress.js CHANGED
@@ -66,7 +66,7 @@ function updateAgencyVersion() {
66
66
  function doCompress() {
67
67
 
68
68
  var inNames = ['agency.js'];
69
- compressCrabaJs(inNames, 'agency.js', null, updateAgencyVersion);
69
+ compressCrabaJs(inNames, 'agency.js', updateAgencyVersion);
70
70
 
71
71
  // craba.min.js
72
72
  inNames = ['type.js', 'craba.js', 'common.js', 'es6.js', 'controls.js', 'required.js', 'listView.js', 'crabaEx.js', 'crabaFC.js', 'crabaMS.js'];
@@ -119,7 +119,9 @@ function compressJs(inNames, targetJs, onEnd) {
119
119
  hidejspath: config.hidejspath
120
120
  });
121
121
 
122
- if (onEnd) onEnd();
122
+ if (onEnd) {
123
+ onEnd();
124
+ }
123
125
 
124
126
  /*
125
127
  var p = fork(_mergeJsPath, [`${[inNames]}`, `${[targetJs]}`, _compressArgs, _blackFilePath, config.hidejspath]);
package/tool/start.js CHANGED
@@ -82,6 +82,7 @@ class Start {
82
82
  { name: '-progress', type: '' },
83
83
  { name: '-host', type: '' },
84
84
  { name: '-version', type: '' },
85
+ { name: '-branchName', type: '' },
85
86
  { name: '-abortUrl', type: '' },
86
87
 
87
88
  { name: '-ignoreCheck', type: 'array' },
@@ -142,7 +143,7 @@ class Start {
142
143
  config.webPath = utils.join(config.webPath);
143
144
  }
144
145
 
145
- bindBranchName();
146
+ this.bindBranchName();
146
147
  }
147
148
 
148
149
  checkPath() {
@@ -160,6 +161,7 @@ class Start {
160
161
  }
161
162
 
162
163
  checkCraba() {
164
+ this.checkWebPath();
163
165
  var crabaJs = utils.join(config.webPath, 'js/craba.min.js');
164
166
  if (!fs.existsSync(crabaJs)) {
165
167
  throw new Error('平台前端组件不存在,请检查指定的webPath路径是否为craba前端框架的根目录。' + crabaJs);
@@ -237,45 +239,53 @@ class Start {
237
239
  createProject(options) {
238
240
  upgrade.createProject(options);
239
241
  }
240
- }
241
242
 
242
- var start = new Start();
243
- module.exports = start;
244
243
 
244
+ bindBranchName() {
245
+ if (config.branchName) {
246
+ return true;
247
+ }
245
248
 
246
- function bindBranchName() {
247
- var gitPath = utils.searchRootFolter('.git', config.webPath);
248
- if (!gitPath) return;
249
- var headPath = utils.join(gitPath, 'HEAD');
250
- if (!fs.existsSync(headPath)) return;
249
+ var gitPath = utils.searchRootFolter('.git', config.webPath);
250
+ if (!gitPath) return;
251
251
 
252
- // 读取Head文件内容
253
- var headStr = fs.readFileSync(headPath).toString().trim();
254
- var arr = headStr.split('/');
252
+ var headPath = utils.join(gitPath, 'HEAD');
253
+ if (!fs.existsSync(headPath)) return;
255
254
 
256
- // 情况1:取到分支名包含斜杠
257
- if (arr.length > 1) {
258
- config.branchName = arr[arr.length - 1]; // 分支名称
259
- return;
260
- }
255
+ // 读取Head文件内容
256
+ var headStr = fs.readFileSync(headPath).toString().trim();
257
+ var arr = headStr.split('/');
261
258
 
262
- // 情况2:取到hash值
259
+ // 情况1:取到分支名包含斜杠
260
+ if (arr.length > 1) {
261
+ config.branchName = arr[arr.length - 1];
262
+ config.branchName = config.branchName.replace(/'/g, ''); // 分支名称
263
+ return;
264
+ }
263
265
 
264
- headPath = utils.join(gitPath, 'FETCH_HEAD');
265
- if (!fs.existsSync(headPath)) return;
266
+ // 情况2:取到hash值
267
+ headPath = utils.join(gitPath, 'FETCH_HEAD');
268
+ if (!fs.existsSync(headPath)) return;
266
269
 
267
- // 读取Head文件内容
268
- var content = fs.readFileSync(headPath).toString().trim();
269
- arr = content.split('\n');
270
- var results = arr.filter(function(str) {
271
- if (str.startsWith(headStr)) return true;
272
- });
270
+ // 读取Head文件内容
271
+ var content = fs.readFileSync(headPath).toString().trim();
272
+ arr = content.split('\n');
273
+ var results = arr.filter(function(str) {
274
+ if (str.startsWith(headStr)) return true;
275
+ });
273
276
 
274
- if (!results || results.length == 0) return;
277
+ if (!results || results.length == 0) {
278
+ return;
279
+ }
275
280
 
276
- config.branchName = results[0].split(' ')[1];
281
+ config.branchName = results[0].split(' ')[1];
282
+ config.branchName = config.branchName.replace(/'/g, ''); // 分支名称
283
+ }
277
284
  }
278
285
 
286
+ var start = new Start();
287
+ module.exports = start;
288
+
279
289
 
280
290
  /*内部私有方法*/
281
291
 
package/tool/upgrade.js CHANGED
@@ -63,6 +63,7 @@ class Upgrade {
63
63
  var version = config.version; // 默认临时目录下
64
64
  var host = config.host || config.SourceHost;
65
65
  var apis = utils.joinPath(host, '/apis/publish/checkUpdate');
66
+ var that = this;
66
67
 
67
68
  var data = {
68
69
  version: version
@@ -83,13 +84,46 @@ class Upgrade {
83
84
  // 如果没有手工记录更新日志,就不需要更新平台,即便是补丁也要手动标记
84
85
  var data = response.data;
85
86
  if (data.success && data.remark) {
86
- updateCraba(); // 需要更新平台
87
+ console.log(data.remark);
88
+ that.gitLogs = data.remark; // 先记录日志列表
89
+ that.updateCraba(); // 需要更新平台
90
+ that.clearLog(); // 每次更新后都要清除标记,避免下次又去更新;
91
+ } else {
92
+ console.log('没有检测到更新标记,无需更新平台资源');
87
93
  }
88
94
  }).catch(function(err) {
89
95
  console.log(err);
90
96
  });
91
97
  }
92
98
 
99
+ clearLog() {
100
+ var host = config.SourceHost;
101
+ var version = config.version; // 默认临时目录下
102
+ var host = config.host || config.SourceHost;
103
+ var apis = utils.joinPath(host, '/apis/publish/clearLog');
104
+ var that = this;
105
+
106
+ var data = {
107
+ version: version
108
+ };
109
+
110
+ // 调用api检查是否需要更新平台,传参数version,返回参数{code:200,success:true,data:{remark:'提交日志备注信息'}}
111
+ axios({
112
+ method: 'POST',
113
+ url: apis,
114
+ data: data,
115
+ headers: {
116
+ version: version,
117
+ token: 'wssf2021' // 临时授权码
118
+ }
119
+ }).then(function(response) {
120
+ console.log(response.data);
121
+ console.log('已删除分支标记');
122
+ }).catch(function(err) {
123
+ console.log(err);
124
+ });
125
+ }
126
+
93
127
  updateCraba(cb) {
94
128
  utils.cleardirsSync(config.SaveFilePath);
95
129
 
@@ -131,6 +165,27 @@ class Upgrade {
131
165
  this.downloadCraba()
132
166
  }
133
167
 
168
+ // 更新完成后推送平台并提交日志
169
+ pushGitLog() {
170
+ if (!this.gitLogs || this.gitLogs.length < 1) {
171
+ return;
172
+ }
173
+
174
+ const execSync = require('child_process').execSync;
175
+
176
+ var logs = [];
177
+ this.gitLogs.forEach(function(log, index) {
178
+ logs.push((index + 1) + '. 修改日志:' + log.branch_log + ', 修改时间:' + log.create_time);
179
+ });
180
+
181
+ //console.log(config);
182
+
183
+ execSync('cd ' + config.webPath);
184
+ execSync('git add .');
185
+ execSync('git commit -m "' + logs.join('; ') + '"');
186
+ execSync('git push origin ' + (config.branchName || config.version));
187
+ }
188
+
134
189
  _updateDone() {
135
190
  this.pb.clear('完成');
136
191
 
@@ -139,6 +194,9 @@ class Upgrade {
139
194
  delete this.cb;
140
195
  }
141
196
 
197
+ // 推送git和日志
198
+ this.pushGitLog();
199
+
142
200
  // 可能文件占用中
143
201
  setTimeout(function() {
144
202
  utils.cleardirsSync(config.SaveFilePath);