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

package rename changelog validation #157

Merged
merged 17 commits into from
Oct 17, 2023
Merged

Conversation

kanthesha
Copy link
Contributor

In the current released version, if we rename the package and would like to preserve the changelog, validation is failing for the format. Which is expected as package name doesn't match.

These changes will help to preserve the old package release/tag history and also works fine with new package release/s when we run the validation.
It addresses

  1. Changelog validation working fine for the old package name in the entries and also for the new package release entries
  2. An option to configure Old Tag Prefix and Old Package Version

original tag prefix and original latest version can be configured in package.json

"autoChangelog": {
    "packageRename": {
      "originalLastestVersion": "5.0.1",
      "originalTagPrefix": "json-rpc-middleware-stream@"
    }
  },

@kanthesha kanthesha marked this pull request as ready for review October 6, 2023 15:58
@kanthesha kanthesha requested a review from a team as a code owner October 6, 2023 15:58
src/changelog-config.ts Outdated Show resolved Hide resolved
src/changelog-config.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
@MajorLift
Copy link
Contributor

MajorLift commented Oct 6, 2023

Looks good overall, especially with how quickly you got this to work!

Maybe you could add a barebones test case in changelog.test.ts with a mock renamed package to ensure that stringifyLinkReferenceDefinitions doesn't break in the future?

@MajorLift MajorLift added the enhancement New feature or request label Oct 6, 2023
src/changelog-config.ts Outdated Show resolved Hide resolved
kanthesha and others added 5 commits October 9, 2023 10:52
removing redundant null check.

Co-authored-by: Jongsun Suh <34228073+MajorLift@users.noreply.github.com>
Co-authored-by: Jongsun Suh <34228073+MajorLift@users.noreply.github.com>
Co-authored-by: Jongsun Suh <34228073+MajorLift@users.noreply.github.com>
Co-authored-by: Jongsun Suh <34228073+MajorLift@users.noreply.github.com>
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

I wonder if using a config file is the right way to go here? I've left some comments below.

src/changelog-config.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated
Comment on lines 357 to 359
readonly #versionBeforePkgRename: string | undefined;

readonly #tagPrefixBeforePkgRename: string | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Consistent typing for optional properties.

Suggested change
readonly #versionBeforePkgRename: string | undefined;
readonly #tagPrefixBeforePkgRename: string | undefined;
readonly #versionBeforePkgRename?: string;
readonly #tagPrefixBeforePkgRename?: string;

Copy link
Contributor

Choose a reason for hiding this comment

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

An optional property and a property that can be undefined isn't the same thing in TypeScript. An optional property may or may not be set, but it looks like we do set this property in the constructor — it just might be undefined. So this one seems right to me, but does that make sense to you?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I like | undefined better than ?: here, since undefined is explicitly being passed in with these two variables, and not making them optional will prevent the code from breaking if exactOptionalPropertyTypes is turned on.

My concern is around consistent typing for the other properties in these files that are defined as optional. exactOptionalPropertyTypes would enforce that consistency.

src/changelog.ts Outdated
Comment on lines 383 to 384
versionBeforePkgRename?: string | undefined;
tagPrefixBeforePkgRename?: string | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Consistent typing for optional values. With exactOptionalPropertyTypes disabled, the | undefined is redundant.

Suggested change
versionBeforePkgRename?: string | undefined;
tagPrefixBeforePkgRename?: string | undefined;
versionBeforePkgRename?: string;
tagPrefixBeforePkgRename?: string;

src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/cli.ts Outdated Show resolved Hide resolved
src/cli.ts Show resolved Hide resolved
src/cli.ts Show resolved Hide resolved
src/parse-changelog.ts Outdated Show resolved Hide resolved
@kanthesha
Copy link
Contributor Author

kanthesha commented Oct 12, 2023

@MajorLift I see you have added [] inconsistently around the params and few other changes in couple of places, which are not related to this PR! And if required, it can stay separate, which can be independently reviewed.

@MajorLift
Copy link
Contributor

MajorLift commented Oct 12, 2023

Yes, [] is the JSDoc syntax for optional params (https://jsdoc.app/tags-param.html#optional-parameters-and-default-values). They could replace the "An optional, which is required only..." comments although I didn't remove those.

The fixes adding [] were cluttering up the feed and there's no variation between them so I thought I'd consolidate them into a single commit.

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Sorry for the delay in reviewing. As you can see I left a lot of comments. Try not to be overwhelmed 😅 I think as a whole this implementation makes sense. A lot of the comments are minor.

src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/cli.ts Outdated Show resolved Hide resolved
src/cli.ts Outdated Show resolved Hide resolved
src/cli.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

I have another suggestion for how we can make the code match the intended usage.

src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/parse-changelog.ts Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/cli.ts Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
src/parse-changelog.ts Show resolved Hide resolved
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

I have one more suggestion around removing the brackets for the optional arguments, but this otherwise looks good to me.

src/changelog.ts Outdated Show resolved Hide resolved
src/changelog.ts Outdated Show resolved Hide resolved
kanthesha and others added 2 commits October 17, 2023 18:26
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants