@icebreakers/monorepo-templates 1.0.2 → 1.0.4
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/assets/.github/workflows/release.yml +42 -2
- package/assets/commitlint.config.ts +1 -3
- package/assets/eslint.config.js +2 -14
- package/assets/lint-staged.config.js +1 -3
- package/assets/package.json +8 -6
- package/assets/stylelint.config.js +1 -3
- package/assets/tsconfig.json +2 -1
- package/assets/vitest.config.ts +1 -3
- package/assets-data.mjs +0 -1
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +12 -0
- package/dist/index.mjs +1 -260
- package/dist/prepare-CtCifHGT.mjs +306 -0
- package/package.json +2 -2
- package/templates/client/package.json +2 -2
- package/templates/client/vite.config.ts +27 -21
- package/templates/vitepress/.vitepress/config.ts +152 -69
- package/templates/vitepress/en/index.md +63 -0
- package/templates/vitepress/en/knowledge/monorepo.md +37 -0
- package/templates/vitepress/en/repoctl/adopt-existing.md +131 -0
- package/templates/vitepress/en/repoctl/aliases.md +71 -0
- package/templates/vitepress/en/repoctl/commands.md +120 -0
- package/templates/vitepress/en/repoctl/config.md +69 -0
- package/templates/vitepress/en/repoctl/getting-started.md +116 -0
- package/templates/vitepress/en/repoctl/index.md +74 -0
- package/templates/vitepress/en/repoctl/scenarios.md +117 -0
- package/templates/vitepress/en/repoctl/templates.md +128 -0
- package/templates/vitepress/en/repoctl/troubleshooting.md +96 -0
- package/templates/vitepress/en/repoctl/workflows.md +89 -0
- package/templates/vitepress/getting-started.md +21 -224
- package/templates/vitepress/index.md +47 -176
- package/templates/vitepress/monorepo/commands.md +13 -283
- package/templates/vitepress/monorepo/manage.md +16 -3
- package/templates/vitepress/monorepo/publish.md +52 -6
- package/templates/vitepress/monorepo/templates.md +14 -60
- package/templates/vitepress/monorepo/troubleshooting.md +14 -220
- package/templates/vitepress/package.json +3 -2
- package/templates/vitepress/repoctl/adopt-existing.md +135 -0
- package/templates/vitepress/repoctl/aliases.md +71 -0
- package/templates/vitepress/repoctl/commands.md +154 -0
- package/templates/vitepress/repoctl/config.md +81 -0
- package/templates/vitepress/repoctl/getting-started.md +122 -0
- package/templates/vitepress/repoctl/index.md +74 -0
- package/templates/vitepress/repoctl/scenarios.md +119 -0
- package/templates/vitepress/repoctl/templates.md +156 -0
- package/templates/vitepress/repoctl/troubleshooting.md +98 -0
- package/templates/vitepress/repoctl/workflows.md +105 -0
- package/templates/vitepress/tools/changeset.md +11 -0
- package/templates/vitepress/tools/husky.md +17 -0
- package/templates/vitepress/tools/lint-staged.md +10 -0
- package/templates/vitepress/tools/llms-txt.md +29 -0
- package/templates/vitepress/tools/pnpm.md +26 -0
- package/templates/vitepress/tools/turborepo.md +17 -0
- package/templates/vitepress/why/examples/2.npm-basic-package/README.md +1 -1
- package/templates/vitepress/why/examples/3.npm-basic-package/README.md +1 -1
- package/templates/vitepress/wrangler.jsonc +5 -0
- package/templates/vue-lib/package.json +1 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Choose By Scenario
|
|
2
|
+
|
|
3
|
+
Start here when you know what you want to do, but not which repoctl command to use.
|
|
4
|
+
|
|
5
|
+
## I Just Opened A Repository
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm install
|
|
9
|
+
pnpm doctor
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
If `pnpm doctor` does not exist yet:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add -D repoctl
|
|
16
|
+
pnpm exec repo setup --yes
|
|
17
|
+
pnpm exec repo doctor
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Keep reading: [Getting Started](./getting-started.md).
|
|
21
|
+
|
|
22
|
+
## I Want To Adopt repoctl In An Existing Repo
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add -D repoctl
|
|
26
|
+
pnpm exec repo setup --yes
|
|
27
|
+
pnpm exec repo doctor --markdown --redact --out reports/doctor-before.md
|
|
28
|
+
pnpm exec repo upgrade --no-overwrite
|
|
29
|
+
pnpm exec repo doctor --markdown --redact --out reports/doctor-after.md
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Keep reading: [Adopt Existing Repositories](./adopt-existing.md).
|
|
33
|
+
|
|
34
|
+
## I Want To Create A Package Or App
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pnpm exec repo templates
|
|
38
|
+
pnpm exec repo new sdk --template tsdown
|
|
39
|
+
pnpm exec repo new docs --template vitepress --dry-run
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For daily development, root scripts also work:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pnpm new sdk --template tsdown
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Keep reading: [Templates](./templates.md).
|
|
49
|
+
|
|
50
|
+
## I Want To Check Before Committing
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm check
|
|
54
|
+
pnpm exec repo check --dry-run
|
|
55
|
+
pnpm exec repo check --full
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Save the plan when automation needs it:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pnpm exec repo check --json --out reports/check-plan.json
|
|
62
|
+
pnpm exec repo check --markdown --redact --out reports/check-plan.md
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Keep reading: [Workflows and CI](./workflows.md).
|
|
66
|
+
|
|
67
|
+
## I Want To Debug CI Or Another Machine
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pnpm exec repo doctor --markdown --redact --out reports/doctor.md
|
|
71
|
+
pnpm exec repo env support --markdown --redact --out reports/support.md
|
|
72
|
+
pnpm exec repo env snapshot --json --out reports/snapshot.json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Keep reading: [Troubleshooting](./troubleshooting.md).
|
|
76
|
+
|
|
77
|
+
## I Want To Sync Standard Assets
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pnpm exec repo upgrade --no-overwrite
|
|
81
|
+
pnpm exec repo upgrade --yes
|
|
82
|
+
pnpm exec repo upgrade --core
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
| Goal | Command |
|
|
86
|
+
| ------------------------------------------ | ----------------------------- |
|
|
87
|
+
| First adoption pass, preserve local config | `repo upgrade --no-overwrite` |
|
|
88
|
+
| Explicitly overwrite managed assets | `repo upgrade --yes` |
|
|
89
|
+
| Sync only core config | `repo upgrade --core` |
|
|
90
|
+
|
|
91
|
+
## I Want To Inspect Workspace Structure
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pnpm exec repo ws ls
|
|
95
|
+
pnpm exec repo ws ls --json --out reports/workspaces.json
|
|
96
|
+
pnpm exec repo ws ls --markdown --redact --out reports/workspaces.md
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## I Want To Inspect Config
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pnpm exec repo config inspect
|
|
103
|
+
pnpm exec repo cfg i --json --out reports/config.json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Keep reading: [Configuration](./config.md).
|
|
107
|
+
|
|
108
|
+
## I Want Shorter Commands
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
repo tpl
|
|
112
|
+
repo ws ls
|
|
113
|
+
repo e support --markdown --redact
|
|
114
|
+
repo cfg i
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Keep reading: [Command Aliases](./aliases.md).
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Templates
|
|
2
|
+
|
|
3
|
+
repoctl templates are maintained by `@icebreakers/monorepo-templates`. The CLI, scaffolder, and docs share the same template metadata.
|
|
4
|
+
|
|
5
|
+
## Built-In Templates
|
|
6
|
+
|
|
7
|
+
| Key | Category | Default target | Use case |
|
|
8
|
+
| ------------- | -------- | ------------------ | ----------------------- |
|
|
9
|
+
| `tsdown` | library | `packages/tsdown` | TypeScript library |
|
|
10
|
+
| `vue-lib` | library | `packages/vue-lib` | Vue 3 component library |
|
|
11
|
+
| `vue-hono` | app | `apps/client` | Vue 3 + Hono app |
|
|
12
|
+
| `hono-server` | service | `apps/server` | Hono API service |
|
|
13
|
+
| `vitepress` | docs | `apps/website` | VitePress docs site |
|
|
14
|
+
| `cli` | tool | `apps/cli` | TypeScript CLI |
|
|
15
|
+
|
|
16
|
+
## Discover Templates
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
repo templates
|
|
20
|
+
repo templates tsdown
|
|
21
|
+
repo templates --category library
|
|
22
|
+
repo templates --json
|
|
23
|
+
repo templates --markdown --out docs/templates.md
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Create From A Template
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
repo new sdk --template tsdown
|
|
30
|
+
repo new ui --template vue-lib
|
|
31
|
+
repo new api --template hono-server
|
|
32
|
+
repo new website --template vitepress
|
|
33
|
+
repo new toolbox --template cli
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Simple names are placed in the conventional target folder. Library templates go under `packages/`; app templates go under `apps/`. If you pass an explicit path such as `packages/shared-utils`, repoctl respects it.
|
|
37
|
+
|
|
38
|
+
## Choose By Goal
|
|
39
|
+
|
|
40
|
+
### Publish an npm library
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
repo new sdk --template tsdown
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Check first:
|
|
47
|
+
|
|
48
|
+
- `package.json` `name`, `exports`, and `types`.
|
|
49
|
+
- Whether `tsdown.config.ts` matches the desired output format.
|
|
50
|
+
- Whether public types need `tsd` tests.
|
|
51
|
+
|
|
52
|
+
### Build reusable Vue components
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
repo new ui --template vue-lib
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Check first:
|
|
59
|
+
|
|
60
|
+
- Component entry points only expose stable APIs.
|
|
61
|
+
- Styles pass Stylelint.
|
|
62
|
+
- A docs site or example app should be created alongside it if needed.
|
|
63
|
+
|
|
64
|
+
### Create an app or service
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
repo new web --template vue-hono
|
|
68
|
+
repo new api --template hono-server
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Check first:
|
|
72
|
+
|
|
73
|
+
- Runtime environment variables and deployment constraints.
|
|
74
|
+
- `dev`, `build`, and `typecheck` scripts are part of root tasks.
|
|
75
|
+
- CI needs integration or E2E tests.
|
|
76
|
+
|
|
77
|
+
### Create a docs site
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
repo new docs --template vitepress
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Check first:
|
|
84
|
+
|
|
85
|
+
- Nav and sidebar are organized around the product or package.
|
|
86
|
+
- A second locale is required.
|
|
87
|
+
- `repo templates --markdown` output should be written into docs.
|
|
88
|
+
|
|
89
|
+
### Create a CLI
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
repo new toolbox --template cli
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Check first:
|
|
96
|
+
|
|
97
|
+
- The `bin` field matches the final command name.
|
|
98
|
+
- Argument parsing, exit codes, and help output are testable.
|
|
99
|
+
- README documents command usage.
|
|
100
|
+
|
|
101
|
+
## Preview Creation
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
repo new website --template vitepress --dry-run
|
|
105
|
+
repo new website --template vitepress --json
|
|
106
|
+
repo new website --template vitepress --json --out plans/website.json
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`--dry-run` does not write files. It shows the template, source directory, target directory, package name, and output files.
|
|
110
|
+
|
|
111
|
+
`--json` emits the same plan as structured data and implies `--dry-run`.
|
|
112
|
+
|
|
113
|
+
`--out <file>` persists the preview and also implies `--dry-run`.
|
|
114
|
+
|
|
115
|
+
## Check Template Health
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
repo templates --check
|
|
119
|
+
repo templates --check --json
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The check validates duplicate sources and targets, existing source directories, package metadata, categories, descriptions, and temporary files that would be filtered by the scaffolder.
|
|
123
|
+
|
|
124
|
+
## Keep Reading
|
|
125
|
+
|
|
126
|
+
- [Adopt Existing Repositories](./adopt-existing.md)
|
|
127
|
+
- [Workflows and CI](./workflows.md)
|
|
128
|
+
- [Configuration](./config.md)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
repoctl focuses on reports that can be reproduced, saved, and shared.
|
|
4
|
+
|
|
5
|
+
## Start With Doctor
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
repo doctor
|
|
9
|
+
repo doctor --strict
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`doctor` checks:
|
|
13
|
+
|
|
14
|
+
- Current directory and repository root.
|
|
15
|
+
- Node.js version.
|
|
16
|
+
- `pnpm-workspace.yaml`.
|
|
17
|
+
- The `repoctl` CLI dependency.
|
|
18
|
+
- Recommended root scripts.
|
|
19
|
+
- Conflicting config files.
|
|
20
|
+
- Husky and lint-staged wiring.
|
|
21
|
+
|
|
22
|
+
## Save A Diagnostic Report
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
repo doctor --json --out reports/doctor.json
|
|
26
|
+
repo doctor --markdown --redact --out reports/doctor.md
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Markdown reports are useful in issues and PRs. `--redact` removes local absolute paths.
|
|
30
|
+
|
|
31
|
+
## Inspect The Verification Plan
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
repo check --dry-run
|
|
35
|
+
repo check --json --out reports/check-plan.json
|
|
36
|
+
repo check --markdown --redact --out reports/check-plan.md
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Use this when you need to understand why a file triggers a workspace typecheck or which tasks pre-push would run.
|
|
40
|
+
|
|
41
|
+
## Collect Environment Information
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
repo env info
|
|
45
|
+
repo env support --markdown --redact --out reports/support.md
|
|
46
|
+
repo env snapshot --json --out reports/snapshot.json
|
|
47
|
+
repo env paths --markdown --redact --out reports/paths.md
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
These commands help compare local, CI, Git, Node, pnpm, and workspace differences.
|
|
51
|
+
|
|
52
|
+
## Common Fixes
|
|
53
|
+
|
|
54
|
+
### Not At Repository Root
|
|
55
|
+
|
|
56
|
+
Change into the directory that contains `pnpm-workspace.yaml` and the root `package.json`, then run:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
repo doctor
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Conflicting Config Files
|
|
63
|
+
|
|
64
|
+
Keep only:
|
|
65
|
+
|
|
66
|
+
```txt
|
|
67
|
+
repoctl.config.ts
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`monorepo.config.ts` is for compatibility with older projects.
|
|
71
|
+
|
|
72
|
+
### Unknown Template Key
|
|
73
|
+
|
|
74
|
+
List available templates:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
repo templates
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Explicit `--template` values are validated first. Invalid keys fail with suggestions.
|
|
81
|
+
|
|
82
|
+
### Automation Should Not Prompt
|
|
83
|
+
|
|
84
|
+
Use non-interactive options:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
repo setup --yes
|
|
88
|
+
repo upgrade --no-overwrite
|
|
89
|
+
repo check --json --out reports/check-plan.json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Keep Reading
|
|
93
|
+
|
|
94
|
+
- [Workflows and CI](./workflows.md)
|
|
95
|
+
- [Command Reference](./commands.md)
|
|
96
|
+
- [Command Aliases](./aliases.md)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Workflows and CI
|
|
2
|
+
|
|
3
|
+
repoctl commands have two audiences: humans using short daily commands, and automation consuming stable reports.
|
|
4
|
+
|
|
5
|
+
## Local Daily Workflow
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm install
|
|
9
|
+
pnpm doctor
|
|
10
|
+
pnpm new sdk --template tsdown
|
|
11
|
+
pnpm check
|
|
12
|
+
pnpm build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
| Step | What It Proves |
|
|
16
|
+
| -------------- | ------------------------------------------------------- |
|
|
17
|
+
| `pnpm install` | Workspace dependencies and local links are ready |
|
|
18
|
+
| `pnpm doctor` | Root files, Node, scripts, config, and hooks are usable |
|
|
19
|
+
| `pnpm new` | New packages follow template conventions |
|
|
20
|
+
| `pnpm check` | The lightweight local verification flow is reproducible |
|
|
21
|
+
| `pnpm build` | The workspace build graph has no obvious breakage |
|
|
22
|
+
|
|
23
|
+
## Adopt An Existing Repository
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpm add -D repoctl
|
|
27
|
+
pnpm exec repo setup --yes
|
|
28
|
+
pnpm exec repo doctor --markdown --out reports/doctor.md
|
|
29
|
+
pnpm exec repo upgrade --no-overwrite
|
|
30
|
+
pnpm exec repo doctor
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Start conservatively with `--no-overwrite`. After reviewing asset drift, decide whether `--yes` or `--overwrite` is appropriate.
|
|
34
|
+
|
|
35
|
+
## Fast CI Gate
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm install --frozen-lockfile
|
|
39
|
+
pnpm exec repo doctor --strict
|
|
40
|
+
pnpm exec repo check --full
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
This is a simple gate for small repositories or early projects. `doctor --strict` treats warnings as failures.
|
|
44
|
+
|
|
45
|
+
## CI Report Mode
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pnpm exec repo doctor --json --out reports/doctor.json
|
|
49
|
+
pnpm exec repo check --json --out reports/check-plan.json
|
|
50
|
+
pnpm exec repo env support --markdown --redact --out reports/support.md
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Use these outputs as CI artifacts:
|
|
54
|
+
|
|
55
|
+
- `doctor.json` for scripts.
|
|
56
|
+
- `check-plan.json` to explain verification routing.
|
|
57
|
+
- `support.md` for issues, PRs, and external collaboration.
|
|
58
|
+
|
|
59
|
+
## Hooks
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
repo verify pre-commit
|
|
63
|
+
repo verify staged-typecheck packages/app/src/main.ts
|
|
64
|
+
repo verify commit-msg .git/COMMIT_EDITMSG
|
|
65
|
+
repo verify pre-push
|
|
66
|
+
```
|
|
67
|
+
|
|
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 |
|
|
73
|
+
|
|
74
|
+
## Non-Interactive Options
|
|
75
|
+
|
|
76
|
+
| Scenario | Option |
|
|
77
|
+
| ------------------------------------- | -------------------------------------------------- |
|
|
78
|
+
| Accept setup defaults | `repo setup --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>` |
|
|
84
|
+
|
|
85
|
+
## Keep Reading
|
|
86
|
+
|
|
87
|
+
- [Command Reference](./commands.md)
|
|
88
|
+
- [Troubleshooting](./troubleshooting.md)
|
|
89
|
+
- [Command Aliases](./aliases.md)
|
|
@@ -1,243 +1,40 @@
|
|
|
1
|
-
---
|
|
2
|
-
layout: doc
|
|
3
|
-
---
|
|
4
|
-
|
|
5
1
|
# 新手使用指南
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## 你需要先准备什么
|
|
3
|
+
这篇旧入口已经收敛到 repoctl 主线。新读者建议直接阅读:
|
|
10
4
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
5
|
+
- [repoctl 快速开始](./repoctl/getting-started.md)
|
|
6
|
+
- [repoctl 命令速查](./repoctl/commands.md)
|
|
7
|
+
- [repoctl 配置文件](./repoctl/config.md)
|
|
14
8
|
|
|
15
|
-
|
|
9
|
+
## 先这样用
|
|
16
10
|
|
|
17
11
|
```bash
|
|
18
|
-
|
|
19
|
-
pnpm
|
|
20
|
-
|
|
12
|
+
pnpm add -D repoctl
|
|
13
|
+
pnpm exec repo setup
|
|
14
|
+
pnpm exec repo doctor
|
|
15
|
+
pnpm exec repo new
|
|
16
|
+
pnpm exec repo check
|
|
21
17
|
```
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
模板生成仓库里可以使用更短的根脚本:
|
|
24
20
|
|
|
25
21
|
```bash
|
|
26
|
-
pnpm install
|
|
27
22
|
pnpm setup
|
|
28
23
|
pnpm doctor
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
这三步分别解决三件事:
|
|
32
|
-
|
|
33
|
-
| 命令 | 作用 |
|
|
34
|
-
| -------------- | ---------------------------------- |
|
|
35
|
-
| `pnpm install` | 安装 workspace 依赖 |
|
|
36
|
-
| `pnpm setup` | 同步推荐的根脚本、配置和工具链入口 |
|
|
37
|
-
| `pnpm doctor` | 检查当前仓库能不能顺利开始开发 |
|
|
38
|
-
|
|
39
|
-
如果 `doctor` 报错,先按输出里的 `fix:` 处理。处理完再跑一次 `pnpm doctor`,直到没有 blocking issue。
|
|
40
|
-
|
|
41
|
-
如果要在 CI 或脚本里读取诊断结果:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
pnpm exec repo doctor --json
|
|
45
|
-
pnpm exec repo doctor --json --out reports/doctor.json
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
如果希望 CI 把建议项也当成失败,使用 strict 模式:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
pnpm exec repo doctor --strict
|
|
52
|
-
pnpm exec repo doctor --strict --json --out reports/doctor.json
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## 创建第一个包或应用
|
|
56
|
-
|
|
57
|
-
不知道要用哪个模板时,先看列表:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
pnpm exec repo templates
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
只看库包模板:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
pnpm exec repo templates --category library
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
常用模板:
|
|
70
|
-
|
|
71
|
-
| 模板 | 适合什么 |
|
|
72
|
-
| ------------- | ----------------- |
|
|
73
|
-
| `tsdown` | TypeScript 库包 |
|
|
74
|
-
| `vue-lib` | Vue 3 组件库 |
|
|
75
|
-
| `vue-hono` | Vue 3 + Hono 应用 |
|
|
76
|
-
| `hono-server` | Hono API 服务 |
|
|
77
|
-
| `vitepress` | 文档站 |
|
|
78
|
-
| `cli` | 命令行工具 |
|
|
79
|
-
|
|
80
|
-
创建时可以走交互式:
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
24
|
pnpm new
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
也可以直接指定:
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
pnpm new my-lib --template tsdown
|
|
90
|
-
pnpm new website --template vitepress
|
|
91
|
-
pnpm new api --template hono-server
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
创建前想先确认目标目录:
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
pnpm new website --template vitepress --dry-run
|
|
98
|
-
pnpm new website --template vitepress --json
|
|
99
|
-
pnpm new website --template vitepress --json --out plans/website.json
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
如果模板 key 拼错,CLI 会直接失败并提示最接近的模板 key;它不会静默回退到默认模板。
|
|
103
|
-
`--json` 用于脚本读取创建计划,隐含 `--dry-run`,不会写入文件。
|
|
104
|
-
`--out` 会把创建计划写入文件,也隐含 `--dry-run`。
|
|
105
|
-
|
|
106
|
-
普通名字会自动放进合适目录,比如库包放到 `packages/`,应用放到 `apps/`。如果你传入了带 `/` 的路径,例如 `packages/shared-utils`,CLI 会尊重这个路径。
|
|
107
|
-
|
|
108
|
-
## 开发时怎么跑
|
|
109
|
-
|
|
110
|
-
先看新建 workspace 的 `package.json`,确认它提供了哪些脚本。常见流程是:
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
pnpm dev
|
|
114
|
-
pnpm build
|
|
115
|
-
pnpm typecheck
|
|
116
|
-
pnpm test
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
整仓命令由 Turborepo 调度。你在根目录执行 `pnpm build`,会构建所有声明了 `build` 脚本的 workspace 包。
|
|
120
|
-
|
|
121
|
-
## 提交前检查
|
|
122
|
-
|
|
123
|
-
提交前推荐按这个顺序跑:
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
pnpm build
|
|
127
|
-
pnpm lint
|
|
128
|
-
pnpm typecheck
|
|
129
|
-
pnpm test
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
如果只是想跑模板推荐的本地检查:
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
25
|
pnpm check
|
|
136
26
|
```
|
|
137
27
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
pnpm tsd
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## 什么时候用 repo 命令
|
|
145
|
-
|
|
146
|
-
生成仓库里优先记住短命令:
|
|
147
|
-
|
|
148
|
-
| 日常命令 | 等价 CLI |
|
|
149
|
-
| ------------- | ----------------------- |
|
|
150
|
-
| `pnpm setup` | `pnpm exec repo setup` |
|
|
151
|
-
| `pnpm new` | `pnpm exec repo new` |
|
|
152
|
-
| `pnpm doctor` | `pnpm exec repo doctor` |
|
|
153
|
-
| `pnpm check` | `pnpm exec repo check` |
|
|
154
|
-
|
|
155
|
-
需要更细的能力时再用 `repo`:
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
pnpm exec repo templates
|
|
159
|
-
pnpm exec repo env paths
|
|
160
|
-
pnpm exec repo env support --json --out reports/support.json
|
|
161
|
-
pnpm exec repo config inspect
|
|
162
|
-
pnpm exec repo ws ls
|
|
163
|
-
pnpm exec repo ws ls --json --out reports/workspaces.json
|
|
164
|
-
pnpm exec repo tg init --all
|
|
165
|
-
pnpm exec repo upgrade
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
`repoctl`、`monorepo`、`rc`、`mo` 这些入口仍然兼容。新项目文档统一推荐 `repo`,减少新人记忆负担。
|
|
169
|
-
|
|
170
|
-
## 更新模板标准资产
|
|
171
|
-
|
|
172
|
-
当模板仓库升级后,可以同步最新推荐配置:
|
|
173
|
-
|
|
174
|
-
```bash
|
|
175
|
-
pnpm exec repo upgrade
|
|
176
|
-
pnpm doctor
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
如果只想同步核心配置,跳过 GitHub、Renovate、开源社区文件:
|
|
180
|
-
|
|
181
|
-
```bash
|
|
182
|
-
pnpm exec repo upgrade --core
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
如果你不希望覆盖已有文件:
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
pnpm exec repo upgrade --skip-overwrite
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## 常见问题
|
|
192
|
-
|
|
193
|
-
### 提示目录已经存在
|
|
194
|
-
|
|
195
|
-
`pnpm new` 不会覆盖已有目录。换一个名字,或者手动处理已有目录后再创建。
|
|
196
|
-
|
|
197
|
-
### 不知道模板 key 怎么写
|
|
198
|
-
|
|
199
|
-
运行:
|
|
200
|
-
|
|
201
|
-
```bash
|
|
202
|
-
pnpm exec repo templates
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
查看单个模板详情:
|
|
206
|
-
|
|
207
|
-
```bash
|
|
208
|
-
pnpm exec repo templates tsdown
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
需要给脚本读取时:
|
|
28
|
+
## 知识点保留
|
|
212
29
|
|
|
213
|
-
|
|
214
|
-
pnpm exec repo templates --json
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### `repoctl.config.ts` 和 `monorepo.config.ts` 同时存在
|
|
218
|
-
|
|
219
|
-
只保留一个。推荐保留 `repoctl.config.ts`,旧文件名仅作为兼容入口。
|
|
220
|
-
|
|
221
|
-
### 新建包之后依赖没装上
|
|
222
|
-
|
|
223
|
-
新建模板只负责生成文件。生成后回到根目录运行:
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
pnpm install
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
然后再跑:
|
|
230
|
-
|
|
231
|
-
```bash
|
|
232
|
-
pnpm build
|
|
233
|
-
pnpm typecheck
|
|
234
|
-
pnpm test
|
|
235
|
-
```
|
|
30
|
+
理解工具前,先理解这几个边界:
|
|
236
31
|
|
|
237
|
-
|
|
32
|
+
| 命令 | 解决的问题 |
|
|
33
|
+
| -------------- | ----------------------------------------------------- |
|
|
34
|
+
| `repo setup` | 补齐仓库默认脚本、workspace patterns 和基础工具链入口 |
|
|
35
|
+
| `repo doctor` | 判断仓库当前是否可用,并输出可保存的诊断报告 |
|
|
36
|
+
| `repo new` | 从内置模板创建包、应用、服务、文档站或 CLI |
|
|
37
|
+
| `repo check` | 预览或执行提交前推荐校验 |
|
|
38
|
+
| `repo upgrade` | 同步模板最新标准资产 |
|
|
238
39
|
|
|
239
|
-
|
|
240
|
-
- 想选择合适模板:[模板速查](./monorepo/templates.md)
|
|
241
|
-
- 想理解 workspace 管理:[如何管理 monorepo](./monorepo/manage.md)
|
|
242
|
-
- 遇到校验问题:[常见问题排障](./monorepo/troubleshooting.md)
|
|
243
|
-
- 准备发包:[发包与变更日志](./monorepo/publish.md)
|
|
40
|
+
如果你是在学习 monorepo 的基础概念,可以继续看 [为什么往 monorepo 方向演进](./monorepo/index.md)。
|