mirror of
https://github.com/penpot/penpot.git
synced 2026-11-26 21:00:32 +00:00
📚 Focus pnpm update guidance
Keep pin, lockfile, and verification constraints while removing stale build-output and historical merge details. AI-assisted-by: gpt-6.1-terra
This commit is contained in:
parent
3b98eed73d
commit
d654d32845
@ -1,126 +1,30 @@
|
||||
# Updating pnpm Across All Workspaces
|
||||
# Updating pnpm across workspaces
|
||||
|
||||
Canonical procedure. Run it from the repo root with the log redirected to a
|
||||
file (never pipe tool output through filters).
|
||||
Run from the repo root and redirect logs to a file rather than piping tool output through filters. For Node pins see `mem:workflow/updating-node`; for devenv cache ownership see `mem:devenv/core`.
|
||||
|
||||
## Layout facts
|
||||
## Layout and pins
|
||||
|
||||
- The repo has 11 pnpm workspaces, each with its own `pnpm-workspace.yaml`
|
||||
and `pnpm-lock.yaml`: the repo root plus `backend`, `common`, `docs`,
|
||||
`exporter`, `frontend`, `library`, `mcp`, `media-processor`, `plugins`,
|
||||
and `render-wasm`.
|
||||
- Every package inside a module workspace (for example all `plugins/apps/*`
|
||||
and `plugins/libs/*` packages) is a plain member of that module's
|
||||
workspace. Members must not carry their own `pnpm-workspace.yaml` or
|
||||
`pnpm-lock.yaml`; their dependencies resolve through the parent
|
||||
workspace's lockfile.
|
||||
- One shared pnpm store for the whole repo: `<repo>/.pnpm-store`. Every
|
||||
workspace yaml sets it explicitly: `storeDir: .pnpm-store` at the root,
|
||||
`storeDir: ../.pnpm-store` in each module. pnpm resolves the value
|
||||
against the workspace root, so all workspaces land on the same store.
|
||||
Do not remove these lines: nested workspaces do not inherit settings,
|
||||
and without them each workspace may resolve a different store.
|
||||
- The store survives `node_modules` cleans. It is content-addressed and
|
||||
integrity-verified, so it cannot go stale; staleness lives in
|
||||
node_modules. Only `scripts/clean-node-modules --store` removes it.
|
||||
- Every first-party `package.json` (34 files: workspace roots plus
|
||||
members) must carry a `packageManager` field with the identical
|
||||
`pnpm@<version>+sha512.<hash>` value. Do not let them drift.
|
||||
`external/` (vendored trees with their own lifecycles), `.opencode/`,
|
||||
`.pnpm-store/`, `bundles/`, `target/` build output and
|
||||
`docker/images/bundle-*` copies are never stamped.
|
||||
- pnpm is a system binary everywhere (devenv image, CI runners, Docker
|
||||
images). Nothing may call corepack: it is gone from Node 25+. pnpm
|
||||
auto-downloads the `packageManager` version on mismatch
|
||||
(`pmOnFail: download`, the default), so drift self-heals; aligned pins
|
||||
just skip the download. Inside the devenv that download lands in the
|
||||
penpot user's `package-manager-store`, which `files/entrypoint.sh` chowns
|
||||
to penpot on every start (see `mem:devenv/core`).
|
||||
- The pnpm version pin lives in three places that move together:
|
||||
`PNPM_VERSION` (+ arch SHAs) in `docker/devenv/Dockerfile` and in
|
||||
`docker/images/Dockerfile.{media-processor,exporter,mcp}`, and the
|
||||
`packageManager` fields (stamped by the script below). The
|
||||
`plugins-deploy-*` workflows need no pnpm pin: a single `pnpm/setup`
|
||||
step (`working-directory: plugins`, `install: false`) reads it from
|
||||
the manifest and installs the pinned Node via `runtime: node@<exact>`;
|
||||
bump that pin together with `.nvmrc` on Node updates.
|
||||
- Each workspace root has its own `pnpm-workspace.yaml` and `pnpm-lock.yaml`; packages inside a module are members, not nested workspaces. A nested workspace file changes which lockfile pnpm uses. See `scripts/sync-pnpm-version` for the current scan and workspace list.
|
||||
- Every workspace config points to the shared `<repo>/.pnpm-store` relative to its root. Nested workspaces do not inherit that setting. The content-addressed store survives a normal `node_modules` clean.
|
||||
- Keep the same `packageManager` value, including its integrity hash, across first-party manifests. The sync script excludes vendored trees, `.opencode/`, caches, `target/` build output and Docker build-context copies; `--check` detects drift in the scanned manifests.
|
||||
- pnpm is installed as a system binary; do not use corepack. A mismatched manifest pin can cause pnpm to download the pinned version. The devenv and production image Dockerfiles also pin `PNPM_VERSION` and architecture-specific checksums. Plugin deploy workflows read the pnpm version from the plugins manifest; their Node pin is separate.
|
||||
|
||||
## Procedure
|
||||
|
||||
1. Resolve the target version first and note it. Example:
|
||||
`pnpm view pnpm dist-tags --json` for `latest-12` (latest 12.x). The
|
||||
tag moves over time; always re-check.
|
||||
2. Bump `PNPM_VERSION` (+ arch SHAs) in `docker/devenv/Dockerfile` and in
|
||||
`docker/images/Dockerfile.{media-processor,exporter,mcp}`. Those SHAs are
|
||||
of the **GitHub release tarballs**, one per arch: download
|
||||
`pnpm-linux-{arm64,x64}.tar.gz` from the `v<version>` release and
|
||||
`sha256sum` each. The npm `dist.integrity` that the script stamps in step
|
||||
3 is a different hash of a different artifact — never reuse it for the
|
||||
Dockerfiles.
|
||||
3. From the repo root, on a host whose system pnpm is the target version
|
||||
(rebuilt devenv), run `scripts/sync-pnpm-version`. It resolves the
|
||||
integrity hash via `pnpm view` + node (no npm, no corepack, no
|
||||
python3) and stamps the identical field into all 34 files, replacing
|
||||
only the value line (each file keeps its own indent) and inserting
|
||||
the key after `"name"`/`"version"` where missing. Explicit version
|
||||
instead: `scripts/sync-pnpm-version <version>`. The explicit form works
|
||||
from a host whose system pnpm is older than the target (the registry
|
||||
lookup resolves the hash, and the first later `pnpm` call auto-downloads
|
||||
the target into `package-manager-store`), so a rebuild is only needed for
|
||||
the in-container `pnpm --version` to match.
|
||||
4. Run `scripts/sync-pnpm-version --install` (plain `pnpm install` in
|
||||
each of the 11 workspace roots) to refresh lockfile metadata, then
|
||||
fix any failing workspace (see gotchas) and re-run that directory.
|
||||
For a version-only bump, `pnpm install --lockfile-only` in each root is enough: it rewrites only the pnpm self-reference entries and needs no node_modules. The repo-root `pnpm-lock.yaml` is rewritten by itself on the first `pnpm` call that self-installs the target version.
|
||||
1. Resolve the target version first; a registry dist-tag moves over time.
|
||||
2. Update `PNPM_VERSION` and architecture checksums in `docker/devenv/Dockerfile` and `docker/images/Dockerfile.{media-processor,exporter,mcp}`. Compute SHA-256 from each GitHub release tarball; npm `dist.integrity` is a different hash of a different artifact.
|
||||
3. Run `scripts/sync-pnpm-version <version>` to stamp manifests. It resolves npm integrity through `pnpm view` and Node; the explicit version works even when the system pnpm is older. Without an argument it uses `pnpm --version`.
|
||||
4. Refresh lockfiles in every workspace. `scripts/sync-pnpm-version --install` runs `pnpm install` in each; for a version-only bump, `pnpm install --lockfile-only` in each root can suffice. Inspect diffs: unexpected dependency upgrades indicate re-resolution, not merely a pnpm self-reference update.
|
||||
|
||||
## Gotchas
|
||||
## Gotchas and verification
|
||||
|
||||
- A workspace may fail with `ERR_PNPM_IGNORED_BUILDS`, and pnpm then writes
|
||||
a placeholder scaffold into its `pnpm-workspace.yaml`:
|
||||
`allowBuilds: esbuild: set this to true or false`. Current pnpm writes
|
||||
only the `allowBuilds` placeholder; any legacy key still present
|
||||
(`ignoredBuiltDependencies`, `onlyBuiltDependencies`,
|
||||
`neverBuiltDependencies`) is ignored since pnpm 11. Repo convention is
|
||||
`allowBuilds: esbuild: true`. Replace the placeholder and drop the
|
||||
legacy entry, then re-run.
|
||||
- `plugins/apps/composable-test-suite` once had its own
|
||||
`pnpm-workspace.yaml` and acted as a nested workspace root. That state is
|
||||
gone on purpose: pnpm picks the nearest `pnpm-workspace.yaml` walking up,
|
||||
so a nested one silently forks install and lockfile behavior. Do not
|
||||
reintroduce it.
|
||||
- `media-processor/target/package.json` is a generated, gitignored copy that
|
||||
the script also stamps, so stamping and `--check` report 35 files while
|
||||
only 34 are tracked. A stale copy there makes `--check` fail with nothing
|
||||
wrong in the repo: delete `media-processor/target` and re-run.
|
||||
- Expect metadata-only lockfile diffs when only the pnpm version moves:
|
||||
the pnpm self-reference entries, plus a new `packageManagerDependencies`
|
||||
section in lockfiles last written by older pnpm. Large diffs mean
|
||||
re-resolution; inspect them before accepting.
|
||||
- A backport merge of main into staging can bring a newer `PNPM_VERSION` in `docker/` while every `packageManager` field stays behind, since main receives partial `.github/`+`docker/` backports from develop. Resolve those conflicts with main's version and run `scripts/sync-pnpm-version <version>` in the same merge.
|
||||
- Direction does not decide the winner, the version does. A maintenance→main merge (`main-2.18.x` into `main`) can carry the newer Node and pnpm pins in `docker/` and the `plugins-deploy-*` workflows while main's `.nvmrc` and 35 `packageManager` fields stay on the older pair. Take the newer pair on every pin site (`docker/`, workflows, `.nvmrc`, `packageManager`) and run `scripts/sync-pnpm-version <version>` in the same merge; check with `--check` plus `pnpm install --lockfile-only --frozen-lockfile` per workspace.
|
||||
- Those merges conflict on the pnpm self-reference block in all 11 lockfiles (importers `packageManagerDependencies`, `packages/@pnpm/exe.*@<ver>`, `pnpm@<ver>` and the matching `snapshots` entries). Resolve each workspace's lockfile keeping its own importer/package resolution and swapping only that block to the newer version. Do not start from the older side and regenerate with `pnpm install --lockfile-only`: pnpm re-resolves every changed range upward (this merge took root `@playwright/test` from 1.63.0 to 1.64.1 and `@modelcontextprotocol/server` from 2.3.1 to 2.4.0), which pollutes the merge with unrelated bumps. If a workspace later needs a real re-resolution after a manifest bump, `pnpm install --lockfile-only --fix-lockfile` accepts the hand-merged file and only fills what the manifests demand.
|
||||
- `pnpm install` cannot run in `frontend` or `exporter` when `github.com` does not resolve: the `@penpot/svgo` git dependency triggers a `git fetch`. Frontend's lockfile entry carries no integrity, so pnpm always refetches; exporter's has one and still works. For frontend, resolve the self-reference hunks only.
|
||||
|
||||
## Verification
|
||||
|
||||
- `scripts/sync-pnpm-version --check` passes: every `packageManager`
|
||||
field is byte-identical (same version and hash).
|
||||
- `pnpm install --frozen-lockfile` succeeds in each of the 11 workspaces.
|
||||
- `git diff` on lockfiles matches the expectations above.
|
||||
- No `corepack` call remains in scripts, workflows, Dockerfiles or docs
|
||||
(`rg corepack` shows only `CHANGES.md` history).
|
||||
- `ERR_PNPM_IGNORED_BUILDS` can leave an `allowBuilds` placeholder in a workspace config. Set the intended policy, such as the repo's `esbuild: true`, remove obsolete build-dependency keys ignored by current pnpm, and rerun the affected install.
|
||||
- Backport and maintenance merges can leave Docker, Node, workflow and manifest pins on different versions. Resolve the intended consistent set across all pin sites, not just the merge direction; follow `mem:workflow/updating-node` for Node policy.
|
||||
- Lockfile conflicts can span importer, package and snapshot self-reference entries. Preserve each workspace's own dependency resolution when updating those entries. Regenerating from an older lockfile can resolve unrelated ranges upward; inspect any real re-resolution separately. `--lockfile-only --fix-lockfile` can fill manifest-required entries after a manual merge.
|
||||
- Frontend installs can need GitHub access for the `@penpot/svgo` git dependency even when the lockfile exists. If GitHub is unreachable, resolve relevant lockfile hunks without claiming an install passed.
|
||||
- Run `scripts/sync-pnpm-version --check` and `pnpm install --frozen-lockfile` in each workspace; inspect the lockfile diff and check that scripts, workflows, Dockerfiles and docs introduce no corepack calls.
|
||||
|
||||
## Cleaning stale node_modules
|
||||
|
||||
- `scripts/clean-node-modules` removes every workspace `node_modules`: the
|
||||
repo root, all module workspaces, and all member packages. Use it when
|
||||
installs misbehave after dependency changes: clean, reinstall, done.
|
||||
- Flags: `-n/--dry-run` lists without deleting; `--store` also removes the
|
||||
shared pnpm store at `<repo>/.pnpm-store` (the next install re-downloads
|
||||
what it held). `external/` (vendored dependency trees with their own
|
||||
lifecycles) and `.opencode/` are always ignored.
|
||||
- The script never touches the pnpm store by default, so the reinstall
|
||||
after cleaning reuses cached packages (zero downloads).
|
||||
- After cleaning, run `pnpm install` in each workspace root to restore the
|
||||
development environment; `frontend` postinstall also reinstalls and
|
||||
builds `plugins-runtime`.
|
||||
- `scripts/clean-node-modules --dry-run` previews removal across workspaces and members; normal cleanup leaves the shared store intact. `--store` also deletes the store, so use it only with explicit permission. The script excludes `external/` and `.opencode/`.
|
||||
- Reinstall in each workspace after cleaning. The frontend postinstall also reinstalls and builds `plugins-runtime`.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user