Skip to content

Add support for CLI parameters to specify the version and message in the add() command - #993

Closed
TomOConnor95 wants to merge 16 commits into
changesets:mainfrom
TomOConnor95:allow-changeset-cli-parameters-to-be-specified-as-arguments
Closed

Add support for CLI parameters to specify the version and message in the add() command#993
TomOConnor95 wants to merge 16 commits into
changesets:mainfrom
TomOConnor95:allow-changeset-cli-parameters-to-be-specified-as-arguments

Conversation

@TomOConnor95

@TomOConnor95 TomOConnor95 commented Oct 27, 2022

Copy link
Copy Markdown

First time contributor

Saw this Issue and thought I'd have a go at solving it: #979

I'm not sure of the steps to actually run this locally to test, but I think it should work ok :)

The --version parameter will only work for single package repos.
The --message parameter should work for monorepos with several packages

@changeset-bot

changeset-bot Bot commented Oct 27, 2022

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fa4b14e

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 Minor

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

@codesandbox-ci

codesandbox-ci Bot commented Oct 27, 2022

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit fa4b14e:

Sandbox Source
Vanilla Configuration

Comment thread packages/cli/README.md Outdated

- `--open` - opens the created changeset in an external editor

- `--version` - Creates a changeset with the specified level,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be called change which lines up with what the CLI asks

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even in this very description here it's also called a "level". I'm not sure if that's the best name for the CLI parameter though - I'd like to have cohesive terminology though. So we should call this with a single name all over the place. I agree that version could be misleading here so I wouldn't chose that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call this a "bump type" here:

const bumpTypes = ["none", "patch", "minor", "major"];

but a "version type" here:
export type VersionType = "major" | "minor" | "patch" | "none";


let type: string | undefined;
if (options?.version) {
type = options?.version;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
type = options?.version;
type = options.version;

let summary: string;
if (typeof options?.message === 'string') {
log(
`--message paramter passed: ${options.message}`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`--message paramter passed: ${options.message}`
`--message argument passed: ${options.message}`

log(
`--message paramter passed: ${options.message}`
);
summary = options.message;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we call it summary internally, but also in the prompts - should we then use --message as a CLI parameter? I see how it might be easier for users so I'm not entirely opposed to this but this makes the used terminology ambiguous

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I chose --message to be consistent with Git, but I'm happy to change it to --summary

The CLI asks this question "Please enter a summary for this change (this will be in the changelogs)." so I'll go with summary

Comment thread packages/cli/src/commands/add/index.ts Outdated
import { isListablePackage } from "./isListablePackage";


function isValidVersion(input?: string): input is 'major' | 'minor' | 'patch' {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'none' is also a valid "bump type"

Comment thread packages/cli/src/commands/add/index.ts Outdated
message,
}

if (isValidVersion(version)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is an invalid argument is given by the user then I'd prefer throwing an error

@TomOConnor95
TomOConnor95 force-pushed the allow-changeset-cli-parameters-to-be-specified-as-arguments branch from 76b3baa to 6dd5209 Compare October 31, 2022 09:28
@TomOConnor95

Copy link
Copy Markdown
Author

Thanks for the feedback on this PR. Made all the requested changes.
The bits saying const bumpType: VersionType make me think the parameter should maybe be called --version-type, but I'm interested to hear your feedback, and am happy to make another change if necessary

Also I'm not sure how to actually test this change locally. Can you give me some pointers?
(note: I couldn't find a contribution guide in the repo)

@TomOConnor95
TomOConnor95 requested review from Andarist and JakeGinnivan and removed request for Andarist and JakeGinnivan November 7, 2022 11:00
@bilibiliou

Copy link
Copy Markdown

I review these code, nice solution, thx u contribution @TomOConnor95

@TomOConnor95

Copy link
Copy Markdown
Author

@Andarist / @JakeGinnivan Would be great if you could give this PR another review when you have a chance. I think all issues have been addressed, and it'd be great to get this released some time soon

@thomasmery

Copy link
Copy Markdown

Hi there,

was looking for a way to add changesets during a CI pipeline

this PR looked liked it would allow to do so

is this abandoned?

thnks

@TomOConnor95

Copy link
Copy Markdown
Author

Hi there,

was looking for a way to add changesets during a CI pipeline

this PR looked liked it would allow to do so

is this abandoned?

thnks

Hey, I'm still very keen to get this deployed, but have been waiting for next steps on this PR having fixed the previous requests.
I'm very happy to make any more changes necessary, just waiting on some direction.

@Andarist / @JakeGinnivan please could you give some clarity on the next steps for this?

Tom

@thomasmery

Copy link
Copy Markdown

hi,

would really like to see this happen,

unless I'm mistaken this would be the only way to generate changesets automatically and have a full automated release cycle

I'm guessing this might not be desirable in many cases but in the case of some repetitive workflow with the same kind of changes it would be very helpful

is there any other way to not have to go through the manual steps of producing a changeset?

thanks

@@ -218,12 +222,21 @@ export default async function createChangeset(
}
} else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this option would only be available for single package repos. I would personally like an option like this compatible with monorepos, if it would also accept a cli argument such as --package my-package (or even better, some form that allows you to provide a list of packages --package first-package --package second-package). At the very least I think it should be otherwise documented, and possibly an error thrown if you try to use --bump-type within a monorepo.

For my use-case it would be an acceptable limitation that only a single --bump-type be allowed for creating a changeset against multiple packages.

@ghost ghost Aug 11, 2023

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes would be great to have this applicable to monorepos, seeing as that is a core goal of changesets.

For our monorepo the majority of the time you're only allowed to update single packages at a time.

When you update multiple packages they're required to be the same bump version because it will be just be updating configs and the version type ('major', 'minor', 'patch') will be the same for all packages.

makes it possible to specify a single version for all changes

@ghost

ghost commented Aug 10, 2023

Copy link
Copy Markdown

hi,

would really like to see this happen,

unless I'm mistaken this would be the only way to generate changesets automatically and have a full automated release cycle

I'm guessing this might not be desirable in many cases but in the case of some repetitive workflow with the same kind of changes it would be very helpful

is there any other way to not have to go through the manual steps of producing a changeset?

thanks

+1 would be great to be able to version the change via the command line so we could automate our releases

@TomOConnor95

Copy link
Copy Markdown
Author

+1 would be great to be able to version the change via the command line so we could automate our releases

It'd be great to see this merged. I've been waiting on approval from @Andarist/ @JakeGinnivan , having made the requested changes.

I have seen the comment from @joekur about multi-package repos:
I'd be happy to improve this PR to handle those cases better. But it'd be great to have some guidance form @Andarist / @JakeGinnivan on which options they'd like for this, to avoid implementing the wrong thing.

@ghost

ghost commented Aug 11, 2023

Copy link
Copy Markdown

@TomOConnor95

is your PR here compatible with monorepos, meaning via the cli we can specify the version for all the packages that require version bumps?

@ekans

ekans commented Oct 6, 2023

Copy link
Copy Markdown

It's exactly what I need to automate the creation of a changeset a bit more!

IHMO this PR should be split in 2 parts: one with --bum-type and one with --summary because --summary works with monorepos but --bum-type doesn't.

In this case, the PR with --summary would be ready to merge. WDYT?

@bluwy bluwy linked an issue Nov 18, 2025 that may be closed by this pull request
@Andarist

Copy link
Copy Markdown
Member

Overlapping changes were implemented by #1121 and we just landed this PR.

I know this PR here was first - but the other one caught my attention and it I liked its --patch approach better as that supports better a mix of package names and bump types (each --patch, --minor and --major can separately provide a list of package names).

Nevertheless, thank you for your PR and the contribution. I'm sorry we didn't get to yours earlier.

@Andarist Andarist closed this Jun 30, 2026
@TomOConnor95

TomOConnor95 commented Jun 30, 2026 via email

Copy link
Copy Markdown
Author

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.

[feat] Support non-interactive mode / command way to add changelog

7 participants