rolldown-pnpm-config 3.0.6 → 3.1.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/cli/commands/export.js +1 -1
- package/cli/commands/sync.js +527 -0
- package/cli/effective.js +12 -2
- package/cli/exit-codes.js +9 -2
- package/cli/local-merge.js +66 -1
- package/cli/preview-views.js +1 -1
- package/cli/root.js +3 -1
- package/cli/sync/commit-message.js +19 -0
- package/cli/sync/config.js +83 -0
- package/cli/sync/floors.js +146 -0
- package/cli/sync/local-gate.js +63 -0
- package/cli/sync/membership.js +118 -0
- package/cli/sync/release-plan.js +49 -0
- package/cli/sync/ripples.js +59 -0
- package/cli/sync/running-list.js +153 -0
- package/cli/version.js +1 -1
- package/index.d.ts +76 -9
- package/package.json +10 -10
- package/plugin/freeze.js +2 -1
- package/runtime/strategies/arrays.js +15 -10
- package/skills/rolldown-pnpm-config/SKILL.md +47 -0
- package/skills/rolldown-pnpm-config/assets/catalog-sync.yml +287 -0
- package/skills/rolldown-pnpm-config/assets/pre-push.sh +32 -0
- package/skills/rolldown-pnpm-config/references/catalogs.md +95 -0
- package/skills/rolldown-pnpm-config/references/options.md +314 -0
- package/skills/rolldown-pnpm-config/references/sync.md +138 -0
- package/skills/rolldown-pnpm-config/references/wiring.md +194 -0
- package/tsdoc-metadata.json +1 -1
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# Catalog Sync: keeps the plugin's own catalog at the versions the next release
|
|
2
|
+
# will publish. Copy to .github/workflows/catalog-sync.yml and replace every
|
|
3
|
+
# placeholder:
|
|
4
|
+
#
|
|
5
|
+
# <PLUGIN_DIR> the plugin package directory, relative to the repository
|
|
6
|
+
# root (for example packages/pnpm-plugin-acme)
|
|
7
|
+
# <CONFIG_PATH> the config file, relative to <PLUGIN_DIR> (for example
|
|
8
|
+
# lib/configs/pnpm-config.plugin.ts)
|
|
9
|
+
# <PLUGIN_PACKAGE> the plugin's package name (for example @acme/pnpm-plugin-acme)
|
|
10
|
+
# <OWNER>/<REPO> the repository owner and name, for the App token scope
|
|
11
|
+
# <APP_ID_SECRET> the name of the repository variable holding the GitHub
|
|
12
|
+
# App's client id (for example APP_CLIENT_ID)
|
|
13
|
+
# <APP_KEY_SECRET> the name of the repository secret holding the App's
|
|
14
|
+
# private key (for example APP_PRIVATE_KEY)
|
|
15
|
+
#
|
|
16
|
+
# If you set sync.commit.messagePath, change COMMIT_MESSAGE_PATH below to match.
|
|
17
|
+
#
|
|
18
|
+
# The commit lands on main through createCommitOnBranch, as the App. If main
|
|
19
|
+
# has branch protection or a ruleset (required reviews, required checks), the
|
|
20
|
+
# App must be on its bypass list, or the commit step fails.
|
|
21
|
+
# Release flow assumed: the changesets release PR from changeset-release/main.
|
|
22
|
+
name: Catalog Sync
|
|
23
|
+
|
|
24
|
+
on:
|
|
25
|
+
pull_request:
|
|
26
|
+
# Base-branch filter only; the head-branch filter lives on the job's `if:`.
|
|
27
|
+
branches: [main]
|
|
28
|
+
types: [opened, synchronize, reopened]
|
|
29
|
+
workflow_dispatch:
|
|
30
|
+
|
|
31
|
+
concurrency:
|
|
32
|
+
group: catalog-sync-${{ github.ref }}
|
|
33
|
+
cancel-in-progress: true
|
|
34
|
+
|
|
35
|
+
permissions:
|
|
36
|
+
contents: read
|
|
37
|
+
# The check run is written with GITHUB_TOKEN, so the App's grants stay minimal.
|
|
38
|
+
checks: write
|
|
39
|
+
|
|
40
|
+
jobs:
|
|
41
|
+
catalog-sync:
|
|
42
|
+
# Fork PRs get no secrets, so the App-token step could not mint a token.
|
|
43
|
+
# The head-branch check narrows the job to the changesets release PR: it is
|
|
44
|
+
# the trigger, not the tree. The job checks out main, reads the release
|
|
45
|
+
# plan from main's pending changesets, and commits the sync to main, so
|
|
46
|
+
# the release PR regenerates with the synced catalog.
|
|
47
|
+
if: >-
|
|
48
|
+
github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository &&
|
|
49
|
+
github.head_ref == 'changeset-release/main')
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
steps:
|
|
52
|
+
- name: Generate App Token
|
|
53
|
+
id: app-token
|
|
54
|
+
uses: actions/create-github-app-token@v3
|
|
55
|
+
with:
|
|
56
|
+
# <APP_ID_SECRET>: name of the variable holding the App's client id.
|
|
57
|
+
client-id: ${{ vars.<APP_ID_SECRET> }}
|
|
58
|
+
# <APP_KEY_SECRET>: name of the secret holding the App's private key.
|
|
59
|
+
private-key: ${{ secrets.<APP_KEY_SECRET> }}
|
|
60
|
+
owner: "<OWNER>"
|
|
61
|
+
repositories: "<REPO>"
|
|
62
|
+
permission-contents: write
|
|
63
|
+
|
|
64
|
+
- name: Checkout
|
|
65
|
+
uses: actions/checkout@v7
|
|
66
|
+
with:
|
|
67
|
+
ref: main
|
|
68
|
+
fetch-depth: 0
|
|
69
|
+
token: ${{ steps.app-token.outputs.token }}
|
|
70
|
+
# Every write goes through the API with an explicit token.
|
|
71
|
+
persist-credentials: false
|
|
72
|
+
|
|
73
|
+
# Replace with your runtime setup: Node, pnpm, and an install.
|
|
74
|
+
- name: Setup Runtime
|
|
75
|
+
uses: savvy-web/silk-runtime-action@v2
|
|
76
|
+
|
|
77
|
+
- name: Check the catalog
|
|
78
|
+
id: catalog-check
|
|
79
|
+
# The GATE. It must run before `sync` mutates anything: afterwards the
|
|
80
|
+
# catalog is in sync by construction and a check would always pass.
|
|
81
|
+
# `exec` rather than a package script, so stdout is exactly the JSON
|
|
82
|
+
# document (a script run prints its own header line first). Exit 1 means
|
|
83
|
+
# a finding OR a section that could not be evaluated, so the exit code
|
|
84
|
+
# alone proves nothing; the next step reads the JSON. continue-on-error
|
|
85
|
+
# keeps the exit as `outcome` and lets the sync below run.
|
|
86
|
+
continue-on-error: true
|
|
87
|
+
# `shell: bash` runs with `-eo pipefail`; the default `bash -e {0}` has no
|
|
88
|
+
# pipefail, so the pipe into `tee` would hide the CLI's exit status and
|
|
89
|
+
# `outcome` would always read success.
|
|
90
|
+
shell: bash
|
|
91
|
+
working-directory: "<PLUGIN_DIR>"
|
|
92
|
+
run: pnpm exec rolldown-pnpm-config sync "<CONFIG_PATH>" --check --format json | tee "$RUNNER_TEMP/catalog-check.json"
|
|
93
|
+
|
|
94
|
+
- name: Read the check report
|
|
95
|
+
id: gate
|
|
96
|
+
run: |
|
|
97
|
+
# `evaluated` is false when any section errored (registry or auth
|
|
98
|
+
# failure, a malformed changeset, an unreadable release plan) or when
|
|
99
|
+
# the config could not be loaded. A missing or unparseable report
|
|
100
|
+
# (a usage error prints nothing on stdout) counts as unevaluated.
|
|
101
|
+
#
|
|
102
|
+
# `drift` is true when any section has status "findings". Both outputs
|
|
103
|
+
# come from the JSON, never from the check step's exit status.
|
|
104
|
+
#
|
|
105
|
+
# jq prints nothing for an empty file, so anything but `true` is false.
|
|
106
|
+
report="$RUNNER_TEMP/catalog-check.json"
|
|
107
|
+
evaluated=$(jq -r '.evaluated == true' "$report" 2>/dev/null || true)
|
|
108
|
+
drift=$(jq -r '[.sections[]? | select(.status == "findings")] | length > 0' "$report" 2>/dev/null || true)
|
|
109
|
+
[ "$evaluated" = "true" ] || evaluated=false
|
|
110
|
+
[ "$drift" = "true" ] || drift=false
|
|
111
|
+
echo "evaluated=$evaluated" >> "$GITHUB_OUTPUT"
|
|
112
|
+
echo "drift=$drift" >> "$GITHUB_OUTPUT"
|
|
113
|
+
|
|
114
|
+
- name: Sync the catalog
|
|
115
|
+
# Only for an evaluated run with drift: an unevaluated one is not drift
|
|
116
|
+
# (the sync would hit the same cause), and a clean one needs no repair.
|
|
117
|
+
if: steps.gate.outputs.evaluated == 'true' && steps.gate.outputs.drift == 'true'
|
|
118
|
+
id: catalog-sync
|
|
119
|
+
working-directory: "<PLUGIN_DIR>"
|
|
120
|
+
run: pnpm exec rolldown-pnpm-config sync "<CONFIG_PATH>"
|
|
121
|
+
|
|
122
|
+
- name: Check for changes
|
|
123
|
+
id: changes
|
|
124
|
+
if: steps.gate.outputs.evaluated == 'true' && steps.gate.outputs.drift == 'true'
|
|
125
|
+
# `git status --porcelain`, not `git diff`: the first sync writes an
|
|
126
|
+
# untracked changeset, which `git diff` cannot see.
|
|
127
|
+
run: |
|
|
128
|
+
if [ -z "$(git status --porcelain -- '<PLUGIN_DIR>/<CONFIG_PATH>' .changeset)" ]; then
|
|
129
|
+
echo "changed=false" >> "$GITHUB_OUTPUT"
|
|
130
|
+
else
|
|
131
|
+
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
132
|
+
fi
|
|
133
|
+
|
|
134
|
+
- name: Build
|
|
135
|
+
# The sync rewrites a config the build consumes; prove it still builds
|
|
136
|
+
# before it is proposed. Add your test command here if you have one.
|
|
137
|
+
if: steps.changes.outputs.changed == 'true'
|
|
138
|
+
run: pnpm exec turbo run build --filter="<PLUGIN_PACKAGE>"
|
|
139
|
+
|
|
140
|
+
- name: Commit the sync
|
|
141
|
+
id: commit
|
|
142
|
+
if: steps.changes.outputs.changed == 'true'
|
|
143
|
+
env:
|
|
144
|
+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
145
|
+
REPO: ${{ github.repository }}
|
|
146
|
+
BASE_BRANCH: main
|
|
147
|
+
# Fallback only: `sync` writes the real message (one line per move) to
|
|
148
|
+
# this path, which is gitignored and never committed.
|
|
149
|
+
HEADLINE: "chore: sync the catalog to the next release versions"
|
|
150
|
+
COMMIT_MESSAGE_PATH: .changeset/catalog-sync.commit.txt
|
|
151
|
+
SIGNOFF: "Signed-off-by: ${{ steps.app-token.outputs.app-slug }}[bot] <${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>"
|
|
152
|
+
run: |
|
|
153
|
+
set -euo pipefail
|
|
154
|
+
|
|
155
|
+
# A GraphQL `createCommitOnBranch` rather than `git commit` + push:
|
|
156
|
+
# GitHub signs commits it creates for the caller, so they land verified.
|
|
157
|
+
|
|
158
|
+
# Stage exactly the paths this job owns: the config literal and the
|
|
159
|
+
# changesets. The commit-message file is gitignored. `--no-renames` on
|
|
160
|
+
# both diffs: a floors run that deletes one breaking-floor changeset
|
|
161
|
+
# and writes another reads as a rename otherwise, and the old path
|
|
162
|
+
# would never reach `deletions`.
|
|
163
|
+
git add -A -- '<PLUGIN_DIR>/<CONFIG_PATH>' .changeset
|
|
164
|
+
|
|
165
|
+
additions='[]'
|
|
166
|
+
while IFS= read -r -d '' path; do
|
|
167
|
+
additions=$(jq -c --arg path "$path" --arg contents "$(base64 -w0 <"$path")" \
|
|
168
|
+
'. + [{path: $path, contents: $contents}]' <<<"$additions")
|
|
169
|
+
done < <(git diff --cached --no-renames --name-only -z --diff-filter=d)
|
|
170
|
+
|
|
171
|
+
deletions='[]'
|
|
172
|
+
while IFS= read -r -d '' path; do
|
|
173
|
+
deletions=$(jq -c --arg path "$path" '. + [{path: $path}]' <<<"$deletions")
|
|
174
|
+
done < <(git diff --cached --no-renames --name-only -z --diff-filter=D)
|
|
175
|
+
|
|
176
|
+
if [ "$additions" = '[]' ] && [ "$deletions" = '[]' ]; then
|
|
177
|
+
echo "::notice::Nothing staged"
|
|
178
|
+
exit 0
|
|
179
|
+
fi
|
|
180
|
+
|
|
181
|
+
# First line is the headline, the rest the body; the DCO signoff last.
|
|
182
|
+
if [ -s "$COMMIT_MESSAGE_PATH" ]; then
|
|
183
|
+
headline=$(head -n 1 "$COMMIT_MESSAGE_PATH")
|
|
184
|
+
body="$(tail -n +2 "$COMMIT_MESSAGE_PATH")"$'\n'"$SIGNOFF"
|
|
185
|
+
else
|
|
186
|
+
echo "::warning::$COMMIT_MESSAGE_PATH is missing; using the generic headline"
|
|
187
|
+
headline="$HEADLINE"
|
|
188
|
+
body="$SIGNOFF"
|
|
189
|
+
fi
|
|
190
|
+
|
|
191
|
+
# Guard on the tree the rewrite was computed from: if the base moved
|
|
192
|
+
# during the job the mutation fails instead of reverting what landed.
|
|
193
|
+
base_oid=$(git rev-parse HEAD)
|
|
194
|
+
|
|
195
|
+
jq -n \
|
|
196
|
+
--arg repo "$REPO" \
|
|
197
|
+
--arg branch "$BASE_BRANCH" \
|
|
198
|
+
--arg oid "$base_oid" \
|
|
199
|
+
--arg headline "$headline" \
|
|
200
|
+
--arg body "$body" \
|
|
201
|
+
--argjson additions "$additions" \
|
|
202
|
+
--argjson deletions "$deletions" \
|
|
203
|
+
'{
|
|
204
|
+
query: "mutation($input: CreateCommitOnBranchInput!) { createCommitOnBranch(input: $input) { commit { oid url } } }",
|
|
205
|
+
variables: {
|
|
206
|
+
input: {
|
|
207
|
+
branch: { repositoryNameWithOwner: $repo, branchName: $branch },
|
|
208
|
+
message: { headline: $headline, body: $body },
|
|
209
|
+
expectedHeadOid: $oid,
|
|
210
|
+
fileChanges: { additions: $additions, deletions: $deletions }
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}' > "$RUNNER_TEMP/commit-mutation.json"
|
|
214
|
+
|
|
215
|
+
commit_url=$(gh api graphql --input "$RUNNER_TEMP/commit-mutation.json" \
|
|
216
|
+
--jq '.data.createCommitOnBranch.commit.url')
|
|
217
|
+
echo "commit-url=$commit_url" >> "$GITHUB_OUTPUT"
|
|
218
|
+
|
|
219
|
+
- name: Report the catalog check run
|
|
220
|
+
# `!cancelled()` (runs after a failed step, not after a cancel, which
|
|
221
|
+
# also kills a superseded run under the concurrency group), and ONE call
|
|
222
|
+
# that both creates and concludes the run: a run created early and
|
|
223
|
+
# completed late hangs `in_progress` when the job dies.
|
|
224
|
+
if: ${{ !cancelled() }}
|
|
225
|
+
env:
|
|
226
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
227
|
+
REPO: ${{ github.repository }}
|
|
228
|
+
# The PR's head sha, not `github.sha` (the ephemeral merge commit),
|
|
229
|
+
# so the check shows on the PR and branch protection can key on it.
|
|
230
|
+
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
231
|
+
JOB_STATUS: ${{ job.status }}
|
|
232
|
+
# Both come from the check's JSON report, not its exit status.
|
|
233
|
+
EVALUATED: ${{ steps.gate.outputs.evaluated }}
|
|
234
|
+
DRIFT: ${{ steps.gate.outputs.drift }}
|
|
235
|
+
SYNC: ${{ steps.catalog-sync.outcome }}
|
|
236
|
+
CHANGED: ${{ steps.changes.outputs.changed }}
|
|
237
|
+
COMMIT_URL: ${{ steps.commit.outputs.commit-url }}
|
|
238
|
+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
239
|
+
run: |
|
|
240
|
+
set -euo pipefail
|
|
241
|
+
|
|
242
|
+
# Branch on `evaluated`, not on the check step's exit: exit 1 is both
|
|
243
|
+
# "drift" and "could not be evaluated", and only the JSON tells them apart.
|
|
244
|
+
if [ "${EVALUATED:-false}" != "true" ]; then
|
|
245
|
+
conclusion=failure
|
|
246
|
+
title="Catalog check could not be evaluated"
|
|
247
|
+
summary="\`sync --check\` did not produce an evaluated report: a setup step failed before it ran (the App token, the checkout, the install), or a section or the config errored. The catalog was neither confirmed nor repaired. This is not drift: fix the cause (token or install, registry or auth, a pending changeset, the release plan, the config) and rerun. See the run log."
|
|
248
|
+
elif [ "${DRIFT:-false}" != "true" ]; then
|
|
249
|
+
conclusion=success
|
|
250
|
+
title="Catalog is up to date"
|
|
251
|
+
summary="\`sync --check\` found no drift."
|
|
252
|
+
elif [ "$JOB_STATUS" != "success" ] || [ "$SYNC" = "failure" ]; then
|
|
253
|
+
conclusion=failure
|
|
254
|
+
title="Catalog is out of date and the sync did not complete"
|
|
255
|
+
summary="\`sync --check\` reported drift and the job then ended \`$JOB_STATUS\`, so nothing has been committed. See the run log."
|
|
256
|
+
elif [ -n "${COMMIT_URL:-}" ]; then
|
|
257
|
+
# The drift was real at this ref even though it has been repaired,
|
|
258
|
+
# so the check stays red until a run on a ref with the commit.
|
|
259
|
+
conclusion=failure
|
|
260
|
+
title="Catalog was out of date, synced"
|
|
261
|
+
summary="\`sync --check\` reported drift, so the catalog was rewritten and committed: $COMMIT_URL"$'\n\n'"This reports failure because the catalog was wrong at this ref, not because the repair failed. Rerun once the sync commit is in the branch."
|
|
262
|
+
elif [ "$CHANGED" != "true" ]; then
|
|
263
|
+
conclusion=failure
|
|
264
|
+
title="Catalog check and sync disagree"
|
|
265
|
+
summary="\`sync --check\` reported drift but \`sync\` wrote nothing. One of the two is wrong; do not treat this as a clean catalog."
|
|
266
|
+
else
|
|
267
|
+
conclusion=failure
|
|
268
|
+
title="Catalog is out of date and was not synced"
|
|
269
|
+
summary="\`sync\` rewrote the catalog but no commit was produced, so the drift is unresolved."
|
|
270
|
+
fi
|
|
271
|
+
|
|
272
|
+
# The run link goes in the summary: GitHub ignores `details_url` on a
|
|
273
|
+
# check run created with GITHUB_TOKEN.
|
|
274
|
+
summary="$summary"$'\n\n'"[Run log]($RUN_URL)"
|
|
275
|
+
|
|
276
|
+
gh api "repos/$REPO/check-runs" \
|
|
277
|
+
-f name='Catalog Sync' \
|
|
278
|
+
-f head_sha="$HEAD_SHA" \
|
|
279
|
+
-f status=completed \
|
|
280
|
+
-f conclusion="$conclusion" \
|
|
281
|
+
-f output[title]="$title" \
|
|
282
|
+
-f output[summary]="$summary" >/dev/null
|
|
283
|
+
|
|
284
|
+
echo "::notice::Catalog Sync check run: $conclusion, $title"
|
|
285
|
+
|
|
286
|
+
# Fail the job too, so the outcome shows either way.
|
|
287
|
+
[ "$conclusion" = "success" ]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Pre-push gate for a rolldown-pnpm-config plugin repository.
|
|
3
|
+
#
|
|
4
|
+
# Put this in .husky/pre-push OUTSIDE any section a tool manages (for example a
|
|
5
|
+
# block delimited by "managed by ..." markers): a tool regenerating its section
|
|
6
|
+
# would delete it. Replace every placeholder:
|
|
7
|
+
#
|
|
8
|
+
# <PLUGIN_PACKAGE> the plugin's package name (for example @acme/pnpm-plugin-acme)
|
|
9
|
+
# <PLUGIN_DIR> the plugin package directory (for example packages/pnpm-plugin-acme)
|
|
10
|
+
# <CONFIG_PATH> the config file, relative to <PLUGIN_DIR>
|
|
11
|
+
# (for example lib/configs/pnpm-config.plugin.ts)
|
|
12
|
+
#
|
|
13
|
+
# `sync --local` compares pnpm-workspace.yaml with what the BUILT pnpmfile
|
|
14
|
+
# serves, so the plugin is built first. It never touches the network. It calls
|
|
15
|
+
# the CLI directly: the check gate and --local are mutually exclusive, so
|
|
16
|
+
# routing it through the check script is a usage error (exit 64).
|
|
17
|
+
|
|
18
|
+
# The body runs in a subshell, so its `exit 0` and `cd` stay inside it when
|
|
19
|
+
# this is pasted into an existing hook; `|| exit $?` still fails the push when
|
|
20
|
+
# the gate fails. The steps are chained with `&&` rather than relying on
|
|
21
|
+
# `set -e`, which bash ignores on the left of `||`: a failed build must stop
|
|
22
|
+
# before `sync --local` reads a stale pnpmfile.
|
|
23
|
+
(
|
|
24
|
+
# CI runs the same gate through the Catalog Sync workflow.
|
|
25
|
+
if [ -n "${CI:-}" ]; then
|
|
26
|
+
exit 0
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
pnpm exec turbo run build --filter="<PLUGIN_PACKAGE>" &&
|
|
30
|
+
cd "<PLUGIN_DIR>" &&
|
|
31
|
+
pnpm exec rolldown-pnpm-config sync --local "<CONFIG_PATH>"
|
|
32
|
+
) || exit $?
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Catalog rules for a rolldown-pnpm-config plugin
|
|
2
|
+
|
|
3
|
+
Follow these rules whenever you touch the `catalogs` of a
|
|
4
|
+
`PnpmConfigPlugin({...})` call, or a package that consumes them.
|
|
5
|
+
|
|
6
|
+
## Keep the literal inline
|
|
7
|
+
|
|
8
|
+
Write the `catalogs` object literally inside the `PnpmConfigPlugin({...})`
|
|
9
|
+
call. `upgrade` and `sync` read and rewrite it statically through the AST.
|
|
10
|
+
|
|
11
|
+
- Never hoist it into a variable, a spread, a helper or another module.
|
|
12
|
+
- Never compute a range. Write a string literal.
|
|
13
|
+
- Quoted keys (`"@acme/core"`) are fine.
|
|
14
|
+
|
|
15
|
+
## Specifiers
|
|
16
|
+
|
|
17
|
+
| Field | Write | Why |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `dependencies`, `devDependencies` | `catalog:<name>` | The catalog's `range` |
|
|
20
|
+
| `peerDependencies` | `catalog:<name>:peers` | The entry's `peer` floor |
|
|
21
|
+
| An exact pin | `catalog:<name>:exact` | Only when the declaration sets `exact: true` |
|
|
22
|
+
|
|
23
|
+
`pnpm pack` writes a `catalog:` specifier as the catalog's value, so a peer
|
|
24
|
+
spelled `catalog:<name>` publishes the dependency range instead of the peer
|
|
25
|
+
floor. The `:peers` twin holds only entries that declare a `peer`. Give such
|
|
26
|
+
an entry a `strategy` (`"lock"`, `"lock-minor"` or `"interop"`) so `upgrade`
|
|
27
|
+
and `sync` re-derive `peer` whenever they move `range`.
|
|
28
|
+
|
|
29
|
+
## Entries
|
|
30
|
+
|
|
31
|
+
- An entry for a workspace package sets `source: "workspace"`, so `upgrade`
|
|
32
|
+
and `sync` read the next release version from the workspace (manifests plus
|
|
33
|
+
pending changesets) instead of the registry.
|
|
34
|
+
- Never edit the `range` of a `sync.catalog` entry by hand. `sync` owns it.
|
|
35
|
+
- Add every publishable workspace member in `sync.members.scope` to the sync
|
|
36
|
+
catalog, or leave it out explicitly with `sync.members.exclude`. The
|
|
37
|
+
membership gate fails otherwise.
|
|
38
|
+
|
|
39
|
+
## Never put the plugin in its own catalog
|
|
40
|
+
|
|
41
|
+
The plugin package must never appear in any catalog it serves. Every
|
|
42
|
+
catalog rewrite bumps the plugin; a catalogued plugin would then move its
|
|
43
|
+
own catalog, write another changeset and bump again, a release loop that
|
|
44
|
+
never ends. Membership already excludes the plugin; do not add it back.
|
|
45
|
+
Leave a comment at the catalog saying the omission is deliberate.
|
|
46
|
+
|
|
47
|
+
## Bundle every import; declare none
|
|
48
|
+
|
|
49
|
+
A config dependency installs without its dependencies: pnpm loads the
|
|
50
|
+
pnpmfile before anything else is installed.
|
|
51
|
+
|
|
52
|
+
- Bundle everything the pnpmfile imports (`bundleNodeModules = true` under
|
|
53
|
+
`effected package build`; the bundler's own inlining under rolldown or
|
|
54
|
+
tsdown). The output may import only `node:` builtins.
|
|
55
|
+
- Never add a runtime import to `dependencies` or `peerDependencies` of the
|
|
56
|
+
plugin. Keep what the build needs in `devDependencies`.
|
|
57
|
+
|
|
58
|
+
## `pnpm:up` and `pnpm:export` are the user's
|
|
59
|
+
|
|
60
|
+
Never run `pnpm:up` or `pnpm:export` yourself, and never the underlying
|
|
61
|
+
`rolldown-pnpm-config upgrade` or `export` without `--dry-run`. They change
|
|
62
|
+
versions and the repository's own `pnpm-workspace.yaml` on the user's
|
|
63
|
+
judgement. When a change needs one, stop and tell the user which to run.
|
|
64
|
+
Read-only forms are fine: `pnpm:preview`, `upgrade --check`,
|
|
65
|
+
`upgrade --dry-run`, `export --dry-run`.
|
|
66
|
+
|
|
67
|
+
## Union and map fields keep unmanaged entries on export
|
|
68
|
+
|
|
69
|
+
For fields whose runtime strategy is a union (`publicHoistPattern`,
|
|
70
|
+
`hoistPattern`, `minimumReleaseAgeExclude`, `trustPolicyExclude`,
|
|
71
|
+
`supportedArchitectures`, `auditConfig`, `ignoredOptionalDependencies`,
|
|
72
|
+
`requiredScripts`, `syncInjectedDepsAfterScripts`,
|
|
73
|
+
`mergeGitBranchLockfilesBranchPattern`, `gitShallowHosts`), `export` writes
|
|
74
|
+
the managed value plus every entry already in `pnpm-workspace.yaml`, as an
|
|
75
|
+
install does. An entry the plugin stops managing therefore stays in the file.
|
|
76
|
+
|
|
77
|
+
Map fields do the same (`packageExtensions`, `allowedDeprecatedVersions`,
|
|
78
|
+
`updateConfig`, `catalog`, `patchedDependencies`, `configDependencies`,
|
|
79
|
+
`nodeDownloadMirrors`, and the `audit` and `update` sections). `export`
|
|
80
|
+
keeps every key only the file holds, but on a key both hold the managed value
|
|
81
|
+
wins, so a managed change (a catalog or `configDependencies` bump) is written
|
|
82
|
+
to `pnpm-workspace.yaml`. Section list keys (`audit.ignore`) are unioned. A
|
|
83
|
+
repo that needs its own value for a managed key sets it under `local`.
|
|
84
|
+
|
|
85
|
+
- Pruning those entries is the user's job. Point them out; do not delete
|
|
86
|
+
them from `pnpm-workspace.yaml` by hand.
|
|
87
|
+
- To make export overwrite a field again, set it under `local` with
|
|
88
|
+
`{ strategy: "rewrite" }`, e.g.
|
|
89
|
+
`local: { publicHoistPattern: { strategy: "rewrite" } }`.
|
|
90
|
+
- `{ strategy: "difference", value }` under `local` removes entries from the
|
|
91
|
+
kept file entries too, so a removed entry does not come back. On a map
|
|
92
|
+
field, `value` names keys to remove: a list of key names, or a map whose
|
|
93
|
+
keys are removed.
|
|
94
|
+
- A bare `local` value replaces the managed value, and the file's entries are
|
|
95
|
+
still kept on top.
|