@tmsfe/tmskit 0.0.23 → 0.0.25
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/CHANGELOG.md +1 -1
- package/dist/index.cjs.js +744 -390
- package/package.json +7 -2
- package/src/.DS_Store +0 -0
- package/src/compile/dev.js +4 -2
- package/src/compile/watch.js +1 -0
- package/src/config/defaultTmsConfig.js +24 -0
- package/src/core/buildAppJson.js +1 -0
- package/src/core/cloneModules.js +3 -3
- package/src/core/mpCi.js +62 -14
- package/src/core/report.js +2 -7
- package/src/core/tmsMpconfig.js +4 -19
- package/src/entry.js +35 -10
- package/src/scripts/.DS_Store +0 -0
- package/src/scripts/run/build/index.js +8 -3
- package/src/scripts/run/cloud/index.js +1 -1
- package/src/scripts/run/dev/index.js +4 -3
- package/src/scripts/run/index.js +18 -8
- package/src/scripts/run/preview/index.js +70 -0
- package/src/scripts/run/preview/utils.js +43 -0
- package/src/scripts/run/upload/index.js +65 -0
- package/src/utils/widgets.js +6 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const mpCi = require('../../../core/mpCi');
|
|
2
|
+
const { resolve, createTask, filterField } = require('../../../utils/widgets');
|
|
3
|
+
const { handleError } = require('../../../core/handleError');
|
|
4
|
+
const { info } = require('../../../utils/log');
|
|
5
|
+
const { global } = require('../../../utils/global');
|
|
6
|
+
const { getAllSize, outputInfo, getDesc } = require('../preview/utils');
|
|
7
|
+
const report = require('../../../core/report');
|
|
8
|
+
|
|
9
|
+
const handleParams = (tmsConfig, cmdOptions) => {
|
|
10
|
+
const params = {
|
|
11
|
+
...(tmsConfig.upload ? tmsConfig.upload : {}),
|
|
12
|
+
...cmdOptions,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
if (!params.version) {
|
|
16
|
+
throw new Error('请指定传入版本号 eg: tmskit run upload --version 2022.28.5');
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
...params,
|
|
20
|
+
appId: params.appId || tmsConfig.appId,
|
|
21
|
+
projectPath: resolve(tmsConfig.outputDir),
|
|
22
|
+
privateKey: params.privateKey || tmsConfig.privateKey,
|
|
23
|
+
robot: params.robot || 30,
|
|
24
|
+
desc: params.desc || getDesc(params.desc),
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 上传
|
|
30
|
+
* @param {object} tmsConfig
|
|
31
|
+
* @param {object} cmdOptions {version: '2022.28.5', desc: '', robot: 2, infoOutput: './a.txt' }
|
|
32
|
+
*/
|
|
33
|
+
async function upload(tmsConfig, cmdOptions) {
|
|
34
|
+
try {
|
|
35
|
+
const params = handleParams(tmsConfig, cmdOptions);
|
|
36
|
+
if (typeof tmsConfig?.hooks?.beforeUpload === 'function') {
|
|
37
|
+
await tmsConfig?.hooks?.beforeUpload({
|
|
38
|
+
tmsConfig: filterField(tmsConfig, ['gitAccount']),
|
|
39
|
+
cmdOptions: global.getData('cmdOptions'),
|
|
40
|
+
params,
|
|
41
|
+
});
|
|
42
|
+
report('hooks:beforeUpload');
|
|
43
|
+
};
|
|
44
|
+
const uploadRes = await createTask(
|
|
45
|
+
mpCi.uploadMp,
|
|
46
|
+
'正在上传小程序代码',
|
|
47
|
+
'上传小程序代码完成',
|
|
48
|
+
)({
|
|
49
|
+
...params,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const allSize = getAllSize(uploadRes);
|
|
53
|
+
if (params.infoOutput) {
|
|
54
|
+
outputInfo(params.infoOutput, {
|
|
55
|
+
sourceCode: params.projectPath,
|
|
56
|
+
...uploadRes,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
info(`上传包大小: ${allSize}k; 上传包版本: ${params.version}`);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
console.log('详细错误:', e);
|
|
62
|
+
handleError(`上传错误: ${e.message}`, true);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
module.exports = upload;
|
package/src/utils/widgets.js
CHANGED
|
@@ -231,6 +231,11 @@ function versionCompare(v1, v2) {
|
|
|
231
231
|
return (arr1.length > arr2.length) ? 1 : -1;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
function getGitUser() {
|
|
235
|
+
const res = shelljs.exec('git config user.name', { async: false, silent: true });
|
|
236
|
+
return res.stdout;
|
|
237
|
+
}
|
|
238
|
+
|
|
234
239
|
module.exports = {
|
|
235
240
|
resolve,
|
|
236
241
|
isObject,
|
|
@@ -247,4 +252,5 @@ module.exports = {
|
|
|
247
252
|
getAbsolutePath,
|
|
248
253
|
getNpmRegistry,
|
|
249
254
|
versionCompare,
|
|
255
|
+
getGitUser,
|
|
250
256
|
};
|