Skip to content
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

Flag to create empty changeset #187

Merged
merged 5 commits into from
Oct 11, 2019
Merged

Conversation

itsjackgardner
Copy link
Contributor

@itsjackgardner itsjackgardner commented Oct 11, 2019

Added the --empty flag to the add command, creates an empty changeset:

---
---

yarn changeset add --empty and yarn changeset --empty

Needed to change the regex for parsing changeset files because it assumed existing releases and summary. Also added tests for both creating and reading an empty changeset.

Resolves #145

@changeset-bot
Copy link

changeset-bot bot commented Oct 11, 2019

🦋 Changeset is good to go

Latest commit: 9a525ab

We got this.

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

Copy link
Collaborator

@Noviny Noviny left a comment

Choose a reason for hiding this comment

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

Would be good to get the two more tests I mentioned in my review comments. The implementation itself looks solid.

  • add two tests mentioned in comments

In addition, can we update the README.md to both mention the new flag in add, and explain why you would use this (I'd specifically call out that you likely only need to do this if you have CI set up that blocks merging without a changeset).

  • update readme
  • linting

Final task:

  • Add a changeset 😄

@@ -6,6 +6,7 @@ export type CliOptions = {
verbose?: boolean;
output?: string;
otp?: string;
empty?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor note for learning: empty is actually always a boolean.

Why?

Because there is no 'default' option provided.

We have caught ourselves historically by effectively using 'undefined' as a distinct state for some of these. Here, we don't need a default (we will get false as the default for boolean thanks to meow).

All that said, if you need to update the PR and want to change this, go ahead, but I'm happy to merge this as is.

// @ts-ignore if this is undefined, we have already exited
await add(cwd, config);
await add(cwd, { empty }, config);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch on this being the idiomatic way we were adding these config bits. I'm going to leave a second comment which I don't expect actioned in this PR.


@mitchellhamilton flagging your here as food-for-thought code tidy - it might be worth making these commands pass config, then... cliConfig(?) as a general pattern, allowing us to provide a default for the third argument of the functions and making tests where you just want the defaults easier. Very low priority thought though.

summary: ""
};
// @ts-ignore
const call = writeChangeset.mock.calls[0][0];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a test to writeChangeset

that tests that when passed this, the write function behaves as intended?

releases = Object.entries(yamlStuff).map(([name, type]) => ({
name,
type
}));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can see you added a test to the 'read' package below - it would be good to add one to 'parse', as this is the place where the change is made (the place in charge of the concern as it were).

Code otherwise looks good.

@Noviny Noviny merged commit 8dce96f into master Oct 11, 2019
@Noviny Noviny deleted the flag-to-create-empty-changeset branch October 11, 2019 05:27
@github-actions github-actions bot mentioned this pull request Oct 11, 2019
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.

Feature Request: add --empty flag to create an empty changeset
2 participants