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

feat(package): Add support for missing version #25

Merged
merged 7 commits into from
Aug 29, 2017
Merged

feat(package): Add support for missing version #25

merged 7 commits into from
Aug 29, 2017

Conversation

ffflorian
Copy link
Contributor

This commit adds support for projects without a version field in the package.json file.

Fixes #24.

@robinjoseph08
Copy link
Contributor

robinjoseph08 commented Aug 24, 2017

Hey @ffflorian, thanks for the contribution!

I'd like to support this use-case, but could you help me understand why a package.json wouldn't have a version field? I want to make sure that returning Unknown version is the preferred behavior, because if you keep adding versions, the changelog will look like this:

#### Unknown version (2017-08-24)

##### New Features

* **a:** message ([ada45fed](https://github.com/lob/generate-changelog/commit/ada45fed0bf5a9bbdcf32e1c46176c4cbdcef329))

##### Bug Fixes

* **a:** message ([ada45fed](https://github.com/lob/generate-changelog/commit/ada45fed0bf5a9bbdcf32e1c46176c4cbdcef329))

#### Unknown version (2017-08-22)

##### New Features

* **a:** message ([ada45fed](https://github.com/lob/generate-changelog/commit/ada45fed0bf5a9bbdcf32e1c46176c4cbdcef329))
* **b:** message ([ada45fed](https://github.com/lob/generate-changelog/commit/ada45fed0bf5a9bbdcf32e1c46176c4cbdcef329))

I'm not sure saying Unknown version really adds any value to the changelog. Maybe instead of saying that, we just have the date? What do you think?

@ffflorian
Copy link
Contributor Author

Hi @robinjoseph08!
Thank you for the quick answer.

could you help me understand why a package.json wouldn't have a version field?

At Wire we are looking for a Node.js tool which can generate changelogs - your tool looks like the perfect solution for our needs, but as mentioned before, it breaks in some of our projects.
For example, in the Wire Webapp we don't have a version field in our package.json because it is not an npm package and we are following a version scheme which would not be compatible with npm.

Furthermore IMHO it should at least display an error message if this breaks. 🙂

Maybe instead of saying that, we just have the date? What do you think?

That sounds like a good idea, I will update my pull request accordingly.

@ffflorian ffflorian changed the title feat(package): Add support for missing version Add support for missing version Aug 25, 2017
Copy link
Contributor

@robinjoseph08 robinjoseph08 left a comment

Choose a reason for hiding this comment

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

The code looks good, but could you add some tests to confirm this logic? I want to make sure no regressions happen in the future. Thanks!

@ffflorian
Copy link
Contributor Author

but could you add some tests to confirm this logic?

Sure, I'll update my PR soon. 🙂

@ffflorian
Copy link
Contributor Author

@robinjoseph08
Small note: I changed the return value of calculateNewVersion() to null since other functions expect a version to be returned, not a state.

Copy link
Contributor

@robinjoseph08 robinjoseph08 left a comment

Choose a reason for hiding this comment

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

Some last few nit picks, but then it'll be ready to merge!


return Package.calculateNewVersion()
.then(function (version) {
Expect(version).to.eql(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit pick: can you change this to .to.be.null;. We prefer to use the chai shorthands whenever possible.

.then(function (version) {
Expect(version).to.eql(null);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit pick: can you add a new line after this it block? We usually pad our it blocks with new lines on the top and bottom.

.then(function (changelog) {
var heading = changelog.split('\n')[0];

Expect(heading).to.equal('## ' + new Date().toJSON().slice(0,10));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit pick: can you add a space after the comma in the .slice? There should've been a lint rule for that. I'll look into why that didn't err out.

Copy link
Contributor Author

@ffflorian ffflorian Aug 29, 2017

Choose a reason for hiding this comment

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

Actually I copied this from writer.js but I see that you updated it with the new lint version :)

@robinjoseph08
Copy link
Contributor

@ffflorian I found out that the version of our linter that this repo was using was a bit outdated, so I updated it in #26. You should rebase off of master and you'll get the changes!

@ffflorian
Copy link
Contributor Author

Everything done 🙂. Should I rebase my PR into one commit?

Copy link
Contributor

@robinjoseph08 robinjoseph08 left a comment

Choose a reason for hiding this comment

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

LGTM! The rebase isn't necessary because I'll use the "Squash and Merge" feature that GitHub has. Thanks for asking though!

Thanks again for this contribution! I'll let you know when a new version of the module has been released.

@robinjoseph08 robinjoseph08 changed the title Add support for missing version feat(package): Add support for missing version Aug 29, 2017
@robinjoseph08 robinjoseph08 merged commit 7e91a60 into lob:master Aug 29, 2017
@robinjoseph08
Copy link
Contributor

v1.4.0 has been published! Thanks again!

@ffflorian
Copy link
Contributor Author

Thanks @robinjoseph08! 🙂

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

Successfully merging this pull request may close these issues.

None yet

2 participants