mirror of
https://github.com/pnpm/action-setup.git
synced 2026-09-05 15:08:51 +08:00
* 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
48 lines
1.9 KiB
JavaScript
48 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { execSync } from 'child_process'
|
|
import { mkdtempSync, rmSync, readFileSync, writeFileSync } from 'fs'
|
|
import { join } from 'path'
|
|
import { tmpdir } from 'os'
|
|
|
|
const BOOTSTRAP_DIR = new URL('../src/install-pnpm/bootstrap/', import.meta.url).pathname
|
|
|
|
const legacyVersion = process.argv[2] || resolveLatestVersion(11)
|
|
const nativeVersion = process.argv[3] || resolveLatestVersion(12)
|
|
|
|
console.log(`Updating bootstrap lockfiles to pnpm@${legacyVersion} and pnpm@${nativeVersion} ...`)
|
|
|
|
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(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 v${major} version from npm dist-tags`)
|
|
process.exit(1)
|
|
}
|
|
return version
|
|
}
|
|
|
|
function generateLock(filename, dependencies, name) {
|
|
const tmp = mkdtempSync(join(tmpdir(), 'pnpm-bootstrap-'))
|
|
try {
|
|
writeFileSync(join(tmp, 'package.json'), JSON.stringify({ private: true, dependencies }))
|
|
execSync('npm install --package-lock-only --ignore-scripts', { cwd: tmp, stdio: 'pipe' })
|
|
const lock = readFileSync(join(tmp, 'package-lock.json'), 'utf8')
|
|
const parsed = JSON.parse(lock)
|
|
parsed.name = name
|
|
writeFileSync(join(BOOTSTRAP_DIR, filename), JSON.stringify(parsed, null, 2) + '\n')
|
|
const [packageName, packageVersion] = Object.entries(dependencies)[0]
|
|
console.log(` ${filename} -> ${packageName}@${packageVersion}`)
|
|
} finally {
|
|
rmSync(tmp, { recursive: true, force: true })
|
|
}
|
|
}
|