@icebreakers/monorepo-templates 1.1.0 → 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 (154) hide show
  1. package/README.md +12 -8
  2. package/README.zh-CN.md +16 -0
  3. package/assets/.changeset/ledger.yaml +25 -0
  4. package/assets/.github/ISSUE_TEMPLATE/config.yml +1 -1
  5. package/assets/AGENTS.md +4 -3
  6. package/assets/CONTRIBUTING.md +27 -2
  7. package/assets/SECURITY.md +12 -14
  8. package/assets/package.json +13 -4
  9. package/package.json +6 -4
  10. package/templates/cli/package.json +11 -4
  11. package/templates/client/package.json +17 -1
  12. package/templates/server/package.json +11 -4
  13. package/templates/tsdown/package.json +11 -4
  14. package/templates/vitepress/.vitepress/config.ts +146 -165
  15. package/templates/vitepress/ai/index.md +12 -23
  16. package/templates/vitepress/ai/llms-txt.md +13 -31
  17. package/templates/vitepress/getting-started.md +3 -32
  18. package/templates/vitepress/index.md +27 -30
  19. package/templates/vitepress/knowledge/index.md +17 -41
  20. package/templates/vitepress/monorepo/commands.md +13 -18
  21. package/templates/vitepress/monorepo/index.md +22 -100
  22. package/templates/vitepress/monorepo/manage.md +15 -227
  23. package/templates/vitepress/monorepo/publish.md +15 -70
  24. package/templates/vitepress/monorepo/templates.md +10 -17
  25. package/templates/vitepress/monorepo/troubleshooting.md +13 -16
  26. package/templates/vitepress/package.json +10 -4
  27. package/templates/vitepress/public/_redirects +3 -0
  28. package/templates/vitepress/repoctl/adopt-existing.md +51 -53
  29. package/templates/vitepress/repoctl/aliases.md +18 -18
  30. package/templates/vitepress/repoctl/checks.md +21 -68
  31. package/templates/vitepress/repoctl/commands.md +16 -64
  32. package/templates/vitepress/repoctl/config.md +14 -35
  33. package/templates/vitepress/repoctl/doctor.md +20 -60
  34. package/templates/vitepress/repoctl/execution-model.md +16 -69
  35. package/templates/vitepress/repoctl/getting-started.md +34 -40
  36. package/templates/vitepress/repoctl/index.md +33 -61
  37. package/templates/vitepress/repoctl/reports.md +20 -74
  38. package/templates/vitepress/repoctl/scenarios.md +26 -28
  39. package/templates/vitepress/repoctl/template-assets.md +19 -88
  40. package/templates/vitepress/repoctl/templates.md +50 -81
  41. package/templates/vitepress/repoctl/troubleshooting.md +32 -46
  42. package/templates/vitepress/repoctl/workflows.md +38 -67
  43. package/templates/vitepress/thinking.md +4 -85
  44. package/templates/vitepress/tools/changeset.md +9 -59
  45. package/templates/vitepress/tools/husky.md +6 -124
  46. package/templates/vitepress/tools/index.md +13 -32
  47. package/templates/vitepress/tools/lint-staged.md +5 -96
  48. package/templates/vitepress/tools/llms-txt.md +4 -6
  49. package/templates/vitepress/tools/pnpm.md +7 -119
  50. package/templates/vitepress/tools/renovate.md +3 -87
  51. package/templates/vitepress/tools/turborepo.md +5 -157
  52. package/templates/vitepress/why/how-to-reuse-js-code.md +6 -247
  53. package/templates/vitepress/why/index.md +14 -1
  54. package/templates/vitepress/why/js-cjs-mjs.md +9 -96
  55. package/templates/vitepress/why/js-keywords.md +4 -129
  56. package/templates/vitepress/why/modern/bundlers.md +3 -50
  57. package/templates/vitepress/why/modern/dts.md +4 -90
  58. package/templates/vitepress/why/modern/esm-vs-cjs.md +4 -81
  59. package/templates/vitepress/why/modern/index.md +10 -51
  60. package/templates/vitepress/why/modern/package-entry-points.md +6 -117
  61. package/templates/vitepress/why/modern/typescript.md +4 -152
  62. package/templates/vitepress/why/publish-basic-npm-package.md +17 -144
  63. package/templates/vitepress/why/what-is-npm-package.md +4 -159
  64. package/templates/vitepress/zh/ai/index.md +33 -0
  65. package/templates/vitepress/zh/ai/llms-txt.md +42 -0
  66. package/templates/vitepress/zh/getting-started.md +40 -0
  67. package/templates/vitepress/zh/index.md +66 -0
  68. package/templates/vitepress/zh/knowledge/index.md +50 -0
  69. package/templates/vitepress/zh/monorepo/commands.md +21 -0
  70. package/templates/vitepress/zh/monorepo/index.md +115 -0
  71. package/templates/vitepress/zh/monorepo/manage.md +243 -0
  72. package/templates/vitepress/zh/monorepo/publish.md +87 -0
  73. package/templates/vitepress/zh/monorepo/templates.md +21 -0
  74. package/templates/vitepress/zh/monorepo/troubleshooting.md +20 -0
  75. package/templates/vitepress/zh/repoctl/adopt-existing.md +135 -0
  76. package/templates/vitepress/{en → zh}/repoctl/aliases.md +18 -18
  77. package/templates/vitepress/zh/repoctl/checks.md +86 -0
  78. package/templates/vitepress/zh/repoctl/commands.md +168 -0
  79. package/templates/vitepress/zh/repoctl/config.md +90 -0
  80. package/templates/vitepress/zh/repoctl/doctor.md +86 -0
  81. package/templates/vitepress/zh/repoctl/execution-model.md +81 -0
  82. package/templates/vitepress/zh/repoctl/getting-started.md +122 -0
  83. package/templates/vitepress/zh/repoctl/index.md +102 -0
  84. package/templates/vitepress/zh/repoctl/reports.md +94 -0
  85. package/templates/vitepress/{en → zh}/repoctl/scenarios.md +28 -26
  86. package/templates/vitepress/zh/repoctl/template-assets.md +116 -0
  87. package/templates/vitepress/zh/repoctl/templates.md +159 -0
  88. package/templates/vitepress/zh/repoctl/troubleshooting.md +110 -0
  89. package/templates/vitepress/zh/repoctl/workflows.md +118 -0
  90. package/templates/vitepress/zh/thinking.md +88 -0
  91. package/templates/vitepress/zh/tools/changeset.md +75 -0
  92. package/templates/vitepress/zh/tools/husky.md +130 -0
  93. package/templates/vitepress/zh/tools/index.md +38 -0
  94. package/templates/vitepress/zh/tools/lint-staged.md +103 -0
  95. package/templates/vitepress/zh/tools/llms-txt.md +9 -0
  96. package/templates/vitepress/zh/tools/pnpm.md +127 -0
  97. package/templates/vitepress/zh/tools/renovate.md +91 -0
  98. package/templates/vitepress/zh/tools/turborepo.md +166 -0
  99. package/templates/vitepress/zh/why/assets/npm-dt.svg +15 -0
  100. package/templates/vitepress/zh/why/assets/npm-ts.svg +19 -0
  101. package/templates/vitepress/zh/why/examples/0.npm-basic-package/index.js +10 -0
  102. package/templates/vitepress/zh/why/examples/0.npm-basic-package/package.json +11 -0
  103. package/templates/vitepress/zh/why/examples/1.npm-basic-package/index.cjs +12 -0
  104. package/templates/vitepress/zh/why/examples/1.npm-basic-package/index.d.ts +1 -0
  105. package/templates/vitepress/zh/why/examples/1.npm-basic-package/index.js +8 -0
  106. package/templates/vitepress/zh/why/examples/1.npm-basic-package/package.json +19 -0
  107. package/templates/vitepress/zh/why/examples/2.npm-basic-package/README.md +1 -0
  108. package/templates/vitepress/zh/why/examples/2.npm-basic-package/package-lock.json +30 -0
  109. package/templates/vitepress/zh/why/examples/2.npm-basic-package/package.json +35 -0
  110. package/templates/vitepress/zh/why/examples/2.npm-basic-package/rename-ext.js +24 -0
  111. package/templates/vitepress/zh/why/examples/2.npm-basic-package/src/index.ts +8 -0
  112. package/templates/vitepress/zh/why/examples/2.npm-basic-package/tsconfig.cjs.json +8 -0
  113. package/templates/vitepress/zh/why/examples/2.npm-basic-package/tsconfig.esm.json +7 -0
  114. package/templates/vitepress/zh/why/examples/2.npm-basic-package/tsconfig.json +18 -0
  115. package/templates/vitepress/zh/why/examples/3.npm-basic-package/README.md +1 -0
  116. package/templates/vitepress/zh/why/examples/3.npm-basic-package/package-lock.json +1496 -0
  117. package/templates/vitepress/zh/why/examples/3.npm-basic-package/package.json +31 -0
  118. package/templates/vitepress/zh/why/examples/3.npm-basic-package/src/index.ts +8 -0
  119. package/templates/vitepress/zh/why/examples/3.npm-basic-package/tsconfig.json +16 -0
  120. package/templates/vitepress/zh/why/examples/3.npm-basic-package/tsdown.config.ts +16 -0
  121. package/templates/vitepress/zh/why/examples/usage-cjs/cjs.cjs +4 -0
  122. package/templates/vitepress/zh/why/examples/usage-cjs/esm.mjs +4 -0
  123. package/templates/vitepress/zh/why/examples/usage-cjs/index.js +8 -0
  124. package/templates/vitepress/zh/why/examples/usage-cjs/package-lock.json +36 -0
  125. package/templates/vitepress/zh/why/examples/usage-cjs/package.json +20 -0
  126. package/templates/vitepress/zh/why/examples/usage-esm/cjs.cjs +4 -0
  127. package/templates/vitepress/zh/why/examples/usage-esm/createRequire.js +7 -0
  128. package/templates/vitepress/zh/why/examples/usage-esm/esm.mjs +4 -0
  129. package/templates/vitepress/zh/why/examples/usage-esm/index.js +8 -0
  130. package/templates/vitepress/zh/why/examples/usage-esm/package-lock.json +36 -0
  131. package/templates/vitepress/zh/why/examples/usage-esm/package.json +21 -0
  132. package/templates/vitepress/zh/why/how-to-reuse-js-code.md +250 -0
  133. package/templates/vitepress/zh/why/index.md +1 -0
  134. package/templates/vitepress/zh/why/js-cjs-mjs.md +99 -0
  135. package/templates/vitepress/zh/why/js-keywords.md +132 -0
  136. package/templates/vitepress/zh/why/modern/bundlers.md +52 -0
  137. package/templates/vitepress/zh/why/modern/dts.md +93 -0
  138. package/templates/vitepress/zh/why/modern/esm-vs-cjs.md +84 -0
  139. package/templates/vitepress/zh/why/modern/index.md +55 -0
  140. package/templates/vitepress/zh/why/modern/package-entry-points.md +128 -0
  141. package/templates/vitepress/zh/why/modern/typescript.md +155 -0
  142. package/templates/vitepress/zh/why/publish-basic-npm-package.md +146 -0
  143. package/templates/vitepress/zh/why/what-is-npm-package.md +162 -0
  144. package/templates/vue-lib/package.json +12 -5
  145. package/templates/vitepress/en/index.md +0 -63
  146. package/templates/vitepress/en/knowledge/monorepo.md +0 -37
  147. package/templates/vitepress/en/repoctl/adopt-existing.md +0 -133
  148. package/templates/vitepress/en/repoctl/commands.md +0 -120
  149. package/templates/vitepress/en/repoctl/config.md +0 -69
  150. package/templates/vitepress/en/repoctl/getting-started.md +0 -116
  151. package/templates/vitepress/en/repoctl/index.md +0 -74
  152. package/templates/vitepress/en/repoctl/templates.md +0 -128
  153. package/templates/vitepress/en/repoctl/troubleshooting.md +0 -96
  154. package/templates/vitepress/en/repoctl/workflows.md +0 -89
@@ -1,50 +1,26 @@
1
1
  ---
2
- description: repoctl 文档站的知识库入口,汇总 monorepo 管理、现代 npm 包和 JavaScript 模块化基础。
2
+ outline: deep
3
3
  ---
4
4
 
5
- # 知识库
5
+ # Knowledge Base
6
6
 
7
- 知识库用于解释 repoctl 背后的工程背景。这里不放命令速查,而是回答为什么要这样组织仓库、包、构建和发布流程。
7
+ This section explains the engineering decisions behind repoctl rather than only listing commands.
8
8
 
9
- ## 1. monorepo 主题
9
+ ## Monorepo Topics
10
10
 
11
- | 页面 | 适合解决的问题 |
12
- | -------------------------------------------------- | ---------------------------------- |
13
- | [为什么往 monorepo 方向演进](../monorepo/index.md) | 判断多包仓库是否值得合并管理 |
14
- | [如何管理 monorepo](../monorepo/manage.md) | 理解 workspace、任务编排和依赖边界 |
15
- | [发包与变更日志](../monorepo/publish.md) | 设计 pnpm intent、版本和发布链路 |
16
- | [monorepo 命令参考](../monorepo/commands.md) | 查看通用 monorepo 操作命令 |
17
- | [monorepo 模板体系](../monorepo/templates.md) | 理解模板如何减少重复初始化 |
18
- | [monorepo 排障](../monorepo/troubleshooting.md) | 排查依赖、构建、类型和发布问题 |
11
+ - [Why Monorepo](../monorepo/index.md)
12
+ - [Managing A Monorepo](../monorepo/manage.md)
13
+ - [Publishing and Changelogs](../monorepo/publish.md)
14
+ - [Command Reference](../monorepo/commands.md)
15
+ - [Template Systems](../monorepo/templates.md)
16
+ - [Troubleshooting](../monorepo/troubleshooting.md)
19
17
 
20
- ## 2. 现代 npm 包主题
18
+ ## Modern Package Topics
21
19
 
22
- | 页面 | 适合解决的问题 |
23
- | ------------------------------------------------------ | ---------------------------------- |
24
- | [如何复用 js 代码](../why/how-to-reuse-js-code.md) | 从复制文件演进到发布包 |
25
- | [什么是 npm 包](../why/what-is-npm-package.md) | 理解 package.json、入口和安装方式 |
26
- | [如何发布 npm 包](../why/publish-basic-npm-package.md) | 走通最小 npm 发布流程 |
27
- | [改进并发布现代 npm 包](../why/index.md) | 把普通包升级成更规范的现代包 |
28
- | [现代包指南](../why/modern/index.md) | 汇总类型、入口、模块格式和构建工具 |
20
+ - [Reusing JavaScript Code](../why/how-to-reuse-js-code.md)
21
+ - [JavaScript Module Extensions](../why/js-cjs-mjs.md)
22
+ - [What Is An npm Package?](../why/what-is-npm-package.md)
23
+ - [Publishing An npm Package](../why/publish-basic-npm-package.md)
24
+ - [Modern Package Guide](../why/modern/index.md)
29
25
 
30
- ## 3. 阅读顺序
31
-
32
- 如果你第一次接触 monorepo,建议按下面顺序阅读:
33
-
34
- ```txt
35
- 为什么 monorepo
36
- -> 如何管理 monorepo
37
- -> 什么是 npm 包
38
- -> 现代包指南
39
- -> 发包与变更日志
40
- ```
41
-
42
- 如果你已经在维护仓库,可以直接从具体问题进入:
43
-
44
- | 你遇到的问题 | 建议入口 |
45
- | ----------------------------- | ----------------------------------------------- |
46
- | workspace 包互相引用不清楚 | [如何管理 monorepo](../monorepo/manage.md) |
47
- | 不确定 CJS、ESM、types 怎么配 | [现代包指南](../why/modern/index.md) |
48
- | 发布后使用方拿不到类型 | [类型声明](../why/modern/dts.md) |
49
- | 包入口太多、导入路径混乱 | [包入口](../why/modern/package-entry-points.md) |
50
- | CI 和发版流程容易漂移 | [发包与变更日志](../monorepo/publish.md) |
26
+ Start with the repoctl guide when you need an action. Use this knowledge base when you need to understand the tradeoffs behind that action.
@@ -1,21 +1,16 @@
1
- # 命令速查
1
+ # Monorepo Command Reference
2
2
 
3
- repoctl 现在是这套文档的主线。完整命令说明请阅读:
3
+ | Task | Command |
4
+ | ------------------------------ | ---------------------- |
5
+ | Initialize repository defaults | `repo init` |
6
+ | Diagnose workspace state | `repo doctor` |
7
+ | Create a package or app | `repo new` |
8
+ | Preview or run verification | `repo check` |
9
+ | Synchronize managed assets | `repo upgrade` |
10
+ | List workspace packages | `repo ws ls` |
11
+ | Initialize tooling configs | `repo tg init --all` |
12
+ | Run pre-push verification | `repo verify pre-push` |
4
13
 
5
- - [repoctl 命令速查](../repoctl/commands.md)
6
- - [repoctl 模板与创建](../repoctl/templates.md)
7
- - [repoctl 排障与报告](../repoctl/troubleshooting.md)
14
+ One command layer matters because scripts, documentation, CI, and contributor expectations otherwise drift independently. repoctl keeps task names stable while pnpm and Turborepo continue to perform dependency installation and task execution.
8
15
 
9
- ## monorepo 知识点:为什么要统一命令入口
10
-
11
- monorepo 的难点通常不是“能不能跑某个工具”,而是团队成员是否能稳定地用同一套入口完成日常动作。
12
-
13
- repoctl 把命令分成三层:
14
-
15
- | 层级 | 示例 | 适合场景 |
16
- | -------- | -------------------------------------------- | -------------------- |
17
- | 根脚本 | `pnpm run repo:doctor` / `pnpm run repo:new` | 日常开发和团队教程 |
18
- | 主 CLI | `pnpm exec repo doctor` | CI、脚本、排障和文档 |
19
- | 分组命令 | `repo ws ls` / `repo env support` | 维护者和自动化 |
20
-
21
- 保留这个旧页面,是为了让已有链接继续可用,同时把读者导向新的 repoctl 命令文档。
16
+ See the complete [repoctl command reference](../repoctl/commands.md).
@@ -1,115 +1,37 @@
1
- # 为什么往 monorepo 方向演进
1
+ # Why Monorepo
2
2
 
3
- 选择 monorepo,不是为了“更先进”,而是为了把多包协作里最常见的重复劳动砍掉。
3
+ This project uses monorepo practices because multiple packages, applications, CLIs, and docs sites usually share the same engineering rules.
4
4
 
5
- 当你的仓库里同时存在应用、类库、CLI、文档站,或者多个团队要共享同一套类型、配置、脚手架时,monorepo 的收益会很快超过它的管理成本。
5
+ The goal is not to make the repository look more complex. The goal is to reduce repeated setup work.
6
6
 
7
- ## 这套模板解决的真实问题
7
+ ## Problems A Monorepo Solves
8
8
 
9
- ### 1. 依赖和脚本不再分散
9
+ ### Shared Tooling
10
10
 
11
- 在 polyrepo 里,最常见的问题不是代码本身,而是:
11
+ In separate repositories, each package tends to maintain its own lint, typecheck, test, release, and commit setup. That makes upgrades slow and inconsistent.
12
12
 
13
- - 每个仓库都要单独装依赖
14
- - 每个仓库都维护一套 lint / typecheck / test 脚本
15
- - 同样的工具链升级要重复做很多次
16
- - 团队成员很难判断哪个仓库的规范才是“当前标准”
13
+ In a pnpm workspace, those rules can be centralized at the root and reused by every package.
17
14
 
18
- 在 monorepo 里,这些东西可以收敛到一个根目录。
15
+ ### Atomic Cross-Package Changes
19
16
 
20
- ### 2. 跨包改动可以原子提交
17
+ When one type change affects a library, an app, and a CLI, a monorepo lets you update, verify, review, and revert that change together.
21
18
 
22
- 如果一个接口变更同时影响:
19
+ ### Incremental Builds
23
20
 
24
- - `packages/types`
25
- - `packages/sdk`
26
- - `apps/web`
27
- - `apps/server`
21
+ pnpm handles workspace dependencies. Turborepo coordinates tasks and caching. Together they make it practical to run build, lint, test, and typecheck flows across many packages.
28
22
 
29
- 那么在 monorepo 里,一次提交就能把它们一起改完、一起验证、一起回滚。对重构和版本审计都更友好。
23
+ ## Where repoctl Fits
30
24
 
31
- ### 3. 构建与测试更容易增量化
25
+ repoctl adds the missing workflow layer:
32
26
 
33
- `pnpm` 负责 workspace 依赖管理,`turborepo` 负责任务编排和缓存,结果就是:
27
+ - `repo init` aligns root scripts and standard files.
28
+ - `repo doctor` checks whether the workspace is ready.
29
+ - `repo new` creates packages and apps from known templates.
30
+ - `repo check` previews and runs local verification.
31
+ - `repo upgrade` syncs standard assets as the template evolves.
34
32
 
35
- - 没改动的包不需要重复构建
36
- - CI 可以按依赖图只跑受影响任务
37
- - 大仓库也能保持比较稳定的反馈速度
33
+ ## Keep Reading
38
34
 
39
- ## 这套模板的立场
40
-
41
- 这不是一个“什么都能配”的框架,而是一套偏实战、偏收敛的默认值:
42
-
43
- | 维度 | 默认选择 |
44
- | -------- | --------------------------------------- |
45
- | 包管理 | `pnpm workspace` |
46
- | 任务编排 | `turborepo` |
47
- | 语言 | TypeScript 优先 |
48
- | 校验链路 | ESLint + Stylelint + typecheck + Vitest |
49
- | 提交规范 | Husky + lint-staged + commitlint |
50
- | 发包 | pnpm versioning |
51
- | 命令入口 | `repo` 为主,`repoctl` 为完整包名入口 |
52
-
53
- 这些选择的目的只有一个:减少“每个项目重新想一遍”的成本。
54
-
55
- ## 什么时候适合用 monorepo
56
-
57
- 下面这些情况,适合直接上:
58
-
59
- - 你要同时维护多个 npm 包
60
- - 你有前后端、CLI、文档站共用一套类型或工具
61
- - 你希望升级脚本、工程化配置时一次同步全仓
62
- - 你有持续重构、跨包联动改动的需求
63
-
64
- 下面这些情况,不一定值得上:
65
-
66
- - 只有一个很小的应用,没有共享代码需求
67
- - 团队还没有接受统一规范的准备
68
- - 构建链路本身还不稳定,先统一仓库只会放大问题
69
-
70
- ## 模板提供的补位能力
71
-
72
- 单纯有 monorepo 还不够,真正难的是“如何让它易用”。这个模板多补了三层东西:
73
-
74
- ### 1. 更短的日常命令
75
-
76
- ```bash
77
- pnpm exec repo init
78
- pnpm exec repo doctor
79
- pnpm run repo:new
80
- pnpm run repo:check
81
- ```
82
-
83
- 不用先背完整 CLI,先把日常路径跑顺。
84
-
85
- ### 2. `repo doctor` 这种面向新人的诊断命令
86
-
87
- 它会直接回答这些问题:
88
-
89
- - 你是不是站在仓库根目录
90
- - `pnpm-workspace.yaml` 在不在
91
- - Node 版本对不对
92
- - 有没有安装 CLI 依赖
93
- - 根脚本齐不齐
94
- - 是否仍残留已废弃的 `monorepo.config.ts`
95
- - Husky / lint-staged 链路是不是半残状态
96
-
97
- ### 3. `repo upgrade` 这种面向存量仓库的同步命令
98
-
99
- 当模板默认值变了,你不需要手抄配置,只要选择性同步标准资产。
100
-
101
- ## 实际收益通常体现在这里
102
-
103
- | 场景 | Polyrepo 常见成本 | Monorepo 常见收益 |
104
- | ------------ | ------------------ | ---------------------- |
105
- | 工具链升级 | 多仓重复改配置 | 一次升级,多包受益 |
106
- | 共享类型变更 | 多仓分别发版联调 | 一次改动,一次验证 |
107
- | CI 反馈 | 每仓重复跑全量 | 利用缓存和依赖图做增量 |
108
- | 新人接手 | 先理解多个仓库差异 | 先理解一套统一约定 |
109
-
110
- ## 继续阅读
111
-
112
- - [如何管理 monorepo](./manage.md)
113
- - [命令速查](./commands.md)
114
- - [排障指南](./troubleshooting.md)
115
- - [发包与变更日志](./publish.md)
35
+ - [repoctl Overview](../repoctl/index.md)
36
+ - [Command Reference](../repoctl/commands.md)
37
+ - [Templates](../repoctl/templates.md)
@@ -1,243 +1,31 @@
1
- # 如何管理 monorepo
1
+ # Managing A Monorepo
2
2
 
3
- 这一页是 repoctl 文档后面的知识库页面。它不再重新解释所有命令参数,而是解释:为什么这些命令能让 monorepo 日常管理变简单。
3
+ repoctl gives a pnpm and Turborepo workspace a predictable operating model without hiding the underlying tools.
4
4
 
5
- 如果你只想查命令,直接看 [repoctl 工作流与 CI](../repoctl/workflows.md) 或 [repoctl 命令速查](../repoctl/commands.md)。
6
-
7
- ## 先记住默认工作流
5
+ ## Daily Workflow
8
6
 
9
7
  ```bash
10
8
  pnpm install
11
- pnpm exec repo doctor
12
- pnpm run repo:new
9
+ pnpm run repo:doctor
10
+ pnpm run repo:new -- sdk
13
11
  pnpm run repo:check
14
12
  pnpm build
15
- ```
16
-
17
- 大多数场景里,这已经够了。
18
-
19
- 如果你在接入一个旧仓库,再多加一步:
20
-
21
- ```bash
22
- pnpm exec repo init
23
- ```
24
-
25
- 这个工作流背后的顺序是:
26
-
27
- | 阶段 | 目标 |
28
- | ---- | ------------------------------------------------ |
29
- | 安装 | 让 workspace 依赖和本地包链接完整 |
30
- | 诊断 | 先确认仓库结构、Node、脚本、配置和提交链路可用 |
31
- | 创建 | 用模板生成新包,减少手写 package metadata 和配置 |
32
- | 校验 | 在提交前复现默认 hook 和 workspace typecheck |
33
- | 构建 | 最后再跑更重的全仓任务 |
34
-
35
- ## 命令分层
36
-
37
- 这套模板故意把入口做得很少。
38
-
39
- ### 第一层:根脚本
40
-
41
- 这是最推荐的入口:
42
-
43
- ```bash
44
- pnpm exec repo init
45
- pnpm run repo:new
46
- pnpm exec repo doctor
47
- pnpm run repo:check
48
- ```
49
-
50
- 适合:
51
-
52
- - 新人
53
- - 日常开发
54
- - 文档教程
55
- - 团队内部统一约定
56
-
57
- ### 第二层:主 CLI
58
-
59
- 当你要明确告诉别人“这是 CLI 行为,不只是 package.json 脚本”时,用:
60
-
61
- ```bash
62
- pnpm exec repo init
63
- pnpm exec repo new
64
- pnpm exec repo doctor
65
- pnpm exec repo check
66
- pnpm exec repo upgrade
67
- ```
68
-
69
- ### 第三层:分组命令
70
-
71
- 更细的高级操作保留在分组里:
72
-
73
- ```bash
74
- repo workspace upgrade
75
- repo ws up
76
- repo tooling init eslint vitest
77
- repo tg init --all
78
- repo skills sync --codex
79
- repo ai prompt create --name checkout
80
- ```
81
-
82
- ## 日常任务对照表
83
-
84
- | 你想做什么 | 推荐命令 | 说明 |
85
- | ---------------------- | ------------------------------- | ---------------------------------------------------- |
86
- | 初始化一个刚接入的仓库 | `pnpm exec repo init` | 同步推荐的仓库元信息和基础工程化配置 |
87
- | 看仓库当前状态是否健康 | `pnpm exec repo doctor` | 先排根目录、Node、脚本、遗留配置、提交链路 |
88
- | 创建一个新的包或应用 | `pnpm run repo:new` | 支持交互式选择,也支持 `-- --template` |
89
- | 提交前做本地校验 | `pnpm run repo:check` | 默认对齐推荐 pre-commit / pre-push 逻辑 |
90
- | 同步模板最新标准资产 | `pnpm exec repo upgrade` | 适合模板升级、老仓库补齐 |
91
- | 清理演示仓库或非必要包 | `pnpm exec repo ws clean --yes` | 零安装也可以用 `pnpm dlx repo@latest ws clean --yes` |
92
-
93
- ## `doctor`、`check`、`upgrade` 的边界
94
-
95
- 这是最容易混淆的三个命令。
96
-
97
- ### `doctor`
98
-
99
- 偏“仓库体检”。
100
-
101
- 它不关心你当前改了什么代码,而是关心:
102
-
103
- - 这个仓库是不是完整
104
- - 当前目录是不是根目录
105
- - 当前机器的 Node 版本能不能跑
106
- - 命令入口和配置文件是不是一致
107
-
108
- ### `check`
109
-
110
- 偏“提交前校验”。
111
-
112
- 它更像一个人工触发的推荐检查入口,适合:
113
-
114
- - 提交前自查
115
- - 怀疑 lint / typecheck / hooks 有问题时快速复现
116
- - 用 `repo check --dry-run`、`repo check --json --out reports/check-plan.json` 或 `repo check --markdown --redact --out reports/check-plan.md` 先确认校验路由
117
-
118
- ### `upgrade`
119
-
120
- 偏“模板资产同步”。
121
-
122
- 它解决的是:
123
-
124
- - 模板最新默认脚本要不要补进来
125
- - 工作流、配置文件、GitHub 资产要不要同步
126
- - 存量仓库要不要追上现在的标准
127
-
128
- ## 配置推荐
129
-
130
- 推荐只保留一个文件:
131
-
132
- ```ts
133
- // repoctl.config.ts
134
- import { defineMonorepoConfig } from 'repoctl'
135
-
136
- export default defineMonorepoConfig({
137
- commands: {
138
- create: {
139
- defaultTemplate: 'tsdown',
140
- },
141
- clean: {
142
- autoConfirm: true,
143
- },
144
- upgrade: {
145
- skipOverwrite: true,
146
- },
147
- },
148
- })
149
- ```
150
-
151
- 说明:
152
-
153
- - 优先使用 `repoctl.config.ts`
154
- - `monorepo.config.ts` 已不再加载
155
- - 两者不能同时存在
156
-
157
- 如果同时存在,现在 CLI 会直接报错,`repo doctor` 也会把它判成阻塞项。
158
-
159
- ## `new` 的推荐用法
160
-
161
- ### 交互式
162
-
163
- ```bash
164
- pnpm run repo:new
165
- ```
166
-
167
- 适合第一次使用模板、想先看看有哪些模板可选。
168
-
169
- ### 直接指定模板
170
-
171
- ```bash
172
- pnpm exec repo new docs --template vitepress
173
- pnpm exec repo new sdk --template tsdown
174
- ```
175
-
176
- 适合你已经明确知道要创建什么。
177
-
178
- ### 固化团队默认模板
179
-
180
- ```ts
181
- import { defineMonorepoConfig } from 'repoctl'
182
-
183
- export default defineMonorepoConfig({
184
- commands: {
185
- create: {
186
- defaultTemplate: 'tsdown',
187
- },
188
- },
189
- })
190
- ```
191
-
192
- 设置后:
193
-
194
- ```bash
195
- pnpm exec repo new utils
196
- ```
197
-
198
- 会直接按默认模板生成,不再额外询问模板类型。
199
-
200
- ## 默认提交链路
201
-
202
- 如果你保留模板默认生成的 `.husky` 与 `lint-staged.config.js`,通常会得到这条链路:
203
-
204
- | 阶段 | 默认行为 |
205
- | ------------ | ----------------------------------------------------------------------- |
206
- | `pre-commit` | 聚焦 staged 文件运行 `stylelint`、`eslint`、workspace `typecheck` |
207
- | `pre-push` | 运行整仓 `lint`、`typecheck`,再补跑受影响包的 `build` / `test` / `tsd` |
208
-
209
- 这也是为什么:
210
-
211
- - `pnpm exec repo doctor` 会检查 Husky 与 lint-staged 是否同时存在
212
- - `pnpm run repo:check` 会成为最自然的人工入口
213
-
214
- ## 依赖与构建建议
215
-
216
- ```bash
217
- pnpm install
218
- pnpm up -rLi
219
- pnpm build
220
13
  pnpm test
221
14
  ```
222
15
 
223
- - `pnpm install`:统一安装 workspace 依赖
224
- - `pnpm up -rLi`:交互式升级依赖
225
- - `pnpm build` / `pnpm test`:让 Turborepo 帮你做任务编排与缓存
226
-
227
- ## 工具层 API 什么时候用
16
+ Use root `repo:*` scripts in team documentation, direct `repo` commands in automation, and grouped commands such as `repo ws ls` when maintainers need finer control.
228
17
 
229
- 如果你只是要使用默认 CLI,不需要直接碰 `@icebreakers/monorepo/tooling`。
18
+ ## Command Boundaries
230
19
 
231
- 只有下面两种情况建议直接使用:
20
+ - `doctor` reads repository state and reports drift.
21
+ - `check` previews or runs verification.
22
+ - `upgrade` synchronizes managed assets while preserving custom files by default.
23
+ - `new` creates packages and applications from the shared template registry.
232
24
 
233
- - 你要在仓库里手写 tooling wrapper 配置
234
- - 你在维护这套 CLI / 模板本身
25
+ ## Configuration
235
26
 
236
- 其余大多数团队,停留在 `repoctl.config.ts` 这一层就够了。
27
+ Store team defaults in `repoctl.config.ts`. Explicit CLI options override configuration, which keeps CI reproducible without making local interactive use verbose.
237
28
 
238
- ## 继续阅读
29
+ ## Dependency and Build Guidance
239
30
 
240
- - [repoctl 工作流与 CI](../repoctl/workflows.md)
241
- - [repoctl 命令速查](../repoctl/commands.md)
242
- - [repoctl 排障与报告](../repoctl/troubleshooting.md)
243
- - [发包与变更日志](./publish.md)
31
+ Keep shared dependency versions aligned through pnpm workspace policy. Let Turborepo model task dependencies and caching. Build publishable packages before testing their delivery artifacts.
@@ -1,87 +1,32 @@
1
- # monorepo 发包与变更日志
1
+ # Publishing and Changelogs
2
2
 
3
- 这套模板默认使用 pnpm 原生 versioning。它保留 Changesets 格式的变更意图,同时把版本计算、依赖传播、changelog 和发布收进 pnpm 本身。
3
+ repoctl coordinates release tasks with pnpm versioning. It does not replace the registry, GitHub Actions, or package build scripts.
4
4
 
5
- ## 日常流程
6
-
7
- 先完成质量校验,再记录变更:
5
+ ## Development Flow
8
6
 
9
7
  ```bash
10
- pnpm build
11
- pnpm lint
12
- pnpm typecheck
13
- pnpm tsd
14
- pnpm test
15
8
  pnpm change
16
9
  pnpm change status
10
+ repo release stable prepare
11
+ repo release stable publish
17
12
  ```
18
13
 
19
- 变更意图文件放在 `.changeset/*.md`,描述受影响包和 patch/minor/major。不要手动修改包版本。
20
-
21
- ## Release PR
22
-
23
- main push 会运行:
24
-
25
- ```bash
26
- pnpm version -r --dry-run
27
- pnpm version -r
28
- ```
29
-
30
- CI 将版本号、各包 `CHANGELOG.md` 和 `.changeset/ledger.yaml` 提交到 Release PR。合并 Release PR 后,下一次 main push 执行:
31
-
32
- ```bash
33
- pnpm publish -r --report-summary --provenance --no-git-checks
34
- ```
35
-
36
- pnpm 根据 registry 中已有的版本自动跳过已发布包。CI 读取 `pnpm-publish-summary.json` 创建 `package@version` tag 和 GitHub Release,发布操作可以安全重试。
14
+ Change intents record the affected package and release level. The release preparation step updates versions and repository changelogs; publish sends built packages to the configured registry.
37
15
 
38
- ## Workspace versioning 配置
16
+ ## Versioning Configuration
39
17
 
40
- 根 `pnpm-workspace.yaml` 中的关键配置:
18
+ Fixed groups and repository changelog storage live in `pnpm-workspace.yaml`. `repo doctor` reports missing or legacy release configuration.
41
19
 
42
- ```yaml
43
- versioning:
44
- fixed:
45
- - ['@icebreakers/monorepo', repoctl]
46
- ignore:
47
- - '@icebreakers/client'
48
- changelog:
49
- storage: repository
50
- ```
51
-
52
- `fixed` 保证组内包同版本;`ignore` 排除 private 包;`repository` 让 changelog 作为源代码提交。
53
-
54
- ## Prerelease lanes
55
-
56
- 预发布使用 pnpm lanes:
20
+ ## Prerelease Lanes
57
21
 
58
22
  ```bash
59
- pnpm exec repo release pre enter beta
60
- git add pnpm-workspace.yaml && git commit -m "chore(release): enter beta lane"
61
- git push
62
- pnpm exec repo release pre publish
23
+ repo release pre enter beta
24
+ repo release pre publish
25
+ repo release pre exit
63
26
  ```
64
27
 
65
- 预发布版本为 `X.Y.Z-beta.N`,并使用 npm `beta` dist-tag。退出时运行:
66
-
67
- ```bash
68
- pnpm exec repo release pre exit
69
- git add pnpm-workspace.yaml && git commit -m "chore(release): exit prerelease lane"
70
- ```
71
-
72
- fixed group 必须整体切换 lane,不能只移动其中一个包。
73
-
74
- ## 恢复未发布版本
75
-
76
- 如果版本提交已合并但 npm 发布失败,在 Release workflow 手动选择 `publish-unpublished`,填入 package 和 version。CI 会校验 main 上的 manifest 版本,使用 pnpm 发布并重新生成 tag 和 GitHub Release 元数据。
77
-
78
- ## repoctl 的边界
28
+ Supported lane names include `alpha`, `beta`, `rc`, and `next`.
79
29
 
80
- 生成的 GitHub Actions 只保留环境准备和一个 `pnpm exec repo release ci` 调用。
81
- repoctl 负责发布前 build/lint/test、lane 一致性检查、Release PR、npm
82
- 发布、package tag 与 GitHub Release;pnpm 负责变更意图、版本计算、changelog、
83
- ledger 和 registry 发布细节。
30
+ ## Recovery
84
31
 
85
- 存量项目首次迁移运行 `pnpm dlx repoctl@latest upgrade --yes`,后续使用
86
- `pnpm exec repo upgrade --yes` 即可跟随 repoctl 升级。未标记的自定义 release
87
- workflow 默认不会被覆盖,确认后可使用 `repo upgrade --overwrite-release`。
32
+ Use the publish-unpublished release mode to recover versions that were prepared but not published. Inspect the generated report before retrying a partial release.
@@ -1,21 +1,14 @@
1
- # 模板速查
1
+ # Template Systems
2
2
 
3
- 模板创建已经收敛到 repoctl 文档:
3
+ Templates make repository conventions executable. repoctl ships internal source workspaces for libraries, Vue components, apps, services, documentation sites, and CLIs.
4
4
 
5
- - [repoctl 模板与创建](../repoctl/templates.md)
6
- - [repoctl 快速开始](../repoctl/getting-started.md)
5
+ ```bash
6
+ repo templates
7
+ repo templates --category library
8
+ repo new sdk --template tsdown --dry-run
9
+ repo templates --check
10
+ ```
7
11
 
8
- ## monorepo 知识点:模板为什么重要
12
+ The publishable `@icebreakers/monorepo-templates` package owns the registry and packaged assets. Individual `templates/*` workspaces are private and are not release units.
9
13
 
10
- 当仓库里存在多种产物时,模板能把重复选择前置成稳定默认值:
11
-
12
- | 产物 | 常见目录 | 关注点 |
13
- | ------------- | ------------------------ | ------------------------------ |
14
- | TypeScript 库 | `packages/*` | exports、types、构建和 tsd |
15
- | Vue 组件库 | `packages/*` | SFC、样式校验、类型声明 |
16
- | 应用 | `apps/*` | dev、build、部署资产 |
17
- | 服务 | `apps/*` | API 入口、运行时类型、环境变量 |
18
- | 文档站 | `apps/*` | VitePress 配置、导航、内容结构 |
19
- | CLI | `apps/*` 或 `packages/*` | bin 入口、参数解析、发布 |
20
-
21
- repoctl 的 `repo templates` 和 `repo new` 负责把这些约定落实到文件系统。
14
+ See [Templates](../repoctl/templates.md) and [Template Asset Management](../repoctl/template-assets.md).
@@ -1,20 +1,17 @@
1
- # 常见问题排障
1
+ # Monorepo Troubleshooting
2
2
 
3
- repoctl 排障文档已经集中到:
3
+ Start by identifying the problem class: workspace discovery, dependency installation, task orchestration, repository policy, or release state.
4
4
 
5
- - [repoctl 排障与报告](../repoctl/troubleshooting.md)
6
- - [repoctl 命令速查](../repoctl/commands.md)
5
+ ```bash
6
+ repo doctor
7
+ repo env support --markdown --redact --out reports/support.md
8
+ repo check --full --dry-run
9
+ pnpm change status
10
+ ```
7
11
 
8
- ## monorepo 知识点:先区分问题类型
12
+ - Workspace discovery failures usually point to `pnpm-workspace.yaml` patterns.
13
+ - Missing task output or cache behavior belongs to Turbo task configuration.
14
+ - Tooling drift belongs to managed config and `repo upgrade`.
15
+ - Release failures require checking both versioning state and registry publication.
9
16
 
10
- 排障前先判断问题属于哪一类:
11
-
12
- | 类型 | 先看什么 | 常用命令 |
13
- | -------------- | ------------------------------------- | --------------------------------------- |
14
- | 仓库结构问题 | 根目录、workspace 文件、Node 版本 | `repo doctor` |
15
- | 模板创建问题 | 模板 key、目标目录、创建计划 | `repo templates` / `repo new --dry-run` |
16
- | 提交前校验问题 | staged 文件、workspace 归属、任务路由 | `repo check --dry-run` |
17
- | 环境差异问题 | Node、pnpm、Git、CI、路径 | `repo env support --markdown --redact` |
18
- | 遗留配置问题 | `repoctl.config.ts` 与旧配置文件 | `repo config inspect` |
19
-
20
- 旧页面继续保留为知识点索引,具体排查步骤以后优先维护在 repoctl 分区。
17
+ Do not overwrite custom files until the diagnostic report and planned changes are understood.