Repository navigation
Improve support for semver prerelease identifiers when publishing - #960
Conversation
| type: "string", | ||
| requiresArg: true, | ||
| }, | ||
| "prerelease-id": { |
| if (!["major", "minor", "patch"].some((inc) => choice === inc)) { | ||
| throw new Error(`--cd-version must be one of 'major', 'minor', or 'patch', got '${choice}'`); | ||
| try { | ||
| semver.inc("1.0.0", choice); |
There was a problem hiding this comment.
Oh, interesting, this is much better than a static whitelist.
|
|
||
| this.updates.forEach((update) => { | ||
| versions[update.package.name] = semver.inc(update.package.version, this.options.cdVersion); | ||
| // TODO add semver.inc() argument for prerelease identifier |
There was a problem hiding this comment.
This TODO seems satisfied? (but the one below is not)
| * INDEPENDENT - CD VERSION - PRERELEASE | ||
| * ======================================================================= */ | ||
|
|
||
| it("should bump to prerelease versions with --cd-version=prerelease --prerelease-id=foo", (done) => { |
There was a problem hiding this comment.
These are great tests, what happens when you bump a non-canary prepatch with another prepatch?
I would expect 1.0.0-beta.0 bumps to 1.0.0-beta.1, but I don't see any tests to that effect.
There was a problem hiding this comment.
prepatch will make it 1.0.1-beta.1 (actually, that's the difference between prepatch and prerelease)
There was a problem hiding this comment.
Hah, I learned something! That makes sense.
|
|
||
| ```sh | ||
| $ lerna publish --cd-version (patch | major | minor) | ||
| $ lerna publish --cd-version (patch | major | minor | prepatch | premajor | preminor | prerelease) |
There was a problem hiding this comment.
I prefer the ordering in the other PR, patch -> minor -> major
There was a problem hiding this comment.
What do you think about ordering these to be consistent with npm version, which, from npm help version is:
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]
| "cd-version": { | ||
| group: "Command Options:", | ||
| describe: "Skip the version selection prompt and increment semver 'major', 'minor', or 'patch'.", | ||
| describe: "Skip the version selection prompt and increment semver 'major', 'minor', 'patch', etc.", |
There was a problem hiding this comment.
I think we should still enumerate here the values that semver accepts currently
There was a problem hiding this comment.
Yep, your PR's loop-generated string is preferable here.
| getCanaryVersion(version, metaName) { | ||
| if (metaName == null || typeof metaName !== "string") { | ||
| metaName = "alpha"; | ||
| getCanaryVersion(version, prerelease) { |
There was a problem hiding this comment.
I agree, that's a better name
|
I am a fan of that ordering
… On Aug 9, 2017, at 19:12, Darryl Hodgins ***@***.***> wrote:
@darrylhodgins commented on this pull request.
In README.md:
> @@ -380,14 +380,30 @@ Useful in [Continuous integration (CI)](https://en.wikipedia.org/wiki/Continuous
#### --cd-version
```sh
-$ lerna publish --cd-version (patch | major | minor)
+$ lerna publish --cd-version (patch | major | minor | prepatch | premajor | preminor | prerelease)
What do you think about ordering these to be consistent with npm version, which, from npm help version is:
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
Thanks for the feedback, everyone! I'll get cracking on incorporating it this week. |
|
Okay @evocateur and @Hypnosphi, I think I've addressed all of your feedback. Let me know if you see anything else. |
--cd-version prerelease and --canary --cd-version
evocateur
left a comment
There was a problem hiding this comment.
You'll need to rebase to fix upstream conflicts, sorry. Almost there.
| coerce: (choice) => { | ||
| if (!["major", "minor", "patch"].some((inc) => choice === inc)) { | ||
| throw new Error(`--cd-version must be one of 'major', 'minor', or 'patch', got '${choice}'`); | ||
| if (!cdVersionOptions.includes(choice)) { |
There was a problem hiding this comment.
We still support node v4, so we can't use Array#includes(). Can probably just restore the previous .some() iterator, or maybe just a plain old if (cdVersionOptions.indexOf(choice) === -1) { ? Not as fancy, but should get the job done.
There was a problem hiding this comment.
Ah, gotcha. I'll roll it back.
| const defaultVersion = semver.inc(currentVersion, "prerelease", existingId); | ||
| const prompt = `(default: ${existingId ? `"${existingId}"` : "none"}, yielding ${defaultVersion})`; | ||
|
|
||
| // TODO: allow specifying prerelease identifier as CLI option to skip the prompt |
There was a problem hiding this comment.
Honestly, I'm not sure. Should passing --preid skip the prompt?
There was a problem hiding this comment.
It seems like --preid, in this case, should possibly be able to provide an override (or fallback?) for the existingId above. It wouldn't skip the prompt, I don't think, unless they pass --yes.
In any case, let's leave the TODO and address it later (dunno how useful it would be, really)
starting work on a solution for #915
and clean up some TODOs
|
@shawnbot Oh, and I, uh, rebased and fixed the array.includes bug for you. Apologies for the force push. |
|
No worries, @evocateur! ✌️ |
|
We can ignore the appveyor failure, it's some weird permissions problem with the npm cache :P |
The Inevitable One Line Fix (after 8 hours of refactoring tests) Resolves #989 * fix ambiguous snapshot tests from #960 * add test/helpers/yargsRunner * Command: run() returns a Promise; better validation errors * DiffCommand: migrate tests to yargsRunner * PublishCommand: migrate tests to yargsRunner * Add test to confirm --cd-version choices
|
Question: The initial description for this pull request says that this fixes #567, but I don't see anything in the changed files that addresses that issue. When you first publish a prerelease version (prerelease, premajor, preminor, prepatch) and later publish a regular version (major, minor, or patch), does this change force packages with the prerelease version to update to the non-prerelease version even if those packages haven't changed? In other words, say I do the following:
Will both pkgA and pkgB be on 1.0.0, or will pkgA still be on 1.0.0-rc.1? |
|
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This updates the
lerna publishcommand to accept any semver-compatible release type for--cd-versionand allows you to use--canaryand--cd-versiontogether. It fixes #915 and #567 (and #936), and conflicts with #958 😬 .Description
Here are the changes to the publish command:
Any semver-compatible release type is for the value of
--cd-version, rather than whitelisting "major", "minor", and "patch". The value coercion only fails ifsemver.inc("1.0.0", choice)throws an error.The
--preidoption can be used to specify the semver prerelease identifier (major.minor.patch-prerelease), e.g. with:The
--canaryoption now works with--cd-versionto change how everything up to the prerelease identifier is changed, so you can do this:Motivation and Context
I filed #915 while trying to tweak the way that our canary release were being automatically published by our Primer CI builds. Specifically, I wanted the prerelease identifier to be
commitrather thanalpha, and I wanted the releases to be incremented as patches rather than major versions, so that changes to9.0.0would publish canary builds for9.0.1-commit.{sha}rather than9.1.0-alpha.{sha}.We set up release candidate automation for Primer release branches, which have updated
package.jsonversions in git but need to have incremented prerelease identifiers, so we would go from9.0.1to9.0.1-rc.0. This change allows you to do that with:How Has This Been Tested?
I've added publish command tests for the following cases:
--cd-version=prerelease --preid=foo--cd-version=prerelease(without a prerelease identifier, which semver handles transparently)--canary --cd-version=patchTypes of changes
Checklist: