@icebreakers/monorepo-templates 1.0.15 → 1.2.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 (161) hide show
  1. package/README.md +12 -8
  2. package/README.zh-CN.md +16 -0
  3. package/assets/.changeset/ledger.yaml +51 -0
  4. package/assets/.github/ISSUE_TEMPLATE/config.yml +1 -1
  5. package/assets/.github/workflows/release.yml +22 -97
  6. package/assets/AGENTS.md +5 -4
  7. package/assets/CONTRIBUTING.md +27 -2
  8. package/assets/SECURITY.md +12 -14
  9. package/assets/package.json +18 -10
  10. package/assets/pnpm-workspace.yaml +8 -0
  11. package/package.json +6 -4
  12. package/templates/cli/package.json +11 -4
  13. package/templates/client/package.json +22 -6
  14. package/templates/server/package.json +14 -7
  15. package/templates/server/vitest.config.ts +1 -4
  16. package/templates/tsdown/package.json +11 -4
  17. package/templates/tsdown/vitest.config.ts +1 -4
  18. package/templates/vitepress/.vitepress/config.ts +146 -165
  19. package/templates/vitepress/ai/index.md +12 -23
  20. package/templates/vitepress/ai/llms-txt.md +13 -31
  21. package/templates/vitepress/getting-started.md +3 -32
  22. package/templates/vitepress/index.md +27 -30
  23. package/templates/vitepress/knowledge/index.md +17 -41
  24. package/templates/vitepress/monorepo/commands.md +13 -18
  25. package/templates/vitepress/monorepo/index.md +22 -100
  26. package/templates/vitepress/monorepo/manage.md +15 -227
  27. package/templates/vitepress/monorepo/publish.md +17 -245
  28. package/templates/vitepress/monorepo/templates.md +10 -17
  29. package/templates/vitepress/monorepo/troubleshooting.md +13 -16
  30. package/templates/vitepress/package.json +11 -5
  31. package/templates/vitepress/public/_redirects +3 -0
  32. package/templates/vitepress/repoctl/adopt-existing.md +51 -53
  33. package/templates/vitepress/repoctl/aliases.md +18 -18
  34. package/templates/vitepress/repoctl/checks.md +21 -68
  35. package/templates/vitepress/repoctl/commands.md +16 -64
  36. package/templates/vitepress/repoctl/config.md +14 -35
  37. package/templates/vitepress/repoctl/doctor.md +20 -60
  38. package/templates/vitepress/repoctl/execution-model.md +16 -69
  39. package/templates/vitepress/repoctl/getting-started.md +34 -40
  40. package/templates/vitepress/repoctl/index.md +33 -61
  41. package/templates/vitepress/repoctl/reports.md +20 -74
  42. package/templates/vitepress/repoctl/scenarios.md +26 -28
  43. package/templates/vitepress/repoctl/template-assets.md +19 -88
  44. package/templates/vitepress/repoctl/templates.md +50 -81
  45. package/templates/vitepress/repoctl/troubleshooting.md +32 -46
  46. package/templates/vitepress/repoctl/workflows.md +38 -67
  47. package/templates/vitepress/thinking.md +4 -85
  48. package/templates/vitepress/tools/changeset.md +12 -85
  49. package/templates/vitepress/tools/husky.md +6 -124
  50. package/templates/vitepress/tools/index.md +13 -32
  51. package/templates/vitepress/tools/lint-staged.md +5 -96
  52. package/templates/vitepress/tools/llms-txt.md +4 -6
  53. package/templates/vitepress/tools/pnpm.md +7 -119
  54. package/templates/vitepress/tools/renovate.md +3 -87
  55. package/templates/vitepress/tools/turborepo.md +5 -157
  56. package/templates/vitepress/why/how-to-reuse-js-code.md +6 -247
  57. package/templates/vitepress/why/index.md +14 -1
  58. package/templates/vitepress/why/js-cjs-mjs.md +9 -96
  59. package/templates/vitepress/why/js-keywords.md +4 -129
  60. package/templates/vitepress/why/modern/bundlers.md +3 -50
  61. package/templates/vitepress/why/modern/dts.md +4 -90
  62. package/templates/vitepress/why/modern/esm-vs-cjs.md +4 -81
  63. package/templates/vitepress/why/modern/index.md +10 -51
  64. package/templates/vitepress/why/modern/package-entry-points.md +6 -117
  65. package/templates/vitepress/why/modern/typescript.md +4 -152
  66. package/templates/vitepress/why/publish-basic-npm-package.md +17 -144
  67. package/templates/vitepress/why/what-is-npm-package.md +4 -159
  68. package/templates/vitepress/zh/ai/index.md +33 -0
  69. package/templates/vitepress/zh/ai/llms-txt.md +42 -0
  70. package/templates/vitepress/zh/getting-started.md +40 -0
  71. package/templates/vitepress/zh/index.md +66 -0
  72. package/templates/vitepress/zh/knowledge/index.md +50 -0
  73. package/templates/vitepress/zh/monorepo/commands.md +21 -0
  74. package/templates/vitepress/zh/monorepo/index.md +115 -0
  75. package/templates/vitepress/zh/monorepo/manage.md +243 -0
  76. package/templates/vitepress/zh/monorepo/publish.md +87 -0
  77. package/templates/vitepress/zh/monorepo/templates.md +21 -0
  78. package/templates/vitepress/zh/monorepo/troubleshooting.md +20 -0
  79. package/templates/vitepress/zh/repoctl/adopt-existing.md +135 -0
  80. package/templates/vitepress/{en → zh}/repoctl/aliases.md +18 -18
  81. package/templates/vitepress/zh/repoctl/checks.md +86 -0
  82. package/templates/vitepress/zh/repoctl/commands.md +168 -0
  83. package/templates/vitepress/zh/repoctl/config.md +90 -0
  84. package/templates/vitepress/zh/repoctl/doctor.md +86 -0
  85. package/templates/vitepress/zh/repoctl/execution-model.md +81 -0
  86. package/templates/vitepress/zh/repoctl/getting-started.md +122 -0
  87. package/templates/vitepress/zh/repoctl/index.md +102 -0
  88. package/templates/vitepress/zh/repoctl/reports.md +94 -0
  89. package/templates/vitepress/{en → zh}/repoctl/scenarios.md +28 -26
  90. package/templates/vitepress/zh/repoctl/template-assets.md +116 -0
  91. package/templates/vitepress/zh/repoctl/templates.md +159 -0
  92. package/templates/vitepress/zh/repoctl/troubleshooting.md +110 -0
  93. package/templates/vitepress/zh/repoctl/workflows.md +118 -0
  94. package/templates/vitepress/zh/thinking.md +88 -0
  95. package/templates/vitepress/zh/tools/changeset.md +75 -0
  96. package/templates/vitepress/zh/tools/husky.md +130 -0
  97. package/templates/vitepress/zh/tools/index.md +38 -0
  98. package/templates/vitepress/zh/tools/lint-staged.md +103 -0
  99. package/templates/vitepress/zh/tools/llms-txt.md +9 -0
  100. package/templates/vitepress/zh/tools/pnpm.md +127 -0
  101. package/templates/vitepress/zh/tools/renovate.md +91 -0
  102. package/templates/vitepress/zh/tools/turborepo.md +166 -0
  103. package/templates/vitepress/zh/why/assets/npm-dt.svg +15 -0
  104. package/templates/vitepress/zh/why/assets/npm-ts.svg +19 -0
  105. package/templates/vitepress/zh/why/examples/0.npm-basic-package/index.js +10 -0
  106. package/templates/vitepress/zh/why/examples/0.npm-basic-package/package.json +11 -0
  107. package/templates/vitepress/zh/why/examples/1.npm-basic-package/index.cjs +12 -0
  108. package/templates/vitepress/zh/why/examples/1.npm-basic-package/index.d.ts +1 -0
  109. package/templates/vitepress/zh/why/examples/1.npm-basic-package/index.js +8 -0
  110. package/templates/vitepress/zh/why/examples/1.npm-basic-package/package.json +19 -0
  111. package/templates/vitepress/zh/why/examples/2.npm-basic-package/README.md +1 -0
  112. package/templates/vitepress/zh/why/examples/2.npm-basic-package/package-lock.json +30 -0
  113. package/templates/vitepress/zh/why/examples/2.npm-basic-package/package.json +35 -0
  114. package/templates/vitepress/zh/why/examples/2.npm-basic-package/rename-ext.js +24 -0
  115. package/templates/vitepress/zh/why/examples/2.npm-basic-package/src/index.ts +8 -0
  116. package/templates/vitepress/zh/why/examples/2.npm-basic-package/tsconfig.cjs.json +8 -0
  117. package/templates/vitepress/zh/why/examples/2.npm-basic-package/tsconfig.esm.json +7 -0
  118. package/templates/vitepress/zh/why/examples/2.npm-basic-package/tsconfig.json +18 -0
  119. package/templates/vitepress/zh/why/examples/3.npm-basic-package/README.md +1 -0
  120. package/templates/vitepress/zh/why/examples/3.npm-basic-package/package-lock.json +1496 -0
  121. package/templates/vitepress/zh/why/examples/3.npm-basic-package/package.json +31 -0
  122. package/templates/vitepress/zh/why/examples/3.npm-basic-package/src/index.ts +8 -0
  123. package/templates/vitepress/zh/why/examples/3.npm-basic-package/tsconfig.json +16 -0
  124. package/templates/vitepress/zh/why/examples/3.npm-basic-package/tsdown.config.ts +16 -0
  125. package/templates/vitepress/zh/why/examples/usage-cjs/cjs.cjs +4 -0
  126. package/templates/vitepress/zh/why/examples/usage-cjs/esm.mjs +4 -0
  127. package/templates/vitepress/zh/why/examples/usage-cjs/index.js +8 -0
  128. package/templates/vitepress/zh/why/examples/usage-cjs/package-lock.json +36 -0
  129. package/templates/vitepress/zh/why/examples/usage-cjs/package.json +20 -0
  130. package/templates/vitepress/zh/why/examples/usage-esm/cjs.cjs +4 -0
  131. package/templates/vitepress/zh/why/examples/usage-esm/createRequire.js +7 -0
  132. package/templates/vitepress/zh/why/examples/usage-esm/esm.mjs +4 -0
  133. package/templates/vitepress/zh/why/examples/usage-esm/index.js +8 -0
  134. package/templates/vitepress/zh/why/examples/usage-esm/package-lock.json +36 -0
  135. package/templates/vitepress/zh/why/examples/usage-esm/package.json +21 -0
  136. package/templates/vitepress/zh/why/how-to-reuse-js-code.md +250 -0
  137. package/templates/vitepress/zh/why/index.md +1 -0
  138. package/templates/vitepress/zh/why/js-cjs-mjs.md +99 -0
  139. package/templates/vitepress/zh/why/js-keywords.md +132 -0
  140. package/templates/vitepress/zh/why/modern/bundlers.md +52 -0
  141. package/templates/vitepress/zh/why/modern/dts.md +93 -0
  142. package/templates/vitepress/zh/why/modern/esm-vs-cjs.md +84 -0
  143. package/templates/vitepress/zh/why/modern/index.md +55 -0
  144. package/templates/vitepress/zh/why/modern/package-entry-points.md +128 -0
  145. package/templates/vitepress/zh/why/modern/typescript.md +155 -0
  146. package/templates/vitepress/zh/why/publish-basic-npm-package.md +146 -0
  147. package/templates/vitepress/zh/why/what-is-npm-package.md +162 -0
  148. package/templates/vue-lib/package.json +12 -5
  149. package/templates/vue-lib/vitest.config.ts +1 -1
  150. package/assets/.changeset/config.json +0 -21
  151. package/assets/.changeset/publish-versioned-packages.md +0 -5
  152. package/templates/vitepress/en/index.md +0 -63
  153. package/templates/vitepress/en/knowledge/monorepo.md +0 -37
  154. package/templates/vitepress/en/repoctl/adopt-existing.md +0 -133
  155. package/templates/vitepress/en/repoctl/commands.md +0 -120
  156. package/templates/vitepress/en/repoctl/config.md +0 -69
  157. package/templates/vitepress/en/repoctl/getting-started.md +0 -116
  158. package/templates/vitepress/en/repoctl/index.md +0 -74
  159. package/templates/vitepress/en/repoctl/templates.md +0 -128
  160. package/templates/vitepress/en/repoctl/troubleshooting.md +0 -96
  161. package/templates/vitepress/en/repoctl/workflows.md +0 -89
@@ -1,116 +1,47 @@
1
1
  ---
2
- description: 说明 repoctl 内置模板、templateMap、模板健康检查、创建计划和模板资产维护方式。
2
+ outline: deep
3
3
  ---
4
4
 
5
- # repoctl 模板资产治理
5
+ # Template Asset Management
6
6
 
7
- repoctl 的模板能力不只是复制目录。它会把模板元数据、默认生成目录、创建计划、健康检查和配置覆盖串起来。
7
+ Templates are one repoctl capability. `@icebreakers/monorepo-templates` packages built-in project templates and managed repository assets; templates under `templates/*` are private source workspaces and are not published independently.
8
8
 
9
- ## 1. 内置模板映射
9
+ ## Built-In Mapping
10
10
 
11
- | key | source | 默认 target | 类型 |
12
- | ------------- | --------------------- | ------------------ | --------------------- |
13
- | `tsdown` | `templates/tsdown` | `packages/tsdown` | TypeScript library |
14
- | `vue-lib` | `templates/vue-lib` | `packages/vue-lib` | Vue component library |
15
- | `hono-server` | `templates/server` | `apps/server` | Hono service |
16
- | `vue-hono` | `templates/client` | `apps/client` | Vue + Hono app |
17
- | `vitepress` | `templates/vitepress` | `apps/website` | docs site |
18
- | `cli` | `templates/cli` | `apps/cli` | command line tool |
19
-
20
- 查看实际可用模板:
11
+ Template metadata defines a stable key, category, source directory, default target, and description. The CLI, create commands, and documentation consume the same registry.
21
12
 
22
13
  ```bash
23
14
  repo templates
24
- repo templates --json
25
- repo templates --markdown --out docs/templates.md
15
+ repo templates tsdown
16
+ repo templates --category library
26
17
  ```
27
18
 
28
- ## 2. 创建计划
29
-
30
- `repo new` 会先解析创建计划,再决定是否写入文件。计划包含:
31
-
32
- | 字段 | 含义 |
33
- | ------------------- | ------------------------------------------------ |
34
- | `requestedTemplate` | 用户请求的模板 key |
35
- | `template` | 实际使用的模板 key |
36
- | `sourceDir` | 模板源目录 |
37
- | `targetDir` | 输出目录 |
38
- | `targetExists` | 目标目录是否已存在 |
39
- | `packageName` | 写入 package.json 的包名 |
40
- | `renameJson` | 是否把 `package.json` 输出为 `package.mock.json` |
41
-
42
- 预览创建:
19
+ ## Creation Plans
43
20
 
44
21
  ```bash
45
- repo new docs --template vitepress --dry-run
22
+ repo new sdk --template tsdown --dry-run
46
23
  repo new docs --template vitepress --json --out plans/docs.json
47
24
  ```
48
25
 
49
- `--json` 和 `--out` 都隐含 `--dry-run`,不会写入文件。
26
+ A plan records the selected template, source, destination, package name, workspace pattern, and whether fallback behavior was used. Unknown explicit keys fail with a suggestion.
50
27
 
51
- ## 3. 模板选择和报错
52
-
53
- 显式传入 `--template` 时,repoctl 会先校验模板 key:
54
-
55
- ```bash
56
- repo new sdk --template tsdown
57
- ```
58
-
59
- 如果模板 key 拼错,命令会失败并提示相近 key。它不会静默回退到默认模板,这样 CI 和脚本不会生成错误类型的项目。
60
-
61
- ## 4. 健康检查
62
-
63
- 模板资产可以通过 `repo templates --check` 检查:
28
+ ## Health Checks
64
29
 
65
30
  ```bash
66
31
  repo templates --check
67
- repo templates --check --json --out reports/templates.json
32
+ repo templates --check --json
68
33
  ```
69
34
 
70
- 检查内容包括:
71
-
72
- | 检查 | 目的 |
73
- | -------------- | ------------------------------------ |
74
- | source 唯一性 | 避免多个模板 key 指向同一源目录 |
75
- | target 唯一性 | 避免多个模板默认写到同一目标目录 |
76
- | source 目录 | 确认模板目录存在 |
77
- | package.json | 确认模板根目录包含包元数据 |
78
- | metadata | 确认模板有 category 和 description |
79
- | filtered files | 避免把临时、缓存或生成文件放入模板源 |
80
-
81
- ## 5. 自定义模板
82
-
83
- 可以在 `repoctl.config.ts` 里扩展模板映射:
84
-
85
- ```ts
86
- import { defineMonorepoConfig } from 'repoctl'
87
-
88
- export default defineMonorepoConfig({
89
- commands: {
90
- create: {
91
- defaultTemplate: 'internal-service',
92
- templateMap: {
93
- 'internal-service': {
94
- source: 'templates/internal-service',
95
- target: 'apps/internal-service',
96
- },
97
- },
98
- },
99
- },
100
- })
101
- ```
35
+ Health checks validate unique sources and targets, source directories, package manifests, metadata, and filtered temporary files.
102
36
 
103
- 自定义模板建议遵守同样的治理规则:唯一 source、唯一 target、模板根目录包含 `package.json`,并避免提交构建输出和缓存文件。
37
+ ## Managed Assets
104
38
 
105
- ## 6. 维护流程
39
+ `repo init` and `repo upgrade` synchronize root scripts, configuration, hooks, and release assets. Existing custom files are preserved unless overwrite behavior is explicitly selected.
106
40
 
107
- 更新模板时建议按下面流程验证:
41
+ Repository maintainers refresh packaged copies with:
108
42
 
109
- ```txt
110
- 修改 templates/<name>
111
- -> repo templates --check
112
- -> repo new demo --template <name> --json --out plans/demo.json
113
- -> 构建或测试生成后的 workspace
43
+ ```bash
44
+ pnpm --filter @icebreakers/monorepo-templates sync:assets
114
45
  ```
115
46
 
116
- 如果模板文件数量发生变化,维护模板快照的测试也需要同步更新。
47
+ Generated copies should never be edited by hand.
@@ -1,21 +1,19 @@
1
- # 模板与创建
1
+ # Templates
2
2
 
3
- repoctl 的模板由 `@icebreakers/monorepo-templates` 维护。CLI、脚手架和文档都复用同一份模板元数据。
3
+ repoctl templates are maintained by `@icebreakers/monorepo-templates`. The CLI, scaffolder, and docs share the same template metadata.
4
4
 
5
- 更偏维护者视角的模板元数据、健康检查和自定义模板说明见:[模板资产治理](./template-assets.md)。
5
+ ## Built-In Templates
6
6
 
7
- ## 内置模板
7
+ | Key | Category | Default target | Use case |
8
+ | ------------- | -------- | ------------------ | ----------------------- |
9
+ | `tsdown` | library | `packages/tsdown` | TypeScript library |
10
+ | `vue-lib` | library | `packages/vue-lib` | Vue 3 component library |
11
+ | `vue-hono` | app | `apps/client` | Vue 3 + Hono app |
12
+ | `hono-server` | service | `apps/server` | Hono API service |
13
+ | `vitepress` | docs | `apps/website` | VitePress docs site |
14
+ | `cli` | tool | `apps/cli` | TypeScript CLI |
8
15
 
9
- | Key | Category | 默认目录 | 适合场景 |
10
- | ------------- | -------- | ------------------ | --------------------------- |
11
- | `tsdown` | library | `packages/tsdown` | TypeScript 库包 |
12
- | `vue-lib` | library | `packages/vue-lib` | Vue 3 组件库 |
13
- | `vue-hono` | app | `apps/client` | Vue 3 + Hono 前后端一体应用 |
14
- | `hono-server` | service | `apps/server` | Hono API 服务 |
15
- | `vitepress` | docs | `apps/website` | VitePress 文档站 |
16
- | `cli` | tool | `apps/cli` | TypeScript 命令行工具 |
17
-
18
- ## 查看模板
16
+ ## Discover Templates
19
17
 
20
18
  ```bash
21
19
  repo templates
@@ -25,7 +23,7 @@ repo templates --json
25
23
  repo templates --markdown --out docs/templates.md
26
24
  ```
27
25
 
28
- ## 创建模板
26
+ ## Create From A Template
29
27
 
30
28
  ```bash
31
29
  repo new sdk --template tsdown
@@ -35,72 +33,72 @@ repo new website --template vitepress
35
33
  repo new toolbox --template cli
36
34
  ```
37
35
 
38
- 普通名字会自动放到模板约定的目录里,例如库包进入 `packages/`,应用进入 `apps/`。如果你传入带 `/` 的路径,例如 `packages/shared-utils`,repoctl 会尊重这个路径。
36
+ Simple names are placed in the conventional target folder. Library templates go under `packages/`; app templates go under `apps/`. If you pass an explicit path such as `packages/shared-utils`, repoctl respects it.
39
37
 
40
- ## 按目标选择模板
38
+ ## Choose By Goal
41
39
 
42
- ### 要发布 npm 库
40
+ ### Publish an npm library
43
41
 
44
42
  ```bash
45
43
  repo new sdk --template tsdown
46
44
  ```
47
45
 
48
- 生成后先检查:
46
+ Check first:
49
47
 
50
- - `package.json` 的 `name`、`exports`、`types`。
51
- - `tsdown.config.ts` 是否符合产物格式。
52
- - 是否需要补 `tsd` 类型测试。
48
+ - `package.json` `name`, `exports`, and `types`.
49
+ - Whether `tsdown.config.ts` matches the desired output format.
50
+ - Whether public types need `tsd` tests.
53
51
 
54
- ### 要沉淀 Vue 组件
52
+ ### Build reusable Vue components
55
53
 
56
54
  ```bash
57
55
  repo new ui --template vue-lib
58
56
  ```
59
57
 
60
- 生成后先检查:
58
+ Check first:
61
59
 
62
- - 组件入口是否只导出稳定 API。
63
- - 样式是否能通过 Stylelint。
64
- - 文档站或示例应用是否需要同步创建。
60
+ - Component entry points only expose stable APIs.
61
+ - Styles pass Stylelint.
62
+ - A docs site or example app should be created alongside it if needed.
65
63
 
66
- ### 要创建应用或服务
64
+ ### Create an app or service
67
65
 
68
66
  ```bash
69
67
  repo new web --template vue-hono
70
68
  repo new api --template hono-server
71
69
  ```
72
70
 
73
- 生成后先检查:
71
+ Check first:
74
72
 
75
- - 运行时环境变量和部署平台约束。
76
- - `dev`、`build`、`typecheck` 脚本是否接入根任务。
77
- - 是否需要在 CI 里加入 E2E 或集成测试。
73
+ - Runtime environment variables and deployment constraints.
74
+ - `dev`, `build`, and `typecheck` scripts are part of root tasks.
75
+ - CI needs integration or E2E tests.
78
76
 
79
- ### 要创建文档站
77
+ ### Create a docs site
80
78
 
81
79
  ```bash
82
80
  repo new docs --template vitepress
83
81
  ```
84
82
 
85
- 生成后先检查:
83
+ Check first:
86
84
 
87
- - 导航和 sidebar 是否围绕产品或包名组织。
88
- - 是否需要中英文 locale。
89
- - 是否需要把 `repo templates --markdown` 输出写进文档。
85
+ - Nav and sidebar are organized around the product or package.
86
+ - A second locale is required.
87
+ - `repo templates --markdown` output should be written into docs.
90
88
 
91
- ### 要创建 CLI
89
+ ### Create a CLI
92
90
 
93
91
  ```bash
94
92
  repo new toolbox --template cli
95
93
  ```
96
94
 
97
- 生成后先检查:
95
+ Check first:
98
96
 
99
- - `bin` 字段是否符合最终命令名。
100
- - 参数解析、退出码和帮助信息是否可测试。
101
- - 是否需要把命令用法写入 README。
97
+ - The `bin` field matches the final command name.
98
+ - Argument parsing, exit codes, and help output are testable.
99
+ - README documents command usage.
102
100
 
103
- ## 创建前预览
101
+ ## Preview Creation
104
102
 
105
103
  ```bash
106
104
  repo new website --template vitepress --dry-run
@@ -108,52 +106,23 @@ repo new website --template vitepress --json
108
106
  repo new website --template vitepress --json --out plans/website.json
109
107
  ```
110
108
 
111
- `--dry-run` 不写入磁盘,只展示模板、源目录、目标目录、package name 和输出文件。
112
-
113
- `--json` 输出同一份创建计划的结构化数据,隐含 `--dry-run`。
114
-
115
- `--out <file>` 可以把文本或 JSON 预览写入文件,也隐含 `--dry-run`。
109
+ `--dry-run` does not write files. It shows the template, source directory, target directory, package name, and output files.
116
110
 
117
- ## 固化默认模板
111
+ `--json` emits the same plan as structured data and implies `--dry-run`.
118
112
 
119
- ```ts
120
- import { defineMonorepoConfig } from 'repoctl'
113
+ `--out <file>` persists the preview and also implies `--dry-run`.
121
114
 
122
- export default defineMonorepoConfig({
123
- commands: {
124
- create: {
125
- defaultTemplate: 'tsdown',
126
- },
127
- },
128
- })
129
- ```
130
-
131
- 之后:
132
-
133
- ```bash
134
- repo new utils
135
- ```
136
-
137
- 会直接创建 `tsdown` 库包。
138
-
139
- ## 检查模板健康状态
115
+ ## Check Template Health
140
116
 
141
117
  ```bash
142
118
  repo templates --check
143
119
  repo templates --check --json
144
120
  ```
145
121
 
146
- 模板检查会确认:
147
-
148
- - 模板 source 和 target 没有重复。
149
- - 每个模板 source 目录都存在。
150
- - 每个模板根目录都有 `package.json`。
151
- - 每个模板都有 category 和 description。
152
- - 模板源目录里没有会被脚手架过滤掉的临时或生成文件。
122
+ The check validates duplicate sources and targets, existing source directories, package metadata, categories, descriptions, and temporary files that would be filtered by the scaffolder.
153
123
 
154
- ## 继续阅读
124
+ ## Keep Reading
155
125
 
156
- - [接入已有仓库](./adopt-existing.md)
157
- - [工作流与 CI](./workflows.md)
158
- - [配置文件](./config.md)
159
- - [模板资产治理](./template-assets.md)
126
+ - [Adopt Existing Repositories](./adopt-existing.md)
127
+ - [Workflows and CI](./workflows.md)
128
+ - [Configuration](./config.md)
@@ -1,34 +1,34 @@
1
- # 排障与报告
1
+ # Troubleshooting
2
2
 
3
- repoctl 的排障重点不是让你猜错在哪里,而是尽量输出可以复现、可以保存、可以发给同事的报告。
3
+ repoctl focuses on reports that can be reproduced, saved, and shared.
4
4
 
5
- ## 先跑 doctor
5
+ ## Start With Doctor
6
6
 
7
7
  ```bash
8
8
  repo doctor
9
9
  repo doctor --strict
10
10
  ```
11
11
 
12
- `doctor` 主要检查:
12
+ `doctor` checks:
13
13
 
14
- - 当前目录是不是仓库根目录。
15
- - Node 版本是否满足要求。
16
- - `pnpm-workspace.yaml` 是否存在。
17
- - `repoctl` 是否作为 CLI 依赖安装。
18
- - 根脚本是否齐全。
19
- - 是否仍残留已废弃的 `monorepo.config.ts`。
20
- - Husky 与 lint-staged 是否都接上。
14
+ - Current directory and repository root.
15
+ - Node.js version.
16
+ - `pnpm-workspace.yaml`.
17
+ - The `repoctl` CLI dependency.
18
+ - Recommended root scripts.
19
+ - Conflicting config files.
20
+ - Husky and lint-staged wiring.
21
21
 
22
- ## 保存诊断报告
22
+ ## Save A Diagnostic Report
23
23
 
24
24
  ```bash
25
25
  repo doctor --json --out reports/doctor.json
26
26
  repo doctor --markdown --redact --out reports/doctor.md
27
27
  ```
28
28
 
29
- 推荐把 Markdown 报告贴到 issue 或 PR。`--redact` 会脱敏本机路径。
29
+ Markdown reports are useful in issues and PRs. `--redact` removes local absolute paths.
30
30
 
31
- ## 查看校验计划
31
+ ## Inspect The Verification Plan
32
32
 
33
33
  ```bash
34
34
  repo check --dry-run
@@ -36,9 +36,9 @@ repo check --json --out reports/check-plan.json
36
36
  repo check --markdown --redact --out reports/check-plan.md
37
37
  ```
38
38
 
39
- 当你不确定为什么某个文件触发了 workspace typecheck、pre-push 要跑哪些任务时,先看 check plan。
39
+ Use this when you need to understand why a file triggers a workspace typecheck or which tasks pre-push would run.
40
40
 
41
- ## 收集环境信息
41
+ ## Collect Environment Information
42
42
 
43
43
  ```bash
44
44
  repo env info
@@ -47,51 +47,41 @@ repo env snapshot --json --out reports/snapshot.json
47
47
  repo env paths --markdown --redact --out reports/paths.md
48
48
  ```
49
49
 
50
- 这些命令适合排查 Node、pnpm、workspace、Git、路径和 CI 环境差异。
50
+ These commands help compare local, CI, Git, Node, pnpm, and workspace differences.
51
51
 
52
- ## 先判断问题类型
52
+ ## Common Fixes
53
53
 
54
- | 现象 | 优先命令 | 继续阅读 |
55
- | ------------------------------ | ----------------------------------------- | ------------------------------------ |
56
- | 不确定当前目录是不是仓库根目录 | `repo doctor` | [doctor 诊断](./doctor.md) |
57
- | 不知道 `repo check` 会跑什么 | `repo check --dry-run` | [校验链路](./checks.md) |
58
- | CI 失败但日志不完整 | `repo env support --markdown --redact` | [报告与自动化输出](./reports.md) |
59
- | 模板创建结果不符合预期 | `repo new <name> --template <key> --json` | [模板资产治理](./template-assets.md) |
60
- | 模板列表或元数据异常 | `repo templates --check` | [模板资产治理](./template-assets.md) |
54
+ ### Not At Repository Root
61
55
 
62
- ## 常见问题
63
-
64
- ### 当前目录不是仓库根目录
65
-
66
- 切回包含 `pnpm-workspace.yaml` 和根 `package.json` 的目录,再运行:
56
+ Change into the directory that contains `pnpm-workspace.yaml` and the root `package.json`, then run:
67
57
 
68
58
  ```bash
69
59
  repo doctor
70
60
  ```
71
61
 
72
- ### 同时存在两个配置文件
62
+ ### Conflicting Config Files
73
63
 
74
- 只保留一个:
64
+ Keep only:
75
65
 
76
66
  ```txt
77
67
  repoctl.config.ts
78
68
  ```
79
69
 
80
- `monorepo.config.ts` 已不再加载。旧项目需要改名为 `repoctl.config.ts`。
70
+ `monorepo.config.ts` is no longer loaded at runtime; rename it to `repoctl.config.ts`.
81
71
 
82
- ### `repo new` 提示模板不存在
72
+ ### Unknown Template Key
83
73
 
84
- 先查看可用模板:
74
+ List available templates:
85
75
 
86
76
  ```bash
87
77
  repo templates
88
78
  ```
89
79
 
90
- 显式传入的 `--template` 会先校验。拼错时命令会失败并提示相近 key,不会静默回退。
80
+ Explicit `--template` values are validated first. Invalid keys fail with suggestions.
91
81
 
92
- ### 自动化里不希望出现交互
82
+ ### Automation Should Not Prompt
93
83
 
94
- 使用非交互参数:
84
+ Use non-interactive options:
95
85
 
96
86
  ```bash
97
87
  repo init --yes
@@ -99,12 +89,8 @@ repo upgrade --no-overwrite
99
89
  repo check --json --out reports/check-plan.json
100
90
  ```
101
91
 
102
- 非 TTY 环境下,repoctl 不会弹出交互选择框。
103
-
104
- ## 继续阅读
92
+ ## Keep Reading
105
93
 
106
- - [工作流与 CI](./workflows.md)
107
- - [命令速查](./commands.md)
108
- - [doctor 诊断](./doctor.md)
109
- - [报告与自动化输出](./reports.md)
110
- - [命令别名](./aliases.md)
94
+ - [Workflows and CI](./workflows.md)
95
+ - [Command Reference](./commands.md)
96
+ - [Command Aliases](./aliases.md)
@@ -1,8 +1,8 @@
1
- # 工作流与 CI
1
+ # Workflows and CI
2
2
 
3
- repoctl 的命令可以分成两类:给人用的日常入口,以及给 CI、脚本、编辑器用的可保存输出。
3
+ repoctl commands have two audiences: humans using short daily commands, and automation consuming stable reports.
4
4
 
5
- ## 本地日常工作流
5
+ ## Local Daily Workflow
6
6
 
7
7
  ```bash
8
8
  pnpm install
@@ -12,17 +12,15 @@ pnpm run repo:check
12
12
  pnpm build
13
13
  ```
14
14
 
15
- 这条链路适合新成员第一次进入仓库:
15
+ | Step | What It Proves |
16
+ | ---------------------- | ------------------------------------------------------- |
17
+ | `pnpm install` | Workspace dependencies and local links are ready |
18
+ | `pnpm run repo:doctor` | Root files, Node, scripts, config, and hooks are usable |
19
+ | `pnpm run repo:new` | New packages follow template conventions |
20
+ | `pnpm run repo:check` | The lightweight local verification flow is reproducible |
21
+ | `pnpm build` | The workspace build graph has no obvious breakage |
16
22
 
17
- | 步骤 | 判断标准 |
18
- | ---------------------- | ------------------------------------------------ |
19
- | `pnpm install` | workspace 依赖和本地链接完整 |
20
- | `pnpm run repo:doctor` | 仓库根目录、Node、脚本、配置和提交链路可用 |
21
- | `pnpm run repo:new` | 新包由模板创建,目录和 package metadata 符合约定 |
22
- | `pnpm run repo:check` | 提交前轻量校验可以复现 |
23
- | `pnpm build` | 全仓构建链路没有明显断点 |
24
-
25
- ## 存量仓库接入
23
+ ## Adopt An Existing Repository
26
24
 
27
25
  ```bash
28
26
  pnpm add -D repoctl
@@ -32,9 +30,9 @@ pnpm exec repo upgrade --no-overwrite
32
30
  pnpm exec repo doctor
33
31
  ```
34
32
 
35
- 推荐先用 `--no-overwrite` 保守接入。确认标准资产差异后,再决定是否使用 `--yes` 或 `--overwrite`。
33
+ Start conservatively with `--no-overwrite`. After reviewing asset drift, decide whether `--yes` or `--overwrite` is appropriate.
36
34
 
37
- ## CI 快速门禁
35
+ ## Fast CI Gate
38
36
 
39
37
  ```bash
40
38
  pnpm install --frozen-lockfile
@@ -42,9 +40,9 @@ pnpm exec repo doctor --strict
42
40
  pnpm exec repo check --full
43
41
  ```
44
42
 
45
- 适合小仓库或早期项目。`doctor --strict` 会把 warning 也当成失败,能避免配置漂移慢慢积累。
43
+ This is a simple gate for small repositories or early projects. `doctor --strict` treats warnings as failures.
46
44
 
47
- ## CI 报告模式
45
+ ## CI Report Mode
48
46
 
49
47
  ```bash
50
48
  pnpm exec repo doctor --json --out reports/doctor.json
@@ -52,15 +50,13 @@ pnpm exec repo check --json --out reports/check-plan.json
52
50
  pnpm exec repo env support --markdown --redact --out reports/support.md
53
51
  ```
54
52
 
55
- 这组命令适合想保存构建上下文的 CI:
56
-
57
- - `doctor.json` 给脚本判断仓库健康状态。
58
- - `check-plan.json` 记录本次会跑哪些校验。
59
- - `support.md` 适合上传为 artifact,或贴进 issue / PR。
53
+ Use these outputs as CI artifacts:
60
54
 
61
- ## pre-commit 与 pre-push
55
+ - `doctor.json` for scripts.
56
+ - `check-plan.json` to explain verification routing.
57
+ - `support.md` for issues, PRs, and external collaboration.
62
58
 
63
- repoctl 暴露了底层 verify 命令,方便 hook 和脚本复用:
59
+ ## Hooks
64
60
 
65
61
  ```bash
66
62
  repo verify pre-commit
@@ -69,50 +65,25 @@ repo verify commit-msg .git/COMMIT_EDITMSG
69
65
  repo verify pre-push
70
66
  ```
71
67
 
72
- 默认建议:
73
-
74
- | 阶段 | 推荐行为 |
75
- | ---------- | ------------------------------------------------------- |
76
- | pre-commit | 聚焦 staged 文件,运行格式、lint 和 workspace typecheck |
77
- | commit-msg | 校验 Conventional Commit 格式 |
78
- | pre-push | 跑整仓 lint/typecheck,并按变更范围补 build/test/tsd |
79
-
80
- ## 自动化创建预览
81
-
82
- ```bash
83
- repo new dashboard --template vue-hono --json --out plans/dashboard.json
84
- repo templates --markdown --out docs/templates.md
85
- repo ws ls --json --out reports/workspaces.json
86
- ```
87
-
88
- 这些命令都不会要求人工选择,适合编辑器插件、脚本和 CI bot。
89
-
90
- ## 推荐流水线拆分
91
-
92
- | 阶段 | 命令 | 失败后先看 |
93
- | ---- | --------------------------------------------------------------- | ------------------------------------ |
94
- | 安装 | `pnpm install --frozen-lockfile` | lockfile、Node、pnpm 版本 |
95
- | 诊断 | `repo doctor --strict` | [doctor 诊断](./doctor.md) |
96
- | 计划 | `repo check --full --json --out reports/check-plan.json` | [报告与自动化输出](./reports.md) |
97
- | 执行 | `repo check --full` | 失败的 root script 或 workspace 任务 |
98
- | 留证 | `repo env support --markdown --redact --out reports/support.md` | CI artifact |
99
-
100
- 早期项目可以把计划和执行合并。成熟项目建议保留 `reports/`,方便失败时复盘实际执行路径。
68
+ | Stage | Recommended Behavior |
69
+ | ---------- | --------------------------------------------------------- |
70
+ | pre-commit | Focus on staged files, lint, and workspace typecheck |
71
+ | commit-msg | Enforce Conventional Commit messages |
72
+ | pre-push | Run root lint/typecheck and affected build/test/tsd tasks |
101
73
 
102
- ## 非交互参数选择
74
+ ## Non-Interactive Options
103
75
 
104
- | 场景 | 推荐参数 |
105
- | ------------------ | -------------------------------------------------- |
106
- | 初始化时接受默认值 | `repo init --yes` |
107
- | 同步时保留已有改动 | `repo upgrade --no-overwrite` |
108
- | 明确覆盖标准资产 | `repo upgrade --yes` 或 `repo upgrade --overwrite` |
109
- | 只看计划不执行 | `--dry-run` |
110
- | 输出给脚本 | `--json --out <file>` |
111
- | 输出给人看并脱敏 | `--markdown --redact --out <file>` |
76
+ | Scenario | Option |
77
+ | ------------------------------------- | -------------------------------------------------- |
78
+ | Accept setup defaults | `repo init --yes` |
79
+ | Preserve changed files during upgrade | `repo upgrade --no-overwrite` |
80
+ | Explicitly overwrite standard assets | `repo upgrade --yes` or `repo upgrade --overwrite` |
81
+ | Preview only | `--dry-run` |
82
+ | Output for scripts | `--json --out <file>` |
83
+ | Share a redacted report | `--markdown --redact --out <file>` |
112
84
 
113
- ## 下一步
85
+ ## Keep Reading
114
86
 
115
- - 查所有参数:[命令速查](./commands.md)
116
- - 理解校验链路:[校验链路](./checks.md)
117
- - 生成排障包:[报告与自动化输出](./reports.md)
118
- - 看短命令:[命令别名](./aliases.md)
87
+ - [Command Reference](./commands.md)
88
+ - [Troubleshooting](./troubleshooting.md)
89
+ - [Command Aliases](./aliases.md)