Skip to content

feat: npm stage (#9201)#9379

Merged
reggi merged 1 commit into
release/v11from
backport/v11/9201
May 20, 2026
Merged

feat: npm stage (#9201)#9379
reggi merged 1 commit into
release/v11from
backport/v11/9201

Conversation

@reggi
Copy link
Copy Markdown
Contributor

@reggi reggi commented May 20, 2026

Backports #9201 to release/v11.

Original commit: 254809e

Conflict resolutions

  • docs/lib/content/nav.yml and lib/utils/cmd-list.js: kept shrinkwrap, star, and stars (still present on release/v11) and added stage in alphabetical order. On latest, those three commands were dropped in separate commits not part of this backport.
  • lib/utils/tar.js: combined both sides — kept the key == null ? tarball : { [key]: tarball } form from release/v11 and added the new redact / META handling from the stage commit.
  • Snapshots (test/lib/docs.js.test.cjs, test/lib/npm.js.test.cjs, smoke-tests/test/index.js.test.cjs, tap-snapshots/test/lib/commands/publish.js.test.cjs): regenerated locally via npm test and npm run snap -w smoke-tests.

A new command for staged publishing — allowing package maintainers to
decouple the act of publishing from proof-of-presence (2FA), making
automated workflows more secure.

🔗
[Docs](https://github.com/npm/cli/blob/014d8b211ae4a2eb35e65a3f54cb962ca04f009f/docs/lib/content/commands/npm-stage.md)

With `npm stage publish`, an automated workflow can stage a package
version *without* a 2FA prompt. The maintainer can then review and
approve the staged package at their convenience, providing 2FA only at
the approval step. This keeps proof-of-presence in the loop while
keeping CI/CD fully automated.

| Command | Description | Requires 2FA |
| --- | --- | --- |
| `npm stage publish [<package-spec>]` | Stage a package for publishing
| No |
| `npm stage list [<package-spec>]` | List all staged package versions |
No |
| `npm stage view <stage-id>` | View details of a specific staged
package | No |
| `npm stage approve <stage-id>` | Approve and publish a staged package
| Yes |
| `npm stage reject <stage-id>` | Reject and remove a staged package |
Yes |
| `npm stage download <stage-id>` | Download the staged tarball for
inspection | No |

1. **Stage** — CI runs `npm stage publish` using any token type (no 2FA
needed). The package version is held in a pending state, not publicly
available.
2. **Review** — Maintainer runs `npm stage list` to see pending staged
packages, and `npm stage view <id>` or `npm stage download <id>` to
inspect them.
3. **Approve or Reject** — Maintainer runs `npm stage approve <id>`
(with 2FA) to publish, or `npm stage reject <id>` to discard.

- Staged packages share the same semver uniqueness constraint as
published packages — you can't publish a version that's already staged.
- Normal `npm publish` continues to work alongside staged publishing.
- Multiple versions of the same package can be staged concurrently.
- `npm stage publish` has full parity with `npm publish` (respects
`"private": true`, workspace support, etc).
- Tags are immutable once staged — reject and re-stage to change a tag.

- **Trust relationship permissions** — A follow-up PR will add granular
command permissions to `npm trust`, with `--allow-publish` and
`--allow-stage-publish` flags to control whether a trust relationship
can be used for `npm publish`, `npm stage publish`, or both.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit 254809e)
@reggi reggi requested review from a team as code owners May 20, 2026 17:27
@reggi reggi changed the title [Backport release/v11] feat: npm stage (#9201) feat: npm stage (#9201) May 20, 2026
@reggi reggi merged commit 0d5d899 into release/v11 May 20, 2026
52 checks passed
@reggi reggi deleted the backport/v11/9201 branch May 20, 2026 17:56
@github-actions github-actions Bot mentioned this pull request May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants