mirror of
https://github.com/pnpm/action-setup.git
synced 2026-09-05 15:08:51 +08:00
feat: support pnpm v12 (#288)
* feat: support pnpm v12 Approve the pinned @pnpm/exe install script for npm 12, add pnpm 12 coverage across supported runner platforms, and clarify that action-setup remains supported alongside pnpm/setup. * refactor: use pnpm 12 native bootstrap Install the plain pnpm v12 package as the single native bootstrap, remove the legacy @pnpm/exe lockfile and runtime path, and retain the standalone input as a no-op for workflow compatibility. * fix: keep bootstrap updates on pnpm 12 Handle npm's array-shaped view output and resolve only pnpm 12 distribution tags. * fix: use native bootstrap only for pnpm 12 Route pnpm 12-only versions and ranges through the plain pnpm native package while preserving the existing Node and @pnpm/exe bootstrap paths for older releases. * style: remove updater narrative comments
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Usage: node scripts/update-bootstrap.mjs [version]
|
||||
// If version is omitted, fetches the latest next-11 tag from npm.
|
||||
// Regenerates the bootstrap lockfiles used by action-setup to install pnpm via npm.
|
||||
|
||||
import { execSync } from 'child_process'
|
||||
import { mkdtempSync, rmSync, readFileSync, writeFileSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
@@ -11,21 +7,24 @@ import { tmpdir } from 'os'
|
||||
|
||||
const BOOTSTRAP_DIR = new URL('../src/install-pnpm/bootstrap/', import.meta.url).pathname
|
||||
|
||||
const version = process.argv[2] || resolveLatestVersion()
|
||||
const legacyVersion = process.argv[2] || resolveLatestVersion(11)
|
||||
const nativeVersion = process.argv[3] || resolveLatestVersion(12)
|
||||
|
||||
console.log(`Updating bootstrap lockfiles to pnpm@${version} ...`)
|
||||
console.log(`Updating bootstrap lockfiles to pnpm@${legacyVersion} and pnpm@${nativeVersion} ...`)
|
||||
|
||||
generateLock('pnpm-lock.json', { pnpm: version }, 'bootstrap-pnpm')
|
||||
generateLock('exe-lock.json', { '@pnpm/exe': version }, 'bootstrap-exe')
|
||||
generateLock('pnpm-lock.json', { pnpm: legacyVersion }, 'bootstrap-pnpm')
|
||||
generateLock('exe-lock.json', { '@pnpm/exe': legacyVersion }, 'bootstrap-exe')
|
||||
generateLock('native-lock.json', { pnpm: nativeVersion }, 'bootstrap-native-pnpm')
|
||||
|
||||
console.log('Done!')
|
||||
|
||||
function resolveLatestVersion() {
|
||||
const json = execSync('npm view @pnpm/exe dist-tags --json', { encoding: 'utf8' })
|
||||
const tags = JSON.parse(json)
|
||||
const version = tags['next-11'] || tags['latest']
|
||||
function resolveLatestVersion(major) {
|
||||
const json = execSync('npm view pnpm dist-tags --json', { encoding: 'utf8' })
|
||||
const parsed = JSON.parse(json)
|
||||
const tags = Array.isArray(parsed) ? parsed[0] : parsed
|
||||
const version = tags[`next-${major}`] || tags[`latest-${major}`]
|
||||
if (!version) {
|
||||
console.error('Could not determine latest pnpm version from npm dist-tags')
|
||||
console.error(`Could not determine latest pnpm v${major} version from npm dist-tags`)
|
||||
process.exit(1)
|
||||
}
|
||||
return version
|
||||
@@ -40,7 +39,8 @@ function generateLock(filename, dependencies, name) {
|
||||
const parsed = JSON.parse(lock)
|
||||
parsed.name = name
|
||||
writeFileSync(join(BOOTSTRAP_DIR, filename), JSON.stringify(parsed, null, 2) + '\n')
|
||||
console.log(` ${filename} -> ${Object.values(dependencies)[0]}@${version}`)
|
||||
const [packageName, packageVersion] = Object.entries(dependencies)[0]
|
||||
console.log(` ${filename} -> ${packageName}@${packageVersion}`)
|
||||
} finally {
|
||||
rmSync(tmp, { recursive: true, force: true })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user