@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,86 +1,39 @@
1
1
  ---
2
- description: 说明 repoctl check 和 verify 的校验模式、pre-commit、staged typecheck、pre-push 与 commit-msg 链路。
2
+ outline: deep
3
3
  ---
4
4
 
5
- # repoctl 校验链路
5
+ # repoctl Verification
6
6
 
7
- `repo check` 是给人使用的统一入口,`repo verify` 是给 hook、CI 和脚本复用的底层入口。
7
+ `repo check` provides stable, task-oriented entrypoints for local and CI verification. It preserves the underlying workspace scripts and reports which commands will run before execution.
8
8
 
9
- ## 1. 模式速查
9
+ ## Modes
10
10
 
11
- | 命令 | 模式 | 实际动作 |
12
- | -------------------------------------------- | ------------ | -------------------------------------------------------------- |
13
- | `repo check` | `default` | 执行 `repo verify pre-commit` |
14
- | `repo check --staged` | `staged` | 执行 pre-commit,并按 staged TypeScript/Vue 文件路由 typecheck |
15
- | `repo check --full` | `full` | 按根脚本执行 `lint`、`typecheck`、`test`、`build` 中存在的任务 |
16
- | `repo check --edit-file .git/COMMIT_EDITMSG` | `commit-msg` | 执行 commit message 校验 |
11
+ | Mode | Command | Purpose |
12
+ | -------------- | ------------------------------- | --------------------------------------------------- |
13
+ | Default | `repo check` | Lightweight pre-commit verification |
14
+ | Staged | `repo check --staged` | lint-staged plus workspace-aware type checking |
15
+ | Full | `repo check --full` | Root lint, typecheck, build, test, and tsd workflow |
16
+ | Commit message | `repo check --edit-file <file>` | Validate a commit message file |
17
17
 
18
- 预览模式不会真正执行校验:
18
+ Use `--dry-run`, `--json`, or `--markdown` to inspect the plan without running it. `--out <file>` persists the result and `--redact` removes local paths.
19
19
 
20
- ```bash
21
- repo check --dry-run
22
- repo check --full --json --out reports/check-plan.json
23
- repo check --markdown --redact --out reports/check-plan.md
24
- ```
25
-
26
- ## 2. pre-commit
27
-
28
- `repo verify pre-commit` 默认执行 lint-staged。适合在提交前只处理 staged 文件,避免每次提交都跑整仓校验。
29
-
30
- 推荐的 lint-staged 行为包括:
31
-
32
- | 文件类型 | 推荐处理 |
33
- | -------------------------- | ---------------------------------------- |
34
- | JS、TS、Vue | ESLint 自动修复 |
35
- | CSS、SCSS、Less、Vue style | Stylelint 自动修复 |
36
- | TS、TSX、MTS、CTS、Vue | 路由到最近 workspace 的 `typecheck` 脚本 |
37
-
38
- ## 3. staged typecheck
39
-
40
- `repo verify staged-typecheck <files...>` 会根据文件路径向上查找最近的 workspace,并执行该 workspace 的 `typecheck`。
41
-
42
- ```bash
43
- repo verify staged-typecheck packages/ui/src/button.ts templates/client/src/App.vue
44
- ```
45
-
46
- 它解决的是 monorepo 里常见的问题:一个提交只改了某个包,不应该让所有 Vue 和 TypeScript workspace 都重复跑类型检查。
47
-
48
- ## 4. pre-push
49
-
50
- `repo verify pre-push` 面向推送前的完整保护。默认策略是:
51
-
52
- | 阶段 | 行为 |
53
- | ------------ | ------------------------------------------------ |
54
- | 根任务 | 强制执行整仓 `lint` 与 `typecheck` |
55
- | 变更范围任务 | 按 workspace 改动范围补跑 `build`、`test`、`tsd` |
56
- | 失败处理 | 任一任务失败时停止并返回失败状态 |
20
+ ## Pre-Commit
57
21
 
58
- 如果 CI 想要更明确地复现整仓校验,可以使用:
22
+ `repo verify pre-commit` runs the repository's staged-file policy. JavaScript, TypeScript, Vue, and style files are routed to the configured lint tasks.
59
23
 
60
- ```bash
61
- repo check --full
62
- ```
24
+ ## Staged Type Checking
63
25
 
64
- ## 5. commit message
26
+ `repo verify staged-typecheck <files...>` maps changed TypeScript and Vue files to their owning workspace. Vue packages use their `vue-tsc` based typecheck script; TypeScript packages use `tsc`.
65
27
 
66
- `repo verify commit-msg <file>` 用于 Git 的 `commit-msg` hook。未配置自定义命令时,它会执行:
28
+ ## Pre-Push
67
29
 
68
- ```bash
69
- pnpm exec commitlint --edit <file>
70
- ```
30
+ `repo verify pre-push` is the comprehensive delivery gate. The repository policy builds first, then runs lint, type checks, type-level tests, and test suites against built artifacts.
71
31
 
72
- 如果你只是手动验证当前提交信息,可以运行:
32
+ ## Automation
73
33
 
74
34
  ```bash
75
- repo check --edit-file .git/COMMIT_EDITMSG
35
+ repo check --full --dry-run --json --out reports/check-plan.json
36
+ repo check --staged --markdown --redact --out reports/check-plan.md
76
37
  ```
77
38
 
78
- ## 6. 选择建议
79
-
80
- | 场景 | 推荐命令 |
81
- | ------------------ | ------------------------------------------------- |
82
- | 本地提交前快速复现 | `repo check` |
83
- | lint-staged 调试 | `repo check --staged --dry-run` |
84
- | 推送前完整检查 | `repo check --full` |
85
- | CI 门禁 | `repo doctor --strict` 后接 `repo check --full` |
86
- | 只生成计划 | `repo check --json --out reports/check-plan.json` |
39
+ JSON field names and command IDs do not change with `--lang`; only human-readable descriptions do.
@@ -1,8 +1,8 @@
1
- # 命令速查
1
+ # Command Reference
2
2
 
3
- 这一页只保留 repoctl 高频、实用、容易记错的命令。
3
+ This page focuses on high-value repoctl commands and options.
4
4
 
5
- ## 最推荐入口
5
+ ## Main Entry
6
6
 
7
7
  ```bash
8
8
  pnpm exec repo init
@@ -12,7 +12,7 @@ pnpm exec repo new
12
12
  pnpm exec repo check
13
13
  ```
14
14
 
15
- 模板生成仓库里的推荐根脚本:
15
+ Generated repositories also expose:
16
16
 
17
17
  ```bash
18
18
  pnpm run repo:init
@@ -31,31 +31,20 @@ repo init --preset standard --force
31
31
  repo init --overwrite
32
32
  ```
33
33
 
34
- 用途:
35
-
36
- - 初始化当前 workspace 的推荐默认值。
37
- - 默认不覆盖已有 README、package.json、pnpm-workspace.yaml 和 tooling 配置。
38
- - 追加缺失的 `apps/*`、`packages/*`、`examples/*` workspace patterns。
39
- - `--yes` 用于 CI 或非 TTY 环境。
40
- - 需要重写受管理文件时显式传 `--force` 或 `--overwrite`。
34
+ Use it to initialize recommended workspace defaults. It skips existing managed files by default, appends missing workspace patterns, and supports non-interactive CI usage with `--yes`.
41
35
 
42
36
  ## `repo doctor`
43
37
 
44
38
  ```bash
45
39
  repo doctor
46
40
  repo doctor --strict
47
- repo doctor --json
48
41
  repo doctor --json --out reports/doctor.json
49
42
  repo doctor --markdown --redact --out reports/doctor.md
50
43
  ```
51
44
 
52
- 用途:
45
+ Use it to check root workspace files, Node compatibility, CLI dependency presence, `repo:*` root scripts, stale config files, and commit hooks.
53
46
 
54
- - 诊断当前目录是不是可直接开始使用的 monorepo 根目录。
55
- - 检查 Node 版本、workspace 文件、CLI 依赖、根脚本、遗留配置和提交链路。
56
- - `--strict` 会把 warning 也视为失败,适合 CI 门禁。
57
- - `--json` 和 `--markdown` 适合自动化、PR、issue 和外部协作。
58
- - `--redact` 会脱敏 workspace、cwd、home 等绝对路径。
47
+ `--strict` treats warnings as failures. `--redact` removes local absolute paths from shareable reports.
59
48
 
60
49
  ## `repo templates`
61
50
 
@@ -68,11 +57,7 @@ repo templates --json
68
57
  repo templates --markdown --out docs/templates.md
69
58
  ```
70
59
 
71
- 用途:
72
-
73
- - 查看内置模板 key、分类、默认生成目录和用途。
74
- - 检查模板元数据和源目录健康状态。
75
- - 给脚本读取 JSON,或生成 Markdown 文档片段。
60
+ Use it to discover built-in template keys, inspect metadata, verify template health, or generate machine-readable output.
76
61
 
77
62
  ## `repo new`
78
63
 
@@ -84,12 +69,7 @@ repo new docs --template vitepress --dry-run
84
69
  repo new docs --template vitepress --json --out plans/docs.json
85
70
  ```
86
71
 
87
- 用途:
88
-
89
- - 交互式或直接创建新的 package、app、service、docs 或 CLI。
90
- - `--dry-run` 只预览模板、目标目录、package name 和输出文件。
91
- - `--json` 输出结构化创建计划,隐含 `--dry-run`。
92
- - 显式传入的 `--template` 会先校验,拼错时会失败并提示相近 key。
72
+ Use it to create packages and apps. Explicit template keys are validated first; invalid keys fail with suggestions instead of silently falling back.
93
73
 
94
74
  ## `repo check`
95
75
 
@@ -103,13 +83,7 @@ repo check --json --out reports/check-plan.json
103
83
  repo check --markdown --redact --out reports/check-plan.md
104
84
  ```
105
85
 
106
- 用途:
107
-
108
- - 运行推荐的本地校验入口。
109
- - `--staged` 偏 pre-commit。
110
- - `--full` 偏 pre-push。
111
- - `--edit-file` 用于 commit message 校验。
112
- - `--dry-run` 只预览将要执行的校验。
86
+ Use it to preview or run the recommended local verification flow. `--staged` is closer to pre-commit; `--full` is closer to pre-push.
113
87
 
114
88
  ## `repo upgrade`
115
89
 
@@ -123,15 +97,9 @@ repo upgrade -i
123
97
  repo upgrade -s
124
98
  ```
125
99
 
126
- 用途:
100
+ Use it to sync standard assets and scripts. `--core` skips GitHub-related assets. `--no-overwrite` preserves changed files.
127
101
 
128
- - 同步仓库标准资产与脚本。
129
- - `--core` 只同步核心配置,跳过 GitHub 相关资产。
130
- - `-i` 交互式选择。
131
- - `--no-overwrite` / `-s` 保留已有 drifted 文件。
132
- - `--yes` / `--overwrite` 非交互覆盖 drifted 标准资产。
133
-
134
- ## 分组命令
102
+ ## Grouped Commands
135
103
 
136
104
  ```bash
137
105
  repo ws ls
@@ -145,24 +113,8 @@ repo config inspect
145
113
  repo skills sync --codex
146
114
  ```
147
115
 
148
- 分组命令适合维护者和自动化脚本。日常开发优先使用顶层命令。
149
-
150
- ## 输出参数速查
151
-
152
- | 参数 | 适用命令 | 说明 |
153
- | -------------- | -------------------------------------------- | ------------------------------------- |
154
- | `--json` | `doctor`、`check`、`templates`、`new`、`env` | 输出机器可读数据 |
155
- | `--markdown` | `doctor`、`check`、`templates`、`env` | 输出适合 PR 和 issue 的 Markdown |
156
- | `--out <file>` | 多数报告和计划命令 | 写入文件,便于 CI artifact 或脚本读取 |
157
- | `--redact` | `doctor`、`check`、`env` | 分享报告前脱敏本机路径 |
158
- | `--strict` | `doctor`、`env snapshot`、`env support` | warning 也会导致失败 |
159
- | `--dry-run` | `check`、`new` | 只看计划,不执行校验或写入文件 |
160
-
161
- ## 继续阅读
116
+ ## Keep Reading
162
117
 
163
- - [执行模型](./execution-model.md)
164
- - [校验链路](./checks.md)
165
- - [doctor 诊断](./doctor.md)
166
- - [工作流与 CI](./workflows.md)
167
- - [报告与自动化输出](./reports.md)
168
- - [命令别名](./aliases.md)
118
+ - [Workflows and CI](./workflows.md)
119
+ - [Troubleshooting](./troubleshooting.md)
120
+ - [Command Aliases](./aliases.md)
@@ -1,16 +1,14 @@
1
- # 配置文件
1
+ # Configuration
2
2
 
3
- repoctl 推荐在仓库根目录使用一个配置文件:
3
+ repoctl recommends one root config file:
4
4
 
5
5
  ```txt
6
6
  repoctl.config.ts
7
7
  ```
8
8
 
9
- `monorepo.config.ts` 已不再作为运行时配置入口。迁移旧仓库时请改名为 `repoctl.config.ts`。
9
+ `monorepo.config.ts` is no longer loaded at runtime. Rename it to `repoctl.config.ts` before running repoctl.
10
10
 
11
- repoctl 支持 `ts`、`mts`、`cts`、`js`、`mjs`、`cjs` 等配置文件后缀。新项目优先使用 `repoctl.config.ts`,这样能保留类型提示和更清晰的迁移路径。
12
-
13
- ## 最小配置
11
+ ## Minimal Config
14
12
 
15
13
  ```ts
16
14
  import { defineMonorepoConfig } from 'repoctl'
@@ -24,15 +22,13 @@ export default defineMonorepoConfig({
24
22
  })
25
23
  ```
26
24
 
27
- 设置 `commands.create.defaultTemplate` 后:
25
+ After setting `commands.create.defaultTemplate`, this command can create a package without asking for the template:
28
26
 
29
27
  ```bash
30
28
  repo new utils
31
29
  ```
32
30
 
33
- 会直接按默认模板创建,不再询问模板类型。
34
-
35
- ## 常用配置
31
+ ## Common Config
36
32
 
37
33
  ```ts
38
34
  import { defineMonorepoConfig } from 'repoctl'
@@ -55,14 +51,14 @@ export default defineMonorepoConfig({
55
51
  })
56
52
  ```
57
53
 
58
- | 配置 | 作用 |
59
- | --------------------------------- | --------------------------------------- |
60
- | `commands.init.preset` | 控制初始化默认预设 |
61
- | `commands.create.defaultTemplate` | 控制 `repo new <name>` 的默认模板 |
62
- | `commands.clean.autoConfirm` | 清理命令是否默认确认 |
63
- | `commands.upgrade.skipOverwrite` | 同步标准资产时是否保留已有 drifted 文件 |
54
+ | Option | Purpose |
55
+ | --------------------------------- | ----------------------------------------------- |
56
+ | `commands.init.preset` | Default setup preset |
57
+ | `commands.create.defaultTemplate` | Default template for `repo new <name>` |
58
+ | `commands.clean.autoConfirm` | Whether clean commands confirm by default |
59
+ | `commands.upgrade.skipOverwrite` | Whether upgrade preserves changed managed files |
64
60
 
65
- ## 查看当前配置
61
+ ## Inspect Config
66
62
 
67
63
  ```bash
68
64
  repo config inspect
@@ -70,21 +66,4 @@ repo cfg i --json --out reports/config.json
70
66
  repo cfg i --markdown --redact --out reports/config.md
71
67
  ```
72
68
 
73
- `--redact` 适合把报告发到 issue、PR 或外部协作渠道。
74
-
75
- ## 配置的定位
76
-
77
- 配置文件只负责团队默认值,不建议把一次性命令参数都写进去。
78
-
79
- 推荐做法:
80
-
81
- - 团队长期一致的选择写进 `repoctl.config.ts`。
82
- - 临时行为用命令参数表达,例如 `--dry-run`、`--json`、`--out`。
83
- - 自动化脚本优先使用显式参数,减少隐藏状态。
84
-
85
- ## 继续阅读
86
-
87
- - [执行模型](./execution-model.md)
88
- - [模板与创建](./templates.md)
89
- - [模板资产治理](./template-assets.md)
90
- - [报告与自动化输出](./reports.md)
69
+ Use `--redact` before sharing reports in issues, PRs, or external support channels.
@@ -1,86 +1,46 @@
1
1
  ---
2
- description: 说明 repoctl doctor 的检查项、状态含义、strict 模式和修复建议。
2
+ outline: deep
3
3
  ---
4
4
 
5
- # repoctl doctor 诊断
5
+ # repoctl Doctor
6
6
 
7
- `repo doctor` 用来判断当前目录是不是一个可维护、可开发、可接入 repoctl 工作流的 pnpm monorepo 根目录。
7
+ `repo doctor` diagnoses whether the current pnpm workspace is ready for development and release. It does not rewrite files.
8
8
 
9
- ## 1. 状态含义
9
+ ## Statuses
10
10
 
11
- | 状态 | 含义 | 对退出码的影响 |
12
- | ------ | -------------- | ----------------------------- |
13
- | `pass` | 检查通过 | 不影响 |
14
- | `warn` | 存在建议修复项 | 默认不失败,`--strict` 下失败 |
15
- | `fail` | 阻塞项 | 命令返回失败状态 |
11
+ - `pass`: the check is satisfied.
12
+ - `warn`: the repository works, but maintenance or consistency needs attention.
13
+ - `fail`: a required workspace contract is missing or invalid.
16
14
 
17
- CI 中推荐使用:
15
+ ## Checks
18
16
 
19
- ```bash
20
- repo doctor --strict
21
- ```
17
+ Doctor covers the root `package.json`, `pnpm-workspace.yaml`, Node compatibility, the `repoctl` dependency, recommended `repo:*` scripts, `repoctl.config.ts`, commit hooks, workspace pattern coverage, tooling imports, and release configuration.
22
18
 
23
- 这样 warning 不会长期堆积成隐性风险。
19
+ Check IDs and JSON fields remain stable in every locale.
24
20
 
25
- ## 2. 核心检查项
26
-
27
- | 检查项 | 通过标准 | 常见修复 |
28
- | ---------------------------- | ---------------------------------------------------------------- | ---------------------------- |
29
- | `package-json` | 当前 workspace 根目录存在 `package.json` | 回到仓库根目录或先初始化项目 |
30
- | `workspace-manifest` | 存在 `pnpm-workspace.yaml` | `repo init --yes` |
31
- | `node-version` | 当前 Node 满足 `engines.node` | 切换 Node 版本或补充 engines |
32
- | `tool-package` | 根依赖包含 `repoctl` | `pnpm add -D repoctl` |
33
- | `root-scripts` | 存在 `repo:init`、`repo:new`、`repo:check`、`repo:doctor` 根脚本 | `repo init --yes` |
34
- | `config-file` | 使用 `repoctl.config.ts`,且没有残留 `monorepo.config.ts` | 保留 `repoctl.config.ts` |
35
- | `commit-hooks` | Husky 和 lint-staged 同时就绪 | `repo upgrade --yes` |
36
- | `tooling-imports` | 配置不再引用本地源码 loader 或旧 config wrapper | `repo upgrade --yes` |
37
- | `workspace-patterns` | 常见目录被 workspace patterns 覆盖 | `repo init --yes` |
38
- | `workspace-package-coverage` | 常见目录下的包都被 pnpm 覆盖 | `repo init --yes` |
39
-
40
- ## 3. 输出报告
21
+ ## Reports
41
22
 
42
23
  ```bash
43
- repo doctor
44
24
  repo doctor --json
45
- repo doctor --markdown --redact
46
- repo doctor --json --out reports/doctor.json
25
+ repo doctor --markdown
47
26
  repo doctor --markdown --redact --out reports/doctor.md
48
27
  ```
49
28
 
50
- 自动化脚本推荐使用 `pnpm run repo:doctor -- --json` 或 `pnpm exec repo doctor --json`。
51
-
52
- | 输出 | 适合场景 |
53
- | ------------ | --------------------------- |
54
- | 默认交互文本 | 本地直接阅读 |
55
- | JSON | CI、编辑器、脚本消费 |
56
- | Markdown | 粘贴到 issue、PR 或排障文档 |
57
- | `--redact` | 分享报告前隐藏本机绝对路径 |
29
+ `--redact` replaces workspace, current-directory, and home paths before output is shared.
58
30
 
59
- ## 4. strict 模式
60
-
61
- `--strict` 会把 warning 也视为失败。它适合放在 CI 早期阶段:
31
+ ## Strict Mode
62
32
 
63
33
  ```bash
64
- pnpm install --frozen-lockfile
65
34
  repo doctor --strict
66
- repo check --full
67
35
  ```
68
36
 
69
- 如果你正在接入存量仓库,建议先不用 strict,把报告保存下来逐项修复:
37
+ Normal mode exits non-zero for failures. Strict mode also treats warnings as blocking, which is useful for CI policy enforcement.
38
+
39
+ ## Language
70
40
 
71
41
  ```bash
72
- repo doctor --markdown --redact --out reports/doctor.md
73
- repo upgrade --no-overwrite
74
- repo doctor
42
+ repo --lang zh-CN doctor
43
+ REPOCTL_LANG=zh-CN repo doctor
75
44
  ```
76
45
 
77
- ## 5. 排查顺序
78
-
79
- 建议按阻塞程度处理:
80
-
81
- 1. 先处理 `fail`,否则命令或 CI 很可能无法继续。
82
- 2. 再处理遗留配置和 Node 版本问题。
83
- 3. 然后补根脚本、hook 和 lint-staged。
84
- 4. 最后整理 workspace patterns 与 tooling imports。
85
-
86
- 如果不确定报告能否安全分享,使用 [报告与自动化输出](./reports.md) 里的 `--redact` 和 `env support`。
46
+ The explicit option wins over `REPOCTL_LANG`; English is the fixed fallback.
@@ -1,81 +1,28 @@
1
1
  ---
2
- description: 说明 repoctl CLI 的入口层级、命令懒加载、非交互输出和脚本集成方式。
2
+ outline: deep
3
3
  ---
4
4
 
5
- # repoctl 执行模型
5
+ # repoctl Execution Model
6
6
 
7
- repoctl 的核心设计是把日常入口保持短,把细粒度能力放到分组命令里,并让 CI、编辑器和脚本可以读取结构化输出。
7
+ repoctl is a task layer over pnpm, Turborepo, repository scripts, and managed assets. It coordinates those systems without replacing them.
8
8
 
9
- ## 1. 入口层级
9
+ ## Entrypoints
10
10
 
11
- | 层级 | 示例 | 使用场景 |
12
- | ----------- | ------------------------------------------------------------------ | ------------------------------ |
13
- | 根脚本 | `pnpm run repo:doctor`、`pnpm run repo:new`、`pnpm run repo:check` | 团队日常开发、README、贡献指南 |
14
- | `repo` 命令 | `pnpm exec repo doctor` | 文档、CI、脚本、排障 |
15
- | 分组命令 | `repo env support`、`repo verify pre-push` | 维护者、自动化和集成工具 |
11
+ The recommended binary is `repo`. `repoctl` is an equivalent public bin. Generated workspaces also expose `repo:init`, `repo:new`, `repo:doctor`, and `repo:check` root scripts.
16
12
 
17
- ## 2. 命令执行过程
13
+ ## Command Lifecycle
18
14
 
19
- repoctl 启动时只注册命令树。具体实现会在 action 执行时再加载,因此查看帮助和列出命令不会提前扫描所有 workspace、Git 状态和模板文件。
15
+ 1. Resolve locale from `--lang`, then `REPOCTL_LANG`, then English.
16
+ 2. Find the pnpm workspace root and load `repoctl.config.ts` when present.
17
+ 3. Build a deterministic plan from workspace state and command options.
18
+ 4. Prompt only when the terminal is interactive and the command needs a choice.
19
+ 5. Execute the plan or emit text, Markdown, or JSON output.
20
+ 6. Set a non-zero exit code for blocking diagnostics or command failures.
20
21
 
21
- ```txt
22
- repo --help
23
- -> 注册命令树
24
- -> 输出帮助
22
+ ## Output Contracts
25
23
 
26
- repo doctor
27
- -> 注册命令树
28
- -> 加载 doctor 实现
29
- -> 发现 workspace
30
- -> 输出诊断报告
31
- ```
24
+ Text and Markdown are localized. JSON keys, status values, check IDs, command names, and option names are stable across locales.
32
25
 
33
- 这种模型适合命令数量较多的 monorepo 工具:日常命令保持快,重逻辑只在真正执行时进入。
26
+ ## Configuration
34
27
 
35
- ## 3. 输出模式
36
-
37
- 很多 repoctl 命令都同时服务人和机器:
38
-
39
- | 参数 | 行为 | 典型用途 |
40
- | -------------- | -------------------------------- | ------------------------ |
41
- | `--json` | 输出结构化 JSON | CI、编辑器、脚本 |
42
- | `--markdown` | 输出 Markdown 报告 | issue、PR、协作文档 |
43
- | `--out <file>` | 写入文件 | 保存 artifact 或生成计划 |
44
- | `--redact` | 脱敏 cwd、workspace、home 等路径 | 分享本机报告 |
45
- | `--dry-run` | 只生成计划,不写入业务文件 | 审查创建和校验动作 |
46
-
47
- `--json`、`--markdown`、`--out` 在 `repo check` 和 `repo new` 这类命令里会隐含预览语义,避免自动化读取计划时意外执行写入。
48
-
49
- ## 4. 失败状态
50
-
51
- repoctl 的失败状态遵循阻塞优先:
52
-
53
- | 命令 | 什么时候失败 |
54
- | ------------------------ | ----------------------------------------------------- |
55
- | `repo doctor` | 存在 `fail` 检查项;加 `--strict` 时 warning 也会失败 |
56
- | `repo templates --check` | 模板健康检查出现 fail |
57
- | `repo new` | 模板不存在、目标校验失败或写入失败 |
58
- | `repo check --full` | 任一 root script 校验失败 |
59
- | `repo verify *` | 对应 hook 或校验命令失败 |
60
-
61
- 如果只是想知道会发生什么,先加 `--dry-run` 或输出计划:
62
-
63
- ```bash
64
- repo new docs --template vitepress --json --out plans/docs.json
65
- repo check --markdown --out reports/check-plan.md
66
- ```
67
-
68
- ## 5. 和配置文件的关系
69
-
70
- repoctl 会从 workspace 根目录加载 `repoctl.config.*`。`monorepo.config.*` 已不再加载。
71
-
72
- 配置加载后会影响具体命令,例如:
73
-
74
- | 配置区域 | 影响命令 |
75
- | ------------------ | ------------------------------------------------------------------- |
76
- | `commands.init` | `repo init` |
77
- | `commands.create` | `repo new` |
78
- | `commands.upgrade` | `repo upgrade` |
79
- | `tooling` | `repoctl/tooling` wrapper 生成的 ESLint、Vitest、lint-staged 等配置 |
80
-
81
- 更多配置示例见:[配置文件](./config.md)。
28
+ Configuration supplies repository defaults. Explicit CLI options take precedence. Non-interactive automation should use `--yes`, explicit template keys, and report output options instead of relying on prompts.