@icebreakers/monorepo-templates 1.0.15 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -8
- package/README.zh-CN.md +16 -0
- package/assets/.changeset/ledger.yaml +51 -0
- package/assets/.github/ISSUE_TEMPLATE/config.yml +1 -1
- package/assets/.github/workflows/release.yml +22 -97
- package/assets/AGENTS.md +5 -4
- package/assets/CONTRIBUTING.md +27 -2
- package/assets/SECURITY.md +12 -14
- package/assets/package.json +18 -10
- package/assets/pnpm-workspace.yaml +8 -0
- package/package.json +6 -4
- package/templates/cli/package.json +11 -4
- package/templates/client/package.json +22 -6
- package/templates/server/package.json +14 -7
- package/templates/server/vitest.config.ts +1 -4
- package/templates/tsdown/package.json +11 -4
- package/templates/tsdown/vitest.config.ts +1 -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 +17 -245
- package/templates/vitepress/monorepo/templates.md +10 -17
- package/templates/vitepress/monorepo/troubleshooting.md +13 -16
- package/templates/vitepress/package.json +11 -5
- 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 +12 -85
- 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/vue-lib/vitest.config.ts +1 -1
- package/assets/.changeset/config.json +0 -21
- package/assets/.changeset/publish-versioned-packages.md +0 -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,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
|
-
我采用了 `changesets`,它在 `monorepo` 环境下发布非常方便。功能非常的多,具体可以查看官方文档。
|
|
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,98 +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
|
-
pnpm
|
|
9
|
-
pnpm
|
|
10
|
-
pnpm changeset
|
|
11
|
-
pnpm exec repo release stable
|
|
8
|
+
pnpm change
|
|
9
|
+
pnpm change status
|
|
12
10
|
```
|
|
13
11
|
|
|
14
|
-
|
|
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.
|
|
15
13
|
|
|
16
|
-
##
|
|
17
|
-
|
|
18
|
-
- **核心思想**:每一次改动,不直接修改 `package.json` 里的版本号,而是通过写一个 `changeset` 文件(通常放在 `.changeset` 文件夹下)。
|
|
19
|
-
- **作用**:
|
|
20
|
-
- 记录每次改动影响了哪些包(哪些需要 bump 版本)。
|
|
21
|
-
- 指定改动类型(`patch`、`minor`、`major`)。
|
|
22
|
-
- 自动生成 **Changelog**。
|
|
23
|
-
- 自动修改 `package.json` 的版本号。
|
|
24
|
-
- 与 CI/CD 集成后,可以实现一键自动发版。
|
|
25
|
-
|
|
26
|
-
## 2. 如何使用 Changesets?
|
|
27
|
-
|
|
28
|
-
### 安装
|
|
14
|
+
## Release
|
|
29
15
|
|
|
30
16
|
```bash
|
|
31
|
-
|
|
17
|
+
repo release stable prepare
|
|
18
|
+
repo release stable publish
|
|
32
19
|
```
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
npx changeset init
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
会生成一个 `.changeset` 文件夹,里面包含配置文件。
|
|
41
|
-
|
|
42
|
-
### 添加变更
|
|
43
|
-
|
|
44
|
-
当你完成某个功能或修复后,运行:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
npx changeset
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
它会问:
|
|
51
|
-
|
|
52
|
-
1. 哪些包受影响?
|
|
53
|
-
2. 这是 **patch**(补丁)、**minor**(新功能)、还是 **major**(重大变更)?
|
|
54
|
-
3. 变更的描述是什么?
|
|
55
|
-
|
|
56
|
-
这会生成一个类似这样的文件:
|
|
57
|
-
|
|
58
|
-
```yaml
|
|
59
|
-
# .changeset/sweet-pandas-sing.md
|
|
60
|
-
---
|
|
61
|
-
my-package: patch
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
修复了登录时的 bug
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### 应用版本更新
|
|
68
|
-
|
|
69
|
-
当积累了多个 changeset 后,可以执行:
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
npx changeset version
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
它会根据 changeset 文件:
|
|
76
|
-
|
|
77
|
-
- 更新对应包的版本号。
|
|
78
|
-
- 生成/更新 `CHANGELOG.md`。
|
|
79
|
-
|
|
80
|
-
### 发布
|
|
81
|
-
|
|
82
|
-
最后可以发布:
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npx changeset publish
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
会自动调用 `npm publish`,把包发到 npm registry。
|
|
89
|
-
|
|
90
|
-
## 3. 在 Monorepo 中的优势
|
|
91
|
-
|
|
92
|
-
- 避免多人协作时冲突:大家都往 `.changeset` 添加文件,不会直接改 `package.json`。
|
|
93
|
-
- 统一生成 changelog:自动保证每个版本的改动都被记录。
|
|
94
|
-
- 自动化发布:和 GitHub Actions 等 CI 工具结合,可在合并到主分支后自动发版。
|
|
21
|
+
repoctl coordinates the release workflow, validates configuration, and publishes metadata. pnpm owns the versioning state and repository changelog storage.
|
|
95
22
|
|
|
96
|
-
##
|
|
23
|
+
## Prerelease Lanes
|
|
97
24
|
|
|
98
|
-
|
|
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
|
-
| changeset | 多包版本、变更记录和发布准备 | [changeset](./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
|
-
| 建立规范发版链路 | [changeset](./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.
|
|
@@ -1,127 +1,15 @@
|
|
|
1
1
|
# pnpm
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- `pnpm-workspace.yaml` 决定哪些目录属于 workspace。
|
|
6
|
-
- `pnpm install` 会把 workspace 包链接起来。
|
|
7
|
-
- 根脚本,例如 `pnpm doctor`、`pnpm new`、`pnpm check`,最终会调用 repoctl 的 `repo` CLI。
|
|
8
|
-
|
|
9
|
-
## 在 repoctl 项目里怎么用 pnpm
|
|
3
|
+
pnpm owns workspace discovery, dependency installation, script execution, and versioning configuration.
|
|
10
4
|
|
|
11
5
|
```bash
|
|
12
6
|
pnpm install
|
|
13
|
-
pnpm
|
|
14
|
-
pnpm
|
|
15
|
-
pnpm
|
|
16
|
-
pnpm
|
|
7
|
+
pnpm --filter <package> build
|
|
8
|
+
pnpm -r test
|
|
9
|
+
pnpm change
|
|
10
|
+
pnpm change status
|
|
17
11
|
```
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
| --------------------- | ----------------------------- |
|
|
21
|
-
| `pnpm install` | 安装依赖并创建 workspace link |
|
|
22
|
-
| `pnpm add -D repoctl` | 给已有仓库接入 repoctl CLI |
|
|
23
|
-
| `pnpm doctor` | 通过根脚本运行 `repo doctor` |
|
|
24
|
-
| `pnpm new` | 通过根脚本运行 `repo new` |
|
|
25
|
-
| `pnpm check` | 通过根脚本运行 `repo check` |
|
|
26
|
-
|
|
27
|
-
继续看:[repoctl 快速开始](../repoctl/getting-started.md)。
|
|
28
|
-
|
|
29
|
-
## 1. 什么是 pnpm?
|
|
30
|
-
|
|
31
|
-
**pnpm** 是一种 Node.js 的包管理器(类似于 **npm** 和 **yarn**)。
|
|
32
|
-
名字里的 **p** 代表 **Performant(高性能)**,也有人说是 **“poor man's npm”** 😂。
|
|
33
|
-
|
|
34
|
-
它的核心特点是:
|
|
35
|
-
|
|
36
|
-
- 使用 **硬链接 + 符号链接** 的方式来存储依赖。
|
|
37
|
-
- 避免不同项目重复下载相同的依赖,大大节省磁盘空间。
|
|
38
|
-
- 更快的安装速度。
|
|
39
|
-
|
|
40
|
-
## 2. pnpm 有什么用?
|
|
41
|
-
|
|
42
|
-
### 🚀 性能和空间优势
|
|
43
|
-
|
|
44
|
-
- **npm/yarn**:每个项目都要复制一份完整的依赖到 `node_modules`。
|
|
45
|
-
- **pnpm**:把所有依赖放在一个全局的 **内容可寻址存储(content-addressable store)**,项目里只是通过符号链接指向。
|
|
46
|
-
|
|
47
|
-
结果就是:
|
|
48
|
-
|
|
49
|
-
- 相同的依赖只会存一份。
|
|
50
|
-
- 安装速度更快,磁盘占用更小。
|
|
51
|
-
|
|
52
|
-
### 📦 严格的依赖隔离
|
|
53
|
-
|
|
54
|
-
- 在 `npm` 或 `yarn` 中,`node_modules` 会形成一个“扁平化”结构,有时可能让项目误依赖到不是自己声明的包(幽灵依赖问题)。
|
|
55
|
-
- **pnpm** 使用符号链接保持严格的依赖树,避免隐式依赖。
|
|
56
|
-
👉 如果你的 `package.json` 里没声明,就无法直接引用。
|
|
57
|
-
|
|
58
|
-
### 🛠 Monorepo 支持更好
|
|
59
|
-
|
|
60
|
-
- `pnpm` 原生支持 monorepo 管理(工作空间 `pnpm-workspace.yaml`)。
|
|
61
|
-
- 比如在一个仓库里有多个子包,`pnpm` 可以高效地安装和链接它们,代替 Lerna、Yarn workspaces 等工具。
|
|
62
|
-
|
|
63
|
-
### 🌍 与 npm 生态完全兼容
|
|
64
|
-
|
|
65
|
-
- `pnpm` 底层还是调用 npm registry,所以和 npm 包生态 **100%兼容**。
|
|
66
|
-
- 使用方式也和 `npm` 很接近,学习成本低。
|
|
67
|
-
|
|
68
|
-
## 3. 如何使用 pnpm?
|
|
69
|
-
|
|
70
|
-
### 安装 pnpm
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
npm install -g pnpm
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### 常用命令对照
|
|
77
|
-
|
|
78
|
-
| 操作 | npm | pnpm |
|
|
79
|
-
| ---------- | ------------------ | ---------------- |
|
|
80
|
-
| 安装依赖 | `npm install` | `pnpm install` |
|
|
81
|
-
| 安装某个包 | `npm install xx` | `pnpm add xx` |
|
|
82
|
-
| 移除某个包 | `npm uninstall xx` | `pnpm remove xx` |
|
|
83
|
-
| 更新依赖 | `npm update` | `pnpm update` |
|
|
84
|
-
| 初始化项目 | `npm init` | `pnpm init` |
|
|
85
|
-
|
|
86
|
-
### Monorepo 示例
|
|
87
|
-
|
|
88
|
-
创建 `pnpm-workspace.yaml`:
|
|
89
|
-
|
|
90
|
-
```yaml
|
|
91
|
-
packages:
|
|
92
|
-
- 'packages/*'
|
|
93
|
-
- 'apps/*'
|
|
94
|
-
- 'templates/*'
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
这样 `pnpm` 会自动管理多个子项目的依赖和链接。
|
|
98
|
-
|
|
99
|
-
## 总结
|
|
100
|
-
|
|
101
|
-
- **pnpm 是一种更快、更省空间、更严格的包管理器**。
|
|
102
|
-
- 核心优势:
|
|
103
|
-
1. **磁盘节省**(共享依赖存储)。
|
|
104
|
-
2. **安装速度快**。
|
|
105
|
-
3. **严格依赖管理**,避免幽灵依赖。
|
|
106
|
-
4. **原生支持 monorepo**。
|
|
107
|
-
|
|
108
|
-
## npm vs Yarn vs pnpm 对比表
|
|
109
|
-
|
|
110
|
-
| 特性 / 工具 | **npm** | **Yarn** | **pnpm** |
|
|
111
|
-
| ----------------- | -------------------------------- | ----------------------------- | -------------------------------------- |
|
|
112
|
-
| **生态兼容性** | ✅ 官方,100% 兼容 npm registry | ✅ 兼容 npm registry | ✅ 兼容 npm registry |
|
|
113
|
-
| **安装速度** | ⏳ 较慢(尤其是全量安装时) | 🚀 比 npm 快,缓存优化 | ⚡ 非常快(硬链接 + 全局存储机制) |
|
|
114
|
-
| **磁盘空间占用** | 📦 高,每个项目一份完整依赖 | 📦 中等,有缓存但依赖重复存储 | 🪶 很低,共享依赖存储,节省大量空间 |
|
|
115
|
-
| **依赖结构** | 扁平化,可能产生“幽灵依赖” | 扁平化,依旧可能有幽灵依赖 | 严格隔离,避免幽灵依赖 |
|
|
116
|
-
| **Monorepo 支持** | 🚫 无原生支持,需要 Lerna 等工具 | ⚠️ Yarn Workspaces 支持 | ✅ 原生支持 Workspaces,管理更高效 |
|
|
117
|
-
| **命令兼容性** | 标准 npm 命令 | 大部分与 npm 相似 | 基本兼容,部分命令略有不同(如 `add`) |
|
|
118
|
-
| **锁文件** | `package-lock.json` | `yarn.lock` | `pnpm-lock.yaml` |
|
|
119
|
-
| **稳定性** | ✅ 官方维护,稳定性高 | ✅ 较成熟,社区维护 | ✅ 越来越流行,性能最佳 |
|
|
120
|
-
| **学习成本** | ⭐⭐ 最低 | ⭐⭐ 略有差异(命令相似) | ⭐⭐⭐ 略高,但上手简单 |
|
|
121
|
-
| **适用场景** | 小型项目,或默认环境 | 中大型项目,需要更快安装 | 中大型/Monorepo 项目,重视性能和空间 |
|
|
122
|
-
|
|
123
|
-
## 对比总结
|
|
13
|
+
`pnpm-workspace.yaml` is the source of truth for package patterns and release groups. repoctl can diagnose missing patterns and synchronize recommended defaults, but pnpm remains the package manager.
|
|
124
14
|
|
|
125
|
-
|
|
126
|
-
- **Yarn**:性能较优,适合需要加快依赖安装的团队。
|
|
127
|
-
- **pnpm**:性能最好、磁盘最省、依赖最严格,特别适合 **大型项目** 和 **monorepo** 场景。
|
|
15
|
+
Prefer exact workspace filters in automation and keep `packageManager` plus `engines.node` declared at the repository root.
|