Skip to content

feat(publish): Add --dry-run and --json flag to yarn npm publish #6850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

Saadnajmi
Copy link

@Saadnajmi Saadnajmi commented Jul 17, 2025

What's the problem this PR addresses?

Addresses #6849

...

How did you fix it?

Full disclosure, used Github Copilot Agent Mode to generate most of this PR here --> Saadnajmi#2

This adds a couple of flags to yarn npm publish, so that it matches other package managers like pnpm and bun, and is thus easier for tools like nx release to use (see nrwl/nx#29242 ). We add

  • --dry-run (Bails out right before the final publish to NPM)
  • --json (This takes advantage of StreamReports JSON config)

Using both flags together looks something like this:

sanajmi@Saads-MacBook-Pro-14 berry % yarn ./packages/foo npm publish --dry-run
➤ YN0000: another-one.js
➤ YN0000: bar.js
➤ YN0000: foo.js
➤ YN0000: index.js
➤ YN0000: package.json
➤ YN0000: [DRY RUN] Package would be published to https://registry.yarnpkg.com with tag latest
➤ YN0000: Done in 0s 56ms

sanajmi@Saads-MacBook-Pro-14 berry % yarn ./packages/foo npm publish --json --dry-run
{"type":"files","files":["another-one.js","bar.js","foo.js","index.js","package.json"]}
{"name":"foo","version":"1.0.0","registry":"https://registry.yarnpkg.com","dryRun":true,"published":false,"message":"[DRY RUN] Package would be published to https://registry.yarnpkg.com with tag latest"}
sanajmi@Saads-MacBook-Pro-14 berry % 

Checklist

(TODO)

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@Saadnajmi Saadnajmi changed the title feat(publish): Add flags to match other package managers feat(publish): Add --dry-run and --json flag to yarn npm publish Jul 18, 2025
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