@icebreakers/monorepo 2.1.6 → 3.0.0

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/dist/index.d.cts CHANGED
@@ -1,284 +1,402 @@
1
- import * as _pnpm_types from '@pnpm/types';
2
- import * as simple_git from 'simple-git';
3
- import { SimpleGitOptions, ConfigValues } from 'simple-git';
4
- export { ConfigValues, SimpleGit, SimpleGitOptions } from 'simple-git';
5
- import * as gitUrlParse from 'git-url-parse';
6
- import gitUrlParse__default from 'git-url-parse';
7
- import * as consola from 'consola';
8
- import crypto from 'node:crypto';
9
- export { PackageJson } from 'pkg-types';
1
+ import { PackageJson } from "pkg-types";
2
+ import * as simple_git0 from "simple-git";
3
+ import { ConfigValues, SimpleGit, SimpleGitOptions } from "simple-git";
4
+ import * as git_url_parse0 from "git-url-parse";
5
+ import gitUrlParse from "git-url-parse";
6
+ import * as _pnpm_types0 from "@pnpm/types";
7
+ import * as consola0 from "consola";
8
+ import crypto from "node:crypto";
10
9
 
10
+ //#region src/types/cli.d.ts
11
11
  /**
12
- * 工作区包列表的查询选项,允许控制根包、私有包与匹配模式。
12
+ * CLI 公用参数,保证各命令对外暴露一致的行为。
13
13
  */
14
- interface GetWorkspacePackagesOptions {
15
- ignoreRootPackage?: boolean;
16
- ignorePrivatePackage?: boolean;
17
- patterns?: string[];
14
+ interface CliOpts {
15
+ /**
16
+ * 是否开启交互模式,开启后每一步都会提示用户确认。
17
+ * @default false
18
+ */
19
+ interactive?: boolean;
20
+ /**
21
+ * 是否使用 core 版资产,只同步最精简的文件集合。
22
+ * @default false
23
+ */
24
+ core?: boolean;
25
+ /**
26
+ * 输出目录(相对 `cwd`),用于放置生成或拷贝出来的文件。
27
+ * @default ''
28
+ */
29
+ outDir?: string;
30
+ /**
31
+ * 命令执行的工作目录。
32
+ * @default process.cwd()
33
+ */
34
+ cwd?: string;
35
+ /**
36
+ * 是否跳过已有文件的覆写;开启后保留旧文件不做对比。
37
+ * @default false
38
+ */
39
+ skipOverwrite?: boolean;
18
40
  }
41
+ //#endregion
42
+ //#region src/commands/create.d.ts
19
43
  /**
20
- * 读取 pnpm workspace 下的所有包,并根据配置过滤与补充字段。
44
+ * 内置模板映射表,value 指向仓库中对应模板所在路径。
21
45
  */
22
- declare function getWorkspacePackages(workspaceDir: string, options?: GetWorkspacePackagesOptions): Promise<{
23
- pkgJsonPath: string;
24
- rootDir: _pnpm_types.ProjectRootDir;
25
- rootDirRealPath: _pnpm_types.ProjectRootDirRealPath;
26
- modulesDir?: string;
27
- manifest: _pnpm_types.ProjectManifest;
28
- writeProjectManifest: (manifest: _pnpm_types.ProjectManifest, force?: boolean | undefined) => Promise<void>;
29
- }[]>;
46
+ declare const templateMap: {
47
+ readonly tsup: "packages/tsup-template";
48
+ readonly tsdown: "packages/tsdown-template";
49
+ readonly unbuild: "packages/unbuild-template";
50
+ readonly 'vue-lib': "packages/vue-lib-template";
51
+ readonly 'hono-server': "apps/server";
52
+ readonly 'vue-hono': "apps/client";
53
+ readonly vitepress: "apps/website";
54
+ readonly cli: "apps/cli";
55
+ };
56
+ type CreateNewProjectType = keyof typeof templateMap;
57
+ interface CreateNewProjectOptions {
58
+ name?: string;
59
+ cwd?: string;
60
+ renameJson?: boolean;
61
+ type?: CreateNewProjectType | string;
62
+ }
30
63
  /**
31
- * 将工作区绝对路径、包列表与当前 cwd 打包返回,方便调用方一次获取所有信息。
64
+ * 若配置中提供 choices 则优先使用,否则退回默认预设。
32
65
  */
33
- declare function getWorkspaceData(cwd: string, options?: GetWorkspacePackagesOptions): Promise<{
34
- cwd: string;
35
- workspaceDir: string;
36
- packages: {
37
- pkgJsonPath: string;
38
- rootDir: _pnpm_types.ProjectRootDir;
39
- rootDirRealPath: _pnpm_types.ProjectRootDirRealPath;
40
- modulesDir?: string;
41
- manifest: _pnpm_types.ProjectManifest;
42
- writeProjectManifest: (manifest: _pnpm_types.ProjectManifest, force?: boolean | undefined) => Promise<void>;
43
- }[];
44
- }>;
45
-
66
+ declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[] | ({
67
+ readonly name: "unbuild 打包";
68
+ readonly value: "unbuild";
69
+ } | {
70
+ readonly name: "tsup 打包";
71
+ readonly value: "tsup";
72
+ } | {
73
+ readonly name: "tsdown 打包";
74
+ readonly value: "tsdown";
75
+ } | {
76
+ readonly name: "vue 组件";
77
+ readonly value: "vue-lib";
78
+ } | {
79
+ readonly name: "vue hono 全栈";
80
+ readonly value: "vue-hono";
81
+ } | {
82
+ readonly name: "hono 模板";
83
+ readonly value: "hono-server";
84
+ } | {
85
+ readonly name: "vitepress 文档";
86
+ readonly value: "vitepress";
87
+ } | {
88
+ readonly name: "cli 模板";
89
+ readonly value: "cli";
90
+ })[];
46
91
  /**
47
- * CLI 命令通用参数,便于在各个子命令之间复用。
92
+ * 合并内置与自定义模板映射,允许扩展新的模板类型。
48
93
  */
49
- interface CliOpts {
50
- interactive?: boolean;
51
- core?: boolean;
52
- outDir?: string;
53
- cwd?: string;
54
- skipOverwrite?: boolean;
94
+ declare function getTemplateMap(extra?: Record<string, string>): Record<string, string>;
95
+ /**
96
+ * 根据提供的参数或配置生成新工程目录,并可自动改写 package.json。
97
+ */
98
+ declare function createNewProject(options?: CreateNewProjectOptions): Promise<void>;
99
+ //#endregion
100
+ //#region src/types/workspace.d.ts
101
+ /**
102
+ * 工作区工具可接收的筛选选项。
103
+ */
104
+ interface GetWorkspacePackagesOptions {
105
+ /**
106
+ * 是否在结果中排除 workspace 根包。
107
+ * @default true
108
+ */
109
+ ignoreRootPackage?: boolean;
110
+ /**
111
+ * 是否过滤掉标记为 `private` 的包。
112
+ * @default true
113
+ */
114
+ ignorePrivatePackage?: boolean;
115
+ /**
116
+ * 自定义 glob,覆盖 `pnpm-workspace.yaml` 的 `packages` 配置。
117
+ * @default workspace manifest `packages`
118
+ */
119
+ patterns?: string[];
55
120
  }
56
-
121
+ //#endregion
122
+ //#region src/types/config.d.ts
57
123
  /**
58
124
  * `monorepo new` 命令的配置项,允许外部覆写模板目录、模板清单等。
59
125
  */
60
126
  interface CreateCommandConfig extends Partial<Omit<CreateNewProjectOptions, 'cwd'>> {
61
- /** 自定义模板根目录(默认为包内置模板) */
62
- templatesDir?: string;
63
- /** 扩展模板映射表,key 为类型,value 为模板相对路径 */
64
- templateMap?: Record<string, string>;
65
- /** 自定义交互提示的选项列表 */
66
- choices?: CreateChoiceOption[];
67
- /** 当未选择模板时使用的默认模板 */
68
- defaultTemplate?: CreateNewProjectOptions['type'];
127
+ /**
128
+ * 自定义模板根目录。
129
+ * @default 内置模板所在的 `packages/monorepo/templates`
130
+ */
131
+ templatesDir?: string;
132
+ /**
133
+ * 扩展模板映射表,key 为类型,value 为模板相对路径。
134
+ * @default 内置 `templateMap`
135
+ */
136
+ templateMap?: Record<string, string>;
137
+ /**
138
+ * 自定义交互提示的选项列表。
139
+ * @default 内置 `baseChoices`
140
+ */
141
+ choices?: CreateChoiceOption[];
142
+ /**
143
+ * 当未选择模板时使用的默认模板。
144
+ * @default 'unbuild'
145
+ */
146
+ defaultTemplate?: CreateNewProjectOptions['type'];
69
147
  }
70
148
  /**
71
149
  * CLI 交互式选择框的选项结构。
72
150
  */
73
151
  interface CreateChoiceOption {
74
- value: string;
75
- name?: string;
76
- description?: string;
77
- short?: string;
78
- disabled?: boolean | string;
152
+ /**
153
+ * 唯一值,将回传给命令逻辑使用。
154
+ * @default undefined
155
+ */
156
+ value: string;
157
+ /**
158
+ * 选项展示名称。
159
+ * @default value
160
+ */
161
+ name?: string;
162
+ /**
163
+ * 选项描述信息。
164
+ * @default undefined
165
+ */
166
+ description?: string;
167
+ /**
168
+ * 短名称,用于命令行紧凑展示。
169
+ * @default undefined
170
+ */
171
+ short?: string;
172
+ /**
173
+ * 设置为 true 或字符串即可禁用该选项并显示原因。
174
+ * @default false
175
+ */
176
+ disabled?: boolean | string;
79
177
  }
80
178
  /**
81
179
  * `monorepo clean` 命令配置,可控制自动选择、排除包等行为。
82
180
  */
83
181
  interface CleanCommandConfig {
84
- /** 是否跳过交互直接清理全部 */
85
- autoConfirm?: boolean;
86
- /** 不允许被清理的包名列表 */
87
- ignorePackages?: string[];
88
- /** 是否包含 private 包 */
89
- includePrivate?: boolean;
90
- /** 强制写回的 @icebreakers/monorepo 版本 */
91
- pinnedVersion?: string;
182
+ /**
183
+ * 是否跳过交互直接清理全部。
184
+ * @default false
185
+ */
186
+ autoConfirm?: boolean;
187
+ /**
188
+ * 不允许被清理的包名列表。
189
+ * @default []
190
+ */
191
+ ignorePackages?: string[];
192
+ /**
193
+ * 是否包含 private 包。
194
+ * @default false
195
+ */
196
+ includePrivate?: boolean;
197
+ /**
198
+ * 强制写回的 @icebreakers/monorepo 版本。
199
+ * @default 当前依赖版本
200
+ */
201
+ pinnedVersion?: string;
92
202
  }
93
203
  /**
94
204
  * `monorepo sync` 命令配置,可覆盖 workspace 过滤规则或同步命令模板。
95
205
  */
96
206
  interface SyncCommandConfig extends Partial<GetWorkspacePackagesOptions> {
97
- /** 并发执行同步命令的最大数量 */
98
- concurrency?: number;
99
- /** 自定义执行的同步命令模板,使用 {name} 占位 */
100
- command?: string;
101
- /** 仅同步指定的包(按名称过滤) */
102
- packages?: string[];
207
+ /**
208
+ * 并发执行同步命令的最大数量。
209
+ * @default os.cpus().length
210
+ */
211
+ concurrency?: number;
212
+ /**
213
+ * 自定义执行的同步命令模板,使用 {name} 占位。
214
+ * @default 'cnpm sync {name}'
215
+ */
216
+ command?: string;
217
+ /**
218
+ * 仅同步指定的包(按名称过滤)。
219
+ * @default 同步全部可见包
220
+ */
221
+ packages?: string[];
103
222
  }
104
223
  /**
105
224
  * `monorepo upgrade` 命令配置,覆盖脚本、目标文件等能力。
106
225
  */
107
226
  interface UpgradeCommandConfig extends Partial<CliOpts> {
108
- /** 额外需要写入的目标文件列表 */
109
- targets?: string[];
110
- /** 是否与默认目标合并,false 表示完全覆盖 */
111
- mergeTargets?: boolean;
112
- /** 需要写入 package.json 的脚本集合 */
113
- scripts?: Record<string, string>;
114
- /** 是否跳过生成 changeset markdown */
115
- skipChangesetMarkdown?: boolean;
227
+ /**
228
+ * 额外需要写入的目标文件列表。
229
+ * @default []
230
+ */
231
+ targets?: string[];
232
+ /**
233
+ * 是否与默认目标合并,false 表示完全覆盖。
234
+ * @default true
235
+ */
236
+ mergeTargets?: boolean;
237
+ /**
238
+ * 需要写入 package.json 的脚本集合。
239
+ * @default {}
240
+ */
241
+ scripts?: Record<string, string>;
242
+ /**
243
+ * 是否跳过生成 changeset markdown。
244
+ * @default true
245
+ */
246
+ skipChangesetMarkdown?: boolean;
116
247
  }
117
248
  /**
118
249
  * `monorepo init` 命令配置,用于跳过部分初始化步骤。
119
250
  */
120
251
  interface InitCommandConfig {
121
- skipReadme?: boolean;
122
- skipPkgJson?: boolean;
123
- skipChangeset?: boolean;
252
+ /**
253
+ * 是否跳过 README 生成。
254
+ * @default false
255
+ */
256
+ skipReadme?: boolean;
257
+ /**
258
+ * 是否跳过 package.json 写入。
259
+ * @default false
260
+ */
261
+ skipPkgJson?: boolean;
262
+ /**
263
+ * 是否跳过 changeset 的更新。
264
+ * @default false
265
+ */
266
+ skipChangeset?: boolean;
124
267
  }
125
268
  /**
126
269
  * `monorepo mirror` 命令配置,可增加额外的环境变量镜像。
127
270
  */
128
271
  interface MirrorCommandConfig {
129
- env?: Record<string, string>;
272
+ /**
273
+ * 需要注入的环境变量键值对。
274
+ * @default {}
275
+ */
276
+ env?: Record<string, string>;
130
277
  }
131
278
  /**
132
279
  * 项目级配置入口,按命令划分可插拔的配置块。
133
280
  */
134
281
  interface MonorepoConfig {
135
- commands?: {
136
- create?: CreateCommandConfig;
137
- clean?: CleanCommandConfig;
138
- sync?: SyncCommandConfig;
139
- upgrade?: UpgradeCommandConfig;
140
- init?: InitCommandConfig;
141
- mirror?: MirrorCommandConfig;
142
- };
282
+ /**
283
+ * 按命令分类的可选配置。
284
+ * @default {}
285
+ */
286
+ commands?: {
287
+ create?: CreateCommandConfig;
288
+ clean?: CleanCommandConfig;
289
+ sync?: SyncCommandConfig;
290
+ upgrade?: UpgradeCommandConfig;
291
+ init?: InitCommandConfig;
292
+ mirror?: MirrorCommandConfig;
293
+ };
143
294
  }
295
+ //#endregion
296
+ //#region src/core/git.d.ts
144
297
  /**
145
- * 提供类型提示的辅助函数,供外部定义配置时使用。
146
- */
147
- declare function defineMonorepoConfig(config: MonorepoConfig): MonorepoConfig;
148
- /**
149
- * 加载指定目录的 monorepo 配置,并利用缓存提升性能。
150
- */
151
- declare function loadMonorepoConfig(cwd: string): Promise<MonorepoConfig>;
152
- /**
153
- * 获取命令对应的合并配置,若未配置则返回空对象,保证调用端逻辑简单。
154
- */
155
- declare function resolveCommandConfig<Name extends keyof NonNullable<MonorepoConfig['commands']>>(name: Name, cwd: string): Promise<NonNullable<MonorepoConfig['commands']>[Name]>;
156
-
157
- /**
158
- * 内置模板映射表,value 指向仓库中对应模板所在路径。
298
+ * 对 simple-git 的轻量封装,集中处理配置缓存与常用查询。
159
299
  */
160
- declare const templateMap: {
161
- readonly tsup: "packages/tsup-template";
162
- readonly tsdown: "packages/tsdown-template";
163
- readonly unbuild: "packages/unbuild-template";
164
- readonly 'vue-lib': "packages/vue-lib-template";
165
- readonly 'hono-server': "apps/server";
166
- readonly 'vue-hono': "apps/client";
167
- readonly vitepress: "apps/website";
168
- readonly cli: "apps/cli";
169
- };
170
- type CreateNewProjectType = keyof typeof templateMap;
171
- interface CreateNewProjectOptions {
172
- name?: string;
173
- cwd?: string;
174
- renameJson?: boolean;
175
- type?: CreateNewProjectType | string;
300
+ declare class GitClient {
301
+ #private;
302
+ private readonly client;
303
+ constructor(options?: Partial<SimpleGitOptions>);
304
+ /**
305
+ * 读取 Git 的 config 列表,原样返回 simple-git 的结果。
306
+ */
307
+ listConfig(): simple_git0.Response<simple_git0.ConfigListSummary>;
308
+ /**
309
+ * 初始化配置缓存,避免多次访问 Git 产生的性能损耗。
310
+ */
311
+ init(): Promise<ConfigValues>;
312
+ /**
313
+ * 获取缓存的配置,若未初始化则自动触发 init。
314
+ */
315
+ getConfig(): Promise<ConfigValues>;
316
+ /**
317
+ * 解析 remote.origin.url,返回 git-url-parse 的结构,便于获取仓库元信息。
318
+ */
319
+ getGitUrl(): Promise<gitUrlParse.GitUrl | undefined>;
320
+ /**
321
+ * 组合 owner/name,生成常用的仓库名表达。
322
+ */
323
+ getRepoName(): Promise<string | undefined>;
324
+ /**
325
+ * 从 Git 配置中提取用户信息,用于填充 package.json author 字段。
326
+ */
327
+ getUser(): Promise<{
328
+ name: string;
329
+ email: string;
330
+ }>;
331
+ /**
332
+ * 获取当前仓库的顶层目录路径。
333
+ */
334
+ getRepoRoot(): Promise<string | undefined>;
176
335
  }
336
+ //#endregion
337
+ //#region src/core/workspace.d.ts
177
338
  /**
178
- * 若配置中提供 choices 则优先使用,否则退回默认预设。
179
- */
180
- declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[] | ({
181
- readonly name: "unbuild 打包";
182
- readonly value: "unbuild";
183
- } | {
184
- readonly name: "tsup 打包";
185
- readonly value: "tsup";
186
- } | {
187
- readonly name: "tsdown 打包";
188
- readonly value: "tsdown";
189
- } | {
190
- readonly name: "vue 组件";
191
- readonly value: "vue-lib";
192
- } | {
193
- readonly name: "vue hono 全栈";
194
- readonly value: "vue-hono";
195
- } | {
196
- readonly name: "hono 模板";
197
- readonly value: "hono-server";
198
- } | {
199
- readonly name: "vitepress 文档";
200
- readonly value: "vitepress";
201
- } | {
202
- readonly name: "cli 模板";
203
- readonly value: "cli";
204
- })[];
205
- /**
206
- * 合并内置与自定义模板映射,允许扩展新的模板类型。
207
- */
208
- declare function getTemplateMap(extra?: Record<string, string>): Record<string, string>;
209
- /**
210
- * 根据提供的参数或配置生成新工程目录,并可自动改写 package.json。
339
+ * 读取 pnpm workspace 下的所有包,并根据配置过滤与补充字段。
211
340
  */
212
- declare function createNewProject(options?: CreateNewProjectOptions): Promise<void>;
213
-
341
+ declare function getWorkspacePackages(workspaceDir: string, options?: GetWorkspacePackagesOptions): Promise<{
342
+ pkgJsonPath: string;
343
+ rootDir: _pnpm_types0.ProjectRootDir;
344
+ rootDirRealPath: _pnpm_types0.ProjectRootDirRealPath;
345
+ modulesDir?: string;
346
+ manifest: _pnpm_types0.ProjectManifest;
347
+ writeProjectManifest: (manifest: _pnpm_types0.ProjectManifest, force?: boolean | undefined) => Promise<void>;
348
+ }[]>;
214
349
  /**
215
- * simple-git 的轻量封装,集中处理配置缓存与常用查询。
350
+ * 将工作区绝对路径、包列表与当前 cwd 打包返回,方便调用方一次获取所有信息。
216
351
  */
217
- declare class GitClient {
218
- #private;
219
- private readonly client;
220
- constructor(options?: Partial<SimpleGitOptions>);
221
- /**
222
- * 读取 Git 的 config 列表,原样返回 simple-git 的结果。
223
- */
224
- listConfig(): simple_git.Response<simple_git.ConfigListSummary>;
225
- /**
226
- * 初始化配置缓存,避免多次访问 Git 产生的性能损耗。
227
- */
228
- init(): Promise<ConfigValues>;
229
- /**
230
- * 获取缓存的配置,若未初始化则自动触发 init。
231
- */
232
- getConfig(): Promise<ConfigValues>;
233
- /**
234
- * 解析 remote.origin.url,返回 git-url-parse 的结构,便于获取仓库元信息。
235
- */
236
- getGitUrl(): Promise<gitUrlParse__default.GitUrl | undefined>;
237
- /**
238
- * 组合 owner/name,生成常用的仓库名表达。
239
- */
240
- getRepoName(): Promise<string | undefined>;
241
- /**
242
- * 从 Git 配置中提取用户信息,用于填充 package.json author 字段。
243
- */
244
- getUser(): Promise<{
245
- name: string;
246
- email: string;
247
- }>;
248
- /**
249
- * 获取当前仓库的顶层目录路径。
250
- */
251
- getRepoRoot(): Promise<string | undefined>;
252
- }
253
-
352
+ declare function getWorkspaceData(cwd: string, options?: GetWorkspacePackagesOptions): Promise<{
353
+ cwd: string;
354
+ workspaceDir: string;
355
+ packages: {
356
+ pkgJsonPath: string;
357
+ rootDir: _pnpm_types0.ProjectRootDir;
358
+ rootDirRealPath: _pnpm_types0.ProjectRootDirRealPath;
359
+ modulesDir?: string;
360
+ manifest: _pnpm_types0.ProjectManifest;
361
+ writeProjectManifest: (manifest: _pnpm_types0.ProjectManifest, force?: boolean | undefined) => Promise<void>;
362
+ }[];
363
+ }>;
364
+ //#endregion
365
+ //#region src/commands/clean.d.ts
254
366
  /**
255
367
  * 交互式清理被选中的包目录,同时重写根 package.json 中的 @icebreakers/monorepo 版本。
256
368
  */
257
369
  declare function cleanProjects(cwd: string): Promise<void>;
258
-
370
+ //#endregion
371
+ //#region src/commands/init/index.d.ts
259
372
  /**
260
373
  * 初始化命令入口,根据配置逐步生成基础文件。
261
374
  */
262
375
  declare function init(cwd: string): Promise<void>;
263
-
376
+ //#endregion
377
+ //#region src/commands/mirror/binaryMirror.d.ts
264
378
  /**
265
379
  * 根据中国大陆镜像源,自动向 VSCode settings.json 注入终端环境变量。
266
380
  */
267
381
  declare function setVscodeBinaryMirror(cwd: string): Promise<void>;
268
-
382
+ //#endregion
383
+ //#region src/commands/sync.d.ts
269
384
  /**
270
385
  * 批量执行 `cnpm sync`(或自定义命令),将所有包同步到 npmmirror。
271
386
  */
272
387
  declare function syncNpmMirror(cwd: string, options?: GetWorkspacePackagesOptions): Promise<void>;
273
-
388
+ //#endregion
389
+ //#region src/commands/upgrade/index.d.ts
274
390
  /**
275
391
  * 将 assets 目录的模版文件同步到工程中,实现一键升级脚手架能力。
276
392
  */
277
393
  declare function upgradeMonorepo(opts: CliOpts): Promise<void>;
278
-
279
- var name = "@icebreakers/monorepo";
280
- var version = "2.1.6";
281
-
394
+ //#endregion
395
+ //#region package.d.ts
396
+ declare let name: string;
397
+ declare let version: string;
398
+ //#endregion
399
+ //#region src/constants.d.ts
282
400
  /**
283
401
  * @icebreakers/monorepo 包的根目录,所有模板与资产目录都以此为基准。
284
402
  */
@@ -295,47 +413,65 @@ declare const assetsDir: string;
295
413
  * monorepo 根目录,方便需要跳出当前包的逻辑(例如定位工作区文件)。
296
414
  */
297
415
  declare const rootDir: string;
298
-
416
+ //#endregion
417
+ //#region src/core/config.d.ts
418
+ /**
419
+ * 提供类型提示的辅助函数,供外部定义配置时使用。
420
+ */
421
+ declare function defineMonorepoConfig(config: MonorepoConfig): MonorepoConfig;
422
+ /**
423
+ * 加载指定目录的 monorepo 配置,并利用缓存提升性能。
424
+ */
425
+ declare function loadMonorepoConfig(cwd: string): Promise<MonorepoConfig>;
426
+ /**
427
+ * 获取命令对应的合并配置,若未配置则返回空对象,保证调用端逻辑简单。
428
+ */
429
+ declare function resolveCommandConfig<Name extends keyof NonNullable<MonorepoConfig['commands']>>(name: Name, cwd: string): Promise<NonNullable<MonorepoConfig['commands']>[Name]>;
430
+ //#endregion
431
+ //#region src/core/context.d.ts
299
432
  /**
300
433
  * 构建命令执行上下文,封装常用的工作区、Git、配置等信息。
301
434
  */
302
435
  declare function createContext(cwd: string): Promise<{
303
- cwd: string;
304
- git: GitClient;
305
- gitUrl: gitUrlParse.GitUrl | undefined;
306
- gitUser: {
307
- name: string;
308
- email: string;
309
- };
310
- workspaceDir: string;
311
- workspaceFilepath: string;
312
- packages: {
313
- pkgJsonPath: string;
314
- rootDir: _pnpm_types.ProjectRootDir;
315
- rootDirRealPath: _pnpm_types.ProjectRootDirRealPath;
316
- modulesDir?: string;
317
- manifest: _pnpm_types.ProjectManifest;
318
- writeProjectManifest: (manifest: _pnpm_types.ProjectManifest, force?: boolean | undefined) => Promise<void>;
319
- }[];
320
- config: MonorepoConfig;
436
+ cwd: string;
437
+ git: GitClient;
438
+ gitUrl: git_url_parse0.GitUrl | undefined;
439
+ gitUser: {
440
+ name: string;
441
+ email: string;
442
+ };
443
+ workspaceDir: string;
444
+ workspaceFilepath: string;
445
+ packages: {
446
+ pkgJsonPath: string;
447
+ rootDir: _pnpm_types0.ProjectRootDir;
448
+ rootDirRealPath: _pnpm_types0.ProjectRootDirRealPath;
449
+ modulesDir?: string;
450
+ manifest: _pnpm_types0.ProjectManifest;
451
+ writeProjectManifest: (manifest: _pnpm_types0.ProjectManifest, force?: boolean | undefined) => Promise<void>;
452
+ }[];
453
+ config: MonorepoConfig;
321
454
  }>;
322
455
  /**
323
456
  * 统一导出的上下文类型,方便下游函数准确获知可用字段。
324
457
  */
325
458
  type Context = Awaited<ReturnType<typeof createContext>>;
326
-
459
+ //#endregion
460
+ //#region src/core/logger.d.ts
327
461
  /**
328
462
  * 统一的日志实例,便于在命令行中输出带有前缀和颜色的消息。
329
463
  */
330
- declare const logger: consola.ConsolaInstance;
331
-
464
+ declare const logger: consola0.ConsolaInstance;
465
+ //#endregion
466
+ //#region src/utils/fs.d.ts
332
467
  /**
333
468
  * 判断是否为可忽略的文件系统错误。
334
469
  * - ENOENT: 文件已被删除
335
470
  * - EBUSY: Windows 中资源被系统占用
336
471
  */
337
472
  declare function isIgnorableFsError(error: unknown): error is NodeJS.ErrnoException;
338
-
473
+ //#endregion
474
+ //#region src/utils/gitignore.d.ts
339
475
  /**
340
476
  * Map a workspace path (containing `.gitignore`) to its packaged variant.
341
477
  */
@@ -349,7 +485,8 @@ declare function toWorkspaceGitignorePath(input: string): string;
349
485
  * should be treated as a gitignore file.
350
486
  */
351
487
  declare function isGitignoreFile(name: string): boolean;
352
-
488
+ //#endregion
489
+ //#region src/utils/hash.d.ts
353
490
  /**
354
491
  * 生成给定二进制内容的 md5 摘要,用于快速比较文件内容。
355
492
  */
@@ -358,7 +495,8 @@ declare function getFileHash(data: crypto.BinaryLike): string;
358
495
  * 对比两个文件的 md5,如果不一致则认为内容有变化。
359
496
  */
360
497
  declare function isFileChanged(src: crypto.BinaryLike, dest: crypto.BinaryLike): boolean;
361
-
498
+ //#endregion
499
+ //#region src/utils/regexp.d.ts
362
500
  /**
363
501
  * 逃逸正则表达式中所有特殊字符,避免被当做模式解析。
364
502
  */
@@ -367,5 +505,5 @@ declare function escapeStringRegexp(str: string): string;
367
505
  * 判断字符串是否命中任意一个正则,用于过滤要同步的资产文件。
368
506
  */
369
507
  declare function isMatch(str: string, arr: RegExp[]): boolean;
370
-
371
- export { type CleanCommandConfig, type CliOpts, type Context, type CreateChoiceOption, type CreateCommandConfig, type CreateNewProjectOptions, type GetWorkspacePackagesOptions, GitClient, type InitCommandConfig, type MirrorCommandConfig, type MonorepoConfig, type SyncCommandConfig, type UpgradeCommandConfig, assetsDir, cleanProjects, createContext, createNewProject, defineMonorepoConfig, escapeStringRegexp, getCreateChoices, getFileHash, getTemplateMap, getWorkspaceData, getWorkspacePackages, init, isFileChanged, isGitignoreFile, isIgnorableFsError, isMatch, loadMonorepoConfig, logger, name, packageDir, resolveCommandConfig, rootDir, setVscodeBinaryMirror, syncNpmMirror, templateMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath, upgradeMonorepo, version };
508
+ //#endregion
509
+ export { type CleanCommandConfig, type CliOpts, type ConfigValues, Context, type CreateChoiceOption, type CreateCommandConfig, CreateNewProjectOptions, type GetWorkspacePackagesOptions, GitClient, type InitCommandConfig, type MirrorCommandConfig, type MonorepoConfig, type PackageJson, type SimpleGit, type SimpleGitOptions, type SyncCommandConfig, type UpgradeCommandConfig, assetsDir, cleanProjects, createContext, createNewProject, defineMonorepoConfig, escapeStringRegexp, getCreateChoices, getFileHash, getTemplateMap, getWorkspaceData, getWorkspacePackages, init, isFileChanged, isGitignoreFile, isIgnorableFsError, isMatch, loadMonorepoConfig, logger, name, packageDir, resolveCommandConfig, rootDir, setVscodeBinaryMirror, syncNpmMirror, templateMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath, upgradeMonorepo, version };