@icebreakers/monorepo 5.6.0 → 5.7.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.
Files changed (50) hide show
  1. package/README.md +2 -0
  2. package/dist/baseline-DPfotf4y.mjs +146 -0
  3. package/dist/bundle-B9vRch4R.mjs +49 -0
  4. package/dist/catalog-CDEyc1uA.mjs +299 -0
  5. package/dist/cli.mjs +1487 -156
  6. package/dist/commands-TS8ABFdP.mjs +13820 -0
  7. package/dist/config-C38c_Q8L.mjs +66 -0
  8. package/dist/{create-flow-CXRhfGbb.mjs → create-flow-CCr2hfSY.mjs} +90 -24
  9. package/dist/deps-CUdI2DaB.mjs +47 -0
  10. package/dist/execute-PX1hT0qv.mjs +68 -0
  11. package/dist/execute-Vi4qHe-D.mjs +663 -0
  12. package/dist/format-DZ7L34rf.mjs +28 -0
  13. package/dist/index-CoCTFWZJ.d.mts +2150 -0
  14. package/dist/index.d.mts +1738 -112
  15. package/dist/index.mjs +60 -7
  16. package/dist/inputs-_xIVONmB.mjs +50 -0
  17. package/dist/npm-B25nrSyz.mjs +82 -0
  18. package/dist/plan-B5aE_WNF.mjs +75 -0
  19. package/dist/run-Lu7y1bNf.mjs +165 -0
  20. package/dist/save-CdCf630Z.mjs +79 -0
  21. package/dist/scan-4nboHNXP.mjs +293 -0
  22. package/dist/template-drift-BBhnrHY1.mjs +2740 -0
  23. package/dist/tooling-entry.d.mts +1 -1
  24. package/dist/tooling-entry.mjs +2 -2
  25. package/dist/transaction-DAhY8EpG.mjs +168 -0
  26. package/dist/tsconfig-CGntrzBM.mjs +1483 -0
  27. package/dist/{vitest-Blzbh8xZ.mjs → vitest-DkGh4Ygo.mjs} +1 -1
  28. package/dist/workspace-tasks-CnB8kkS0.mjs +4435 -0
  29. package/package.json +22 -4
  30. package/resources/api-report/runner.cjs +76 -0
  31. package/resources/devcontainer/setup.mjs +36 -0
  32. package/resources/knip/reporter.mjs +46 -0
  33. package/resources/maintenance/migration-lanes.mjs +141 -0
  34. package/resources/maintenance/migration-lock.mjs +119 -0
  35. package/resources/maintenance/migrations.mjs +215 -0
  36. package/resources/maintenance/presets.mjs +130 -0
  37. package/resources/maintenance/validate.mjs +233 -0
  38. package/resources/maintenance/workflow.yml +151 -0
  39. package/resources/skills/repoctl/SKILL.md +2 -0
  40. package/resources/skills/repoctl/references/commands.md +224 -13
  41. package/resources/skills/repoctl/references/config.md +70 -6
  42. package/resources/skills/repoctl/references/dependencies.md +37 -0
  43. package/resources/skills/repoctl/references/knip.md +34 -0
  44. package/resources/skills/repoctl/references/templates.md +23 -0
  45. package/dist/commands-D4xZQ5t-.mjs +0 -5685
  46. package/dist/config-p842Knhq.mjs +0 -114
  47. package/dist/index-Bl_PB2Ch.d.mts +0 -1039
  48. package/dist/tsconfig-BrjI_5yI.mjs +0 -75
  49. package/dist/types-MAUIQpfp.mjs +0 -499
  50. package/dist/workspace-MCKewElu.mjs +0 -123
@@ -1,1039 +0,0 @@
1
- import { ConfigValues, SimpleGit, SimpleGitOptions } from "simple-git";
2
- import { TemplateDefinition } from "@icebreakers/monorepo-templates";
3
- import { IcebreakerCommitlintConfig, IcebreakerCommitlintOptions } from "@icebreakers/commitlint-config";
4
- import { IcebreakerEslintConfig, UserConfigItem, UserDefinedOptions } from "@icebreakers/eslint-config";
5
- import { IcebreakerStylelintConfig, StylelintConfig } from "@icebreakers/stylelint-config";
6
- import { ViteUserConfig } from "vitest/config";
7
- import { Configuration } from "lint-staged";
8
- //#region src/types/cli.d.ts
9
- /**
10
- * CLI 公用参数,保证各命令对外暴露一致的行为。
11
- */
12
- interface CliOpts {
13
- /**
14
- * 是否开启交互模式,开启后每一步都会提示用户确认。
15
- * @default false
16
- */
17
- interactive?: boolean;
18
- /**
19
- * 是否使用 core 版资产,只同步最精简的文件集合。
20
- * @default false
21
- */
22
- core?: boolean;
23
- /**
24
- * 输出目录(相对 `cwd`),用于放置生成或拷贝出来的文件。
25
- * @default ''
26
- */
27
- outDir?: string;
28
- /**
29
- * 命令执行的工作目录。
30
- * @default process.cwd()
31
- */
32
- cwd?: string;
33
- /**
34
- * 是否跳过已有文件的覆写;开启后保留旧文件不做对比。
35
- * @default false
36
- */
37
- skipOverwrite?: boolean;
38
- /**
39
- * 跳过交互并接受默认写入策略。upgrade 中等价于覆盖 drifted 标准资产。
40
- * @default false
41
- */
42
- yes?: boolean;
43
- /**
44
- * 显式覆盖已有文件。
45
- * @default false
46
- */
47
- overwrite?: boolean;
48
- /**
49
- * 显式不覆盖已有文件。
50
- * @default false
51
- */
52
- noOverwrite?: boolean;
53
- /**
54
- * 是否允许覆盖未标记的自定义 release workflow。
55
- * @default false
56
- */
57
- overwriteRelease?: boolean;
58
- }
59
- //#endregion
60
- //#region src/commands/ai.d.ts
61
- type AgenticTemplateFormat = 'md' | 'json';
62
- interface GenerateAgenticTemplateOptions {
63
- cwd?: string;
64
- output?: string;
65
- force?: boolean;
66
- format?: AgenticTemplateFormat;
67
- /**
68
- * 任务名,用于快速生成带目录与后缀的文件。
69
- */
70
- name?: string;
71
- /**
72
- * 基础目录,配合 name 使用。
73
- * @default 'agentic/prompts'
74
- */
75
- baseDir?: string;
76
- /**
77
- * 自动生成目录时使用的自定义文件夹名称。
78
- * @default 自动生成的时间戳
79
- */
80
- folderName?: string;
81
- }
82
- type AgenticTemplateTask = string | (Omit<GenerateAgenticTemplateOptions, 'cwd'> & {
83
- name?: string;
84
- });
85
- declare const defaultAgenticBaseDir = "agentic/prompts";
86
- declare function createTimestampFolderName(date?: Date): string;
87
- /**
88
- * 生成 Agentic 任务提示词模板,默认写入 agentic/prompts/<timestamp>/prompt.md,可自定义输出路径。
89
- */
90
- declare function generateAgenticTemplate(options?: GenerateAgenticTemplateOptions): Promise<string>;
91
- declare function loadAgenticTasks(filePath: string, cwd: string): Promise<AgenticTemplateTask[]>;
92
- declare function generateAgenticTemplates(tasks: AgenticTemplateTask[], defaults?: GenerateAgenticTemplateOptions): Promise<string[]>;
93
- //#endregion
94
- //#region src/commands/create/plan.d.ts
95
- /**
96
- * 内置模板映射表,source 指向 templates 根目录下的来源目录,target 为生成路径。
97
- */
98
- declare const templateMap: {
99
- readonly tsdown: {
100
- readonly source: "tsdown";
101
- readonly target: "packages/tsdown";
102
- };
103
- readonly 'vue-lib': {
104
- readonly source: "vue-lib";
105
- readonly target: "packages/vue-lib";
106
- };
107
- readonly 'hono-server': {
108
- readonly source: "server";
109
- readonly target: "apps/server";
110
- };
111
- readonly 'vue-hono': {
112
- readonly source: "client";
113
- readonly target: "apps/client";
114
- };
115
- readonly vitepress: {
116
- readonly source: "vitepress";
117
- readonly target: "apps/website";
118
- };
119
- readonly cli: {
120
- readonly source: "cli";
121
- readonly target: "apps/cli";
122
- };
123
- readonly nimbus: {
124
- readonly source: "nimbus";
125
- readonly target: "apps/docs";
126
- };
127
- };
128
- type CreateNewProjectType = keyof typeof templateMap;
129
- interface CreateNewProjectOptions {
130
- /**
131
- * 目标项目名。
132
- * 未提供时使用模板映射中的 `target`。
133
- * @default undefined
134
- */
135
- name?: string;
136
- /**
137
- * 生成目标的工作目录。
138
- * @default process.cwd()
139
- */
140
- cwd?: string;
141
- /**
142
- * 是否把模板里的 `package.json` 输出为 `package.mock.json`。
143
- * @default false
144
- */
145
- renameJson?: boolean;
146
- /**
147
- * 模板类型。
148
- * 未提供时优先读取 `commands.create.defaultTemplate`,最后回退到 `'tsdown'`。
149
- * @default 'tsdown'
150
- */
151
- type?: CreateNewProjectType | string;
152
- }
153
- interface CreateNewProjectPlan {
154
- cwd: string;
155
- requestedTemplate: string;
156
- template: string;
157
- usedFallback: boolean;
158
- sourceDir: string;
159
- targetName: string;
160
- targetDir: string;
161
- targetExists: boolean;
162
- renameJson: boolean;
163
- hasPackageJson: boolean;
164
- packageJsonFileName: 'package.json' | 'package.mock.json';
165
- packageName: string;
166
- templateDefinition: TemplateDefinition;
167
- }
168
- declare function getCreateChoices(choices?: CreateChoiceOption[]): CreateChoiceOption[];
169
- declare function getTemplateMap(extra?: Record<string, string | TemplateDefinition>): Record<string, TemplateDefinition>;
170
- declare function resolveCreateNewProjectPlan(options?: CreateNewProjectOptions): Promise<CreateNewProjectPlan>;
171
- //#endregion
172
- //#region src/commands/create/index.d.ts
173
- /**
174
- * 根据模板生成一个新项目目录,并自动补写 `package.json` 常用字段。
175
- *
176
- * 默认行为:
177
- * - 读取 `repoctl.config.ts -> commands.create`
178
- * - 模板类型默认回退到 `'tsdown'`
179
- * - 若目标目录已存在则直接抛错
180
- * - 若模板包含 `package.json`,会自动写入 `name`、`version` 与 Git 仓库信息
181
- *
182
- * @param options 运行时覆盖项
183
- * @returns Promise<void>
184
- */
185
- declare function createNewProject(options?: CreateNewProjectOptions): Promise<void>;
186
- //#endregion
187
- //#region src/commands/init/tooling/types.d.ts
188
- declare const initToolingTargets: readonly ["commitlint", "eslint", "stylelint", "lint-staged", "tsconfig", "vitest"];
189
- type InitToolingTarget = (typeof initToolingTargets)[number];
190
- interface InitToolingExecutionOptions {
191
- targets?: InitToolingTarget[];
192
- all?: boolean;
193
- force?: boolean;
194
- }
195
- interface InitToolingResult {
196
- selectedTargets: InitToolingTarget[];
197
- writtenFiles: string[];
198
- skippedFiles: string[];
199
- updatedPackageJson: boolean;
200
- }
201
- //#endregion
202
- //#region src/commands/init/tooling/index.d.ts
203
- declare function normalizeInitToolingTargets(input: string[]): InitToolingTarget[];
204
- declare function initTooling(cwd: string, options?: InitToolingExecutionOptions): Promise<InitToolingResult>;
205
- //#endregion
206
- //#region src/commands/init/index.d.ts
207
- type InitPreset = 'minimal' | 'standard';
208
- interface InitCommandRuntimeOptions {
209
- tooling?: readonly InitToolingTarget[];
210
- all?: boolean;
211
- force?: boolean;
212
- overwrite?: boolean;
213
- yes?: boolean;
214
- preset?: InitPreset;
215
- }
216
- declare function initMetadata(cwd: string): Promise<void>;
217
- /**
218
- * 初始化命令入口,根据配置逐步生成基础文件。
219
- */
220
- declare function init(cwd: string, options?: InitCommandRuntimeOptions): Promise<void>;
221
- //#endregion
222
- //#region src/types/release.d.ts
223
- interface ReleaseAfterPublishHookConfig {
224
- /** 执行结果未知时是否允许重试;仅适用于可安全重复执行的脚本。默认 false。 */
225
- idempotent?: boolean;
226
- /** package.json 中要通过 `pnpm run` 执行的脚本名。 */
227
- script: string;
228
- /**
229
- * 脚本失败时是否只记录警告并继续。
230
- * @default false
231
- */
232
- continueOnError?: boolean;
233
- }
234
- interface ReleaseCommandConfig {
235
- /**
236
- * version 与 publish 阶段执行的根 package.json 校验脚本。
237
- * 配置后完整替换内置的 build、lint、test。
238
- * @default ['build', 'lint', 'test']
239
- */
240
- qualityScripts?: string[];
241
- hooks?: {
242
- /**
243
- * qualityScripts 通过后追加执行的校验脚本。
244
- * 任一脚本失败都会中止版本或发布流程。
245
- * @default []
246
- */
247
- verify?: string[];
248
- /**
249
- * pnpm version 前执行的根 package.json 脚本。
250
- * @default []
251
- */
252
- beforeVersion?: string[];
253
- /**
254
- * pnpm version 后执行的根 package.json 脚本。
255
- * @default []
256
- */
257
- afterVersion?: string[];
258
- /**
259
- * pnpm publish 前执行的根 package.json 脚本。
260
- * @default []
261
- */
262
- beforePublish?: string[];
263
- /**
264
- * npm metadata 与 GitHub Release 处理完成后执行的根 package.json 脚本。
265
- * 在新发布或恢复未完成发布时执行;跨 runner 恢复会跳过已完成的脚本。
266
- * @default []
267
- */
268
- afterPublish?: ReleaseAfterPublishHookConfig[];
269
- };
270
- }
271
- //#endregion
272
- //#region src/types/config.d.ts
273
- interface AiCommandConfig {
274
- /**
275
- * 默认输出路径,不填则自动创建 `agentic/prompts/<timestamp>/prompt.md` 文件夹与模板。
276
- * @default undefined
277
- */
278
- output?: string;
279
- /**
280
- * 默认存放目录,配合 name / tasks 批量生成时使用。
281
- * @default 'agentic/prompts'
282
- */
283
- baseDir?: string;
284
- /**
285
- * 是否允许覆盖已存在文件。
286
- * @default false
287
- */
288
- force?: boolean;
289
- /**
290
- * 模板格式。
291
- * @default 'md'
292
- */
293
- format?: AgenticTemplateFormat;
294
- /**
295
- * 任务清单文件路径(JSON 数组),用于批量生成。
296
- * @default undefined
297
- */
298
- tasksFile?: string;
299
- }
300
- /**
301
- * `repo package create` 命令的配置项。
302
- */
303
- interface CreateCommandConfig extends Partial<Omit<CreateNewProjectOptions, 'cwd'>> {
304
- /**
305
- * 自定义模板根目录。
306
- * @default 内置模板所在的 `packages/monorepo/templates`
307
- */
308
- templatesDir?: string;
309
- /**
310
- * 扩展模板映射表,key 为类型,value 为模板来源/目标路径。
311
- * @default 内置 `templateMap`
312
- */
313
- templateMap?: Record<string, string | TemplateDefinition>;
314
- /**
315
- * 自定义交互提示的选项列表。
316
- * @default 内置 `baseChoices`
317
- */
318
- choices?: CreateChoiceOption[];
319
- /**
320
- * 当未选择模板时使用的默认模板。
321
- * @default 'tsdown'
322
- */
323
- defaultTemplate?: CreateNewProjectOptions['type'];
324
- }
325
- /**
326
- * CLI 交互式选择框的选项结构。
327
- */
328
- interface CreateChoiceOption {
329
- /**
330
- * 唯一值,将回传给命令逻辑使用。
331
- * @default undefined
332
- */
333
- value: string;
334
- /**
335
- * 选项展示名称。
336
- * @default value
337
- */
338
- name?: string;
339
- /**
340
- * 选项描述信息。
341
- * @default undefined
342
- */
343
- description?: string;
344
- /**
345
- * 短名称,用于命令行紧凑展示。
346
- * @default undefined
347
- */
348
- short?: string;
349
- /**
350
- * 设置为 true 或字符串即可禁用该选项并显示原因。
351
- * @default false
352
- */
353
- disabled?: boolean | string;
354
- }
355
- /**
356
- * `repo workspace clean` 命令配置,可控制自动选择、排除包等行为。
357
- */
358
- interface CleanCommandConfig {
359
- /**
360
- * 是否跳过交互直接清理全部。
361
- * @default false
362
- */
363
- autoConfirm?: boolean;
364
- /**
365
- * 不允许被清理的包名列表。
366
- * @default []
367
- */
368
- ignorePackages?: string[];
369
- /**
370
- * 是否包含 private 包。
371
- * @default true
372
- */
373
- includePrivate?: boolean;
374
- /**
375
- * 强制写回的 repoctl 版本。
376
- * @default 当前依赖版本
377
- */
378
- pinnedVersion?: string;
379
- }
380
- /**
381
- * `repo workspace upgrade` 命令配置,覆盖脚本、目标文件等能力。
382
- */
383
- interface UpgradeCommandConfig extends Partial<CliOpts> {
384
- /**
385
- * 额外需要写入的目标文件列表。
386
- * @default []
387
- */
388
- targets?: string[];
389
- /**
390
- * 是否与默认目标合并,false 表示完全覆盖。
391
- * @default true
392
- */
393
- mergeTargets?: boolean;
394
- /**
395
- * 需要写入 package.json 的脚本集合。
396
- * @default {}
397
- */
398
- scripts?: Record<string, string>;
399
- /**
400
- * 是否跳过生成 pnpm change intent markdown。
401
- * @default true
402
- */
403
- skipChangesetMarkdown?: boolean;
404
- }
405
- /**
406
- * `repo workspace init` / `repo tooling init` 共享配置,用于跳过部分初始化步骤并配置 tooling 默认目标。
407
- */
408
- interface InitCommandConfig {
409
- /**
410
- * 是否跳过 README 生成。
411
- * @default false
412
- */
413
- skipReadme?: boolean;
414
- /**
415
- * 是否跳过 package.json 写入。
416
- * @default false
417
- */
418
- skipPkgJson?: boolean;
419
- /**
420
- * 是否跳过 pnpm versioning 元数据的更新。
421
- * @default false
422
- */
423
- skipChangeset?: boolean;
424
- /**
425
- * 是否跳过 Issue 模版 discussions 链接的更新。
426
- * @default false
427
- */
428
- skipIssueTemplateConfig?: boolean;
429
- /**
430
- * 额外要生成的 tooling 配置文件列表。
431
- * @default []
432
- */
433
- tooling?: InitToolingTarget[];
434
- /**
435
- * 初始化预设。
436
- * @default undefined
437
- */
438
- preset?: InitPreset;
439
- /**
440
- * 是否覆盖已存在的 tooling 配置文件。
441
- * @default false
442
- */
443
- force?: boolean;
444
- }
445
- /**
446
- * `monorepo env mirror` 命令配置,可增加额外的环境变量镜像。
447
- */
448
- interface MirrorCommandConfig {
449
- /**
450
- * 需要注入的环境变量键值对。
451
- * @default {}
452
- */
453
- env?: Record<string, string>;
454
- }
455
- /**
456
- * `tooling.commitlint` 配置块。
457
- *
458
- * 该对象会与 `@icebreakers/commitlint-config` 的默认配置合并。
459
- */
460
- interface CommitlintToolingConfig extends IcebreakerCommitlintOptions {}
461
- /**
462
- * `tooling.eslint` 配置块。
463
- *
464
- * 该对象会与 `@icebreakers/eslint-config` 的默认 flat config 合并。
465
- */
466
- interface EslintToolingConfig extends UserDefinedOptions {
467
- /**
468
- * 额外传给 `createEslint(...userConfigs)` 的后续配置项。
469
- * 在 `defineEslintConfig({ options, configs })` 中也可以放到顶层 `configs`。
470
- * @default []
471
- */
472
- configs?: UserConfigItem[];
473
- }
474
- /**
475
- * `tooling.stylelint` 配置块。
476
- *
477
- * 该对象会与 `@icebreakers/stylelint-config` 的默认配置合并。
478
- */
479
- interface StylelintToolingConfig extends StylelintConfig {}
480
- /**
481
- * `tooling.lintStaged` 配置块。
482
- */
483
- interface LintStagedToolingConfig {
484
- /**
485
- * 调用 repo CLI 的基础命令。
486
- * 通常保持为 `pnpm exec repo`,以便 Husky 与 lint-staged 入口统一。
487
- * @default 'pnpm exec repo'
488
- */
489
- repoCommand?: string;
490
- /**
491
- * 直接透传完整的 lint-staged 原生配置。
492
- * 一旦提供,monorepo 默认规则将不再自动注入。
493
- * @default undefined
494
- */
495
- config?: Configuration;
496
- }
497
- /**
498
- * `tooling.tsconfig` 配置块。
499
- *
500
- * 该对象会与 monorepo 内置的 TypeScript 基线配置合并。
501
- */
502
- interface TsconfigToolingConfig {
503
- /**
504
- * 顶层 `extends` 字段。
505
- * @default undefined
506
- */
507
- extends?: string | string[];
508
- /**
509
- * TypeScript `compilerOptions` 配置。
510
- * @default undefined
511
- */
512
- compilerOptions?: Record<string, unknown>;
513
- /**
514
- * 顶层 `include` 字段。
515
- * @default undefined
516
- */
517
- include?: string[];
518
- /**
519
- * 顶层 `exclude` 字段。
520
- * @default undefined
521
- */
522
- exclude?: string[];
523
- /**
524
- * 顶层 `files` 字段。
525
- * @default undefined
526
- */
527
- files?: string[];
528
- /**
529
- * 顶层 `references` 字段。
530
- * @default undefined
531
- */
532
- references?: Array<{
533
- path: string;
534
- }>;
535
- /**
536
- * 顶层 `compileOnSave` 字段。
537
- * @default undefined
538
- */
539
- compileOnSave?: boolean;
540
- }
541
- /**
542
- * `tooling.vitest` 配置块。
543
- *
544
- * 这些字段会参与根级 Vitest 配置的自动推导。
545
- */
546
- interface VitestToolingConfig {
547
- /**
548
- * 项目扫描与 workspace 文件解析的根目录。
549
- * @default process.cwd()
550
- */
551
- rootDir?: string;
552
- /**
553
- * 显式指定需要扫描的项目根目录。
554
- * 未提供时优先从 `pnpm-workspace.yaml` 推导,失败后回退到 `['packages', 'apps']`。
555
- * @default undefined
556
- */
557
- projectRoots?: string[];
558
- /**
559
- * 子项目 Vitest 配置文件候选名列表。
560
- * @default ['vitest.config.ts', 'vitest.config.mts', 'vitest.config.js', 'vitest.config.cjs', 'vitest.workspace.ts', 'vitest.workspace.mts']
561
- */
562
- configCandidates?: string[];
563
- /**
564
- * workspace 配置文件名。
565
- * @default 'pnpm-workspace.yaml'
566
- */
567
- workspaceFile?: string;
568
- /**
569
- * 是否把根级 `vitest.config.*` 也加入 `test.projects`。
570
- * @default false
571
- */
572
- includeWorkspaceRootConfig?: boolean;
573
- /**
574
- * coverage 需要额外排除的 glob。
575
- * @default undefined
576
- */
577
- coverageExclude?: string[];
578
- /**
579
- * 是否开启 coverage。
580
- * @default true
581
- */
582
- coverageEnabled?: boolean;
583
- /**
584
- * 是否对未被测试覆盖的文件也统计 coverage。
585
- * @default false
586
- */
587
- coverageAll?: boolean;
588
- /**
589
- * 是否跳过 100% 覆盖文件的输出。
590
- * @default true
591
- */
592
- coverageSkipFull?: boolean;
593
- /**
594
- * 直接透传到最终 `vitest.config.*` 返回值的完整配置覆盖项。
595
- * 适合配置 `test.coverage`、`resolve.alias`、`plugins` 等原生 Vitest/Vite 字段。
596
- * @default undefined
597
- */
598
- overrides?: ViteUserConfig;
599
- }
600
- /**
601
- * `tooling.vitestProject` 配置块。
602
- *
603
- * 用于单个 package/app 的项目级 Vitest 默认值。
604
- */
605
- interface VitestProjectToolingConfig {
606
- /**
607
- * 测试环境内的 alias 映射。
608
- * @default undefined
609
- */
610
- alias?: Array<{
611
- find: string | RegExp;
612
- replacement: string;
613
- }>;
614
- /**
615
- * 是否启用 Vitest globals。
616
- * @default true
617
- */
618
- globals?: boolean;
619
- /**
620
- * 单测默认超时时间,单位毫秒。
621
- * @default 60000
622
- */
623
- testTimeout?: number;
624
- /**
625
- * 测试环境类型。
626
- * @default 'node'
627
- */
628
- environment?: string;
629
- }
630
- /**
631
- * `tooling.husky` 配置块。
632
- */
633
- interface HuskyToolingConfig {
634
- /**
635
- * pre-commit 钩子执行命令。
636
- * 未设置时默认运行 `pnpm exec lint-staged`。
637
- * @default undefined
638
- */
639
- preCommitCommand?: string;
640
- /**
641
- * commit-msg 钩子执行命令。
642
- * 可通过 `{editFile}` 占位符注入 commit message 文件路径。
643
- * 未设置时默认运行 `pnpm exec commitlint --edit {editFile}`。
644
- * @default undefined
645
- */
646
- commitMsgCommand?: string;
647
- }
648
- /**
649
- * `repoctl.config.ts` 中 `tooling` 总配置。
650
- *
651
- * 每个字段分别映射到对应的配置工厂与验证命令。
652
- */
653
- interface ToolingConfig {
654
- commitlint?: CommitlintToolingConfig;
655
- eslint?: EslintToolingConfig;
656
- stylelint?: StylelintToolingConfig;
657
- lintStaged?: LintStagedToolingConfig;
658
- tsconfig?: TsconfigToolingConfig;
659
- vitest?: VitestToolingConfig;
660
- vitestProject?: VitestProjectToolingConfig;
661
- husky?: HuskyToolingConfig;
662
- }
663
- /**
664
- * 项目级配置入口,按命令划分可插拔的配置块。
665
- */
666
- interface MonorepoConfig {
667
- /**
668
- * 按命令分类的可选配置。
669
- * 各字段默认均为 `undefined`,命令执行时会按各自逻辑回退到内置默认值。
670
- * @default {}
671
- */
672
- commands?: {
673
- ai?: AiCommandConfig;
674
- create?: CreateCommandConfig;
675
- clean?: CleanCommandConfig;
676
- upgrade?: UpgradeCommandConfig;
677
- init?: InitCommandConfig;
678
- mirror?: MirrorCommandConfig;
679
- release?: ReleaseCommandConfig;
680
- };
681
- /**
682
- * 按工程化能力分类的可选配置。
683
- * 这些配置通常会被 `repoctl/tooling` 中的 helper 消费。
684
- * @default {}
685
- */
686
- tooling?: ToolingConfig;
687
- }
688
- //#endregion
689
- //#region src/tooling/types.d.ts
690
- /**
691
- * `commitlint.config.*` 最终导出的配置类型。
692
- *
693
- */
694
- type MonorepoCommitlintConfig = IcebreakerCommitlintConfig;
695
- /**
696
- * `eslint.config.js` 最终导出的 flat config 类型。
697
- */
698
- type MonorepoEslintConfig = IcebreakerEslintConfig;
699
- /**
700
- * `stylelint.config.js` 最终导出的配置类型。
701
- *
702
- */
703
- type MonorepoStylelintConfig = IcebreakerStylelintConfig;
704
- /**
705
- * `lint-staged` 最终配置对象。
706
- *
707
- * key 为 glob pattern,value 为命令数组或命令生成函数。
708
- */
709
- interface MonorepoLintStagedConfig {
710
- [pattern: string]: string[] | ((files: string[]) => string | string[]);
711
- }
712
- /**
713
- * `tsconfig.json` 最终导出的配置对象。
714
- */
715
- interface MonorepoTsconfig {
716
- extends?: string | string[];
717
- compilerOptions?: Record<string, unknown>;
718
- include?: string[];
719
- exclude?: string[];
720
- files?: string[];
721
- references?: Array<{
722
- path: string;
723
- }>;
724
- compileOnSave?: boolean;
725
- }
726
- interface DefineConfigOptions<TConfig> {
727
- cwd?: string;
728
- options?: TConfig;
729
- }
730
- interface DefineEslintConfigOptions extends DefineConfigOptions<EslintToolingConfig> {
731
- /**
732
- * 额外传给 ESLint flat config 工厂的配置片段。
733
- *
734
- * 这等价于 `options.configs`,但更贴近 flat config 的“基础 options + 后续 configs”写法。
735
- */
736
- configs?: UserConfigItem[];
737
- }
738
- /**
739
- * `createMonorepoLintStagedConfig()` 与 `defineLintStagedConfig()` 的配置项。
740
- */
741
- interface MonorepoLintStagedConfigOptions extends LintStagedToolingConfig {}
742
- /**
743
- * `createMonorepoVitestConfig()` 与 `defineVitestConfig()` 的共享配置项。
744
- *
745
- * 这些值会先参与 monorepo 级默认配置计算,再产出最终的 Vitest `test` 配置。
746
- */
747
- interface MonorepoVitestConfigOptions extends VitestToolingConfig {}
748
- /**
749
- * `createMonorepoVitestProjectConfig()` 的项目级配置项。
750
- */
751
- interface MonorepoVitestProjectConfigOptions extends VitestProjectToolingConfig {}
752
- /**
753
- * `createMonorepoVitestConfig()` 返回的标准结果结构。
754
- *
755
- * 该类型可用于约束自定义封装或二次 merge 的返回值。
756
- */
757
- interface MonorepoVitestConfigResult extends Omit<ViteUserConfig, 'test'> {
758
- test: NonNullable<ViteUserConfig['test']> & {
759
- projects?: NonNullable<ViteUserConfig['test']>['projects'];
760
- coverage?: NonNullable<NonNullable<ViteUserConfig['test']>['coverage']> & {
761
- enabled?: boolean;
762
- all?: boolean;
763
- skipFull?: boolean;
764
- exclude?: string[];
765
- };
766
- forceRerunTriggers?: string[];
767
- };
768
- }
769
- /**
770
- * 单个 package/app 的 `vitest.config.*` 最终导出结构。
771
- */
772
- interface MonorepoVitestProjectConfigResult {
773
- test: {
774
- alias?: Array<{
775
- find: string | RegExp;
776
- replacement: string;
777
- }>;
778
- globals: boolean;
779
- testTimeout: number;
780
- environment?: string;
781
- };
782
- }
783
- /**
784
- * `defineVitestConfig()` 的最终覆盖项。
785
- */
786
- type MonorepoVitestConfigOverrides = ViteUserConfig;
787
- interface DefineVitestConfigOptions {
788
- cwd?: string;
789
- options?: MonorepoVitestConfigOptions;
790
- overrides?: MonorepoVitestConfigOverrides;
791
- }
792
- interface DefineVitestProjectConfigOptions {
793
- cwd?: string;
794
- options?: MonorepoVitestProjectConfigOptions;
795
- }
796
- //#endregion
797
- //#region src/tooling/lint-staged.d.ts
798
- /**
799
- * 创建适用于当前仓库约定的 `lint-staged` 配置。
800
- *
801
- * 默认行为:
802
- * - `*.{js,jsx,mjs,ts,tsx,mts,cts}` 运行 `eslint --fix`
803
- * - `*.vue` 同时运行 `eslint --fix` 与 `stylelint --fix --allow-empty-input`
804
- * - TypeScript/Vue files and workspace `package.json` files share one
805
- * `pnpm exec repo verify staged-typecheck` task to avoid concurrent builds
806
- * - 样式文件运行 `stylelint --fix --allow-empty-input`
807
- *
808
- * @param options 可配置 `repoCommand`,默认值为 `pnpm exec repo`
809
- * @returns 可直接导出的 `lint-staged` 配置对象
810
- *
811
- * @example
812
- * ```js
813
- * import { createMonorepoLintStagedConfig } from 'repoctl/tooling'
814
- *
815
- * export default createMonorepoLintStagedConfig({
816
- * repoCommand: 'pnpm exec repo',
817
- * })
818
- * ```
819
- */
820
- declare function createMonorepoLintStagedConfig(options?: MonorepoLintStagedConfigOptions): MonorepoLintStagedConfig;
821
- /**
822
- * 从 `repoctl.config.ts` 读取 `tooling.lintStaged`,并生成 `lint-staged` 配置。
823
- *
824
- * @param input `cwd` 用于指定配置文件解析起点,`options` 用于追加运行时覆盖项
825
- * @returns 可直接导出的 `lint-staged` 配置对象
826
- */
827
- declare function defineLintStagedConfig(input?: DefineConfigOptions<MonorepoLintStagedConfigOptions>): Promise<MonorepoLintStagedConfig>;
828
- //#endregion
829
- //#region src/tooling/linters.d.ts
830
- /**
831
- * 基于 `@icebreakers/commitlint-config` 创建 commitlint 配置。
832
- *
833
- * 适合在需要手动传入覆盖项时使用;如果只想读取 `repoctl.config.ts` 默认值,
834
- * 优先使用 `defineCommitlintConfig()`。
835
- *
836
- * @param options 额外合并到默认 commitlint 配置上的字段
837
- * @returns 可直接作为 `commitlint.config.ts` 默认导出的配置对象
838
- *
839
- * @example
840
- * ```ts
841
- * import { createMonorepoCommitlintConfig } from 'repoctl/tooling'
842
- *
843
- * export default createMonorepoCommitlintConfig({
844
- * rules: {
845
- * 'subject-case': [0],
846
- * },
847
- * })
848
- * ```
849
- */
850
- declare function createMonorepoCommitlintConfig(options?: CommitlintToolingConfig): MonorepoCommitlintConfig;
851
- /**
852
- * 从 `repoctl.config.ts` 读取 `tooling.commitlint`,并生成 commitlint 配置。
853
- *
854
- * @param input `cwd` 用于指定配置文件解析起点,`options` 用于追加运行时覆盖项
855
- * @returns 可直接导出的 commitlint 配置对象
856
- *
857
- * @example
858
- * ```ts
859
- * import { defineCommitlintConfig } from 'repoctl/tooling'
860
- *
861
- * export default await defineCommitlintConfig()
862
- * ```
863
- */
864
- declare function defineCommitlintConfig(input?: DefineConfigOptions<CommitlintToolingConfig>): Promise<MonorepoCommitlintConfig>;
865
- /**
866
- * 基于 `@icebreakers/eslint-config` 创建 ESLint 配置。
867
- *
868
- * 默认会追加一个用于忽略 `fixtures` 目录的 glob,除非显式传入其他 `ignores`。
869
- *
870
- * @param options 额外 ESLint 配置;`ignores` 默认会忽略 `fixtures` 目录
871
- * @param extraConfigs 额外追加的 flat config 片段,等价于 `options.configs`
872
- * @returns 可直接作为 `eslint.config.js` 默认导出的 flat config
873
- *
874
- * @example
875
- * ```js
876
- * import { createMonorepoEslintConfig } from 'repoctl/tooling'
877
- *
878
- * export default createMonorepoEslintConfig(
879
- * { ignores: ['dist/**'] },
880
- * { rules: { 'no-console': 'off' } },
881
- * )
882
- * ```
883
- */
884
- declare function createMonorepoEslintConfig(options?: EslintToolingConfig, ...extraConfigs: UserConfigItem[]): MonorepoEslintConfig;
885
- /**
886
- * 从 `repoctl.config.ts` 读取 `tooling.eslint`,并生成 ESLint 配置。
887
- *
888
- * @param input `cwd` 用于指定配置文件解析起点,`options` 与 `configs` 用于追加运行时覆盖项
889
- * @returns 可直接导出的 ESLint flat config
890
- *
891
- * @example
892
- * ```js
893
- * import { defineEslintConfig } from 'repoctl/tooling'
894
- *
895
- * export default await defineEslintConfig(
896
- * { ignores: ['dist/**'] },
897
- * { rules: { 'no-console': 'off' } },
898
- * )
899
- * ```
900
- */
901
- declare function defineEslintConfig(input?: DefineEslintConfigOptions | EslintToolingConfig, ...configs: UserConfigItem[]): Promise<MonorepoEslintConfig>;
902
- /**
903
- * 基于 `@icebreakers/stylelint-config` 创建 Stylelint 配置。
904
- *
905
- * @param options 额外合并到默认 stylelint 配置上的字段
906
- * @returns 可直接作为 `stylelint.config.js` 默认导出的配置对象
907
- */
908
- declare function createMonorepoStylelintConfig(options?: StylelintToolingConfig): MonorepoStylelintConfig;
909
- /**
910
- * 从 `repoctl.config.ts` 读取 `tooling.stylelint`,并生成 Stylelint 配置。
911
- *
912
- * @param input `cwd` 用于指定配置文件解析起点,`options` 用于追加运行时覆盖项
913
- * @returns 可直接导出的 Stylelint 配置对象
914
- */
915
- declare function defineStylelintConfig(input?: DefineConfigOptions<StylelintToolingConfig>): Promise<MonorepoStylelintConfig>;
916
- //#endregion
917
- //#region src/tooling/shared.d.ts
918
- /**
919
- * 读取当前工作目录下的 `repoctl.config.*` 中 `tooling` 配置块。
920
- *
921
- * @param cwd 配置文件解析起点。默认使用 `process.cwd()`
922
- * @returns 标准化后的 tooling 配置;未配置时返回空对象
923
- *
924
- * @example
925
- * ```ts
926
- * import { loadMonorepoToolingConfig } from 'repoctl/tooling'
927
- *
928
- * const tooling = await loadMonorepoToolingConfig()
929
- * console.log(tooling.vitest?.includeWorkspaceRootConfig)
930
- * ```
931
- */
932
- declare function loadMonorepoToolingConfig(cwd?: string): Promise<NonNullable<ToolingConfig>>;
933
- //#endregion
934
- //#region src/tooling/tsconfig.d.ts
935
- /**
936
- * 创建 monorepo 内置的 TypeScript 基线配置。
937
- *
938
- * @param options 额外覆盖项,会与包内置 `tsconfig.base.json` 合并
939
- * @returns 可直接写入或二次扩展的 `tsconfig.json` 配置对象
940
- */
941
- declare function createMonorepoTsconfig(options?: TsconfigToolingConfig): MonorepoTsconfig;
942
- /**
943
- * 从 `repoctl.config.ts` 读取 `tooling.tsconfig`,并生成最终的 TypeScript 配置对象。
944
- *
945
- * @param input `cwd` 用于指定配置文件解析起点,`options` 用于追加运行时覆盖项
946
- * @returns 可直接写入或导出的 `tsconfig.json` 配置对象
947
- */
948
- declare function defineTsconfigConfig(input?: DefineConfigOptions<TsconfigToolingConfig>): Promise<MonorepoTsconfig>;
949
- //#endregion
950
- //#region src/tooling/vitest/index.d.ts
951
- /**
952
- * 创建 monorepo 根级 Vitest 配置。
953
- *
954
- * 默认值:
955
- * - `rootDir`: `process.cwd()`
956
- * - `workspaceFile`: `'pnpm-workspace.yaml'`
957
- * - `projectRoots`: 自动从 workspace packages 推导,失败时回退到 `['packages', 'apps']`
958
- * - `includeWorkspaceRootConfig`: `false`
959
- * - `coverageEnabled`: `true`
960
- * - `coverageAll`: `false`
961
- * - `coverageSkipFull`: `true`
962
- *
963
- * @param options Vitest 默认配置生成参数
964
- * @returns 仅包含 `test` 字段的 Vitest 配置片段
965
- *
966
- * @example
967
- * ```ts
968
- * import { createMonorepoVitestConfig } from 'repoctl/tooling'
969
- *
970
- * export default {
971
- * ...createMonorepoVitestConfig({
972
- * includeWorkspaceRootConfig: false,
973
- * coverageExclude: ['dist output glob'],
974
- * }),
975
- * }
976
- * ```
977
- */
978
- declare function createMonorepoVitestConfig(options?: MonorepoVitestConfigOptions): MonorepoVitestConfigResult;
979
- /**
980
- * 从 `repoctl.config.ts` 读取 `tooling.vitest`,再叠加运行时 `options` 与 `overrides`
981
- * 生成最终 Vitest 配置。
982
- *
983
- * 优先级从低到高:
984
- * 1. `repoctl.config.ts -> tooling.vitest`
985
- * 2. `options`
986
- * 3. `overrides`
987
- *
988
- * 推荐把“参与默认值推导”的字段放在 `options`,把“最终局部覆盖”放在 `overrides`。
989
- *
990
- * @param input `options` 会先与 `tooling.vitest` 合并;`overrides` 用于最终局部覆盖;`cwd` 用于配置文件解析起点
991
- * @returns 可直接作为 `defineConfig()` 返回值的 Vitest 配置对象
992
- *
993
- * @example
994
- * ```ts
995
- * import { defineVitestConfig } from 'repoctl/tooling'
996
- * import { defineConfig } from 'vitest/config'
997
- *
998
- * export default defineConfig(async () => await defineVitestConfig({
999
- * options: {
1000
- * includeWorkspaceRootConfig: false,
1001
- * },
1002
- * overrides: {
1003
- * test: {
1004
- * coverage: {
1005
- * exclude: ['dist output glob'],
1006
- * skipFull: true,
1007
- * },
1008
- * },
1009
- * },
1010
- * }))
1011
- * ```
1012
- */
1013
- declare function defineVitestConfig(input?: DefineVitestConfigOptions): Promise<MonorepoVitestConfigResult>;
1014
- /**
1015
- * 创建项目级 Vitest 配置。
1016
- *
1017
- * 默认值:
1018
- * - `globals`: `true`
1019
- * - `testTimeout`: `60_000`
1020
- * - `environment`: `'node'`
1021
- *
1022
- * @param options 单个 package/app 的 Vitest 配置项
1023
- * @returns 可直接给项目内 `vitest.config.ts` 使用的 `test` 配置片段
1024
- */
1025
- declare function createMonorepoVitestProjectConfig(options?: MonorepoVitestProjectConfigOptions): MonorepoVitestProjectConfigResult;
1026
- /**
1027
- * 从 `repoctl.config.ts` 读取 `tooling.vitestProject`,再叠加运行时 `options`
1028
- * 生成单个 package/app 的项目级 Vitest 配置。
1029
- *
1030
- * 优先级从低到高:
1031
- * 1. `repoctl.config.ts -> tooling.vitestProject`
1032
- * 2. `options`
1033
- *
1034
- * @param input `cwd` 用于配置文件解析起点,`options` 用于追加项目内局部覆盖项
1035
- * @returns 可直接传给 `defineProject()` 或与其他 Vite/Vitest 配置 merge 的项目级配置片段
1036
- */
1037
- declare function defineVitestProjectConfig(input?: DefineVitestProjectConfigOptions): Promise<MonorepoVitestProjectConfigResult>;
1038
- //#endregion
1039
- export { init as $, MonorepoVitestProjectConfigResult as A, HuskyToolingConfig as B, MonorepoLintStagedConfigOptions as C, MonorepoVitestConfigOverrides as D, MonorepoVitestConfigOptions as E, CleanCommandConfig as F, StylelintToolingConfig as G, LintStagedToolingConfig as H, CommitlintToolingConfig as I, UpgradeCommandConfig as J, ToolingConfig as K, CreateChoiceOption as L, SimpleGit as M, SimpleGitOptions as N, MonorepoVitestConfigResult as O, AiCommandConfig as P, ReleaseCommandConfig as Q, CreateCommandConfig as R, MonorepoLintStagedConfig as S, MonorepoTsconfig as T, MirrorCommandConfig as U, InitCommandConfig as V, MonorepoConfig as W, VitestToolingConfig as X, VitestProjectToolingConfig as Y, ReleaseAfterPublishHookConfig as Z, DefineEslintConfigOptions as _, generateAgenticTemplates as _t, createMonorepoTsconfig as a, CreateNewProjectOptions as at, MonorepoCommitlintConfig as b, createMonorepoCommitlintConfig as c, getTemplateMap as ct, defineCommitlintConfig as d, AgenticTemplateFormat as dt, initMetadata as et, defineEslintConfig as f, AgenticTemplateTask as ft, DefineConfigOptions as g, generateAgenticTemplate as gt, defineLintStagedConfig as h, defaultAgenticBaseDir as ht, defineVitestProjectConfig as i, createNewProject as it, ConfigValues as j, MonorepoVitestProjectConfigOptions as k, createMonorepoEslintConfig as l, resolveCreateNewProjectPlan as lt, createMonorepoLintStagedConfig as m, createTimestampFolderName as mt, createMonorepoVitestProjectConfig as n, normalizeInitToolingTargets as nt, defineTsconfigConfig as o, CreateNewProjectPlan as ot, defineStylelintConfig as p, GenerateAgenticTemplateOptions as pt, TsconfigToolingConfig as q, defineVitestConfig as r, initToolingTargets as rt, loadMonorepoToolingConfig as s, getCreateChoices as st, createMonorepoVitestConfig as t, initTooling as tt, createMonorepoStylelintConfig as u, templateMap as ut, DefineVitestConfigOptions as v, loadAgenticTasks as vt, MonorepoStylelintConfig as w, MonorepoEslintConfig as x, DefineVitestProjectConfigOptions as y, CliOpts as yt, EslintToolingConfig as z };