Skip to content

add: let a bare --patch use the packages it already detected #2307

Description

@seanogdev

changeset add --patch -m 'Fix the export types' fails before it does anything:

CACError: option `--patch <pkg>` value is missing

I'd like a bare --patch to mean "patch everything you detected". The detection already runs, it just gets dropped on the floor.

The detection is already there

add() works out changedPackagesNames on every run, before anything branches, and passes it into createChangeset. The first branch of that function is:

if (optionsFromCli?.major || optionsFromCli?.minor || optionsFromCli?.patch) {
  // builds releases from the CLI lists only, changedPackages is never read
}

So the right answer is sitting in scope, unused. The interactive path takes that same value and shows it as the changed packages group.

Why I care

The non-interactive path is the agent path, and an agent has no TTY. That leaves two options and I'm not keen on either.

Pass --patch <pkgs> and work the list out yourself. That's the step that goes wrong. On one of our PRs the hand-built list named 2 packages where the real answer was 5.

Or drop the bump flags to get the detection, which ends in a groupMultiselect with required: true and nothing preselected. There's no CI or non-TTY fallback in add, so with piped input it writes nothing and exits on the unsettled prompt.

A human never hits this. changeset add groups the changed packages and selectableGroups: true takes the lot in one keystroke. It's only the scripted path that's stuck, which feels backwards.

What I'm suggesting

Make the value optional and fall back to the detected list.

changeset add --patch -m 'Fix the export types'   # patch everything detected
changeset add --patch pkg-a,pkg-b -m '...'        # unchanged

That's --patch [pkg] in the option declaration, and using changedPackages in createChangeset when a bump flag carries no value. --since would compose with it too, which it can't today.

Happy to open a PR if that shape looks right. I'd be interested to hear if there's a reason it works the way it does, I might be missing something.

On @changesets/cli 3.0.1, cac 7.0.0, Node 24.20.0, pnpm workspace.

Follow-up to #2152 and #1121, which added the flags but kept the package list mandatory.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions