Skip to content

Add support for hidden '--exact' flag - #426

Merged
gigabo merged 2 commits into
lerna:masterfrom
L8D:master
Jan 19, 2017
Merged

gigabo merged 2 commits into
lerna:masterfrom
L8D:master

Conversation

@L8D

@L8D L8D commented Dec 5, 2016 •

Copy link
Copy Markdown
Contributor

This allows for users to opt to use exact versions of cross-dependencies when publishing.

@jamiebuilds

Copy link
Copy Markdown
Contributor

Want to add a test?

@L8D

L8D commented Dec 7, 2016

Copy link
Copy Markdown
Contributor Author

Yeah...

@L8D

L8D commented Dec 7, 2016 •

Copy link
Copy Markdown
Contributor Author

@thejameskyle added a case that tests that it only applies to revised release versions and not diverged ones.


if (deps[depName] && version) {
deps[depName] = "^" + version;
deps[depName] = this.flags.exact ? version : "^" + version;

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.

It's not obvious to me just looking at this that it works.

I mean, I know it does (thanks to your tests), but I'm not confident about operator precedence between ?: and +. This would be a clearer for me with a set of parentheses.

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 think you might have read it wrong. It's just a ternary operator

const a = someFlag ? 1 : 2;

Sets a to 1 if someFlag is true and 2 if it's 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.

I think to understand properly you need to know arity of operators, so it can become confusing for some people. You can read it both as

(this.flags.exact ? version : "^") + version;

and

this.flags.exact ? version : ("^" + version);

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.

Oh facepalm

@gigabo

gigabo commented Dec 12, 2016

Copy link
Copy Markdown
Contributor

@L8D Why is this a hidden option?

Or, asked another way, what makes this option useful? Could you write that down as documentation so other users could more easily benefit from it?

@Gongreg

Gongreg commented Dec 13, 2016

Copy link
Copy Markdown
Contributor

Does it solve this issue #359 ?

@gigabo

gigabo commented Dec 13, 2016

Copy link
Copy Markdown
Contributor

@Gongreg Yeah it looks like it does. Thanks for making that connection!

@nkbt

nkbt commented Dec 21, 2016

Copy link
Copy Markdown

We'd love to have this one in too, since we never use ^ versions anywhere and always save exact versions.

If Lerna supports save-exact = true from .npmrc (per package) that would be even nicer then extra flag.

@jkimbo

jkimbo commented Jan 6, 2017 •

Copy link
Copy Markdown

Just to add, this should be the default when using the --canary flag since otherwise cross dependencies get set to something like ^2.3.1-alpha.123456 which doesn't necessarily resolve to that specific version.

If the canary flag check was added I think this would solve the underlying issue with #277

L8D added 2 commits January 13, 2017 17:08
This allows for users to opt to use exact versions of cross-dependencies
when publishing.
@lewisdawson

Copy link
Copy Markdown

@gigabo @thejameskyle Any idea on when this may be merged into master? This feature definitely is useful when trying to manage multi-dependency builds across different environments.

@hzoo

hzoo commented Jan 16, 2017

Copy link
Copy Markdown
Contributor

If Lerna supports save-exact = true from .npmrc (per package) that would be even nicer then extra flag.

I guess this could be a diff feature request.

Are we still making this hidden? if it solves #359 we such document in the readme?

@L8D

L8D commented Jan 16, 2017

Copy link
Copy Markdown
Contributor Author

@hzoo I originally made it "hidden" because I wasn't gonna spend time writing documentation for it in this PR. If someone is up for documenting it that'd be great but I'm using this patched version of lerna for my production builds so I figure'd I drop a PR for it so I don't have to maintain my patched version.

@dortzur

dortzur commented Jan 19, 2017

Copy link
Copy Markdown

Please god merge this. We're having issues publishing a fix from master branch when dev is ahead.

@gigabo gigabo mentioned this pull request Jan 19, 2017
@gigabo

gigabo commented Jan 19, 2017

Copy link
Copy Markdown
Contributor

I wasn't gonna spend time writing documentation

sigh

Okay, thanks @L8D. Added #510 for documentation.

@gigabo

gigabo commented Jan 19, 2017

Copy link
Copy Markdown
Contributor

Also added #511 for durable configuration in lerna.json.

@gigabo
gigabo merged commit b6e2f00 into lerna:master Jan 19, 2017
@dortzur

dortzur commented Jan 19, 2017

Copy link
Copy Markdown

@gigabo thanks!!!

@lewisdawson

Copy link
Copy Markdown

@gigabo Thanks for merging this in!

@Brantron

Brantron commented Mar 22, 2018 •

Copy link
Copy Markdown

This works with dependencies between Lerna packages? package A which relies on package B and a breaking change is introduced in package B, this allows us to lock A to a previously published version of B?

@evocateur

Copy link
Copy Markdown
Member

@Brantron This just affects the save-prefix of the dependency (which is "^" by default, yielding ^1.2.3; --exact makes it "", yielding 1.2.3)

@lock

lock Bot commented Dec 27, 2018

Copy link
Copy Markdown

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.

@lock lock Bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.