pnpm/.github/scripts/bump.test.mjs
Zoltan Kochan 02a751cbc3
chore: rename the pacquet workspace package to pnpm (#18363)
## Summary

The Rust CLI's npm wrapper was named `pacquet` in the workspace so that
it could not collide with the TypeScript CLI package `pnpm`. The
TypeScript CLI now lives on `release/11`, so the wrapper now uses its
published name, `pnpm`.

### Package and release tooling
- `pnpm/npm/pnpm/package.json` is named `pnpm` and no longer sets
`publishConfig.name`. The `@pnpm/exe` generator no longer strips that
rename.
- The `versioning.fixed` group, the bump script and its tests,
`create-release-pr.yml`, `release.yml` (node-gyp bundle filter, the
GitHub release body path `.changeset/changelogs/pnpm@<version>.md`), and
the install filters in `pacquet-ci.yml`, `pacquet-engine-size.yml` and
the `install-crates` action now use `pnpm`.
- The root pnpmfile's `beforePacking` hook is removed. It stripped
dependencies from any package named `pnpm`, which was the TypeScript CLI
and would now be the Rust wrapper.

### Versioning state
- All 335 pending changesets that targeted `pacquet` now target `pnpm`.
- The ledger's `pacquet@<version>` keys and the parked
`pacquet@<version>.md` changelogs are renamed to `pnpm@<version>`. The
ledger is re-sorted in the order the tool writes it. Consumption is
keyed by each entry's `dir`, so the rename does not change which intents
count as released.
- The parked changelogs of the v11 packages are removed. `release/11`
keeps its own copy. One of them, `pnpm@11.29.0.md`, would otherwise sit
next to the Rust CLI's parked changelogs.

### Not renamed
The Rust project keeps the codename pacquet in crate names, workflow
names, benchmark labels and contributor docs. Only the npm workspace
package changes.

### Coordinated change
pnpm.io reads `.changeset/changelogs/pacquet@<version>.md` at the
release commit to build release pages. pnpm/pnpm.io#997 makes it accept
`pnpm@<version>.md` as well. It must merge before the first release cut
after this PR.

### Verification
- `pnpm change status` gives the same release plan as before the rename:
only the two changesets added since the last release are pending, and
the plan is a patch for `pnpm` and `@pnpm/napi`.
- `pnpm run lint` passes. It covers cspell, meta-updater, `pnpm change
check` (592 intents resolve) and ESLint. Vale passes on the changed
docs.
- `node --test .github/scripts/bump.test.mjs` passes.
- The wrapper tests in `pnpm/npm/pnpm/test` pass (91 tests).
- `--filter "pnpm..."` and `--filter pnpm --filter @pnpm/esm-loader`
select the wrapper, get-pnpm and the loader.

## Checklist

- [ ] Added a changeset (`pnpm changeset`) if this PR changes any
published package. Not needed: the published package name does not
change.
- [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)

<!-- codesmith:footer -->
---
<a
href="https://dashboardbackend.blacksmith.sh/track/run-proof?expires=1797971524&installation_model_id=426870&pr_number=18363&ref=codesmith_pr_footer&repository=pnpm%2Fpnpm&return_to=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F18363&variant=proof_this_pr&signature=fa51b33caf889e45141fe131e099888c912119c8ed1d3896151a80b9564110fb"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-proof-this-pr-v2-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-proof-this-pr-v2-light.svg"><img
alt="Proof this PR"
src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-proof-this-pr-v2-dark-3x.png"
width="121" height="28"></picture></a>
<sup><a
href="https://app.blacksmith.sh/pnpm/codesmith/pnpm/pr/18363?autoLogin=true&ref=codesmith_pr_footer">Open
in [code]smith</a> · Need help on this PR? Tag
<code>@codesmith-bot</code> with what you need.</sup>

<!-- codesmith:autofix:disabled -->
<!-- /codesmith:footer -->

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:48:34 +01:00

118 lines
5.1 KiB
JavaScript

import assert from 'node:assert/strict'
import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import { afterEach, beforeEach, describe, test } from 'node:test'
import { findRepoRoot, parkPublishedPrivateChangelogs, parseSelectedProducts, releaseFilterArgs } from './bump.mjs'
describe('findRepoRoot', () => {
let dir
beforeEach(() => {
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'bump-root-'))
})
afterEach(() => fs.rmSync(dir, { recursive: true, force: true }))
test('walks up to the directory containing .changeset', () => {
fs.mkdirSync(path.join(dir, '.changeset'))
const nested = path.join(dir, '.github', 'scripts')
fs.mkdirSync(nested, { recursive: true })
assert.equal(findRepoRoot(nested), dir)
})
test('throws when no .changeset directory exists above', () => {
assert.throws(() => findRepoRoot(dir), /No \.changeset directory/)
})
})
describe('parseSelectedProducts', () => {
test('collects the products named by --release', () => {
assert.deepEqual(parseSelectedProducts(['--release', 'pnpm', '--release', 'pnpr']), new Set(['pnpm', 'pnpr']))
})
test('is empty when no argument is passed', () => {
assert.deepEqual(parseSelectedProducts([]), new Set())
})
test('skips the leading `--` separator forwarded by `pnpm run bump -- …`', () => {
assert.deepEqual(parseSelectedProducts(['--', '--release', 'pnpm', '--release', 'pnpr']), new Set(['pnpm', 'pnpr']))
assert.deepEqual(parseSelectedProducts(['--']), new Set())
})
test('rejects a `--` that is not in the leading position', () => {
assert.throws(() => parseSelectedProducts(['--release', 'pnpm', '--']), /Unexpected bump argument/)
})
test('throws on an unknown product', () => {
assert.throws(() => parseSelectedProducts(['--release', 'pnpm11']), /Unknown --release product/)
assert.throws(() => parseSelectedProducts(['--release', 'toString']), /Unknown --release product/)
assert.throws(() => parseSelectedProducts(['--release']), /Unknown --release product/)
})
test('fails closed on a misspelled flag instead of releasing everything', () => {
assert.throws(() => parseSelectedProducts(['--releases', 'pnpr']), /Unexpected bump argument/)
})
})
describe('releaseFilterArgs', () => {
test('releases everything (no filter) when nothing is selected', () => {
assert.deepEqual(releaseFilterArgs(new Set()), [])
})
test('includes only the selected products', () => {
assert.deepEqual(releaseFilterArgs(new Set(['pnpm'])), ['--filter=pnpm', '--filter=@pnpm/napi'])
assert.deepEqual(releaseFilterArgs(new Set(['pnpm', 'pnpr'])), ['--filter=pnpm', '--filter=@pnpm/napi', '--filter=@pnpm/pnpr'])
assert.deepEqual(releaseFilterArgs(new Set(['get-pnpm'])), ['--filter=get-pnpm'])
})
})
describe('parkPublishedPrivateChangelogs', () => {
let dir
beforeEach(() => {
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'bump-park-'))
})
afterEach(() => fs.rmSync(dir, { recursive: true, force: true }))
function writeProject (projectDir, manifest, changelog) {
fs.mkdirSync(path.join(dir, projectDir), { recursive: true })
fs.writeFileSync(path.join(dir, projectDir, 'package.json'), JSON.stringify(manifest))
if (changelog != null) {
fs.writeFileSync(path.join(dir, projectDir, 'CHANGELOG.md'), changelog)
}
}
const section = '## 12.8.0\n\n### Minor Changes\n\n- A change.\n\n### Patch Changes\n\n- A fix.\n'
test('moves the committed changelog to the parked section of the released version', () => {
writeProject('pnpm/npm/pnpm', { name: 'pnpm', version: '12.8.0' }, `# pnpm\n\n${section}`)
writeProject('pnpm/npm/napi', { name: '@pnpm/napi', version: '12.8.0' }, '# @pnpm/napi\n\n## 12.8.0\n')
parkPublishedPrivateChangelogs(dir, ['pnpm/npm/pnpm', 'pnpm/npm/napi'])
assert.equal(fs.readFileSync(path.join(dir, '.changeset/changelogs/pnpm@12.8.0.md'), 'utf8'), section)
assert.equal(fs.readFileSync(path.join(dir, '.changeset/changelogs/@pnpm!napi@12.8.0.md'), 'utf8'), '## 12.8.0\n')
assert.equal(fs.existsSync(path.join(dir, 'pnpm/npm/pnpm/CHANGELOG.md')), false)
assert.equal(fs.existsSync(path.join(dir, 'pnpm/npm/napi/CHANGELOG.md')), false)
})
test('skips a project the release did not bump', () => {
writeProject('pnpr/npm/pnpr', { name: '@pnpm/pnpr', version: '0.1.0-alpha.14' })
parkPublishedPrivateChangelogs(dir, ['pnpr/npm/pnpr'])
assert.equal(fs.existsSync(path.join(dir, '.changeset/changelogs')), false)
})
test('refuses a changelog that holds more than the released section', () => {
writeProject('pnpm/npm/pnpm', { name: 'pnpm', version: '12.9.0' }, `# pnpm\n\n## 12.9.0\n\n- New.\n\n${section}`)
assert.throws(() => parkPublishedPrivateChangelogs(dir, ['pnpm/npm/pnpm']), /exactly one section, for pnpm@12\.9\.0/)
assert.equal(fs.existsSync(path.join(dir, 'pnpm/npm/pnpm/CHANGELOG.md')), true)
})
test('refuses a changelog without a section for the released version', () => {
writeProject('pnpm/npm/pnpm', { name: 'pnpm', version: '12.9.0' }, `# pnpm\n\n${section}`)
assert.throws(() => parkPublishedPrivateChangelogs(dir, ['pnpm/npm/pnpm']), /exactly one section/)
})
})