@gmcb/cli 0.4.5 → 0.4.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/CHANGELOG.md +8 -0
- package/README.md +14 -0
- 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,14 @@
|
|
|
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.6](http://10.10.10.16/caoben/front-end/compare/@gmcb/cli@0.4.5...@gmcb/cli@0.4.6) (2026-06-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @gmcb/cli
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [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
15
|
|
|
8
16
|
**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/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.6",
|
|
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
|
}
|