Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/bazel-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ name: Bazel patch compatibility (npm)

# The npm flows of the real-Bazel tests (`npm::` in `e2e_bazel_build`):
# hosted and vendored mode for a package that aspect_rules_js links from a
# pnpm lock, and agent mode for the copy of it in `node_modules`, on each
# Bazel release below. bazel-compatibility.yml holds the legs and what
# pnpm lock, agent mode for the copy of it in `node_modules`, and hosted
# mode on a hub that keeps the lock up to date with a pnpm of its own (a
# pnpm 11, and the pnpm 10 that rules_js picks), on each Bazel release
# below. bazel-compatibility.yml holds the legs and what
# every ecosystem shares; this file says when the npm legs run and on which
# releases.
#
# Beyond what every leg needs, an npm leg downloads Node from nodejs.org and
# ruleset archives from codeload.github.com; its repository cache holds them
# and comes to about 100 MB. An npm tarball under test passes through that
# Beyond what every leg needs, an npm leg downloads Node from nodejs.org,
# ruleset archives from codeload.github.com and, for the hubs that keep
# their lock up to date, the two pnpm releases that rules_js runs: the
# `pnpm` package of registry.npmjs.org, about 5 MB each, held to the
# checksums rules_js has for them. The repository cache of a leg holds them
# and comes to about 110 MB. An npm tarball under test passes through that
# cache as well: Bazel's downloader fetches it and keeps it under its
# sha512. So a test builds the upstream tarball and each patched one anew,
# with an id of the run in the entry file, and writes the upstream sum into
Expand Down
1 change: 1 addition & 0 deletions crates/socket-patch-cli/CLI_CONTRACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2509,6 +2509,7 @@ command's integration tests check its output.
| `patch_fetch_failed` (eject) | `failed` | vendor eject (v5.0): a hosted pin's patch record could not be fetched from `…/patches/view/<uuid>`; the whole eject is refused (`eject_refused`), nothing touched, exit 1. |
| `redirect_pnpm_lockfile_elsewhere` / `redirect_workspace_lockfile_elsewhere` / `cargo_manifest_not_workspace_root` (hosted) | top-level `error.code` (`status: "error"`) | scan / get `--mode hosted` (v5.0): the project directory is a workspace member whose lock lives in another directory, so the rewriters, which read only the project directory, would pin nothing, or would pin a lock of its own that its package manager never reads (`redirect_workspace_lockfile_elsewhere`: a `pnpm-lock.yaml` in a member a `pnpm-workspace.yaml` lists, which pnpm ignores for the workspace's shared lock unless the workspace sets `sharedWorkspaceLockfile: false`, checked with pnpm 10.34 and 11.27; a yarn 1 `yarn.lock` in a `package.json` workspace member, which yarn 1.22 never reads; the message names the workspace root to run from) (pnpm: no npm-family lock here, and the nearest ancestor `pnpm-workspace.yaml` or the project's `lockfile-dir` (`.npmrc`) / `lockfileDir` (`pnpm-workspace.yaml`) puts `pnpm-lock.yaml` elsewhere; npm / yarn / Bun, `redirect_workspace_lockfile_elsewhere`: no npm-family lock here, and the nearest ancestor `package.json` whose `workspaces` (array, or the object form's `packages`) matches the directory holds `package-lock.json`, `npm-shrinkwrap.json`, `yarn.lock`, `bun.lock` or `bun.lockb`; a matching root with none of them that is itself listed by an outer root's `workspaces` hands the check to that root; vlt, same code: the nearest ancestor `vlt.json` whose `workspaces` (a string, an array, or an object of groups) matches the directory holds `vlt-lock.json`, or, as vlt falls back to it when `vlt.json` has no `workspaces` field, the `package.json` `workspaces` root above holds `vlt-lock.json`, and the nearer of a `vlt.json` and a `package.json` root is named; `workspaces` patterns use the glob grammar the package managers share: `*`, `?`, `**`, brace sets and sequences (`{a,b}`, `{1..3}`) and character classes (`[a-c]`, `[!a]`), read the way the root's lock's package manager reads them (#1097): extglobs (`@(a|b)`, `?(…)`, `*(…)`, `+(…)`, `!(…)`) match for npm and yarn but not Bun or vlt; for Bun and vlt, `*`, `?` and `**` never match a directory whose name starts with `.` (`packages/*` does not list `packages/.tools`, #1542, #1631) unless the pattern spells the dot (`packages/.tools`, `packages/.*`), while a `!` pattern still excludes one; yarn berry (picomatch) also reads regex groups (`packages/(a|b)`; a group without `|` only in a pattern fast-glob deems dynamic, or in a `!` pattern), the regex quantifiers `?` / `+` after a group, `+` after a class and `+` inside a group, POSIX classes (`[[:alpha:]]`) and `..` segments in a static pattern or after a static prefix (`packages/a/../b` lists `packages/b`; literal in a `!` pattern); a group alternative holding `/` (`(packages/ui|apps/web)`) is matched across components, and a `?` or `+` quantifying such a group fails closed (the pattern lists every directory, and excludes none as a `!` pattern) (#1490); so does a pattern with extglob or regex groups that is past what socket-patch works out — a brace alternative longer than 4,096 characters or with more than 64 groups, or one whose matching against a directory takes more than about a million steps (an ambiguous group such as `*(a|aa)` repeated dozens of times against a name hundreds of characters long) — while a pattern without groups is read whatever its length, and a brace set is expanded to at most 4,096 alternatives and a megabyte of text; a `!` pattern excludes what earlier patterns matched for npm, Bun 1.3+ (a `bun.lock` with a top-level `configVersion`) and vlt, excludes whatever the order for yarn berry (a `yarn.lock` with `__metadata`, where a leading `!(` is an extglob), and is ignored by yarn classic and older Bun (a `bun.lock` without `configVersion`, or a `bun.lockb` alone without the trailing `cNfGvRsN` config-version extension, its binary twin, #1492); only the root's locks whose package manager lists the directory govern it (and are named), and a lockless root lists it when any of them would; when a pnpm workspace also governs the directory, the nearer root is named and a tie goes to `redirect_pnpm_lockfile_elsewhere`; uv (pypi, #1138), `redirect_workspace_lockfile_elsewhere`: the directory holds a `pyproject.toml`, and the nearest ancestor `pyproject.toml` declaring `[tool.uv.workspace]` lists it in `members` (and not in `exclude`), with no standalone project (`[project]`, no workspace) in between, so uv installs it from that root's `uv.lock` (a `uv.lock`, `poetry.lock`, `pdm.lock`, `Pipfile.lock` or pylock left in the member is never read and does not exempt it); the message says uv workspaces are not patched from their root yet either, and vendored refuses the same layout with `pypi_uv_workspace_unsupported` instead of rewriting a member with Hatch configuration as a lockless Hatch project; a directory whose own locks are all ones its manager never reads inside a workspace member is refused the same way, naming the ignored locks: `package-lock.json` / `npm-shrinkwrap.json` when its `package.json` `workspaces` root holds `package-lock.json` or `npm-shrinkwrap.json` (npm, #1094), `bun.lock` / `bun.lockb` when that root holds `bun.lock` or `bun.lockb` (Bun, #1101), and `vlt-lock.json` in a directory with no `vlt.json` of its own when its vlt workspace root (as above) holds `vlt-lock.json` (vlt, #1134), or, listed or not, when vlt's project root for the directory is another directory holding `vlt-lock.json` (vlt, #1584: the nearest ancestor `vlt.json`, else the outermost directory holding a `package.json` or `node_modules`, the walk ending at a directory holding `.git` and below the home directory, as vlt's own `find("project")` does; the message names that root and says a `vlt.json` in the directory makes it a project of its own); vendored refuses it with `vendor_lockfile_missing`, and `vex` reads the ignored lock as absent, with one `patched_ref_unattributable` warning naming it when it holds Socket references) or rewrite the member as a lockless project (cargo: the vendored workspace-root check). Refused before any takeover or write, `--dry-run` included; the message names the directory to run from; exit 1. Disk runs only (an in-memory project has no ancestors). |
| `redirect_pnpm_settings_elsewhere` | top-level `error.code` (`status: "error"`) | scan / get `--mode hosted`: the project directory is a pnpm workspace member (listed by the `packages:` globs of the nearest ancestor `pnpm-workspace.yaml`) with its own v9 `pnpm-lock.yaml` (`sharedWorkspaceLockfile: false`) and no `pnpm-workspace.yaml` of its own, so its pnpm settings come from that ancestor file, which pnpm reads alone (a member's own file is ignored). A directory those globs do not list (no `packages:`, an empty list, a non-matching or `!`-excluded path) is a standalone project on pnpm 11.28+/12 that reads only its own file: it is pinned and gets its own `pnpm-workspace.yaml` like any single project. A root file that does not parse, or whose patterns use braces, classes or extglobs, counts as listing the project. When that file neither carries `trustLockfile: true` nor explicitly sets another value, the trust auto-config has nowhere to go: refused before any takeover or write, `--dry-run` included; the message names the root file to add `trustLockfile: true` to (or `--no-trust-lockfile-config` pins without it); exit 1. Once the root file trusts the lock (or opts out), the member is pinned and no nested `pnpm-workspace.yaml` is created; the `redirect_pnpm_trust_lockfile` warning names the root file. In memory, a member whose lock is demoted into its workspace root (#492) is never refused; one whose lock is not (the workspace root's files do not confirm it pins or ignores that lock, or socket.yml leaves the root out) is refused with this code as its project error, nothing written for it, whenever its lock is v9, the trust auto-config is on and that file may list it (listed, unreadable, or not readable as globs), whatever it says about `trustLockfile`. |
| `redirect_pnpm_bazel_workspace_hidden` | `warnings[]` (warning, one per run) | scan / get `--mode hosted`, dry and wet, and the in-memory engine: the project is in a Bazel workspace where one `npm.npm_translate_lock` call of aspect_rules_js names its `pnpm-lock.yaml` in a plain string, keeps it up to date (`update_pnpm_lock` is `True` or not written out as `True` or `False`), does not list the `pnpm-workspace.yaml` beside the lock in a `data` that is a list of strings (or lists a file that would hold only what hosted mode writes, or one hosted mode does not write `trustLockfile: true` to), and runs a pnpm that the workspace states as 11 or later or in a way that is no version, or states none under a release of aspect_rules_js whose own choice is not known (any but 1.x to 3.x, 4.0.0-alpha.0 and 4.0.0-alpha.1, by `bazel_dep`, a `single_version_override` and `MODULE.bazel.lock`) (the `pnpm_version`, or the `packageManager` of the `pnpm_version_from` file, of the `pnpm.pnpm` tag whose `name` is the repository of the call's `use_pnpm`, `pnpm` without one; a `use_pnpm` whose repository no `use_repo` takes by position under that name, or that no such tag makes unless it is `pnpm`, is no version). The pnpm that Bazel runs would not read the `trustLockfile: true` hosted mode writes, would reject the pinned lock (`ERR_PNPM_TARBALL_URL_MISMATCH`), and `bazel build` would fail. Every root pnpm lock is left untouched and no npm pin is confirmed from it; the members' own locks of a workspace with `sharedWorkspaceLockfile: false` are pinned as without Bazel (in the root lock each package is a `skipped` event: `redirect_unconfirmed`, or `redirect_unattributable` where another npm lock of the project names it, which is then not pinned either), exit 0, `status: "success"`. The detail starts with the file and the line of the call, named as the file writes it (`MODULE.bazel:7: this `npm.npm_translate_lock` …`; `MODULE.bazel:7, with paths from the root of the Bazel workspace: …` for a project below that root) and ends with what to do: `; pnpm-lock.yaml was not rewritten — list `//:pnpm-workspace.yaml` in the `data` of that call and re-run`, with the label of the file beside the lock. Before the label, or alone where the call lists the file: where the file would hold only what hosted mode writes (none, an empty file, the root-only `packages` scaffold, a file of an earlier hosted run), `put a comment line in pnpm-workspace.yaml (create the file where there is none: …)`, because `rollback` removes such a file and the call would name a missing one; where the file says `trustLockfile:` with another value than `true`, or is YAML a line cannot be added to, to set `trustLockfile: true` in it. Where `data` is not written out as a list of strings, the last step is to write it out as one that holds the label. A hub without `update_pnpm_lock`, one that runs pnpm 10 or states no release under a release of the ruleset whose choice is known, one that lists a file of the user's own that takes the setting, a project whose lock no call names and a project in no Bazel workspace are not affected. See docs/ecosystems.md, "Bazel workspaces: npm". |
| `eject_refused` | top-level `error.code` (`status: "error"`) | vendor eject (v5.0): a record fetch failed or a pin's upstream restore was refused while planning; nothing was changed, exit 1. |
| `eject_planned` | `applied` (reason) | vendor eject `--dry-run` (v5.0): the pin would be restored upstream and vendored; nothing written. |
| `eject_rolled_back` | warning; `skipped` event | vendor eject (v5.0): a package failed after the restore began; every touched file was put back from the pre-eject snapshot, so the project is still hosted; `partialFailure`, exit 1. Also the `errorCode` of the `skipped` event re-reporting each package the eject had vendored before it was rolled back (not counted in `summary.applied`). |
Expand Down
Loading
Loading