Skip to content

feat: allow identifierBase to be false - #548

Merged
wraithgar merged 8 commits into
npm:mainfrom
lsvalina:feature/add_flag_disable_prerelease_identifier_base
Apr 14, 2023
Merged

feat: allow identifierBase to be false#548
wraithgar merged 8 commits into
npm:mainfrom
lsvalina:feature/add_flag_disable_prerelease_identifier_base

Conversation

@lsvalina

Copy link
Copy Markdown
Contributor

What

Added Disable Prerelease Identifier Base flag for creating prerelease identifiers without appending .0/.1
Improved Prerelease Identifier Base to use it when identifier is not set (1.0.0-{Identifier Base}) and adds description to cli help for -n flag

Why

Version 1.0.0-something is valid Semantic Version and its not necessary to have "build" number for identifiers that have only one/ first build, changes reflect that so if another prerelease is created with same identifier the "build" number will be append according Prerelease Identifier Base argument

References

Fixes#441
Improves #532

@lsvalina
lsvalina requested a review from a team as a code ownerApril 12, 2023 14:17
@lsvalina
lsvalina requested a review from nlfApril 12, 2023 14:17
@wraithgar

Copy link
Copy Markdown
Contributor

A "disable" boolean is often very confusing because it's turning something off when it's true.

We already have a flag to change this number, perhaps supporting false would suffice.

@lsvalina
lsvalinaforce-pushed the feature/add_flag_disable_prerelease_identifier_base branch from 157e260 to fda7e36CompareApril 13, 2023 09:39
@lsvalina
lsvalinaforce-pushed the feature/add_flag_disable_prerelease_identifier_base branch from fda7e36 to 14a3913CompareApril 13, 2023 09:41
Comment threadREADME.md Outdated
Comment threadREADME.md Outdated
Comment threadbin/semver.js Outdated
Comment threadclasses/semver.js Outdated
@wraithgar

Copy link
Copy Markdown
Contributor

A very good start. Just some minor copy and code quality feedback.

@wraithgarwraithgar changed the title feat: add Disable Prerelease Identifier Base flagfeat: allow identifierBase to be falseApr 13, 2023
Comment threadclasses/semver.js Outdated
Comment threadclasses/semver.js Outdated
Comment threadbin/semver.js Outdated
@wraithgarwraithgar self-assigned this Apr 13, 2023
Comment threadtest/bin/semver.js
Comment threadtest/fixtures/increments.js Outdated
['1.2.3-dev.bar', 'prerelease', '1.2.3-dev', false, 'dev', false],
['1.2.0', 'preminor', '1.3.0-dev', false, 'dev', false],
['1.2.3-1', 'preminor', '1.3.0-dev', false, 'dev', false],
['1.2.3-dev', 'prerelease', '1.2.3-dev.1', false, 'dev', false],

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.

@nlf what do you think about this? If they have said "increase the prerelease" but also asked for there not to be a prerelease base, do we default to 1 or should we throw?

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.

my gut reaction is we should throw because they've asked for us to do something that doesn't make sense. going from no number to adding a number when we've been asked to not add numbers feels wrong

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 agree, let's throw in this situation. No more guessing user intent!

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

just to clarify do we want to throw also in:

['1.2.0','prerelease','1.2.1-1',false,'',false],

?

@wraithgarwraithgarApr 13, 2023

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.

Oooh good point. We sure do! "increase the prerelease with no identifier and no identifierBase" sure sounds impossible.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

i updated it to throw on both cases

@wraithgar

Copy link
Copy Markdown
Contributor

Can you add the tests from #550 to this PR?

@wraithgar
wraithgar merged commit 503a4e5 into npm:mainApr 14, 2023
@wraithgar

Copy link
Copy Markdown
Contributor

Really useful new feature, thanks!

@GornatorGornator mentioned this pull request Jul 2, 2023
1 task
Sign up for freeto 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.

[BUG] Increase pre* with pre-release identifiers without build

4 participants

@lsvalina@wraithgar@nlf@Leena8686