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