Skip to content
Draft
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
1 change: 1 addition & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ run = [
"bash ./tests/renovate-apm-manager.sh",
"bash ./tests/renovate-batching-contract.sh",
"bash ./tests/renovate-engines-range.sh",
"bash ./tests/renovate-npm-allow-remote.sh",
"bash ./tests/renovate-branch-pin-digests.sh",
"bash ./tests/renovate-abandonment-exemptions.sh",
"bash ./tests/release-please-auth-contract.sh",
Expand Down
20 changes: 20 additions & 0 deletions .renovate/base.json5
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,24 @@
"gradleWrapper",
"mise",
],
// Temp until npm/cli#9800 is fixed (https://github.com/npm/cli/issues/9800):
// npm 12 (default allow-remote=none) misclassifies registry tarballs as
// "remote" under `--package-lock-only` when a package in the tree declares
// bundleDependencies. Every Tailwind CSS 4 repository has one
// (@tailwindcss/oxide-wasm32-wasi), so Renovate's lockfile updates fail with
// EALLOWREMOTE. npm's allow-remote only takes none, root or all, and `root`
// does not cover transitive dependencies, so `all` is the only value that
// works. It is scoped to Renovate's npm manager, which writes this .npmrc for
// its npm, pnpm and Yarn lockfile updates alike; only the npm CLI has an
// allow-remote setting, so pnpm and Yarn ignore the line. Renovate runs these
// updates with --ignore-scripts, and real installs in CI and on developer
// machines keep npm 12's allow-remote=none, so a URL dependency that slips
// into a lockfile still fails there. allow-git stays at npm 12's `none`.
// npmrcMerge keeps a repository's own .npmrc; its lines come after this
// one, so a repository can still set allow-remote itself. Remove this block
// once Renovate ships an npm release with the fix.
npm: {
npmrc: "allow-remote=all\n",
npmrcMerge: true,
Comment thread
DevSecNinja marked this conversation as resolved.
Resolved
},
}
8 changes: 8 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,14 @@ can still assign Code Owners if an automerge PR cannot merge cleanly.
year as abandoned. Known-stable packages that trip this (for example
`@testing-library/user-event`) are exempted by name in
`packageRules.json5`, not per repository.
- **npm 12 `allow-remote` workaround** — npm 12 refuses registry tarballs in
`--package-lock-only` runs when a package in the tree declares
`bundleDependencies` ([npm/cli#9800](https://github.com/npm/cli/issues/9800)),
which breaks Renovate's lockfile updates in every Tailwind CSS 4 repository.
`base.json5` sets `allow-remote=all` for Renovate's npm manager only (merged with
the repository's `.npmrc`). That manager also runs pnpm and Yarn lockfile
updates, which ignore the setting. Installs in CI and on developer machines keep npm 12's
`allow-remote=none`. Remove it once Renovate's npm includes the fix.
- **npm `engines` are never pinned** — `rangeStrategy: "pin"` applies to
dependencies, but `engines` declare the supported range (`node: "^24.0.0"`)
and use `rangeStrategy: "replace"`. The exact Node.js version for
Expand Down
44 changes: 44 additions & 0 deletions tests/renovate-npm-allow-remote.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
#
# Contract test for the npm 12 EALLOWREMOTE workaround (npm/cli#9800) in the
# shared presets. The `npmrc` override must stay as narrow as possible:
#
# - only in the npm manager block, never at the top level or in packageRules,
# so no other manager is affected. Renovate's npm manager also writes it for
# pnpm and Yarn lockfile updates; neither has an allow-remote setting, so for
# them the line is inert;
# - only `allow-remote=all`: no allow-git, registry, script or auth settings;
# - with npmrcMerge, so a repository's own .npmrc is kept and can override it.

set -euo pipefail

repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

fail() {
echo "error: $*" >&2
exit 1
}

command -v pyjson5 >/dev/null 2>&1 || fail "'pyjson5' not found on PATH. Run via 'mise run test'."

found=0
for file in "${repo_root}"/.renovate/*.json5; do
name="$(basename "${file}")"
config="$(pyjson5 --as-json "${file}" | tr -d '\r')"
misplaced="$(jq -r '[paths(objects) as $p | select(getpath($p) | has("npmrc")) | $p | map(tostring) | join(".")]
| map(select(. != "npm")) | join(", ")' <<<"${config}")"
[ -z "${misplaced}" ] || fail "${name}: npmrc is only allowed in the npm manager block, found at: ${misplaced}"
if jq -e 'has("npmrc")' <<<"${config}" >/dev/null; then
fail "${name}: a top-level npmrc would reach every manager and, without npmrcMerge, replace repository .npmrc files"
fi
jq -e '.npm.npmrc' <<<"${config}" >/dev/null || continue
found=$((found + 1))
settings="$(jq -r '.npm.npmrc | split("\n") | map(select(test("^\\s*([#;].*)?$") | not)) | join(" ")' <<<"${config}")"
[ "${settings}" = "allow-remote=all" ] ||
fail "${name}: npm.npmrc may only set allow-remote=all (npm/cli#9800 workaround), found: ${settings}"
jq -e '.npm.npmrcMerge == true' <<<"${config}" >/dev/null ||
fail "${name}: npm.npmrc needs npmrcMerge: true, otherwise it replaces the repository's own .npmrc"
done
[ "${found}" -le 1 ] || fail "npm.npmrc is set in ${found} presets; keep the workaround in one place"

echo "Renovate npm allow-remote workaround: OK"
Loading