mirror of
https://github.com/supabase/setup-cli.git
synced 2026-08-15 17:36:01 +00:00
Honor workspace npm config for CLI installs (#443)
## Summary - Run npm commands from the caller workspace so npm remains the source of truth for `.npmrc` parsing, auth, delegated config files, env expansion, quoting, and precedence. - Keep the CLI install isolated with `--prefix`, while explicitly overriding action-owned npm policy such as `offline=false`, `bin-links=true`, and no package lock. - Treat existing `node` and `npm` commands on musl as sufficient only when they actually run, probing Alpine `/usr/bin` binaries with `/usr/bin` first on PATH. - Prefer Alpine `/usr/bin` runtime binaries when an earlier PATH entry shadows them, and keep apk installation for missing runtime libraries or missing commands. ## Validation - `bun run ci` - Real npm sanity check for workspace `.npmrc` with quoted/env delegated config, `globalconfig`, relative `cafile`, mTLS path keys, `offline=true`, `bin-links=false`, and package-lock policy - Fixture workflow: https://github.com/jgoux/setup-cli-testing/actions/runs/28663875606 Addresses https://github.com/supabase/setup-cli/pull/442#discussion_r3519786253 Addresses https://github.com/supabase/setup-cli/pull/442#discussion_r3519786255
This commit is contained in:
26
action.yml
26
action.yml
@@ -61,12 +61,33 @@ runs:
|
||||
# actions/setup-node uses glibc Node builds, so install Alpine's Node/npm instead.
|
||||
if command -v apk >/dev/null 2>&1; then
|
||||
missing_packages=""
|
||||
for package in libstdc++ libgcc nodejs npm; do
|
||||
prefer_apk_bin=false
|
||||
for package in libstdc++ libgcc; do
|
||||
if ! apk info -e "${package}" >/dev/null 2>&1; then
|
||||
missing_packages="${missing_packages} ${package}"
|
||||
fi
|
||||
done
|
||||
|
||||
if ! command -v node >/dev/null 2>&1 || ! node -p 'process.versions.node' >/dev/null 2>&1; then
|
||||
if [ -x /usr/bin/node ] && PATH="/usr/bin:${PATH}" /usr/bin/node -p 'process.versions.node' >/dev/null 2>&1; then
|
||||
prefer_apk_bin=true
|
||||
else
|
||||
missing_packages="${missing_packages} nodejs"
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! command -v npm >/dev/null 2>&1 || ! npm --version >/dev/null 2>&1; then
|
||||
if [ -x /usr/bin/npm ] && PATH="/usr/bin:${PATH}" /usr/bin/npm --version >/dev/null 2>&1; then
|
||||
prefer_apk_bin=true
|
||||
else
|
||||
missing_packages="${missing_packages} npm"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${prefer_apk_bin}" = "true" ]; then
|
||||
echo "/usr/bin" >> "$GITHUB_PATH"
|
||||
fi
|
||||
|
||||
if [ -z "${missing_packages}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
@@ -77,6 +98,9 @@ runs:
|
||||
fi
|
||||
|
||||
apk add --no-cache ${missing_packages}
|
||||
if echo " ${missing_packages} " | grep -Eq ' (nodejs|npm) '; then
|
||||
echo "/usr/bin" >> "$GITHUB_PATH"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user