sparrow-ci 1.1.1 → 1.1.2
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/bin/ci.js +33 -2
- package/bin/utils/node_utils.js +2 -1
- package/git_tag.sh +9 -0
- package/package.json +1 -1
package/bin/ci.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: wangqi
|
|
3
3
|
* @Date: 2022-08-12 15:56:29
|
|
4
4
|
* @LastEditors: wangqi
|
|
5
|
-
* @LastEditTime: 2023-02-
|
|
5
|
+
* @LastEditTime: 2023-02-10 14:04:51
|
|
6
6
|
* @FilePath: /sparrow-ci/bin/ci.js
|
|
7
7
|
* @Description:
|
|
8
8
|
*/
|
|
@@ -262,6 +262,31 @@ class Ci {
|
|
|
262
262
|
await this.upload('publish');
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
+
// 读取git tag 修改配置
|
|
266
|
+
async changeVerConfig() {
|
|
267
|
+
try {
|
|
268
|
+
//获取文件路径
|
|
269
|
+
const filepath = path.join(__dirname, '../git_tag.sh');
|
|
270
|
+
// 执行git tag
|
|
271
|
+
let firstTag = await handleExecFile(filepath);
|
|
272
|
+
firstTag = firstTag.split('\n')[0].trim(); // 获取第一个tag
|
|
273
|
+
let blankFlag = firstTag.indexOf(' '); // 第一个空格位置
|
|
274
|
+
const config = {
|
|
275
|
+
version: firstTag.slice(0, blankFlag).trim() || '',
|
|
276
|
+
description: firstTag.slice(blankFlag + 1).trim() || '',
|
|
277
|
+
}
|
|
278
|
+
if (config.version.indexOf('v') > 0) {
|
|
279
|
+
config.version = config.version.split('v')[1];
|
|
280
|
+
}
|
|
281
|
+
return config.version && config.description ? config : null;
|
|
282
|
+
} catch (err) {
|
|
283
|
+
console.log('==============');
|
|
284
|
+
console.log('read tag err:', chalk.yellow(err));
|
|
285
|
+
console.log('==============');
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
265
290
|
// 上传代码
|
|
266
291
|
// @isPublish 是否自动上传
|
|
267
292
|
async upload(type = 'upload') {
|
|
@@ -275,8 +300,13 @@ class Ci {
|
|
|
275
300
|
|
|
276
301
|
if (type === 'online') {
|
|
277
302
|
this.robotNum = robotList['online']; // 如果是online, 上传着变为1
|
|
303
|
+
const { version, description } = await this.changeVerConfig(); // online 走这块改变config
|
|
304
|
+
if (version && description) {
|
|
305
|
+
this.version = version;
|
|
306
|
+
this.description = description;
|
|
307
|
+
}
|
|
278
308
|
}
|
|
279
|
-
|
|
309
|
+
|
|
280
310
|
await uploadCi({
|
|
281
311
|
projectPath: this.projectRoot,
|
|
282
312
|
version: this.version,
|
|
@@ -285,6 +315,7 @@ class Ci {
|
|
|
285
315
|
appid: this.appid,
|
|
286
316
|
robotNum: this.robotNum,
|
|
287
317
|
});
|
|
318
|
+
|
|
288
319
|
if (type === 'online') return;
|
|
289
320
|
const packageObj = require(this.versionJSONPath);
|
|
290
321
|
packageObj.version = handleVersion(this.version);
|
package/bin/utils/node_utils.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: wangqi
|
|
3
3
|
* @Date: 2022-08-26 10:39:50
|
|
4
4
|
* @LastEditors: wangqi
|
|
5
|
-
* @LastEditTime:
|
|
5
|
+
* @LastEditTime: 2023-02-10 12:55:39
|
|
6
6
|
* @FilePath: /sparrow-ci/bin/utils/node_utils.js
|
|
7
7
|
* @Description: 工具方法
|
|
8
8
|
*/
|
|
@@ -205,6 +205,7 @@ async function handleExecFile(filePath) {
|
|
|
205
205
|
console.log(stdout);
|
|
206
206
|
console.log(stderr);
|
|
207
207
|
console.log('===================================');
|
|
208
|
+
return stdout;
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
/**
|
package/git_tag.sh
ADDED