@icebreakers/monorepo 5.1.0 → 5.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 CHANGED
@@ -1,225 +1,32 @@
1
1
  # @icebreakers/monorepo
2
2
 
3
- `repoctl` 背后的 core engine 与 tooling wrapper。
3
+ English | [简体中文](README.zh-CN.md)
4
4
 
5
- 如果你只是想使用默认 CLI 体验,优先安装 `repoctl`,并使用更短的 `repo` 命令:
5
+ Core engine and programmatic APIs for repoctl.
6
6
 
7
- ```sh
8
- pnpm add -D repoctl
9
- pnpm exec repo init
10
- pnpm exec repo doctor
11
- pnpm exec repo doctor --json
12
- pnpm exec repo templates
13
- pnpm exec repo new my-package
14
- pnpm exec repo check
15
- pnpm exec repo check --dry-run
16
- pnpm exec repo env info
17
- ```
18
-
19
- 模板生成后的仓库还会带上无冲突的 `repo:*` 根脚本:
20
-
21
- ```sh
22
- pnpm run repo:init
23
- pnpm run repo:doctor -- --json
24
- pnpm run repo:new -- my-package
25
- pnpm run repo:check
26
- ```
27
-
28
- ## 什么时候直接用这个包
29
-
30
- `@icebreakers/monorepo` 更适合下面两类场景:
31
-
32
- - 你需要直接使用 `@icebreakers/monorepo` / `@icebreakers/monorepo/tooling` 的程序化 API
33
- - 你在维护 `repoctl` 的底层实现、模板、升级资产或 wrapper 配置
34
-
35
- ## CLI 入口
36
-
37
- `@icebreakers/monorepo` 仍提供 `repo` / `repoctl` 两个 CLI 入口,旧的 `monorepo`、`mo`、`rc` bin 别名已移除。
38
-
39
- ```sh
40
- pnpm add -D @icebreakers/monorepo@latest
41
-
42
- # 顶层任务命令
43
- pnpm exec repo init
44
- pnpm exec repo doctor
45
- pnpm exec repo templates
46
- pnpm exec repo new my-package
47
- pnpm exec repo check
48
- pnpm exec repo upgrade
49
-
50
- # 分组命令
51
- pnpm exec repo ws up
52
- pnpm exec repo ws ls --json --include-private
53
- pnpm exec repo tg init --all
54
- pnpm exec repo pkg new
55
- pnpm exec repo ai p new --name checkout
56
- pnpm exec repo skills sync --codex
57
- ```
58
-
59
- 推荐顺序是:
60
-
61
- 1. 生成仓库里的 `pnpm run repo:init / pnpm run repo:doctor / pnpm run repo:new / pnpm run repo:check`
62
- 2. `repo ...`
63
- 3. `repoctl ...`
64
-
65
- ## `repo check`
66
-
67
- `check` 是推荐的本地验证入口。默认执行轻量 pre-commit 校验,`--staged` 会追加 staged typecheck 路由,`--full` 会切到 pre-push 级别的完整校验。
68
-
69
- 如果只想看会跑什么,不实际执行校验,可以使用:
70
-
71
- ```sh
72
- repo check --dry-run
73
- repo check --staged --json
74
- repo check --full --json --out reports/check-plan.json
75
- ```
76
-
77
- ## `repo doctor`
78
-
79
- `doctor` 是这次 CLI 增强里最面向新人的入口。它会检查:
80
-
81
- - 根 `package.json`
82
- - `pnpm-workspace.yaml`
83
- - 当前 Node 版本是否满足 `engines.node`
84
- - 根依赖里是否安装了 `repoctl`
85
- - 推荐的根脚本 `repo:init / repo:new / repo:check / repo:doctor` 是否齐全
86
- - 是否仍残留已废弃的 `monorepo.config.ts`
87
- - `.husky/pre-commit` 与 `lint-staged.config.js` 是否同时存在
88
-
89
- 如果有阻塞项,命令会以非零状态结束。
90
-
91
- 需要在 CI、脚本或编辑器集成中消费诊断结果时,使用 `repo doctor --json`。它只输出结构化报告;如果存在 blocking issue,仍会以非零状态结束。
92
- 也可以加 `--out <file>` 把文本或 JSON 报告写入文件,例如 `repo doctor --json --out reports/doctor.json`。
93
-
94
- ## 性能与开发体验
95
-
96
- CLI 启动时只注册命令树,具体命令实现会在 action 执行时懒加载。因此 `repo --help`、`repo doctor --help`、`repoctl` 等入口不会提前加载所有 workspace、Git、配置与模板处理逻辑。
97
-
98
- 同一进程内的 workspace 发现会复用缓存,包括 workspace 根目录、`pnpm-workspace.yaml` 和 package 扫描结果。长期运行的程序化集成在修改 workspace 结构后,可以调用 `clearWorkspaceCache()` 强制后续读取重新扫描磁盘。
99
-
100
- `repo ws ls` 会使用同一套缓存快速列出 workspace 包,并支持 `--json`、`--out <file>`、`--include-private`、`--include-root` 和可重复的 `--pattern`。程序化场景可以直接调用 `getWorkspacePackageSummaries()` 获取相同的轻量摘要数据。
101
-
102
- `repo env info` 会输出当前工作目录、workspace 根目录、Node/pnpm 版本、`packageManager` 和 workspace 包数量。需要把环境信息附到 issue、CI artifact 或编辑器诊断时,可以使用 `repo env info --json --out reports/env.json`。
103
- 需要一次性收集环境、`doctor` 结果和默认 `check` 路由时,可以使用 `repo env snapshot --json --out reports/snapshot.json`。
104
-
105
- ## 默认 CLI 配置
106
-
107
- 工作区根目录使用 `repoctl.config.ts` 覆盖默认行为。`monorepo.config.ts` 已不再作为运行时配置入口。
108
-
109
- ```ts
110
- import { defineMonorepoConfig } from 'repoctl'
111
-
112
- export default defineMonorepoConfig({
113
- commands: {
114
- init: {
115
- preset: 'standard',
116
- },
117
- create: {
118
- defaultTemplate: 'tsdown',
119
- },
120
- },
121
- })
122
- ```
123
-
124
- ## 默认提交校验
125
-
126
- 如果你采用包内默认生成的 `.husky` 与 `lint-staged.config.js`,提交链路会自动包含下面这些校验:
127
-
128
- - `pre-commit` 只检查 staged 文件
129
- - 样式文件会执行 `stylelint --fix --allow-empty-input`
130
- - `js`、`jsx`、`mjs`、`ts`、`tsx`、`mts`、`cts`、`vue` 文件会执行 `eslint --fix`
131
- - `**/package.json` 改动会按所在 workspace 继续执行 `typecheck`
132
- - `ts` / `tsx` / `mts` / `cts` / `vue` staged 文件会按最近的 workspace 执行 `typecheck`
133
- - Vue workspace 的 `typecheck` 通常是 `vue-tsc -b`
134
- - 纯 TypeScript workspace 的 `typecheck` 通常是 `tsc -p tsconfig.json`
135
- - `pre-push` 会强制执行整仓 `pnpm lint` 与 `pnpm typecheck`,再按改动范围补跑 `build`、`test`、`tsd`
136
-
137
- ## `new` 与 `ai prompt` 的常用用法
138
-
139
- 先用 `repo templates` 查看内置模板:
140
-
141
- ```bash
142
- repo templates
143
- repo templates tsdown
144
- repo templates --category library
145
- repo templates --check
146
- repo templates --check --json
147
- repo templates --json
148
- repo templates --markdown
149
- repo templates tsdown --markdown
150
- repo templates --markdown --out docs/templates.md
151
- ```
152
-
153
- `repo new` / `monorepo new` 支持 `--template` 直接指定模板,例如:
7
+ Most users should install [`repoctl`](../repoctl) and use the `repo` command. Install this package directly when you need its lower-level workspace, configuration, diagnostics, release, or tooling APIs.
154
8
 
155
9
  ```bash
156
- repo new dashboard --template vue-hono
157
- repo new dashboard --template vue-hono --dry-run
158
- repo new dashboard --template vue-hono --json
159
- repo new dashboard --template vue-hono --json --out plans/dashboard.json
160
- ```
161
-
162
- 如果 `--template` 拼错,CLI 会直接失败并提示最接近的模板 key;它不会静默回退到默认模板。
163
- `--json` 用于脚本读取创建计划,隐含 `--dry-run`,不会写入文件。
164
- `--out` 会把创建计划写入文件,也隐含 `--dry-run`。
165
-
166
- 当 `repoctl.config.ts` 中设置了 `commands.create.defaultTemplate` 时,命令会直接创建,不再额外询问模板,并自动按模板落到 `packages/` 或 `apps/`。
167
-
168
- `repo ai prompt create` 支持批量生成:
169
-
170
- ```bash
171
- pnpm exec repo ai prompt create --name checkout
172
- pnpm exec repo ai prompt create --tasks agentic/tasks.json --format md -f
10
+ pnpm add -D repoctl
11
+ pnpm exec repo doctor
173
12
  ```
174
13
 
175
- ## Tooling Wrapper API
176
-
177
- 如果你希望在生成后的配置文件基础上继续手写覆盖,推荐使用 `repoctl/tooling` 暴露的 wrapper。
178
-
179
- - `defineCommitlintConfig` / `defineStylelintConfig` / `defineLintStagedConfig` / `defineTsconfigConfig` 统一使用 `options`
180
- - `defineEslintConfig` 支持 `defineEslintConfig(baseOptions, ...configs)`、`{ options, configs }` 和 `options.configs`
181
- - `defineVitestConfig` 使用 `options` 加 `overrides`
182
- - `defineVitestProjectConfig` 也已统一使用 `options`
14
+ ## Programmatic usage
183
15
 
184
16
  ```ts
185
- import { defineEslintConfig, defineVitestConfig, defineVitestProjectConfig } from 'repoctl/tooling'
186
- import { defineConfig, defineProject } from 'vitest/config'
187
-
188
- export const eslintConfig = await defineEslintConfig(
189
- {
190
- ignores: ['fixtures/**'],
191
- },
192
- {
193
- rules: {
194
- 'no-console': 'off',
195
- },
196
- },
197
- )
198
-
199
- export const vitestConfig = defineConfig(async () => await defineVitestConfig({
200
- options: {
201
- includeWorkspaceRootConfig: false,
202
- },
203
- overrides: {
204
- test: {
205
- coverage: {
206
- exclude: ['dist/**'],
207
- },
208
- },
209
- },
210
- }))
17
+ import {
18
+ getWorkspacePackageSummaries,
19
+ runDoctor,
20
+ } from '@icebreakers/monorepo'
211
21
 
212
- export const vitestProject = defineProject(await defineVitestProjectConfig({
213
- options: {
214
- environment: 'jsdom',
215
- },
216
- }))
22
+ const workspace = await getWorkspacePackageSummaries(process.cwd())
23
+ const report = await runDoctor(workspace.workspaceDir)
217
24
  ```
218
25
 
219
- ## 文档地址
26
+ Tooling wrappers are available from either `@icebreakers/monorepo/tooling` or the recommended `repoctl/tooling` entrypoint.
220
27
 
221
- https://repo.icebreaker.top/
28
+ ## Compatibility
222
29
 
223
- ## 需求环境
30
+ This package retains the `repo` and `repoctl` bins for existing installations. New user documentation recommends the `repoctl` package; the command surface is shared.
224
31
 
225
- Node.js >= `v20.12.0`
32
+ Documentation: https://repo.icebreaker.top
@@ -0,0 +1,23 @@
1
+ # @icebreakers/monorepo
2
+
3
+ [English](README.md) | 简体中文
4
+
5
+ repoctl 的 core engine 与程序化 API。
6
+
7
+ 大多数用户应安装 [`repoctl`](../repoctl) 并使用 `repo` 命令。只有在需要底层 workspace、配置、诊断、发布或 tooling API 时,才需要直接安装本包。
8
+
9
+ ```bash
10
+ pnpm add -D repoctl
11
+ pnpm exec repo doctor
12
+ ```
13
+
14
+ ```ts
15
+ import { getWorkspacePackageSummaries, runDoctor } from '@icebreakers/monorepo'
16
+
17
+ const workspace = await getWorkspacePackageSummaries(process.cwd())
18
+ const report = await runDoctor(workspace.workspaceDir)
19
+ ```
20
+
21
+ 本包为已有安装保留 `repo` 和 `repoctl` bin。新用户文档统一推荐 `repoctl` 包。
22
+
23
+ 文档:https://repo.icebreaker.top