pnpm/.github/scripts/prepare-docs-sync.mjs
Zoltan Kochan 425c021c25
chore: move pnpm v11 off main to the release/11 branch (#18358)
## Summary

Moves pnpm v11, the TypeScript CLI, off `main`. `main` now holds only
the newest pnpm major. v11 stays on the new `release/11` branch, cut
from this PR's base (664d81d95b). The docs and agent instructions on
`main` describe only what is on `main`; whether a fix also goes to
`release/11` is decided case by case.

### Removed
- `pnpm11/` and `pnpr/client`, which only v11 used.
- The v11 jobs in `release.yml`, the `pnpm11` product in
`create-release-pr.yml`, the v11 test jobs in TS CI with the pnpr build
they waited on, the test-sharding scripts, the v11 benchmark workflow,
and the WebContainer job.
- Catalog entries, overrides, patches and package extensions that only
v11 dependencies used.

### Moved out of `pnpm11/`, because v12 still needs them
- **`pnpm bump`:** now `.github/scripts/bump.mjs`, with node:test tests.
Its products are `pnpm`, `pnpr` and `get-pnpm`.
- **Node.js release-key refresher:** now
`.github/scripts/update-node-release-keys.mjs`. It regenerates the Rust
key module unchanged. `create-release-pr.yml` runs it when pnpm
releases, and its changeset now targets `pacquet`.
- **PnP resolver bundler:** the deps-restorer crate embeds its output.
It now lives in `pnpm/crates/deps-restorer/pnp-runtime`. The output is
byte-identical apart from the banner, and TS CI checks it for staleness.

### Changed
- **`.meta-updater`:** now plain JS. It only mirrors the Rust versions
and renders the npm signing keys.
- **Linting:** uses the published `@pnpm/eslint-config`. Version
1100.0.3 imports `eslint-plugin-jest` but declares it only as a dev
dependency, so a `packageExtensions` entry supplies it. The package fix
belongs on `release/11`.
- **`create-release-pr.yml`:** must be dispatched from the branch it
releases. Each release branch carries its own copy, so v11 releases run
from `release/11`.
- **TS CI:** keeps its required check names (`TS CI / Compile & Lint`,
`TS CI / Success`).
- **Ecosystem E2E:** compares pacquet against the published pnpm v11
pinned in `pnpm/test-oracles`.
- **Docs:**
- The docs build and the main-branch docs sync take `pnpm11/docs` from
`release/11`, because the pnpm.io importer reads every documentation
line.
- Tag syncs read only the manifest of the tagged release line, so a v11
tag on `release/11` never reads v12's manifest.
- **The `pnpm-v11` oracle pin:** now in `update.ignoreDeps`. Without
that, `pnpm update --latest` (the update-lockfile workflow) retargets
the alias at pnpm 12. That was already the case on `main`.
- **Pending changesets:** v11 targets are removed, and the 39 changesets
that had only v11 targets are deleted. `release/11` keeps the originals.
- **Rust comments:** the ones that cited `pnpm11/` paths now use
permalinks pinned to 664d81d95b.
- **Contributor docs:** AGENTS.md, the contributing and release guides,
and the skills drop the v11 parity and dual-implementation rules.
- **get-pnpm:** stays on `main` and is described without tying it to one
pnpm major.
- **Micro-benchmark and engine-size workflows:** remove main's
`node_modules` before installing the pull request. pnpm refuses to reuse
a modules directory created with other settings, which this PR changes.

### Verification
- A `--frozen-lockfile` install works.
- `lint:meta`, ESLint, spellcheck and `pnpm change check` pass.
- The CI and release script tests pass, as do the git-hook tests.
- `cargo doc` with `-D warnings` builds clean on the 11 crates whose
comments changed.
- The tests of `pnpm-deps-restorer`, `pnpm-crypto-shasums-file` and
`pnpm-reporter` pass (826).
- The PnP tests of `pnpm-cli` pass (414).

### Follow-ups
- **A PR on `release/11`:** trim its copies of `release.yml` and
`create-release-pr.yml` to v11, dropping the v12, pnpr and get-pnpm
jobs. Declare `eslint-plugin-jest` as a dependency of
`@pnpm/eslint-config`.
- **pnpm/pnpm.io:** its docs importer could tolerate a source without
`pnpm11/docs`. The `release/11` fetch in the docs workflows could then
go.
- **Rename the v12 wrapper from `pacquet` to `pnpm`:** this is now
possible, since no other workspace package is named `pnpm`.

## Checklist

- [x] Added or updated tests.
- [x] Updated the documentation if needed.

---
Written by an agent (Claude Code, claude-opus-5-5).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:13:38 +01:00

59 lines
3.3 KiB
JavaScript

import { execFileSync } from 'node:child_process'
import { appendFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
export function prepareDocsSync ({ githubRef, releaseTag: tag, docsRef: correction, git = runGit, publicationState = readPublicationState }) {
if (!tag) {
if (githubRef !== 'refs/heads/main') throw new Error('Manual publication without a release tag must run from main')
if (correction) throw new Error('docs_commit requires a release_tag')
return { publish: true, main_sync: true, docs_commit: git('rev-parse', 'HEAD') }
}
const match = /^(v|pnpr@)(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/.exec(tag ?? '')
if (!match) throw new Error('Expected a pnpm or pnpr release tag such as v12.8.2 or pnpr@0.1.0-alpha.15')
const [, prefix, version] = match
if (prefix === 'v' && !['11', '12'].includes(version.split('.')[0])) {
throw new Error('Only pnpm v11 and v12 documentation is maintained here')
}
if (prefix === 'v' && version.includes('-')) return undefined
const releaseCommit = git('rev-parse', '--verify', `refs/tags/${tag}^{commit}`)
git('verify-tag', tag)
// Each release branch holds only its own line's manifest.
const manifest = prefix === 'pnpr@' ? 'pnpr/npm/pnpr/package.json' : version.startsWith('11.') ? 'pnpm11/pnpm/package.json' : 'pnpm/npm/pnpm/package.json'
if (JSON.parse(git('show', `${releaseCommit}:${manifest}`)).version !== version) {
throw new Error(`Tag ${tag} does not match a committed product version`)
}
const packageName = prefix === 'pnpr@' ? '@pnpm/pnpr' : 'pnpm'
const publication = publicationState(`${packageName}@${version}`)
if (publication !== 'published') throw new Error(`${packageName}@${version} has not been published`)
const line = prefix === 'pnpr@' ? 'pnpr' : `${version.split('.')[0]}.x`
const docsRef = correction || releaseCommit
if (!/^[a-f0-9]{40}$/.test(docsRef)) throw new Error('Documentation corrections require a full commit SHA')
const docsCommit = git('rev-parse', '--verify', `${docsRef}^{commit}`)
if (docsCommit !== releaseCommit) {
git('merge-base', '--is-ancestor', releaseCommit, docsCommit)
const docsPath = line === 'pnpr' ? 'pnpr/docs' : line === '11.x' ? 'pnpm11/docs' : 'pnpm/docs'
const changed = git('diff', '--name-only', releaseCommit, docsCommit).split('\n').filter(Boolean)
if (!changed.length || changed.some(file => !file.startsWith(`${docsPath}/`))) {
throw new Error(`Corrections must be based on ${tag} and change only ${docsPath}/`)
}
}
return { publish: true, line, version, release_commit: releaseCommit, docs_commit: docsCommit }
}
function readPublicationState (spec) {
return execFileSync('bash', ['.github/scripts/npm-package-publication-state.sh', spec], { encoding: 'utf8' }).trim()
}
function runGit (...args) {
return execFileSync('git', args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim()
}
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
const result = prepareDocsSync({
githubRef: process.env.GITHUB_REF,
releaseTag: process.env.RELEASE_TAG,
docsRef: process.env.DOCS_COMMIT,
})
if (result) appendFileSync(process.env.GITHUB_OUTPUT, Object.entries(result).map(([key, value]) => `${key}=${value}\n`).join(''))
}