Compare commits

..
5 changed files with 120 additions and 118 deletions
+2 -2
View File
@@ -13,10 +13,10 @@ jobs:
check-dist: check-dist:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Setup pnpm - name: Setup pnpm
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
with: with:
run_install: true run_install: true
version: 11 version: 11
+7 -13
View File
@@ -7,9 +7,6 @@ on:
- master - master
workflow_dispatch: workflow_dispatch:
permissions:
contents: read
jobs: jobs:
smoke: smoke:
# Cross-OS coverage. Exercises the bootstrap install + PATH on each platform, # Cross-OS coverage. Exercises the bootstrap install + PATH on each platform,
@@ -54,7 +51,7 @@ jobs:
version: '12.3.4' version: '12.3.4'
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- id: pnpm - id: pnpm
name: Run the action name: Run the action
@@ -73,9 +70,6 @@ jobs:
set -e set -e
which pnpm which pnpm
which pnpx which pnpx
case "$PNPM_HOME" in
''|*node_modules*) echo "PNPM_HOME must be set outside node_modules"; exit 1 ;;
esac
actual="$(pnpm --version)" actual="$(pnpm --version)"
echo "pnpm --version: ${actual}" echo "pnpm --version: ${actual}"
if [ "${actual}" != "${REQUIRED}" ]; then if [ "${actual}" != "${REQUIRED}" ]; then
@@ -140,7 +134,7 @@ jobs:
expect_pm_on_fail_unset: true expect_pm_on_fail_unset: true
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Set up package.json - name: Set up package.json
run: echo '${{ matrix.manifest }}' > package.json run: echo '${{ matrix.manifest }}' > package.json
@@ -189,7 +183,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with: with:
persist-credentials: false persist-credentials: false
@@ -240,7 +234,7 @@ jobs:
env: env:
REQUIRED: ${{ matrix.version }} REQUIRED: ${{ matrix.version }}
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with: with:
persist-credentials: false persist-credentials: false
@@ -304,7 +298,7 @@ jobs:
name: 'Standalone Windows self-update (PATH regression)' name: 'Standalone Windows self-update (PATH regression)'
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Set up package.json with a minimal manifest - name: Set up package.json with a minimal manifest
# run_install needs a manifest to install against. Removing the # run_install needs a manifest to install against. Removing the
@@ -362,7 +356,7 @@ jobs:
manifest: '{"devEngines":{"packageManager":{"name":"pnpm","version":">=10 <11"}},"dependencies":{"is-odd":"3.0.1"}}' manifest: '{"devEngines":{"packageManager":{"name":"pnpm","version":">=10 <11"}},"dependencies":{"is-odd":"3.0.1"}}'
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Set up package.json - name: Set up package.json
run: echo '${{ matrix.manifest }}' > package.json run: echo '${{ matrix.manifest }}' > package.json
@@ -406,7 +400,7 @@ jobs:
- yarn - yarn
steps: steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Run the action - name: Run the action
uses: ./ uses: ./
+1 -3
View File
@@ -64,7 +64,7 @@ Input and output changes:
Version of pnpm to install. Version of pnpm to install.
**Optional** when `package.json` declares pnpm in `packageManager`, or sets `devEngines.packageManager.name` to `"pnpm"` and provides `devEngines.packageManager.version`. **Optional** when there is a [`packageManager` or `devEngines.packageManager` field in the `package.json`](https://nodejs.org/api/corepack.html).
otherwise, this field is **required** It supports npm versioning scheme, it could be an exact version (such as `10.9.8`), or a version range (such as `10`, `10.x.x`, `10.9.x`, `^10.9.8`, `*`, etc.), or `latest`. otherwise, this field is **required** It supports npm versioning scheme, it could be an exact version (such as `10.9.8`), or a version range (such as `10`, `10.x.x`, `10.9.x`, `^10.9.8`, `*`, etc.), or `latest`.
@@ -157,8 +157,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v6 - uses: pnpm/action-setup@v6
``` ```
+93 -93
View File
File diff suppressed because one or more lines are too long
+17 -7
View File
@@ -72,12 +72,14 @@ export async function runSelfInstaller(inputs: Inputs): Promise<SelfInstallerRes
return { exitCode: npmExitCode, binDest: path.join(dest, 'node_modules', '.bin') } return { exitCode: npmExitCode, binDest: path.join(dest, 'node_modules', '.bin') }
} }
const bootstrapBinDir = standalone && process.platform === 'win32' const pnpmHome = standalone && process.platform === 'win32'
? path.join(dest, 'node_modules', '@pnpm', 'exe') ? path.join(dest, 'node_modules', '@pnpm', 'exe')
: path.join(dest, 'node_modules', '.bin') : path.join(dest, 'node_modules', '.bin')
const pnpmHome = path.join(dest, 'pnpm-home') // PNPM_HOME/bin is where `pnpm self-update` places the target version
await mkdir(pnpmHome, { recursive: true }) // binary. It must have higher PATH precedence than pnpmHome (which
addPath(bootstrapBinDir) // contains the bootstrap binary) so the self-updated version is found
// first. The bootstrap pnpm is invoked via absolute path, not PATH,
// so this ordering does not affect the bootstrap step.
addPath(pnpmHome) addPath(pnpmHome)
addPath(path.join(pnpmHome, 'bin')) addPath(path.join(pnpmHome, 'bin'))
exportVariable('PNPM_HOME', pnpmHome) exportVariable('PNPM_HOME', pnpmHome)
@@ -104,17 +106,25 @@ export async function runSelfInstaller(inputs: Inputs): Promise<SelfInstallerRes
const bootstrapVersion = native ? bootstrapNativeVersion : standalone ? bootstrapExeVersion : bootstrapPnpmVersion const bootstrapVersion = native ? bootstrapNativeVersion : standalone ? bootstrapExeVersion : bootstrapPnpmVersion
if (targetVersion === bootstrapVersion || (native && satisfies(bootstrapVersion, targetVersion))) { if (targetVersion === bootstrapVersion || (native && satisfies(bootstrapVersion, targetVersion))) {
return { exitCode: 0, binDest: bootstrapBinDir } return { exitCode: 0, binDest: pnpmHome }
} }
const cmd = native || standalone ? bootstrapPnpm : process.execPath const cmd = native || standalone ? bootstrapPnpm : process.execPath
const args = native || standalone ? ['self-update', targetVersion] : [bootstrapPnpm, 'self-update', targetVersion] const args = native || standalone ? ['self-update', targetVersion] : [bootstrapPnpm, 'self-update', targetVersion]
const exitCode = await runCommand(cmd, args, { cwd: dest }) const exitCode = await runCommand(cmd, args, { cwd: dest })
if (exitCode !== 0) { if (exitCode !== 0) {
return { exitCode, binDest: bootstrapBinDir } return { exitCode, binDest: pnpmHome }
} }
// self-update writes the target pnpm/pnpx into PNPM_HOME/bin, leaving
// the bootstrap symlinks in pnpmHome pointing at the old version. Use
// PNPM_HOME/bin so consumers of the bin_dest output (e.g.
// `${steps.pnpm.outputs.bin_dest}/pnpm`) invoke the requested version.
//
// When the requested version resolves to the bootstrap version, self-update
// is a no-op and PNPM_HOME/bin is not created — fall back to pnpmHome,
// whose symlinks already point at the right version.
const updatedBinDir = path.join(pnpmHome, 'bin') const updatedBinDir = path.join(pnpmHome, 'bin')
return { exitCode: 0, binDest: existsSync(updatedBinDir) ? updatedBinDir : bootstrapBinDir } return { exitCode: 0, binDest: existsSync(updatedBinDir) ? updatedBinDir : pnpmHome }
} }
function readTargetVersion(opts: { function readTargetVersion(opts: {