@gmcb/cli 0.4.5 → 0.4.7
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 +16 -0
- package/README.md +14 -0
- package/lib/actions/build.js +16 -6
- package/lib/actions/copy.js +15 -2
- package/lib/utils/function.d.ts +1 -0
- package/lib/utils/function.js +7 -0
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
## [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)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [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)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [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)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @gmcb/cli
|
package/README.md
CHANGED
|
@@ -20,3 +20,17 @@ npm i @gmcb/cli -g
|
|
|
20
20
|
| `gmcb config` | 配置管理 |
|
|
21
21
|
| `gmcb skill sync` | 同步技能到本地项目 |
|
|
22
22
|
| `gmcb skill list` | 列出当前项目所有技能 |
|
|
23
|
+
|
|
24
|
+
## `gmcb copy`
|
|
25
|
+
|
|
26
|
+
将资源从源目录复制到目标目录,支持 `{...}` 占位符自动解析:
|
|
27
|
+
|
|
28
|
+
- `{build.*}` 取自已合并的 `uni.build.json` 配置(扁平化键),例如 `{build.app.windows.packagename}`
|
|
29
|
+
- `{manifest.*}` 取自项目根目录的 `manifest.json`(扁平化键),例如 `{manifest.appid}`
|
|
30
|
+
|
|
31
|
+
示例:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
gmcb copy -s ./dist/build/h5 -d ../electron/out/renderer/{build.app.windows.packagename}/
|
|
35
|
+
gmcb copy -s ./dist/build/app -d ../android/app/src/main/assets/apps/{manifest.appid}/www/
|
|
36
|
+
```
|
package/lib/actions/build.js
CHANGED
|
@@ -179,6 +179,18 @@ async function getCommands(...args) {
|
|
|
179
179
|
}
|
|
180
180
|
return commands;
|
|
181
181
|
}
|
|
182
|
+
function generateH5Manifest() {
|
|
183
|
+
const manifest = (0, utils_1.readManifest)();
|
|
184
|
+
const source = (0, path_1.join)(utils_1.COMMAND_PATH, utils_1.HAS_SRC ? 'dist/build/h5' : 'unpackage/dist/build/web');
|
|
185
|
+
if (!(0, fs_1.existsSync)(source)) {
|
|
186
|
+
utils_1.log.warning('H5 构建输出目录不存在,跳过生成 manifest.json');
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
(0, fs_extra_1.writeJsonSync)((0, path_1.join)(source, 'manifest.json'), {
|
|
190
|
+
versionName: manifest['versionName'] || '',
|
|
191
|
+
versionCode: manifest['versionCode'] || '',
|
|
192
|
+
});
|
|
193
|
+
}
|
|
182
194
|
async function createZip(compiler, platform) {
|
|
183
195
|
const spinner = (0, ora_1.default)(`正在生成资源文件...`).start();
|
|
184
196
|
await (0, delay_1.default)(1000);
|
|
@@ -201,12 +213,6 @@ async function createZip(compiler, platform) {
|
|
|
201
213
|
if ((0, fs_1.existsSync)(dest)) {
|
|
202
214
|
(0, fs_1.unlinkSync)(dest);
|
|
203
215
|
}
|
|
204
|
-
if (compiler === 'uni' && platform === 'h5') {
|
|
205
|
-
(0, fs_extra_1.writeJsonSync)((0, path_1.join)(source, 'manifest.json'), {
|
|
206
|
-
versionName: manifest['versionName'] || '',
|
|
207
|
-
versionCode: manifest['versionCode'] || '',
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
216
|
const zipRoot = compiler === 'uni' && platform === 'h5' ? (config.app?.windows?.packagename || '') : '';
|
|
211
217
|
zip.addLocalFolder(source, zipRoot);
|
|
212
218
|
zip.writeZip(dest);
|
|
@@ -227,6 +233,10 @@ async function default_1(...args) {
|
|
|
227
233
|
utils_1.log.error('检测到您的HbuilderX未启动或项目管理器中未发现构建项目,请检查后重试!');
|
|
228
234
|
}
|
|
229
235
|
}
|
|
236
|
+
// H5 构建完成后立即生成 manifest.json
|
|
237
|
+
if (opts.compiler === 'uni' && opts.platform === 'h5') {
|
|
238
|
+
generateH5Manifest();
|
|
239
|
+
}
|
|
230
240
|
if ((opts.compiler === 'electron-vite' && opts.zip) ||
|
|
231
241
|
(opts.compiler === 'uni' && opts.platform === 'h5' && opts.zip)) {
|
|
232
242
|
await createZip(opts.compiler, opts.platform);
|
package/lib/actions/copy.js
CHANGED
|
@@ -9,7 +9,9 @@ const fs_1 = require("fs");
|
|
|
9
9
|
const fs_extra_1 = require("fs-extra");
|
|
10
10
|
const ora_1 = __importDefault(require("ora"));
|
|
11
11
|
const delay_1 = __importDefault(require("delay"));
|
|
12
|
+
const flat_1 = require("flat");
|
|
12
13
|
const utils_1 = require("../utils");
|
|
14
|
+
const config_1 = require("./config");
|
|
13
15
|
async function default_1(...args) {
|
|
14
16
|
const opts = args[0];
|
|
15
17
|
if (!opts.source) {
|
|
@@ -18,8 +20,19 @@ async function default_1(...args) {
|
|
|
18
20
|
if (!opts.dest) {
|
|
19
21
|
utils_1.log.error('请使用-d或--dest设置复制资源的目标目录');
|
|
20
22
|
}
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
+
const data = {};
|
|
24
|
+
const flatConfig = (0, flat_1.flatten)((0, config_1.getMergeConfig)());
|
|
25
|
+
const flatManifest = (0, flat_1.flatten)((0, utils_1.readManifest)());
|
|
26
|
+
Object.keys(flatConfig).forEach((k) => {
|
|
27
|
+
data[`build.${k}`] = flatConfig[k];
|
|
28
|
+
});
|
|
29
|
+
Object.keys(flatManifest).forEach((k) => {
|
|
30
|
+
data[`manifest.${k}`] = flatManifest[k];
|
|
31
|
+
});
|
|
32
|
+
const resolvedSource = (0, utils_1.resolvePlaceholder)(opts.source, data);
|
|
33
|
+
const resolvedDest = (0, utils_1.resolvePlaceholder)(opts.dest, data);
|
|
34
|
+
const sourcePath = (0, path_1.join)(utils_1.COMMAND_PATH, resolvedSource);
|
|
35
|
+
const destPath = (0, path_1.join)(utils_1.COMMAND_PATH, resolvedDest);
|
|
23
36
|
const srcPath = (0, path_1.join)(utils_1.COMMAND_PATH, 'src');
|
|
24
37
|
const indexPath = (0, path_1.join)(utils_1.COMMAND_PATH, 'index.html');
|
|
25
38
|
let ignore = [];
|
package/lib/utils/function.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export declare function readManifest(): Record<string, unknown>;
|
|
|
2
2
|
export declare function objectToCommand(obj?: Record<string, any>): {};
|
|
3
3
|
export declare function filterToArray(obj?: Record<string, any>): any[];
|
|
4
4
|
export declare function spawnSync(command?: string): import("child_process").SpawnSyncReturns<Buffer>;
|
|
5
|
+
export declare function resolvePlaceholder(input: string, data: Record<string, any>): string;
|
|
5
6
|
export declare function getBinPath(name: string): string;
|
package/lib/utils/function.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.readManifest = readManifest;
|
|
|
7
7
|
exports.objectToCommand = objectToCommand;
|
|
8
8
|
exports.filterToArray = filterToArray;
|
|
9
9
|
exports.spawnSync = spawnSync;
|
|
10
|
+
exports.resolvePlaceholder = resolvePlaceholder;
|
|
10
11
|
exports.getBinPath = getBinPath;
|
|
11
12
|
const fs_1 = require("fs");
|
|
12
13
|
const path_1 = require("path");
|
|
@@ -45,6 +46,12 @@ function spawnSync(command = '') {
|
|
|
45
46
|
console.log(command);
|
|
46
47
|
return cross_spawn_1.default.sync(command, { stdio: 'inherit', shell: true });
|
|
47
48
|
}
|
|
49
|
+
function resolvePlaceholder(input, data) {
|
|
50
|
+
return input.replace(/\{([^}]+)\}/g, (_, key) => {
|
|
51
|
+
const value = data[key];
|
|
52
|
+
return value != null ? String(value) : '';
|
|
53
|
+
});
|
|
54
|
+
}
|
|
48
55
|
function getBinPath(name) {
|
|
49
56
|
const path = (0, path_1.join)(const_1.COMMAND_PATH, 'node_modules/.bin', name);
|
|
50
57
|
if ((0, fs_1.existsSync)(path)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmcb/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "工茂草本前端命令行工具",
|
|
5
5
|
"author": "yinjiazeng@163.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,6 +53,5 @@
|
|
|
53
53
|
"@types/inquirer": "^9.0.7",
|
|
54
54
|
"@types/rimraf": "^4.0.5",
|
|
55
55
|
"@types/user-home": "^2.0.2"
|
|
56
|
-
}
|
|
57
|
-
"gitHead": "a0f819ed8e4aa921a13463b9e2cc987d2e8cbdd1"
|
|
56
|
+
}
|
|
58
57
|
}
|