Repository navigation
Description
The publish --canary docs suggest that the optional value is a version "meta suffix" (what I usually refer to as a "prerelease identifier"):
When run with this flag,
publishpublishes packages in a more granular way (per commit). Before publishing to npm, it creates the newversiontag by taking the currentversion, bumping it to the next minor version, adding the provided meta suffix (defaults toalpha) and appending the current git sha (ex:1.0.0becomes1.1.0-alpha.81e3b443).
But when I tried to publish a canary release with:
lerna --loglevel=debug publish --canary=commit --cd-version=patchI got an error:
lerna sill input [ 'publish' ]
lerna sill flags { _: [ 'publish' ],
lerna sill flags loglevel: 'debug',
lerna sill flags canary: 'commit',
lerna sill flags c: 'commit',
lerna sill flags 'cd-version': 'patch',
lerna sill flags cdVersion: 'patch' }
lerna verb rootPath /Users/shawnbot/primer/primer-css
lerna info version 2.0.0
lerna info versioning independent
lerna sill isInitialized
lerna sill isInitialized true
lerna sill existsSync /Users/shawnbot/primer/primer-css/VERSION
lerna sill initialize attempt
lerna info canary enabled
lerna sill getUpdates
lerna info Checking for updated packages...
lerna sill hasTags
lerna verb hasTags true
lerna info Comparing with commit^..commit.
lerna sill diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-alerts
lerna ERR! initialize Error: fatal: bad revision 'commit^..commit'
I dug into the code to see what was happening here, and the offending code appears to be in UpdatedPackagesCollector, specifically in collectedUpdatedPackages(). If canary is anything other than true (as in my case, it's "commit"), then it treats the value as the current SHA:
if (canary !== true) {
currentSHA = canary;
} else {
currentSHA = GitUtilities.getCurrentSHA(execOpts);
}
since = this.getAssociatedCommits(currentSHA);Now, this will "work" for my case if commit just happens to be a git ref, but not in the way that the docs suggest. So either the docs need to be clearer about what the value should be, or this is a bug.
Expected Behavior
I expected this to simply use the value of --canary for the semver.inc() call in PublishCommand.getCanaryVersion().
I also expected the --cd-version to be accounted for in the canary version increment rather than the hard-coded minor, so that if I run:
lerna publish --canary=commit --cd-version=patchThen it will bump the version as a patch, e.g. from 8.0.0 to 8.0.1-beta.{sha}. Instead, it seems that --cd-version takes precedence, and the version is updated to just 8.0.1 without the prerelease id/meta suffix.
Current Behavior
lerna publish --canary=valuetreats the value of--canaryas a git ref, not a prerelease identifier/meta suffix.lerna publish --canary --cd-version=patchdrops the prerelease identifier/meta suffix instead of bumping thepatchversion then adding the-alpha.{sha}suffix.
Possible Solution
I'm not 100% sure, but it seems like you should be able to remove the currentSHA = canary statement, since the current SHA shouldn't change depending on the value of --canary.
Steps to Reproduce (for bugs)
git clone https://github.com/primer/primer-css
cd primer-css
lerna bootstrap
lerna publish --canary=commit --cd-version=patchlerna.json
{
"lerna": "2.0.0-rc.5",
"packages": [
"modules/*"
],
"version": "independent"
}lerna-debug.log
0 silly input [ 'publish' ]
1 silly flags { _: [ 'publish' ],
1 silly flags loglevel: 'debug',
1 silly flags canary: 'commit',
1 silly flags c: 'commit',
1 silly flags 'cd-version': 'patch',
1 silly flags cdVersion: 'patch' }
2 verbose rootPath /Users/shawnbot/primer/primer-css
3 info version 2.0.0
4 info versioning independent
5 silly isInitialized
6 silly isInitialized true
7 silly existsSync /Users/shawnbot/primer/primer-css/VERSION
8 silly initialize attempt
9 info canary enabled
10 silly getUpdates
11 info Checking for updated packages...
12 silly hasTags
13 verbose hasTags true
14 info Comparing with commit^..commit.
15 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-alerts
16 silly diff
17 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-avatars
18 silly diff
19 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-base
20 silly diff
21 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-blankslate
22 silly diff
23 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-box
24 silly diff
25 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-breadcrumb
26 silly diff
27 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-buttons
28 silly diff
29 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-cards
30 silly diff
31 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-core
32 silly diff
33 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-css
34 silly diff
35 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-forms
36 silly diff
37 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-labels
38 silly diff
39 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-layout
40 silly diff
41 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-markdown
42 silly diff
43 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-marketing-support
44 silly diff
45 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-marketing-type
46 silly diff
47 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-marketing-utilities
48 silly diff
49 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-marketing
50 silly diff
51 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-navigation
52 silly diff
53 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-page-headers
54 silly diff
55 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-page-sections
56 silly diff
57 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-product
58 silly diff
59 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-support
60 silly diff
61 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-table-object
62 silly diff
63 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-tables
64 silly diff
65 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-tooltips
66 silly diff
67 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-truncate
68 silly diff
69 silly diffSinceIn commit^..commit /Users/shawnbot/primer/primer-css/modules/primer-utilities
70 silly diff
71 silly collectDependents
72 silly collectUpdates
73 verbose has filtered update primer-alerts
74 verbose has filtered update primer-avatars
75 verbose has filtered update primer-base
76 verbose has filtered update primer-blankslate
77 verbose has filtered update primer-box
78 verbose has filtered update primer-breadcrumb
79 verbose has filtered update primer-buttons
80 verbose has filtered update primer-cards
81 verbose has filtered update primer-core
82 verbose has filtered update primer-css
83 verbose has filtered update primer-forms
84 verbose has filtered update primer-labels
85 verbose has filtered update primer-layout
86 verbose has filtered update primer-markdown
87 verbose has filtered update primer-marketing-support
88 verbose has filtered update primer-marketing-type
89 verbose has filtered update primer-marketing-utilities
90 verbose has filtered update primer-marketing
91 verbose has filtered update primer-navigation
92 verbose has filtered update primer-page-headers
93 verbose has filtered update primer-page-sections
94 verbose has filtered update primer-product
95 verbose has filtered update primer-support
96 verbose has filtered update primer-table-object
97 verbose has filtered update primer-tables
98 verbose has filtered update primer-tooltips
99 verbose has filtered update primer-truncate
100 verbose has filtered update primer-utilities
101 verbose initialize exited earlyContext
We're trying to come up with an automated workflow that allows Primer contributors to easily test their changes to Primer on github.com (the app itself). Specifically, we're looking at what it would take to have Travis publish new, commit-specific versions of Primer for contributor PRs to npm under a designated dist-tag (e.g. canary), and with unique versions that they could then use both on local installs and staged builds of GitHub.
There are a couple of big problems with how Lerna works that complicate this setup:
- The
--canaryoption unnecessarily increments the minor version of every package. - We can't set the value of
--canary, which is fixed asalpha.
The third, less critical issue is that there's (seemingly) no way to only increment the versions of packages that have been updated. For instance, if a contributor updates a single package, Lerna will still publish a new patch version of every package. This could be because of how Lerna determines what the latest version is (within the scope of the provided --npm-tag?), and the second time you publish to the same dist-tag it'll figure out that it doesn't need to bump the patch version a second time. At least, that's how I hope it would work.
Your Environment
I'm on a new MacBook Air, and we're using Travis for CI builds.
| Executable | Version |
|---|---|
lerna --version |
2.0.0 |
npm --version |
4.2.0 |
yarn --version |
n/a |
node --version |
7.10.1 |
| OS | Version |
|---|---|
| macOS Sierra | 10.12.5 |
Activity
Improve support for semver prerelease identifiers when publishing (#960)
lock commentedon Dec 28, 2018
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.