-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: match npm semantics exactly for installs and updates #296
Conversation
1863e31
to
0a59554
Compare
3321d26
to
f5347e8
Compare
2c8b25e
to
4830298
Compare
4830298
to
02924eb
Compare
So I've replaced all of the free/latest/mode options and replaced them with a single mode parameter that controls existing locks:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work, I'd really like to land this soon, but would value some feedback on the review first when you can.
@@ -345,7 +345,7 @@ export default class TraceMap { | |||
dynamics.map(async ([specifier, parent]) => { | |||
await this.visit( | |||
specifier, | |||
{ visitor, installOpts: { mode: "existing" }, toplevel: false }, | |||
{ visitor, installMode: "freeze", toplevel: false }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This internal unification is really nice to see!!
async install( | ||
install?: string | Install | (string | Install)[] | ||
): Promise<void | { staticDeps: string[]; dynamicDeps: string[] }> { | ||
if (arguments.length > 1) | ||
throw new JspmError( | ||
"Install takes no arguments, a single install target, or a list of install targets." | ||
); | ||
return this._install(install); | ||
} | ||
|
||
private async _install( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I fully understand the reason for this private _install
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on whether install is given an argument or not, two different modes are used:
- No argument - all top-level locks installed in
default
mode, i.e. keep all in-range locks. - Arguments - all arguments installed in
latest-primaries
mode, i.e. bump those arguments to latest but keep in-range secondaries.
This just lets us handle those cases without exposing the mode
argument in the public API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I missed that we were keeping mode
part of the private API. Should we perhaps just expose it though with defaults? Is there a risk in doing that?
|
||
// If there are no arguments, then we reinstall all the top-level locks: | ||
if (!install) { | ||
if (install === null || install === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was previously handled via generator.reinstall
. I believe this change means that reinstall
is now deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reinstall()
method is equivalent to freeze
installing all the top-level locks (or equivalently doing an argumentless link
, since link
uses freeze by default). So I think it can be deprecated now in favour of either of those, yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's do that then, either with this PR or via a follow-up after it lands.
Currently some tests are failing due to the new behaviour, I'm still working
my way through them. There's a script you can run at
test/npm-compatibility/
that will test the behaviour of npm for updates/installs in a bunch of different
scenarios, and tests that make sure the behaviour of the generator is aligned.
npm install <pkg>
bumps the version of<pkg>
to latest, and only bumpstransitive dependencies if they're out of range.
npm update <pkg>
has exactly the same behaviour as 1 in all tested cases.npm install
bumps the versions of anything that is out of range, but keepsversions of in-range primaries and secondaries.
npm update
bumps the versions of everthing to latest.The changes to
latest
that I've made:latest
andfreeze
generator options have both been deprecated infavour of a
ResolutionOptions
object that you can optionally pass intoinstall
/link
/update
.ResolutionsOptions
containsmode
,latestPrimaries
,latestSecondaries
and
freeze
fields. I had to split into the two cases for latest to makesure that
npm install <pkg>
doesn't bump secondaries, but does bumpprimaries.
latest
/freeze
resolution options are set, the defaultis to take existing locks whenever they are in range.