@gmcb/cli 0.6.1 → 0.6.3
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 +115 -92
- package/lib/actions/build.js +18 -15
- package/lib/apis/index.js +151 -133
- package/package.json +2 -3
- package/LICENSE +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
## [0.6.3](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.5.5...@gmcb/cli@0.6.3) (2026-07-06)
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
### Features
|
|
@@ -14,97 +14,120 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
17
|
+
|
|
18
|
+
## [0.6.2](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.5.5...@gmcb/cli@0.6.2) (2026-07-05)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* 优化cli ([676ac43](http://10.10.10.16/caoben/front-end/commits/676ac4381ca645ef232936b86e3b77124337a03c))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# [0.6.0](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.5.5...@gmcb/cli@0.6.0) (2026-07-05)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* 优化cli ([676ac43](http://10.10.10.16/caoben/front-end/commits/676ac4381ca645ef232936b86e3b77124337a03c))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## [0.5.5](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.5.4...@gmcb/cli@0.5.5) (2026-06-30)
|
|
41
|
+
|
|
42
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## [0.5.4](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.5.3...@gmcb/cli@0.5.4) (2026-06-30)
|
|
49
|
+
|
|
50
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## [0.5.3](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.5.2...@gmcb/cli@0.5.3) (2026-06-30)
|
|
57
|
+
|
|
58
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## [0.5.2](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.6.0...@gmcb/cli@0.5.2) (2026-06-28)
|
|
65
|
+
|
|
66
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## [0.5.1](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.5.0...@gmcb/cli@0.5.1) (2026-06-22)
|
|
73
|
+
|
|
74
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# [0.5.0](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.4.7...@gmcb/cli@0.5.0) (2026-06-21)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Features
|
|
84
|
+
|
|
85
|
+
* uni.build.json结构调整 ([4e2b3dc](http://10.10.10.16/caoben/front-end/commits/4e2b3dc10f0ad3a230a8b38f1b3704747abc9c74))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## [0.4.7](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.4.6...@gmcb/cli@0.4.7) (2026-06-15)
|
|
92
|
+
|
|
93
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
## [0.4.6](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.4.5...@gmcb/cli@0.4.6) (2026-06-15)
|
|
100
|
+
|
|
101
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## [0.4.5](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.4.4...@gmcb/cli@0.4.5) (2026-06-14)
|
|
108
|
+
|
|
109
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## [0.4.4](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.4.3...@gmcb/cli@0.4.4) (2026-06-14)
|
|
116
|
+
|
|
117
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
## [0.4.3](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.4.2...@gmcb/cli@0.4.3) (2026-06-10)
|
|
124
|
+
|
|
125
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
108
131
|
|
|
109
132
|
## [0.4.2](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.4.1...@gmcb/cli@0.4.2) (2026-06-03)
|
|
110
133
|
|
package/lib/actions/build.js
CHANGED
|
@@ -69,6 +69,7 @@ async function getCommands(...args) {
|
|
|
69
69
|
const buildEnv = ['master', 'main'].includes(opts.branch) ? 'prod' : opts.branch || opts.env;
|
|
70
70
|
if (buildEnv) {
|
|
71
71
|
commands.push(`BUILD_ENV=${buildEnv}`);
|
|
72
|
+
process.env.BUILD_ENV = buildEnv;
|
|
72
73
|
}
|
|
73
74
|
const currentName = (0, path_1.basename)(utils_1.COMMAND_PATH);
|
|
74
75
|
const projectName = opts.project || currentName;
|
|
@@ -213,7 +214,7 @@ async function generatePackage(opts) {
|
|
|
213
214
|
let dest;
|
|
214
215
|
if (compiler === 'electron-vite' && win) {
|
|
215
216
|
const exeCfg = config_1.CONFIG_DATA.h5?.windows;
|
|
216
|
-
dest = (0, path_1.join)(utils_1.COMMAND_PATH, exeCfg?.path ?? 'dist', exeCfg?.name ??
|
|
217
|
+
dest = (0, path_1.join)(utils_1.COMMAND_PATH, exeCfg?.path ?? 'dist', exeCfg?.name ?? 'app-release.exe');
|
|
217
218
|
}
|
|
218
219
|
else if (compiler === 'gradlew') {
|
|
219
220
|
const apkCfg = config_1.CONFIG_DATA.app?.android;
|
|
@@ -313,22 +314,28 @@ async function fetchRemoteResources(opts) {
|
|
|
313
314
|
spinner.fail(`${appName} wgt链接未上传`);
|
|
314
315
|
process.exit(1);
|
|
315
316
|
}
|
|
316
|
-
const
|
|
317
|
-
(0,
|
|
318
|
-
(0, fs_extra_1.
|
|
317
|
+
const appDir = (0, path_1.join)(utils_1.COMMAND_PATH, 'app', 'src', 'main', 'assets', 'apps');
|
|
318
|
+
const tempDir = (0, path_1.join)(appDir, appId);
|
|
319
|
+
(0, fs_extra_1.removeSync)(tempDir);
|
|
320
|
+
(0, fs_extra_1.ensureDirSync)(tempDir);
|
|
319
321
|
const tmpWgt = (0, path_1.join)(utils_1.COMMAND_PATH, '__tmp_remote.wgt');
|
|
320
322
|
await downloadFile(wgtUrl, tmpWgt);
|
|
321
323
|
const wgtZip = new adm_zip_1.default(tmpWgt);
|
|
322
|
-
wgtZip.extractAllTo(
|
|
324
|
+
wgtZip.extractAllTo(tempDir, true);
|
|
323
325
|
(0, fs_extra_1.removeSync)(tmpWgt);
|
|
324
326
|
// 从目标目录读取 manifest
|
|
325
|
-
const manifest = (0, fs_extra_1.readJsonSync)((0, path_1.join)(
|
|
326
|
-
const {
|
|
327
|
+
const manifest = (0, fs_extra_1.readJsonSync)((0, path_1.join)(tempDir, 'manifest.json'));
|
|
328
|
+
const { version, id } = manifest;
|
|
329
|
+
const assetsDir = (0, path_1.join)(appDir, id, 'www');
|
|
330
|
+
// 将解压内容复制到 assetsDir,然后删除临时目录
|
|
331
|
+
(0, fs_extra_1.ensureDirSync)(assetsDir);
|
|
332
|
+
(0, fs_extra_1.copySync)(tempDir, assetsDir, { overwrite: true });
|
|
333
|
+
(0, fs_extra_1.removeSync)(tempDir);
|
|
327
334
|
// 替换 build.gradle
|
|
328
335
|
const gradlePath = (0, path_1.join)(utils_1.COMMAND_PATH, 'app', 'build.gradle');
|
|
329
336
|
let gradleContent = (0, fs_1.readFileSync)(gradlePath, 'utf-8');
|
|
330
|
-
gradleContent = gradleContent.replace(/versionCode\s+\d+/, `versionCode ${
|
|
331
|
-
gradleContent = gradleContent.replace(/versionName\s+"[^"]*"/, `versionName "${
|
|
337
|
+
gradleContent = gradleContent.replace(/versionCode\s+\d+/, `versionCode ${version.code}`);
|
|
338
|
+
gradleContent = gradleContent.replace(/versionName\s+"[^"]*"/, `versionName "${version.name}"`);
|
|
332
339
|
(0, fs_1.writeFileSync)(gradlePath, gradleContent);
|
|
333
340
|
// 替换 strings.xml
|
|
334
341
|
const stringsPath = (0, path_1.join)(utils_1.COMMAND_PATH, 'app', 'src', 'main', 'res', 'values', 'strings.xml');
|
|
@@ -348,14 +355,10 @@ async function fetchRemoteResources(opts) {
|
|
|
348
355
|
}
|
|
349
356
|
async function default_1(...args) {
|
|
350
357
|
const opts = args[0];
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
if (buildEnv)
|
|
354
|
-
process.env.BUILD_ENV = String(buildEnv);
|
|
358
|
+
const commands = await getCommands(...args);
|
|
359
|
+
if (opts.remote && ['electron-vite', 'gradlew'].includes(opts.compiler)) {
|
|
355
360
|
await fetchRemoteResources(opts);
|
|
356
|
-
return [];
|
|
357
361
|
}
|
|
358
|
-
const commands = await getCommands(...args);
|
|
359
362
|
const command = commands.join(' ');
|
|
360
363
|
const time = Date.now();
|
|
361
364
|
(0, utils_1.spawnSync)(command);
|
package/lib/apis/index.js
CHANGED
|
@@ -80,155 +80,173 @@ function getVersionHistory(params) {
|
|
|
80
80
|
* 上传新版本
|
|
81
81
|
*/
|
|
82
82
|
async function uploadVersion(params) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
83
|
+
try {
|
|
84
|
+
const { brand, username, password, type, status, platform, path, remoteUrl, versionName, versionCode, } = params;
|
|
85
|
+
let brandId = '';
|
|
86
|
+
const { data: { accessToken }, } = await login({ username, password });
|
|
87
|
+
(0, http_1.setToken)(accessToken);
|
|
88
|
+
const { data: brandList } = await getBrandList();
|
|
89
|
+
const brandItem = brandList?.find(({ name, id }) => name === brand && Number(id) > 10000);
|
|
90
|
+
brandId = brandItem?.id;
|
|
91
|
+
const packageName = path?.split('/').filter(Boolean).pop();
|
|
92
|
+
const { data: latest } = await getLastVersion({ type, platform, packageName, version: 0 });
|
|
93
|
+
await saveVersion({
|
|
94
|
+
type,
|
|
95
|
+
status: status || 4,
|
|
96
|
+
platform,
|
|
97
|
+
brandId,
|
|
98
|
+
fileUrl: latest?.fileUrl || 'none',
|
|
99
|
+
hotUpdateUrl: remoteUrl,
|
|
100
|
+
name: versionName,
|
|
101
|
+
version: versionCode,
|
|
102
|
+
packageName,
|
|
103
|
+
comment: '修复一些已知问题',
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
console.error(err);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
104
110
|
}
|
|
105
111
|
/**
|
|
106
112
|
* 发布版本
|
|
107
113
|
*/
|
|
108
114
|
async function publishVersion(params) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
try {
|
|
116
|
+
const { brandName, brandId, appId, username, password, remoteUrl, versionName, versionCode, channel, versionDesc, platform, ...rest } = params;
|
|
117
|
+
const publishType = Number(rest.publishType) || 3;
|
|
118
|
+
const updateType = Number(rest.updateType) || 2;
|
|
119
|
+
const { data: { accessToken }, } = await login({ username, password });
|
|
120
|
+
(0, http_1.setToken)(accessToken);
|
|
121
|
+
const { data: pageData } = await getVersionPage({ appId, publishType, pageNo: 1, pageSize: 10 });
|
|
122
|
+
const pageList = pageData?.list?.filter((item) => {
|
|
123
|
+
if (publishType == 1) {
|
|
124
|
+
return item.platformType === const_1.PLATFORM_TYPE[platform];
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}) || [];
|
|
128
|
+
const existingVersion = pageList.find((item) => String(item.versionNum) === String(versionCode));
|
|
129
|
+
let latest;
|
|
130
|
+
const firstPage = pageList[0];
|
|
131
|
+
if (firstPage) {
|
|
132
|
+
let historyParams;
|
|
133
|
+
if (firstPage.publishType == 1) {
|
|
134
|
+
historyParams = {
|
|
135
|
+
publishType: firstPage.publishType,
|
|
136
|
+
appName: firstPage.appName,
|
|
137
|
+
channelType: firstPage.channelType,
|
|
138
|
+
platformType: firstPage.platformType,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
historyParams = {
|
|
143
|
+
publishType,
|
|
144
|
+
appMofangId: firstPage.appMofangId,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const { data: historyData } = await getVersionHistory({ ...historyParams, pageNo: 1, pageSize: 1 });
|
|
148
|
+
latest = (Array.isArray(historyData) ? historyData : historyData?.list)?.[0];
|
|
118
149
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const existingVersion = pageList.find((item) => String(item.versionNum) === String(versionCode));
|
|
122
|
-
let latest;
|
|
123
|
-
const firstPage = pageList[0];
|
|
124
|
-
if (firstPage) {
|
|
125
|
-
let historyParams;
|
|
126
|
-
if (firstPage.publishType == 1) {
|
|
127
|
-
historyParams = {
|
|
128
|
-
publishType: firstPage.publishType,
|
|
129
|
-
appName: firstPage.appName,
|
|
130
|
-
channelType: firstPage.channelType,
|
|
131
|
-
platformType: firstPage.platformType,
|
|
132
|
-
};
|
|
150
|
+
if (!existingVersion && latest && Number(versionCode) <= Number(latest.versionNum)) {
|
|
151
|
+
throw new Error(`版本号不能小于上次发布 ${latest.versionNum}`);
|
|
133
152
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
appMofangId: firstPage.appMofangId,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
const { data: historyData } = await getVersionHistory({ ...historyParams, pageNo: 1, pageSize: 1 });
|
|
141
|
-
latest = (Array.isArray(historyData) ? historyData : historyData?.list)?.[0];
|
|
142
|
-
}
|
|
143
|
-
if (!existingVersion && latest && Number(versionCode) <= Number(latest.versionNum)) {
|
|
144
|
-
throw new Error(`版本号不能小于上次发布 ${latest.versionNum}`);
|
|
145
|
-
}
|
|
146
|
-
let versionId;
|
|
147
|
-
if (existingVersion) {
|
|
148
|
-
versionId = existingVersion.id;
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
let createData;
|
|
152
|
-
if (publishType == 1) {
|
|
153
|
-
const { data: brandList } = await getBrandList();
|
|
154
|
-
const brandItem = brandList?.find(({ name, id }) => {
|
|
155
|
-
if (Number(id) > 10000) {
|
|
156
|
-
if (brandId && id === brandId) {
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
if (brandName && name === brandName) {
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return false;
|
|
164
|
-
});
|
|
165
|
-
createData = {
|
|
166
|
-
brandId: brandItem?.id,
|
|
167
|
-
appName: brandItem?.name,
|
|
168
|
-
channelType: const_1.CHANNEL_TYPE[channel],
|
|
169
|
-
platformType: const_1.PLATFORM_TYPE[platform],
|
|
170
|
-
updateType,
|
|
171
|
-
versionName,
|
|
172
|
-
versionNum: versionCode,
|
|
173
|
-
versionDesc: versionDesc || '修复一些已知问题',
|
|
174
|
-
fullPackageUrl: '',
|
|
175
|
-
fullPackageFileName: '',
|
|
176
|
-
resourcePackageUrl: '',
|
|
177
|
-
resourcePackageFileName: '',
|
|
178
|
-
publishType,
|
|
179
|
-
};
|
|
153
|
+
let versionId;
|
|
154
|
+
if (existingVersion) {
|
|
155
|
+
versionId = existingVersion.id;
|
|
180
156
|
}
|
|
181
157
|
else {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
158
|
+
let createData;
|
|
159
|
+
if (publishType == 1) {
|
|
160
|
+
const { data: brandList } = await getBrandList();
|
|
161
|
+
const brandItem = brandList?.find(({ name, id }) => {
|
|
162
|
+
if (Number(id) > 10000) {
|
|
163
|
+
if (brandId && id === brandId) {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
if (brandName && name === brandName) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
});
|
|
172
|
+
createData = {
|
|
173
|
+
brandId: brandItem?.id,
|
|
174
|
+
appName: brandItem?.name,
|
|
175
|
+
channelType: const_1.CHANNEL_TYPE[channel],
|
|
176
|
+
platformType: const_1.PLATFORM_TYPE[platform],
|
|
177
|
+
updateType,
|
|
178
|
+
versionName,
|
|
179
|
+
versionNum: versionCode,
|
|
180
|
+
versionDesc: versionDesc || '修复一些已知问题',
|
|
181
|
+
fullPackageUrl: '',
|
|
182
|
+
fullPackageFileName: '',
|
|
183
|
+
resourcePackageUrl: '',
|
|
184
|
+
resourcePackageFileName: '',
|
|
185
|
+
publishType,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
const { data: appList } = await getAppList();
|
|
190
|
+
const appItem = appList?.find((item) => item.appId === appId);
|
|
191
|
+
createData = {
|
|
192
|
+
appMofangId: appItem?.id,
|
|
193
|
+
appId,
|
|
194
|
+
appName: appItem?.name,
|
|
195
|
+
updateType,
|
|
196
|
+
versionName,
|
|
197
|
+
versionNum: versionCode,
|
|
198
|
+
versionDesc: versionDesc || '修复一些已知问题',
|
|
199
|
+
resourcePackageUrl: '',
|
|
200
|
+
resourcePackageFileName: '',
|
|
201
|
+
publishType,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const { data: newId } = await createVersion(createData);
|
|
205
|
+
versionId = newId;
|
|
196
206
|
}
|
|
197
|
-
const
|
|
198
|
-
|
|
207
|
+
const urls = Array.isArray(remoteUrl) ? remoteUrl : [remoteUrl || ''];
|
|
208
|
+
const fullUrl = urls.find((u) => !/\.zip$/i.test(u)) || '';
|
|
209
|
+
const resUrl = urls.find((u) => /\.zip$/i.test(u)) || '';
|
|
210
|
+
const fallbackFullUrl = existingVersion?.fullPackageUrl || latest?.fullPackageUrl || '';
|
|
211
|
+
const fallbackResUrl = existingVersion?.resourcePackageUrl || latest?.resourcePackageUrl || '';
|
|
212
|
+
await postVersion({
|
|
213
|
+
id: versionId,
|
|
214
|
+
fullPackageUrl: fullUrl || fallbackFullUrl,
|
|
215
|
+
resourcePackageUrl: resUrl || fallbackResUrl,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
console.error(err);
|
|
220
|
+
process.exit(1);
|
|
199
221
|
}
|
|
200
|
-
const urls = Array.isArray(remoteUrl) ? remoteUrl : [remoteUrl || ''];
|
|
201
|
-
const fullUrl = urls.find((u) => !/\.zip$/i.test(u)) || '';
|
|
202
|
-
const resUrl = urls.find((u) => /\.zip$/i.test(u)) || '';
|
|
203
|
-
const fallbackFullUrl = existingVersion?.fullPackageUrl || latest?.fullPackageUrl || '';
|
|
204
|
-
const fallbackResUrl = existingVersion?.resourcePackageUrl || latest?.resourcePackageUrl || '';
|
|
205
|
-
await postVersion({
|
|
206
|
-
id: versionId,
|
|
207
|
-
fullPackageUrl: fullUrl || fallbackFullUrl,
|
|
208
|
-
resourcePackageUrl: resUrl || fallbackResUrl,
|
|
209
|
-
});
|
|
210
222
|
}
|
|
211
223
|
/**
|
|
212
224
|
* 获取远程版本信息(自动登录)
|
|
213
225
|
*/
|
|
214
226
|
async function fetchRemoteVersionInfo(appId) {
|
|
215
|
-
const web = config_1.CONFIG_DATA.web;
|
|
216
|
-
const creds = (web?.[process.env.BUILD_ENV || ''] || web || {});
|
|
217
|
-
const { data: { accessToken }, } = await login({ username: creds.username, password: creds.password });
|
|
218
|
-
(0, http_1.setToken)(accessToken);
|
|
219
|
-
const { data: pageData } = await getVersionPage({ appId, publishType: 2, pageNo: 1, pageSize: 10 });
|
|
220
|
-
const version = pageData?.list?.[0];
|
|
221
|
-
if (!version)
|
|
222
|
-
throw new Error(`未查询到 ${appId} 应用数据`);
|
|
223
|
-
const { data: appDetail } = await getAppDetail(version.appMofangId);
|
|
224
|
-
let configJson = {};
|
|
225
227
|
try {
|
|
226
|
-
|
|
228
|
+
const web = config_1.CONFIG_DATA.web;
|
|
229
|
+
const creds = (web?.[process.env.BUILD_ENV || ''] || web || {});
|
|
230
|
+
const { data: { accessToken }, } = await login({ username: creds.username, password: creds.password });
|
|
231
|
+
(0, http_1.setToken)(accessToken);
|
|
232
|
+
const { data: pageData } = await getVersionPage({ appId, publishType: 2, pageNo: 1, pageSize: 10 });
|
|
233
|
+
const version = pageData?.list?.[0];
|
|
234
|
+
if (!version)
|
|
235
|
+
throw new Error(`未查询到 ${appId} 应用数据`);
|
|
236
|
+
const { data: appDetail } = await getAppDetail(version.appMofangId);
|
|
237
|
+
let configJson = {};
|
|
238
|
+
try {
|
|
239
|
+
configJson = JSON.parse(appDetail?.configJson || '{}');
|
|
240
|
+
}
|
|
241
|
+
catch { }
|
|
242
|
+
return {
|
|
243
|
+
...version,
|
|
244
|
+
iconUrl: appDetail?.iconUrl,
|
|
245
|
+
configJson,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
console.error(err);
|
|
250
|
+
process.exit(1);
|
|
227
251
|
}
|
|
228
|
-
catch { }
|
|
229
|
-
return {
|
|
230
|
-
...version,
|
|
231
|
-
iconUrl: appDetail?.iconUrl,
|
|
232
|
-
configJson,
|
|
233
|
-
};
|
|
234
252
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmcb/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "工茂草本前端命令行工具",
|
|
5
5
|
"author": "yinjiazeng@163.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,6 +58,5 @@
|
|
|
58
58
|
"@types/inquirer": "^9.0.7",
|
|
59
59
|
"@types/rimraf": "^4.0.5",
|
|
60
60
|
"@types/user-home": "^2.0.2"
|
|
61
|
-
}
|
|
62
|
-
"gitHead": "7c47fc74419f1ef0f1b3f70148c6dfabb4251f14"
|
|
61
|
+
}
|
|
63
62
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 aniu
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|