@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,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Workflows and CI
|
|
2
2
|
|
|
3
|
-
repoctl
|
|
3
|
+
repoctl commands have two audiences: humans using short daily commands, and automation consuming stable reports.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Local Daily Workflow
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
pnpm install
|
|
@@ -12,17 +12,15 @@ pnpm run repo:check
|
|
|
12
12
|
pnpm build
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
| Step | What It Proves |
|
|
16
|
+
| ---------------------- | ------------------------------------------------------- |
|
|
17
|
+
| `pnpm install` | Workspace dependencies and local links are ready |
|
|
18
|
+
| `pnpm run repo:doctor` | Root files, Node, scripts, config, and hooks are usable |
|
|
19
|
+
| `pnpm run repo:new` | New packages follow template conventions |
|
|
20
|
+
| `pnpm run repo:check` | The lightweight local verification flow is reproducible |
|
|
21
|
+
| `pnpm build` | The workspace build graph has no obvious breakage |
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
| ---------------------- | ------------------------------------------------ |
|
|
19
|
-
| `pnpm install` | workspace 依赖和本地链接完整 |
|
|
20
|
-
| `pnpm run repo:doctor` | 仓库根目录、Node、脚本、配置和提交链路可用 |
|
|
21
|
-
| `pnpm run repo:new` | 新包由模板创建,目录和 package metadata 符合约定 |
|
|
22
|
-
| `pnpm run repo:check` | 提交前轻量校验可以复现 |
|
|
23
|
-
| `pnpm build` | 全仓构建链路没有明显断点 |
|
|
24
|
-
|
|
25
|
-
## 存量仓库接入
|
|
23
|
+
## Adopt An Existing Repository
|
|
26
24
|
|
|
27
25
|
```bash
|
|
28
26
|
pnpm add -D repoctl
|
|
@@ -32,9 +30,9 @@ pnpm exec repo upgrade --no-overwrite
|
|
|
32
30
|
pnpm exec repo doctor
|
|
33
31
|
```
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
Start conservatively with `--no-overwrite`. After reviewing asset drift, decide whether `--yes` or `--overwrite` is appropriate.
|
|
36
34
|
|
|
37
|
-
## CI
|
|
35
|
+
## Fast CI Gate
|
|
38
36
|
|
|
39
37
|
```bash
|
|
40
38
|
pnpm install --frozen-lockfile
|
|
@@ -42,9 +40,9 @@ pnpm exec repo doctor --strict
|
|
|
42
40
|
pnpm exec repo check --full
|
|
43
41
|
```
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
This is a simple gate for small repositories or early projects. `doctor --strict` treats warnings as failures.
|
|
46
44
|
|
|
47
|
-
## CI
|
|
45
|
+
## CI Report Mode
|
|
48
46
|
|
|
49
47
|
```bash
|
|
50
48
|
pnpm exec repo doctor --json --out reports/doctor.json
|
|
@@ -52,15 +50,13 @@ pnpm exec repo check --json --out reports/check-plan.json
|
|
|
52
50
|
pnpm exec repo env support --markdown --redact --out reports/support.md
|
|
53
51
|
```
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- `doctor.json` 给脚本判断仓库健康状态。
|
|
58
|
-
- `check-plan.json` 记录本次会跑哪些校验。
|
|
59
|
-
- `support.md` 适合上传为 artifact,或贴进 issue / PR。
|
|
53
|
+
Use these outputs as CI artifacts:
|
|
60
54
|
|
|
61
|
-
|
|
55
|
+
- `doctor.json` for scripts.
|
|
56
|
+
- `check-plan.json` to explain verification routing.
|
|
57
|
+
- `support.md` for issues, PRs, and external collaboration.
|
|
62
58
|
|
|
63
|
-
|
|
59
|
+
## Hooks
|
|
64
60
|
|
|
65
61
|
```bash
|
|
66
62
|
repo verify pre-commit
|
|
@@ -69,50 +65,25 @@ repo verify commit-msg .git/COMMIT_EDITMSG
|
|
|
69
65
|
repo verify pre-push
|
|
70
66
|
```
|
|
71
67
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
| pre-
|
|
77
|
-
| commit-msg | 校验 Conventional Commit 格式 |
|
|
78
|
-
| pre-push | 跑整仓 lint/typecheck,并按变更范围补 build/test/tsd |
|
|
79
|
-
|
|
80
|
-
## 自动化创建预览
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
repo new dashboard --template vue-hono --json --out plans/dashboard.json
|
|
84
|
-
repo templates --markdown --out docs/templates.md
|
|
85
|
-
repo ws ls --json --out reports/workspaces.json
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
这些命令都不会要求人工选择,适合编辑器插件、脚本和 CI bot。
|
|
89
|
-
|
|
90
|
-
## 推荐流水线拆分
|
|
91
|
-
|
|
92
|
-
| 阶段 | 命令 | 失败后先看 |
|
|
93
|
-
| ---- | --------------------------------------------------------------- | ------------------------------------ |
|
|
94
|
-
| 安装 | `pnpm install --frozen-lockfile` | lockfile、Node、pnpm 版本 |
|
|
95
|
-
| 诊断 | `repo doctor --strict` | [doctor 诊断](./doctor.md) |
|
|
96
|
-
| 计划 | `repo check --full --json --out reports/check-plan.json` | [报告与自动化输出](./reports.md) |
|
|
97
|
-
| 执行 | `repo check --full` | 失败的 root script 或 workspace 任务 |
|
|
98
|
-
| 留证 | `repo env support --markdown --redact --out reports/support.md` | CI artifact |
|
|
99
|
-
|
|
100
|
-
早期项目可以把计划和执行合并。成熟项目建议保留 `reports/`,方便失败时复盘实际执行路径。
|
|
68
|
+
| Stage | Recommended Behavior |
|
|
69
|
+
| ---------- | --------------------------------------------------------- |
|
|
70
|
+
| pre-commit | Focus on staged files, lint, and workspace typecheck |
|
|
71
|
+
| commit-msg | Enforce Conventional Commit messages |
|
|
72
|
+
| pre-push | Run root lint/typecheck and affected build/test/tsd tasks |
|
|
101
73
|
|
|
102
|
-
##
|
|
74
|
+
## Non-Interactive Options
|
|
103
75
|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
|
|
|
108
|
-
|
|
|
109
|
-
|
|
|
110
|
-
|
|
|
111
|
-
|
|
|
76
|
+
| Scenario | Option |
|
|
77
|
+
| ------------------------------------- | -------------------------------------------------- |
|
|
78
|
+
| Accept setup defaults | `repo init --yes` |
|
|
79
|
+
| Preserve changed files during upgrade | `repo upgrade --no-overwrite` |
|
|
80
|
+
| Explicitly overwrite standard assets | `repo upgrade --yes` or `repo upgrade --overwrite` |
|
|
81
|
+
| Preview only | `--dry-run` |
|
|
82
|
+
| Output for scripts | `--json --out <file>` |
|
|
83
|
+
| Share a redacted report | `--markdown --redact --out <file>` |
|
|
112
84
|
|
|
113
|
-
##
|
|
85
|
+
## Keep Reading
|
|
114
86
|
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
- 看短命令:[命令别名](./aliases.md)
|
|
87
|
+
- [Command Reference](./commands.md)
|
|
88
|
+
- [Troubleshooting](./troubleshooting.md)
|
|
89
|
+
- [Command Aliases](./aliases.md)
|
|
@@ -1,88 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Project Evolution
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This repository began as a reusable monorepo template. It has since evolved into repoctl: a task-first CLI for initializing, diagnosing, creating, validating, upgrading, and releasing pnpm and Turborepo monorepos.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Templates remain an important capability, but they are now private source workspaces packaged through `@icebreakers/monorepo-templates`, not the product identity or independent release units.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## 它的由来
|
|
10
|
-
|
|
11
|
-
为了应对越来越多的发包场景,我创建了 [npm-lib-template](https://github.com/sonofmagic/npm-lib-template) 模板
|
|
12
|
-
|
|
13
|
-
这是一个 `git` 单仓单 `npm` 包模板,使用 `rollup` 进行打包,然后再发布到 `npm` 和 `github`
|
|
14
|
-
|
|
15
|
-
然而,在后续开发中,我发现单仓库的模式在某些场景下难以应对。
|
|
16
|
-
|
|
17
|
-
例如,当需要引用其他自己的包,进行单元测试并再次发包时,这时候往往要在多个项目之间进行来回的切换更改,管理复杂度会迅速上升。
|
|
18
|
-
|
|
19
|
-
`git submodule` 也是另外一条路子,但是我对每次都要同步 `hash` 感到深恶痛绝,遂放弃 (不过某些极其特殊场景的实现,还是只能利用这个功能)。
|
|
20
|
-
|
|
21
|
-
因此,我决定要创建一个 [monorepo 项目模板](https://github.com/sonofmagic/monorepo-template) ,以应对这些需求。
|
|
22
|
-
|
|
23
|
-
## 技术选型
|
|
24
|
-
|
|
25
|
-
### 管理工具
|
|
26
|
-
|
|
27
|
-
在 `monorepo` 的管理上,我选择了 `pnpm` 和 `turborepo` 这对组合,原因很简单:它们都非常快。
|
|
28
|
-
|
|
29
|
-
- `pnpm` 又可以节省磁盘空间,又能够链接自特定的内容寻址存储库,是为快也
|
|
30
|
-
- `turborepo` 有构建缓存,是为快也 `too`.
|
|
31
|
-
|
|
32
|
-
### 语言与打包
|
|
33
|
-
|
|
34
|
-
我选择使用纯 `TypeScript` 来编写所有类库项目,并统一使用 `tsdown` 进行打包,默认输出格式为 `cjs` 和 `esm`,并利用 `package.json` 中的 `exports` 字段进行分发。
|
|
35
|
-
|
|
36
|
-
### 直接调试
|
|
37
|
-
|
|
38
|
-
在直接调试时,我抛弃了 `dist` + `sourcemap` 的调试方式,使用了 `tsx`,它非常适合调试 `TypeScript` 编写的 `CLI` 项目。
|
|
39
|
-
|
|
40
|
-
### 测试框架
|
|
41
|
-
|
|
42
|
-
测试方面,我选择了 `vitest`。
|
|
43
|
-
|
|
44
|
-
它不仅速度快,还很好地支持 `cjs`、`esm` 和 `TypeScript`,同时也适合 `monorepo` 项目。你可以利用 `turbo` 来执行单个的 `vitest` 任务,也可以利用 `vitest.workspace` 来进行多任务测试。
|
|
45
|
-
|
|
46
|
-
最初我使用的是 `jest` + `ts-jest`,但它对多格式的混合模块的支持不够理想,最终我选择了 `vitest`。
|
|
47
|
-
|
|
48
|
-
### 代码规范与质量控制
|
|
49
|
-
|
|
50
|
-
为了保持代码质量,我使用了 `eslint` 和 `stylelint`,并基于自己的配置包 `@icebreakers/eslint-config` 和 `@icebreakers/stylelint-config` 来进行代码格式化和规范化。
|
|
51
|
-
|
|
52
|
-
我还为 `.vscode` 配置了一些推荐插件和编辑器选项。
|
|
53
|
-
|
|
54
|
-
此外,通过 `husky` 添加了 `git hook`,配合 `lint-staged` 对提交的代码进行校验。与 `commitlint` 结合使用,以确保 `git` 提交信息符合规范。
|
|
55
|
-
|
|
56
|
-
### 本地引用与发包替换
|
|
57
|
-
|
|
58
|
-
利用 `publishConfig` 会在发包的时候替换 `package.json` 字段的方式,在本地包相互引用的时候,都使用 `Typescript` 源文件的方式导出,在 `publishConfig` 里定义的导出为,真正在不同环境中,指向 `dist` 中不同格式的产物地址。
|
|
59
|
-
|
|
60
|
-
通过这种方式,可以大大加速整个 `monorepo` 的开发测试速度,避免反复通过 `watch` 来构建 `dist` 和 `sourcemap`,也避免一构建出产物,对应的 `Typescript` 文件,就报错的问题。
|
|
61
|
-
|
|
62
|
-
### 发包流程
|
|
63
|
-
|
|
64
|
-
现在使用 pnpm 原生 versioning:用 `pnpm change` 记录意图,用 `pnpm version -r` 生成版本和 changelog,再用 `pnpm publish -r` 发布。版本计划保留在 `.changeset/ledger.yaml`,预发布则由 pnpm lanes 管理。
|
|
65
|
-
|
|
66
|
-
### Github 相关配置
|
|
67
|
-
|
|
68
|
-
在 `.github` 目录下,我提供了默认的 `CI/CD` 流程配置,以及用户提交 `issue` 时的模板。经过少量配置后,就可以实现自动发布 `npm` 包、创建 `git tag` 以及生成 `GitHub release`。
|
|
69
|
-
|
|
70
|
-
此外,模板里还有许多为 `GitHub` 显示优化的 `md` 文档。
|
|
71
|
-
|
|
72
|
-
## 部署
|
|
73
|
-
|
|
74
|
-
文档网站通过 `netlify.toml` 配置部署在 `Netlify` 上。最初我使用的是 `Vercel`,但由于**国内**访问速度的原因,最终迁移到了 `Netlify`。
|
|
75
|
-
|
|
76
|
-
而且由于我是开源项目贡献者的原因,`Netlify` 为我 `免费` 提供了 `Pro` 版本的计划 (通常这需要 `$19/per member/month`)
|
|
77
|
-
|
|
78
|
-
感谢 `Netlify`! 爱你❤️😍。
|
|
79
|
-
|
|
80
|
-
如果看到这里的哥们,你也有一定影响力的开源项目,也可以通过下方的链接申请。
|
|
81
|
-
|
|
82
|
-
https://www.netlify.com/legal/open-source-policy/
|
|
83
|
-
|
|
84
|
-
## 总结
|
|
85
|
-
|
|
86
|
-
从单仓到 `monorepo` 的转变不仅仅是对工具的选择,更是对项目管理模式的优化。通过采用合适的工具链,能够更高效地管理多包项目的同时,利用 `CI/CD` 确保代码的质量和发布的顺畅。
|
|
87
|
-
|
|
88
|
-
希望这些思考对你有所帮助,也欢迎大家提出各种建议和意见。
|
|
7
|
+
See the [repoctl overview](./repoctl/index.md) for the current architecture and public entrypoints.
|
|
@@ -1,75 +1,25 @@
|
|
|
1
1
|
# pnpm Versioning
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This repository uses pnpm change intents and workspace versioning for releases.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Daily Development
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
pnpm change
|
|
9
9
|
pnpm change status
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Choose every publishable package whose public behavior changed and record the correct patch, minor, or major level. Private template workspaces are not release units.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
pnpm change --bump patch --summary "修复空输入崩溃" repoctl
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
变更意图会写入 `.changeset/`,与代码一起提交。`pnpm change status` 只预览计划,不会修改文件。
|
|
19
|
-
|
|
20
|
-
## 版本与 changelog
|
|
21
|
-
|
|
22
|
-
在 Release PR 中由 CI 消费变更意图:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
pnpm version -r --dry-run
|
|
26
|
-
pnpm version -r
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
`pnpm version -r` 会更新受影响包、传播 workspace 依赖、生成 `CHANGELOG.md`,并把消费记录追加到 `.changeset/ledger.yaml`。仓库配置使用 `versioning.changelog.storage: repository`,所以 changelog 会和版本提交一起审查。
|
|
30
|
-
|
|
31
|
-
`@icebreakers/monorepo` 与 `repoctl` 属于 pnpm fixed group,任一包需要发布时两者始终使用同一个版本。
|
|
32
|
-
|
|
33
|
-
## 发布
|
|
34
|
-
|
|
35
|
-
正式发布由 Release PR 合并后的 main workflow 完成:
|
|
14
|
+
## Release
|
|
36
15
|
|
|
37
16
|
```bash
|
|
38
|
-
|
|
17
|
+
repo release stable prepare
|
|
18
|
+
repo release stable publish
|
|
39
19
|
```
|
|
40
20
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
本地推荐使用 repoctl 包装命令:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
pnpm exec repo release stable prepare
|
|
47
|
-
pnpm exec repo release stable publish
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Prerelease lanes
|
|
51
|
-
|
|
52
|
-
alpha、beta、rc、next 是 pnpm lanes,而不是 Changesets pre 状态:
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
pnpm exec repo release pre enter alpha
|
|
56
|
-
git add pnpm-workspace.yaml && git commit -m "chore(release): enter alpha lane"
|
|
57
|
-
git push
|
|
58
|
-
|
|
59
|
-
pnpm exec repo release pre publish
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
退出预发布轨道时执行 `pnpm exec repo release pre exit`,提交 `pnpm-workspace.yaml` 后合并回 main。lane 切换必须覆盖 fixed group 的全部包。
|
|
63
|
-
|
|
64
|
-
## CI 约定
|
|
21
|
+
repoctl coordinates the release workflow, validates configuration, and publishes metadata. pnpm owns the versioning state and repository changelog storage.
|
|
65
22
|
|
|
66
|
-
|
|
67
|
-
- main push 先生成或更新 Release PR;Release PR 合并后才发布 npm。
|
|
68
|
-
- alpha、beta、rc、next 分支要求所有可发布包位于对应 lane。
|
|
69
|
-
- npm 发布使用 GitHub OIDC provenance,不需要长期保存 `NPM_TOKEN`。
|
|
70
|
-
- 未发布版本恢复使用 workflow dispatch 的 `publish-unpublished` 模式,并按 package/version 校验后发布。
|
|
71
|
-
- repoctl 通过 GitHub REST API 幂等创建或更新 Release PR、package tag 和 GitHub Release,重复执行不会重复创建元数据。
|
|
23
|
+
## Prerelease Lanes
|
|
72
24
|
|
|
73
|
-
|
|
74
|
-
`repoctl-managed: release/v2` 的 workflow 会自动升级;未标记的自定义
|
|
75
|
-
workflow 默认保留,可在确认后使用 `repo upgrade --overwrite-release`。
|
|
25
|
+
Use `repo release pre enter <tag>`, `repo release pre publish`, and `repo release pre exit` for alpha, beta, rc, or next lanes.
|
|
@@ -1,130 +1,12 @@
|
|
|
1
1
|
# Husky
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Husky connects repository scripts to Git hooks. repoctl-managed workspaces use it as a thin entrypoint, keeping verification logic in versioned commands.
|
|
4
4
|
|
|
5
|
-
```
|
|
6
|
-
|
|
7
|
-
repo verify commit
|
|
8
|
-
repo verify pre-push
|
|
5
|
+
```sh
|
|
6
|
+
# .husky/pre-commit
|
|
7
|
+
pnpm exec repo verify pre-commit
|
|
9
8
|
```
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
Use `commit-msg` for commitlint and `pre-push` for broader build and test verification. Hooks should remain fast enough for local work and should not contain duplicated task logic.
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
repo check --staged
|
|
15
|
-
repo check --full
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
继续看:[repoctl 工作流与 CI](../repoctl/workflows.md)。
|
|
19
|
-
|
|
20
|
-
## 1. 什么是 Husky?
|
|
21
|
-
|
|
22
|
-
**Husky** 是一个用于在 **Git hooks**(如 `pre-commit`、`pre-push`、`commit-msg` 等)中运行脚本的工具。
|
|
23
|
-
它的作用是让你在提交代码前或推送代码前,自动执行一些校验、格式化或测试,从而保证代码质量和团队规范。
|
|
24
|
-
|
|
25
|
-
> 简单来说:**Husky = Git hooks 的管理工具**。
|
|
26
|
-
|
|
27
|
-
## 2. Husky 有什么用?
|
|
28
|
-
|
|
29
|
-
常见用途:
|
|
30
|
-
|
|
31
|
-
1. **代码格式化**
|
|
32
|
-
在提交前运行 `prettier --write .`,确保代码风格一致。
|
|
33
|
-
2. **Lint 检查**
|
|
34
|
-
在 `pre-commit` 时执行 `eslint`,防止有 lint 错误的代码被提交。
|
|
35
|
-
3. **推送前执行整仓校验**
|
|
36
|
-
在 `pre-push` 时执行整仓 `lint`、`typecheck`,并按需补跑 `build`、`test`、`tsd`,防止未通过校验的代码被推送。
|
|
37
|
-
4. **Commit 信息校验**
|
|
38
|
-
在 `commit-msg` hook 中使用 [commitlint](https://github.com/conventional-changelog/commitlint) 强制提交信息符合规范(如 Conventional Commits)。
|
|
39
|
-
|
|
40
|
-
## 3. 如何使用 Husky?
|
|
41
|
-
|
|
42
|
-
### 安装
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
npm install husky --save-dev
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### 初始化
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
npx husky init
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
这会生成一个 `.husky` 目录,并在里面创建 `pre-commit` 文件,默认内容可能是:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
#!/bin/sh
|
|
58
|
-
npm test
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### 添加 Hook
|
|
62
|
-
|
|
63
|
-
假设你想在提交前运行 ESLint,可以这样:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
npx husky add .husky/pre-commit "npm run lint"
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
生成的 `.husky/pre-commit` 文件类似:
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
#!/bin/sh
|
|
73
|
-
npm run lint
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### 使用 commit-msg 校验提交信息
|
|
77
|
-
|
|
78
|
-
先装 commitlint:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
npm install @commitlint/{config-conventional,cli} --save-dev
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
创建配置文件 `commitlint.config.js`:
|
|
85
|
-
|
|
86
|
-
```js
|
|
87
|
-
module.exports = { extends: ['@commitlint/config-conventional'] }
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
添加 hook:
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
npx husky add .husky/commit-msg "npx --no-install commitlint --edit $1"
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
这样,若提交信息不符合规范,会被拦截。
|
|
97
|
-
|
|
98
|
-
## 4. 和 lint-staged 搭配
|
|
99
|
-
|
|
100
|
-
通常 Husky 会和 [lint-staged](https://github.com/okonet/lint-staged) 搭配使用:
|
|
101
|
-
只检查本次改动的文件,而不是全量检查。
|
|
102
|
-
|
|
103
|
-
示例:
|
|
104
|
-
`package.json` 里加:
|
|
105
|
-
|
|
106
|
-
```json
|
|
107
|
-
{
|
|
108
|
-
"lint-staged": {
|
|
109
|
-
"*.js": "eslint --fix",
|
|
110
|
-
"*.ts": "eslint --fix"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
然后在 `.husky/pre-commit` 文件中写:
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
npx lint-staged
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
在本仓库默认实现里,`pre-commit` 和 `pre-push` 的职责拆分是:
|
|
122
|
-
|
|
123
|
-
- `pre-commit`:只针对 staged 文件执行 `eslint`、`stylelint` 和 workspace `typecheck`
|
|
124
|
-
- `pre-push`:强制执行整仓 `pnpm lint`、`pnpm typecheck`,并根据改动范围补跑 `build`、`test`、`tsd`
|
|
125
|
-
|
|
126
|
-
## 总结
|
|
127
|
-
|
|
128
|
-
- **Husky** 是一个 Git hooks 工具,用来在 commit、push 等阶段运行脚本。
|
|
129
|
-
- 主要用于 **代码质量控制**:lint、格式化、测试、commit message 校验等。
|
|
130
|
-
- 使用方式:安装 → 初始化 → 添加 hooks → 编写脚本。
|
|
12
|
+
`repo doctor` reports when Husky and lint-staged are only partially configured. `repo upgrade` can synchronize the managed defaults.
|
|
@@ -1,38 +1,19 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
outline: deep
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Tool Guides
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
repoctl coordinates established tools instead of replacing them.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
| Tool | Responsibility |
|
|
10
|
+
| --------------------------------- | --------------------------------------------------- |
|
|
11
|
+
| [pnpm](./pnpm.md) | Workspaces, dependency installation, and versioning |
|
|
12
|
+
| [Turborepo](./turborepo.md) | Task graph execution and caching |
|
|
13
|
+
| [pnpm Versioning](./changeset.md) | Change intents, versions, and changelogs |
|
|
14
|
+
| [Husky](./husky.md) | Git hook entrypoints |
|
|
15
|
+
| [lint-staged](./lint-staged.md) | Checks scoped to staged files |
|
|
16
|
+
| [Renovate](./renovate.md) | Automated dependency updates |
|
|
17
|
+
| [llms.txt](./llms-txt.md) | AI-readable documentation discovery |
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
| --------------- | ----------------------------------------------- | ------------------------------- |
|
|
13
|
-
| pnpm | workspace、依赖安装、根脚本和包内脚本执行 | [pnpm](./pnpm.md) |
|
|
14
|
-
| Turborepo | build、lint、typecheck、test 等任务编排 | [turborepo](./turborepo.md) |
|
|
15
|
-
| pnpm versioning | 多包版本、变更记录和发布准备 | [versioning](./changeset.md) |
|
|
16
|
-
| Husky | Git hook 入口 | [husky](./husky.md) |
|
|
17
|
-
| lint-staged | staged 文件级 lint、stylelint 和 typecheck 路由 | [lint-staged](./lint-staged.md) |
|
|
18
|
-
| Renovate | 依赖更新和升级 PR 治理 | [renovate](./renovate.md) |
|
|
19
|
-
|
|
20
|
-
## 2. 和 repoctl 的关系
|
|
21
|
-
|
|
22
|
-
repoctl 不隐藏这些工具。它主要做三件事:
|
|
23
|
-
|
|
24
|
-
1. 生成推荐配置,减少每个仓库重复复制。
|
|
25
|
-
2. 提供 `doctor` 和 `check`,帮助你验证配置是否接上。
|
|
26
|
-
3. 提供 `upgrade`,在模板标准发生变化时同步资产。
|
|
27
|
-
|
|
28
|
-
因此排障时不要只看 repoctl 命令。比如 `repo check --full` 失败时,真正失败的任务可能是 `pnpm lint`、`pnpm typecheck`、某个 workspace 的 `build` 或 `test`。
|
|
29
|
-
|
|
30
|
-
## 3. 按目标阅读
|
|
31
|
-
|
|
32
|
-
| 目标 | 建议页面 |
|
|
33
|
-
| ------------------------- | ------------------------------------------------------ |
|
|
34
|
-
| 让 workspace 包能互相引用 | [pnpm](./pnpm.md) |
|
|
35
|
-
| 提升整仓任务速度 | [turborepo](./turborepo.md) |
|
|
36
|
-
| 建立规范发版链路 | [pnpm versioning](./changeset.md) |
|
|
37
|
-
| 提交前自动修复格式和 lint | [Husky](./husky.md) 与 [lint-staged](./lint-staged.md) |
|
|
38
|
-
| 降低依赖升级成本 | [Renovate](./renovate.md) |
|
|
19
|
+
Use repoctl for repository tasks and these tools directly when you need their lower-level controls.
|
|
@@ -1,103 +1,12 @@
|
|
|
1
1
|
# lint-staged
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
lint-staged runs checks only for files included in the next commit.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
repo verify pre-commit
|
|
7
|
-
repo verify staged-typecheck packages/app/src/main.ts
|
|
8
|
-
repo check --staged
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
继续看:[repoctl 工作流与 CI](../repoctl/workflows.md)。
|
|
12
|
-
|
|
13
|
-
## 1. 什么是 lint-staged?
|
|
14
|
-
|
|
15
|
-
**lint-staged** 是一个工具,主要功能是:
|
|
16
|
-
在 **Git 暂存区(staged)里的文件** 上运行你指定的 linters 或脚本。
|
|
17
|
-
|
|
18
|
-
👉 它和 **Husky** 搭配使用最常见:
|
|
19
|
-
|
|
20
|
-
- Husky 负责触发 Git hooks(比如 `pre-commit`)。
|
|
21
|
-
- lint-staged 负责只对 **本次提交涉及的文件** 进行检查和修复。
|
|
22
|
-
- 在本仓库默认配置里,`ts` / `tsx` / `mts` / `cts` / `vue` 文件还会继续触发对应 workspace 的 `typecheck`。
|
|
23
|
-
|
|
24
|
-
这样就避免了对整个项目运行 lint/format,节省时间。
|
|
25
|
-
|
|
26
|
-
## 2. lint-staged 有什么用?
|
|
27
|
-
|
|
28
|
-
- **提高性能**:只检查本次改动的文件,而不是全量跑 `eslint` 或 `prettier`。
|
|
29
|
-
- **保证提交质量**:阻止不符合规范的代码进入仓库。
|
|
30
|
-
- **常见场景**:
|
|
31
|
-
- 运行 ESLint 自动修复:`eslint --fix`
|
|
32
|
-
- 运行 Prettier 格式化:`prettier --write`
|
|
33
|
-
- 运行 workspace 级类型检查:Vue 项目通常是 `vue-tsc -b`,TS 项目通常是 `tsc -p tsconfig.json`
|
|
34
|
-
- 优化图片、转换 Markdown 等自定义脚本
|
|
35
|
-
|
|
36
|
-
## 3. 如何使用 lint-staged?
|
|
37
|
-
|
|
38
|
-
### 安装
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
npm install lint-staged --save-dev
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### 配置
|
|
45
|
-
|
|
46
|
-
lint-staged 支持在 `package.json`、`.lintstagedrc` 或 `lint-staged.config.js` 中配置。
|
|
47
|
-
|
|
48
|
-
最简单的方式:在 `package.json` 加上:
|
|
49
|
-
|
|
50
|
-
```json
|
|
51
|
-
{
|
|
52
|
-
"lint-staged": {
|
|
53
|
-
"*.js": "eslint --fix",
|
|
54
|
-
"*.ts": "eslint --fix",
|
|
55
|
-
"*.{js,ts,json,css,md}": "prettier --write"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### 结合 Husky
|
|
61
|
-
|
|
62
|
-
一般在 `.husky/pre-commit` 中加:
|
|
5
|
+
The repository policy routes JavaScript, TypeScript, and Vue files through ESLint, style files through Stylelint, and TypeScript or Vue files to the owning workspace's typecheck script.
|
|
63
6
|
|
|
64
7
|
```bash
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
这样在提交时,lint-staged 会自动处理已暂存的文件。
|
|
69
|
-
|
|
70
|
-
本仓库默认生成的规则更接近下面这种形式:
|
|
71
|
-
|
|
72
|
-
```js
|
|
73
|
-
export default {
|
|
74
|
-
'*.{js,jsx,mjs,ts,tsx,mts,cts}': ['eslint --fix'],
|
|
75
|
-
'*.vue': ['eslint --fix', 'stylelint --fix --allow-empty-input'],
|
|
76
|
-
'*.{ts,tsx,mts,cts,vue}': files => `pnpm exec repoctl verify staged-typecheck ${files.join(' ')}`,
|
|
77
|
-
'*.{json,md,mdx,html,yml,yaml}': ['eslint --fix'],
|
|
78
|
-
'*.{css,scss,sass,less}': ['stylelint --fix --allow-empty-input'],
|
|
79
|
-
}
|
|
8
|
+
pnpm exec repo verify pre-commit
|
|
9
|
+
pnpm exec repo verify staged-typecheck <files...>
|
|
80
10
|
```
|
|
81
11
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
假设你改了两个文件:
|
|
85
|
-
|
|
86
|
-
- `src/app.js`
|
|
87
|
-
- `docs/readme.md`
|
|
88
|
-
|
|
89
|
-
然后执行 `git add . && git commit -m "feat: add app"`
|
|
90
|
-
|
|
91
|
-
在 `pre-commit` hook 中,lint-staged 会只对这两个文件运行配置的命令,比如:
|
|
92
|
-
|
|
93
|
-
- `eslint --fix src/app.js`
|
|
94
|
-
- `prettier --write docs/readme.md`
|
|
95
|
-
|
|
96
|
-
最终确保这两个文件在提交之前符合规范。
|
|
97
|
-
|
|
98
|
-
## 总结
|
|
99
|
-
|
|
100
|
-
- **lint-staged = 只在 staged 文件上运行 lint/脚本的工具**。
|
|
101
|
-
- 优点:快、精准,避免全量检查。
|
|
102
|
-
- 常和 **Husky** 搭配,用于 `pre-commit`。
|
|
103
|
-
- 在 monorepo 里很适合把 ESLint、Stylelint 和 workspace `typecheck` 串起来。
|
|
12
|
+
Vue workspaces should use `vue-tsc`; plain TypeScript workspaces should use `tsc`. Keep the routing in `lint-staged.config.js` so local hooks and CI can share the same contract.
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
description: llms.txt 说明页已移动到独立的 AI 文档栏目。
|
|
3
|
-
---
|
|
1
|
+
# llms.txt
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
`llms.txt` is a convention for publishing a compact, AI-readable map of a documentation site.
|
|
6
4
|
|
|
7
|
-
llms.txt
|
|
5
|
+
This site generates an English-default `/llms.txt` and a larger `/llms-full.txt`. Simplified Chinese content is namespaced under `/zh/`, and historical or internal files are excluded from the index.
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
See the [repoctl AI documentation](../ai/llms-txt.md) for URLs and maintenance rules.
|