Fix publish flag handling: --snapshot rejected and --no-git-tag ignored for private packages#1941
Conversation
By semver convention, 0.x packages are allowed to contain breaking changes in minor versions. When a peer dependency change triggers a major bump for a 0.x dependent, bump minor instead to avoid prematurely jumping to 1.0.0. Fixes changesets#1887
…ed for private packages Two fixes for the publish command: 1. Accept --snapshot flag in publish without error (regression from changesets#1889). The flag is a no-op for publish but users commonly pass it when piping `changeset version --snapshot && changeset publish` with shared args. 2. Respect --no-git-tag for private packages when privatePackages.tag is enabled. The gitTag guard was only applied to public package tagging but not to the private package tagging path. Fixes changesets#1939 Fixes changesets#1938
🦋 Changeset detectedLatest commit: 6871119 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1941 +/- ##
==========================================
+ Coverage 83.23% 83.78% +0.54%
==========================================
Files 56 56
Lines 2434 2467 +33
Branches 734 749 +15
==========================================
+ Hits 2026 2067 +41
+ Misses 402 394 -8
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // For 0.x versions, peer dependency major bump should be minor | ||
| // since semver allows breaking changes in minor versions for 0.x | ||
| if (dependentPackage.packageJson.version.startsWith("0.")) { | ||
| type = "minor"; | ||
| } else { | ||
| type = "major"; | ||
| } |
There was a problem hiding this comment.
This is unrelated change, please revert it
| } | ||
| case "publish": { | ||
| const { otp, tag, gitTag, ...rest }: CliOptions = flags; | ||
| const { otp, tag, gitTag, snapshot, ...rest }: CliOptions = flags; |
There was a problem hiding this comment.
I don't think we want to fix this, the usage was incorrect and accidentally accepted. So far we only have a single user report about this. So I'd revert this from here.
| if (gitTag) { | ||
| await tagPublish(tool, untaggedPrivatePackageReleases, cwd); | ||
| } |
There was a problem hiding this comment.
I'm double-checking - this isn't related to a recent regression, right?
|
this seems to be a bot opening PRs randomly without oversight storybookjs/storybook#34453 (comment)
|
|
Note that rejecting the We ran into the same problem in our CIs, which broke after a package-lock.json update. Fix is quite simple (removing the --snapshot parameter from publish command), so we patched everything up now and moved on. |

Summary
Two related fixes for the
changeset publishcommand, both stemming from CLI flag handling issues.1.
--snapshotflag incorrectly rejected bychangeset publish(#1939)Regression from #1889. The unknown-flag validation added in 2.31.0 rejects
--snapshotwhen passed tochangeset publish, even though it was silently accepted in 2.30.0.The flag is a no-op for publish, but users commonly pass shared flags when chaining commands:
changeset version --snapshot && changeset publish --snapshotFix: Destructure
snapshotfrom flags in the publish case so it's not passed tovalidateCommandFlagsas an unknown flag.2.
--no-git-tagstill creates git tags for private packages (#1938)When
privatePackages.tag: true,changeset publish --no-git-tagstill creates git tags for untagged private packages because thegitTagguard only wraps the public package tagging path, not the private one.Fix: Wrap the private package
tagPublishcall in the sameif (gitTag)guard.Changes
packages/cli/src/run.ts: Addsnapshotto the publish case destructuringpackages/cli/src/commands/publish/index.ts: Guard private package tagging withif (gitTag)Tests
All existing tests pass (157 passed, 1 skipped).