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

[FEATURE] Preview a previous version #187

Merged
merged 11 commits into from
Dec 15, 2020

Conversation

matheusfiorin
Copy link
Contributor

Explore the meow package used in CLI to upgrade the preview command - now with an option to preview a previous generated version.

Usage:

$ news-fragments preview --previousVersion 1.0.1
$ news-fragments preview -p 1.0.1

@matheusfiorin matheusfiorin added the enhancement New feature or request label Dec 9, 2020
@matheusfiorin matheusfiorin self-assigned this Dec 9, 2020
@matheusfiorin matheusfiorin force-pushed the feature/preview-previous-version branch from a2299e5 to 0f64767 Compare December 9, 2020 17:25
@matheusfiorin matheusfiorin force-pushed the feature/preview-previous-version branch from 0f64767 to 55c95c6 Compare December 9, 2020 17:39
module.exports.preview = function (inputs, flags) {
if (!!flags && flags.previousVersion) {
const previousVersionRegex = new RegExp(
`# \\[${flags.previousVersion}\\] - \\(.*\\)([^\\[]+)\\.`
Copy link
Member

Choose a reason for hiding this comment

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

🤔 if someone change the default template, will this feature work?

I think this feature should work for any scenario and I think it will not be that simple.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order of our talk, I've added a metadata injection in between the generated changelog so we don't need to worry about custom templates. Nice idea, though 🥇 . What do you think now?

module.exports.renderTemplate = function (changelogTemplate, data) {
function injectMetadata(compiledTemplate, version) {
return `
[//]: # (start ${version})
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about simplifying this metadata?

[//]: # s-${version}
[//]: # e-${version}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to the comment properly work, we need to maintain the (), but I'll update to s- and e- instead of start and end .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@jairhenrique
Copy link
Member

@matheusfiorin could you fix the code smell?

@sonarcloud
Copy link

sonarcloud bot commented Dec 15, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

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

Successfully merging this pull request may close these issues.

None yet

2 participants