@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.
- package/README.md +12 -8
- package/README.zh-CN.md +16 -0
- package/assets/.changeset/ledger.yaml +25 -0
- package/assets/.github/ISSUE_TEMPLATE/config.yml +1 -1
- package/assets/AGENTS.md +4 -3
- package/assets/CONTRIBUTING.md +27 -2
- package/assets/SECURITY.md +12 -14
- package/assets/package.json +13 -4
- package/package.json +6 -4
- package/templates/cli/package.json +11 -4
- package/templates/client/package.json +17 -1
- package/templates/server/package.json +11 -4
- package/templates/tsdown/package.json +11 -4
- package/templates/vitepress/.vitepress/config.ts +146 -165
- package/templates/vitepress/ai/index.md +12 -23
- package/templates/vitepress/ai/llms-txt.md +13 -31
- package/templates/vitepress/getting-started.md +3 -32
- package/templates/vitepress/index.md +27 -30
- package/templates/vitepress/knowledge/index.md +17 -41
- package/templates/vitepress/monorepo/commands.md +13 -18
- package/templates/vitepress/monorepo/index.md +22 -100
- package/templates/vitepress/monorepo/manage.md +15 -227
- package/templates/vitepress/monorepo/publish.md +15 -70
- package/templates/vitepress/monorepo/templates.md +10 -17
- package/templates/vitepress/monorepo/troubleshooting.md +13 -16
- package/templates/vitepress/package.json +10 -4
- package/templates/vitepress/public/_redirects +3 -0
- package/templates/vitepress/repoctl/adopt-existing.md +51 -53
- package/templates/vitepress/repoctl/aliases.md +18 -18
- package/templates/vitepress/repoctl/checks.md +21 -68
- package/templates/vitepress/repoctl/commands.md +16 -64
- package/templates/vitepress/repoctl/config.md +14 -35
- package/templates/vitepress/repoctl/doctor.md +20 -60
- package/templates/vitepress/repoctl/execution-model.md +16 -69
- package/templates/vitepress/repoctl/getting-started.md +34 -40
- package/templates/vitepress/repoctl/index.md +33 -61
- package/templates/vitepress/repoctl/reports.md +20 -74
- package/templates/vitepress/repoctl/scenarios.md +26 -28
- package/templates/vitepress/repoctl/template-assets.md +19 -88
- package/templates/vitepress/repoctl/templates.md +50 -81
- package/templates/vitepress/repoctl/troubleshooting.md +32 -46
- package/templates/vitepress/repoctl/workflows.md +38 -67
- package/templates/vitepress/thinking.md +4 -85
- package/templates/vitepress/tools/changeset.md +9 -59
- package/templates/vitepress/tools/husky.md +6 -124
- package/templates/vitepress/tools/index.md +13 -32
- package/templates/vitepress/tools/lint-staged.md +5 -96
- package/templates/vitepress/tools/llms-txt.md +4 -6
- package/templates/vitepress/tools/pnpm.md +7 -119
- package/templates/vitepress/tools/renovate.md +3 -87
- package/templates/vitepress/tools/turborepo.md +5 -157
- package/templates/vitepress/why/how-to-reuse-js-code.md +6 -247
- package/templates/vitepress/why/index.md +14 -1
- package/templates/vitepress/why/js-cjs-mjs.md +9 -96
- package/templates/vitepress/why/js-keywords.md +4 -129
- package/templates/vitepress/why/modern/bundlers.md +3 -50
- package/templates/vitepress/why/modern/dts.md +4 -90
- package/templates/vitepress/why/modern/esm-vs-cjs.md +4 -81
- package/templates/vitepress/why/modern/index.md +10 -51
- package/templates/vitepress/why/modern/package-entry-points.md +6 -117
- package/templates/vitepress/why/modern/typescript.md +4 -152
- package/templates/vitepress/why/publish-basic-npm-package.md +17 -144
- package/templates/vitepress/why/what-is-npm-package.md +4 -159
- package/templates/vitepress/zh/ai/index.md +33 -0
- package/templates/vitepress/zh/ai/llms-txt.md +42 -0
- package/templates/vitepress/zh/getting-started.md +40 -0
- package/templates/vitepress/zh/index.md +66 -0
- package/templates/vitepress/zh/knowledge/index.md +50 -0
- package/templates/vitepress/zh/monorepo/commands.md +21 -0
- package/templates/vitepress/zh/monorepo/index.md +115 -0
- package/templates/vitepress/zh/monorepo/manage.md +243 -0
- package/templates/vitepress/zh/monorepo/publish.md +87 -0
- package/templates/vitepress/zh/monorepo/templates.md +21 -0
- package/templates/vitepress/zh/monorepo/troubleshooting.md +20 -0
- package/templates/vitepress/zh/repoctl/adopt-existing.md +135 -0
- package/templates/vitepress/{en → zh}/repoctl/aliases.md +18 -18
- package/templates/vitepress/zh/repoctl/checks.md +86 -0
- package/templates/vitepress/zh/repoctl/commands.md +168 -0
- package/templates/vitepress/zh/repoctl/config.md +90 -0
- package/templates/vitepress/zh/repoctl/doctor.md +86 -0
- package/templates/vitepress/zh/repoctl/execution-model.md +81 -0
- package/templates/vitepress/zh/repoctl/getting-started.md +122 -0
- package/templates/vitepress/zh/repoctl/index.md +102 -0
- package/templates/vitepress/zh/repoctl/reports.md +94 -0
- package/templates/vitepress/{en → zh}/repoctl/scenarios.md +28 -26
- package/templates/vitepress/zh/repoctl/template-assets.md +116 -0
- package/templates/vitepress/zh/repoctl/templates.md +159 -0
- package/templates/vitepress/zh/repoctl/troubleshooting.md +110 -0
- package/templates/vitepress/zh/repoctl/workflows.md +118 -0
- package/templates/vitepress/zh/thinking.md +88 -0
- package/templates/vitepress/zh/tools/changeset.md +75 -0
- package/templates/vitepress/zh/tools/husky.md +130 -0
- package/templates/vitepress/zh/tools/index.md +38 -0
- package/templates/vitepress/zh/tools/lint-staged.md +103 -0
- package/templates/vitepress/zh/tools/llms-txt.md +9 -0
- package/templates/vitepress/zh/tools/pnpm.md +127 -0
- package/templates/vitepress/zh/tools/renovate.md +91 -0
- package/templates/vitepress/zh/tools/turborepo.md +166 -0
- package/templates/vitepress/zh/why/assets/npm-dt.svg +15 -0
- package/templates/vitepress/zh/why/assets/npm-ts.svg +19 -0
- package/templates/vitepress/zh/why/examples/0.npm-basic-package/index.js +10 -0
- package/templates/vitepress/zh/why/examples/0.npm-basic-package/package.json +11 -0
- package/templates/vitepress/zh/why/examples/1.npm-basic-package/index.cjs +12 -0
- package/templates/vitepress/zh/why/examples/1.npm-basic-package/index.d.ts +1 -0
- package/templates/vitepress/zh/why/examples/1.npm-basic-package/index.js +8 -0
- package/templates/vitepress/zh/why/examples/1.npm-basic-package/package.json +19 -0
- package/templates/vitepress/zh/why/examples/2.npm-basic-package/README.md +1 -0
- package/templates/vitepress/zh/why/examples/2.npm-basic-package/package-lock.json +30 -0
- package/templates/vitepress/zh/why/examples/2.npm-basic-package/package.json +35 -0
- package/templates/vitepress/zh/why/examples/2.npm-basic-package/rename-ext.js +24 -0
- package/templates/vitepress/zh/why/examples/2.npm-basic-package/src/index.ts +8 -0
- package/templates/vitepress/zh/why/examples/2.npm-basic-package/tsconfig.cjs.json +8 -0
- package/templates/vitepress/zh/why/examples/2.npm-basic-package/tsconfig.esm.json +7 -0
- package/templates/vitepress/zh/why/examples/2.npm-basic-package/tsconfig.json +18 -0
- package/templates/vitepress/zh/why/examples/3.npm-basic-package/README.md +1 -0
- package/templates/vitepress/zh/why/examples/3.npm-basic-package/package-lock.json +1496 -0
- package/templates/vitepress/zh/why/examples/3.npm-basic-package/package.json +31 -0
- package/templates/vitepress/zh/why/examples/3.npm-basic-package/src/index.ts +8 -0
- package/templates/vitepress/zh/why/examples/3.npm-basic-package/tsconfig.json +16 -0
- package/templates/vitepress/zh/why/examples/3.npm-basic-package/tsdown.config.ts +16 -0
- package/templates/vitepress/zh/why/examples/usage-cjs/cjs.cjs +4 -0
- package/templates/vitepress/zh/why/examples/usage-cjs/esm.mjs +4 -0
- package/templates/vitepress/zh/why/examples/usage-cjs/index.js +8 -0
- package/templates/vitepress/zh/why/examples/usage-cjs/package-lock.json +36 -0
- package/templates/vitepress/zh/why/examples/usage-cjs/package.json +20 -0
- package/templates/vitepress/zh/why/examples/usage-esm/cjs.cjs +4 -0
- package/templates/vitepress/zh/why/examples/usage-esm/createRequire.js +7 -0
- package/templates/vitepress/zh/why/examples/usage-esm/esm.mjs +4 -0
- package/templates/vitepress/zh/why/examples/usage-esm/index.js +8 -0
- package/templates/vitepress/zh/why/examples/usage-esm/package-lock.json +36 -0
- package/templates/vitepress/zh/why/examples/usage-esm/package.json +21 -0
- package/templates/vitepress/zh/why/how-to-reuse-js-code.md +250 -0
- package/templates/vitepress/zh/why/index.md +1 -0
- package/templates/vitepress/zh/why/js-cjs-mjs.md +99 -0
- package/templates/vitepress/zh/why/js-keywords.md +132 -0
- package/templates/vitepress/zh/why/modern/bundlers.md +52 -0
- package/templates/vitepress/zh/why/modern/dts.md +93 -0
- package/templates/vitepress/zh/why/modern/esm-vs-cjs.md +84 -0
- package/templates/vitepress/zh/why/modern/index.md +55 -0
- package/templates/vitepress/zh/why/modern/package-entry-points.md +128 -0
- package/templates/vitepress/zh/why/modern/typescript.md +155 -0
- package/templates/vitepress/zh/why/publish-basic-npm-package.md +146 -0
- package/templates/vitepress/zh/why/what-is-npm-package.md +162 -0
- package/templates/vue-lib/package.json +12 -5
- package/templates/vitepress/en/index.md +0 -63
- package/templates/vitepress/en/knowledge/monorepo.md +0 -37
- package/templates/vitepress/en/repoctl/adopt-existing.md +0 -133
- package/templates/vitepress/en/repoctl/commands.md +0 -120
- package/templates/vitepress/en/repoctl/config.md +0 -69
- package/templates/vitepress/en/repoctl/getting-started.md +0 -116
- package/templates/vitepress/en/repoctl/index.md +0 -74
- package/templates/vitepress/en/repoctl/templates.md +0 -128
- package/templates/vitepress/en/repoctl/troubleshooting.md +0 -96
- package/templates/vitepress/en/repoctl/workflows.md +0 -89
|
@@ -1,50 +1,26 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
outline: deep
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Knowledge Base
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This section explains the engineering decisions behind repoctl rather than only listing commands.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Monorepo Topics
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
##
|
|
18
|
+
## Modern Package Topics
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
1
|
+
# Why Monorepo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This project uses monorepo practices because multiple packages, applications, CLIs, and docs sites usually share the same engineering rules.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
###
|
|
9
|
+
### Shared Tooling
|
|
10
10
|
|
|
11
|
-
|
|
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
|
-
|
|
15
|
+
### Atomic Cross-Package Changes
|
|
19
16
|
|
|
20
|
-
|
|
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
|
-
|
|
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
|
-
|
|
23
|
+
## Where repoctl Fits
|
|
30
24
|
|
|
31
|
-
|
|
25
|
+
repoctl adds the missing workflow layer:
|
|
32
26
|
|
|
33
|
-
`
|
|
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
|
-
#
|
|
1
|
+
# Managing A Monorepo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
repoctl gives a pnpm and Turborepo workspace a predictable operating model without hiding the underlying tools.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## 先记住默认工作流
|
|
5
|
+
## Daily Workflow
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
8
|
pnpm install
|
|
11
|
-
pnpm
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
234
|
-
- 你在维护这套 CLI / 模板本身
|
|
25
|
+
## Configuration
|
|
235
26
|
|
|
236
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
1
|
+
# Publishing and Changelogs
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
16
|
+
## Versioning Configuration
|
|
39
17
|
|
|
40
|
-
|
|
18
|
+
Fixed groups and repository changelog storage live in `pnpm-workspace.yaml`. `repo doctor` reports missing or legacy release configuration.
|
|
41
19
|
|
|
42
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
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
|
-
|
|
81
|
-
repoctl 负责发布前 build/lint/test、lane 一致性检查、Release PR、npm
|
|
82
|
-
发布、package tag 与 GitHub Release;pnpm 负责变更意图、版本计算、changelog、
|
|
83
|
-
ledger 和 registry 发布细节。
|
|
30
|
+
## Recovery
|
|
84
31
|
|
|
85
|
-
|
|
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
|
-
|
|
3
|
+
Templates make repository conventions executable. repoctl ships internal source workspaces for libraries, Vue components, apps, services, documentation sites, and CLIs.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3
|
+
Start by identifying the problem class: workspace discovery, dependency installation, task orchestration, repository policy, or release state.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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.
|