sparrow-ci 1.1.4 → 1.1.6
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 +15 -9
- package/bin/command/index.js +44 -5
- package/bin/main.js +0 -0
- package/bin/utils/node_utils.js +2 -2
- package/package.json +1 -1
package/bin/ci.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: wangqi
|
|
3
3
|
* @Date: 2022-08-12 15:56:29
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime:
|
|
4
|
+
* @LastEditors: makunkun
|
|
5
|
+
* @LastEditTime: 2024-01-03 17:26:52
|
|
6
6
|
* @FilePath: /sparrow-ci/bin/ci.js
|
|
7
7
|
* @Description: ci
|
|
8
8
|
*/
|
|
@@ -14,7 +14,7 @@ const chalk = require('chalk');
|
|
|
14
14
|
const { getProInfo, commonFilePath, configOutPut, handleList, printSuccess, printFail, printWarnning } = require('./utils/index');
|
|
15
15
|
const { isDependentExisted, writeToFile, installAndBuild, installPackages, handleExecFile, handleFolder } = require('./utils/node_utils.js');
|
|
16
16
|
const { environment, helpDescription, robotList } = require('../ci.config');
|
|
17
|
-
const { uploadCi, packNpmCi, previewCi } = require('./command');
|
|
17
|
+
const { uploadCi, packNpmCi, packNpmListCi, previewCi } = require('./command');
|
|
18
18
|
|
|
19
19
|
const currentWorkingDirectory = process.cwd(); // 命令执行位置的路径
|
|
20
20
|
|
|
@@ -59,6 +59,7 @@ class Ci {
|
|
|
59
59
|
// 代码根路径,比如src目录
|
|
60
60
|
const configJson = commonFilePath(this.projectRoot, 'project.config.json');
|
|
61
61
|
this.appid = configJson.appid;
|
|
62
|
+
this.packNpmRelationList = configJson.setting.packNpmRelationList || [];
|
|
62
63
|
this.miniprogramRoot = configJson.miniprogramRoot ? path.join(this.projectRoot, configJson.miniprogramRoot) : this.projectRoot;
|
|
63
64
|
this.appJson = commonFilePath(this.miniprogramRoot, 'app.json');
|
|
64
65
|
this.subPackages = this.appJson.subPackages;
|
|
@@ -285,7 +286,6 @@ class Ci {
|
|
|
285
286
|
const answers = await this.showSimpleCliConfig(type);
|
|
286
287
|
if (!answers) return;
|
|
287
288
|
}
|
|
288
|
-
|
|
289
289
|
if (type === 'online') {
|
|
290
290
|
this.robotNum = robotList['online']; // 如果是online, 上传着变为1
|
|
291
291
|
const { version, description } = await this.changeVerConfig(); // online 走这块改变config
|
|
@@ -317,11 +317,17 @@ class Ci {
|
|
|
317
317
|
|
|
318
318
|
// 构建
|
|
319
319
|
async buildNpm() {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
|
|
320
|
+
if(this.packNpmRelationList.length>0){
|
|
321
|
+
const data = await packNpmListCi(this.packNpmRelationList);
|
|
322
|
+
return data;
|
|
323
|
+
}else{
|
|
324
|
+
const data = await packNpmCi({
|
|
325
|
+
packageJSONPath: this.packageJSONPath,
|
|
326
|
+
miniprogramRoot: this.miniprogramRoot,
|
|
327
|
+
});
|
|
328
|
+
return data;
|
|
329
|
+
}
|
|
330
|
+
|
|
325
331
|
}
|
|
326
332
|
|
|
327
333
|
// 预览
|
package/bin/command/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: wangqi
|
|
3
3
|
* @Date: 2022-08-12 10:20:19
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime:
|
|
4
|
+
* @LastEditors: makunkun
|
|
5
|
+
* @LastEditTime: 2024-01-03 17:53:17
|
|
6
6
|
* @FilePath: /sparrow-ci/bin/command/index.js
|
|
7
7
|
* @Description: 上传代码
|
|
8
8
|
*/
|
|
@@ -12,6 +12,7 @@ const path = require('path');
|
|
|
12
12
|
const ora = require("ora");
|
|
13
13
|
const chalk = require('chalk');
|
|
14
14
|
const { handleCodeSize, getKeyName } = require('../utils/index');
|
|
15
|
+
const { robotList } = require('../../ci.config');
|
|
15
16
|
|
|
16
17
|
function project(params) {
|
|
17
18
|
const { projectPath, keyPath, appid } = params;
|
|
@@ -28,7 +29,7 @@ function project(params) {
|
|
|
28
29
|
async function uploadCi(params) {
|
|
29
30
|
const spinner = ora(`${chalk.blue('准备上传')}\n`).start();
|
|
30
31
|
spinner.color = 'blue';
|
|
31
|
-
const { version, description, robotNum } = params;
|
|
32
|
+
const { version, description, robotNum = robotList['default'] } = params;
|
|
32
33
|
try {
|
|
33
34
|
const { subPackageInfo } = await ci.upload({
|
|
34
35
|
project: project(params),
|
|
@@ -58,7 +59,7 @@ async function uploadCi(params) {
|
|
|
58
59
|
});
|
|
59
60
|
console.table(handleCodeSize(subPackageInfo));
|
|
60
61
|
} catch(err) {
|
|
61
|
-
spinner.text = `${chalk.red('上传失败')}\n${chalk.yellow(err)}`;
|
|
62
|
+
spinner.text = `${chalk.red('上传失败')}\n${chalk.yellow(JSON.stringify(err))}`;
|
|
62
63
|
spinner.fail();
|
|
63
64
|
}
|
|
64
65
|
}
|
|
@@ -90,6 +91,43 @@ function packNpmCi(params) {
|
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
// 注意当前构建存在问题--list
|
|
95
|
+
function packNpmListCi(packNpmRelationList) {
|
|
96
|
+
return new Promise(async (resolve) => {
|
|
97
|
+
const spinner = ora(`${chalk.blue('构建中')}\n`).start();
|
|
98
|
+
spinner.color = 'blue';
|
|
99
|
+
// const { packageJSONPath, miniprogramRoot } = params;
|
|
100
|
+
// const { miniProgramPackNum, otherNpmPackNum, warnList} = await ci.packNpmManually({
|
|
101
|
+
// packageJsonPath: packageJSONPath,
|
|
102
|
+
// miniprogramNpmDistDir: miniprogramRoot,
|
|
103
|
+
// })
|
|
104
|
+
let promiseList = [];
|
|
105
|
+
packNpmRelationList.forEach(item=>{
|
|
106
|
+
promiseList.push(ci.packNpmManually({
|
|
107
|
+
packageJsonPath: item.packageJsonPath,
|
|
108
|
+
miniprogramNpmDistDir: item.miniprogramNpmDistDir,
|
|
109
|
+
}))
|
|
110
|
+
})
|
|
111
|
+
const res = await Promise.all(promiseList);
|
|
112
|
+
res.forEach(item=>{
|
|
113
|
+
const { miniProgramPackNum, otherNpmPackNum, warnList} = item;
|
|
114
|
+
if ((miniProgramPackNum > 0 || otherNpmPackNum > 0) && warnList.length === 0) {
|
|
115
|
+
spinner.text = `${chalk.green('构建成功')}\n${chalk.green(`miniProgramPackNum: ${miniProgramPackNum}个,otherNpmPackNum:${otherNpmPackNum}个`)}`;
|
|
116
|
+
spinner.color = 'green';
|
|
117
|
+
spinner.succeed();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (warnList.length > 0) {
|
|
121
|
+
warnList.forEach(item => {
|
|
122
|
+
spinner.text = `${chalk.yellow('提示')}\n${chalk.yellow(`${item.jsPath},${item.msg}`)}`;
|
|
123
|
+
spinner.warn();
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
resolve(true);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
93
131
|
async function previewCi(params) {
|
|
94
132
|
const spinner = ora(`${chalk.blue('准备中...')}\n`).start();
|
|
95
133
|
spinner.color = 'blue';
|
|
@@ -126,7 +164,7 @@ async function previewCi(params) {
|
|
|
126
164
|
scene, // 场景值 1011
|
|
127
165
|
})
|
|
128
166
|
} catch(err) {
|
|
129
|
-
spinner.text = `${chalk.red('生成预览失败')}\n${chalk.yellow(err)}`;
|
|
167
|
+
spinner.text = `${chalk.red('生成预览失败')}\n${chalk.yellow(JSON.stringify(err))}`;
|
|
130
168
|
spinner.fail();
|
|
131
169
|
}
|
|
132
170
|
}
|
|
@@ -134,5 +172,6 @@ async function previewCi(params) {
|
|
|
134
172
|
module.exports = {
|
|
135
173
|
uploadCi,
|
|
136
174
|
packNpmCi,
|
|
175
|
+
packNpmListCi,
|
|
137
176
|
previewCi
|
|
138
177
|
}
|
package/bin/main.js
CHANGED
|
File without changes
|
package/bin/utils/node_utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: wangqi
|
|
3
3
|
* @Date: 2022-08-26 10:39:50
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime:
|
|
4
|
+
* @LastEditors: makunkun
|
|
5
|
+
* @LastEditTime: 2024-01-03 17:38:02
|
|
6
6
|
* @FilePath: /sparrow-ci/bin/utils/node_utils.js
|
|
7
7
|
* @Description: 工具方法
|
|
8
8
|
*/
|