Skip to content

Explain why changeset add skips a package instead of suggesting a typo - #2350

Open
dgesteves wants to merge 1 commit into
changesets:mainfrom
dgesteves:fix/add-private-package-message
Open

dgesteves wants to merge 1 commit into
changesets:mainfrom
dgesteves:fix/add-private-package-message

Conversation

@dgesteves

Copy link
Copy Markdown

Fixes #2339

When I pass a package to --major, --minor or --patch and it exists in the workspace but is skipped, changeset add says it can't be found and that I may have misspelled it. add drops non-versionable packages before createChangeset validates the flags, so the validation can't tell a skipped package from a name that doesn't exist.

This change has add build a map of skipped package names to the reason they are skipped and pass it to createChangeset. The reasons follow the same order as shouldSkipPackage: listed in ignore, private while privatePackages.version is not enabled, or no version field. Packages that really don't exist keep the current message. Nothing changes about which packages are versionable, and the command still exits with code 1.

Before, with the setup from the issue (pnpm workspace, packages/priv is {"name":"priv","version":"1.0.0","private":true}, default config):

$ changeset --patch priv -m "Fix"
The package priv is passed to the `--patch` option but it is not found in the project. You may have misspelled the package name.

After:

$ changeset --patch priv -m "Fix"
The package priv is passed to the `--patch` option but it is skipped because it is private and `privatePackages.version` is not enabled in the config.

The other two reasons read:

The package pkg-ignored is passed to the `--minor` option but it is skipped because it is listed in the `ignore` option of the config.
The package pkg-unversioned is passed to the `--patch` option but it is skipped because its package.json doesn't have a `version` field.

How I tested it:

  • Added a test to packages/cli/src/commands/add/__tests__/add.test.ts that passes a private package, an ignored package, a package without a version and an unknown name in one call, and checks all four messages. It fails on main (all three skipped packages get the "misspelled" message) and passes with the change. The existing tests for unknown names and duplicate flags pass unchanged.
  • pnpm test run packages/cli/src/commands/add: 27 passed
  • pnpm test run: 39 files, 817 passed, 2 todo
  • pnpm types:check, pnpm lint and pnpm format all exit 0
  • Ran the built CLI against the issue's setup. priv gets the new message, a typo like pbu still gets the "misspelled" message, and with privatePackages: { version: true, tag: false } the private package gets a changeset as before.

Changeset included, patch bump for @changesets/cli.

@pintu544 asked on the issue whether a PR along these lines would be welcome. I didn't see one opened, so here's mine; if you already have one in progress, I'm happy to close this in favour of it.

Happy to take suggested changes on the message wording.

Passing a package that exists but is skipped (private while
`privatePackages.version` is not enabled, listed in `ignore`, or
without a `version` field) to `--major`, `--minor` or `--patch` used to
report it as not found and possibly misspelled. The error now says the
package is skipped and why. Unknown names keep the existing message.

Fixes changesets#2339
@changeset-bot

changeset-bot Bot commented Oct 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4072ddc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@changesets/cli Patch

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

@netlify

netlify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for changesets ready!

Name Link
🔨 Latest commit 4072ddc
🔍 Latest deploy log https://app.netlify.com/projects/changesets/deploys/6adcb6cebc196545b7b65207
😎 Deploy Preview https://deploy-preview-2350--changesets.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.54%. Comparing base (e2ee472) to head (4072ddc).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2350      +/-   ##
==========================================
+ Coverage   87.48%   87.54%   +0.05%     
==========================================
  Files          78       78              
  Lines        2973     2987      +14     
  Branches      851      855       +4     
==========================================
+ Hits         2601     2615      +14     
  Misses        337      337              
  Partials       35       35              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hoscardaniel722-maker

Copy link
Copy Markdown

$ changeset --patch priv -m "Fix"
The package priv is passed to the --patch option but it is not found in the project. You may have misspelled the package name.

This branch has not been deployed

No deployments
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.

changeset add says a private package is not found and may be misspelled

2 participants