-
-
Notifications
You must be signed in to change notification settings - Fork 272
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(config): add upgrade code for nodelibs-* deps #2120
Conversation
@guybedford I tried it locally but it did only change some of my |
30a430f
to
4ccab73
Compare
Current coverage is 34.59% (diff: 3.77%)@@ 0.17 #2120 diff @@
==========================================
Files 16 16
Lines 3891 3934 +43
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 1356 1361 +5
- Misses 2535 2573 +38
Partials 0 0
|
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.
Looks good - I'd be interested to hear if including peerDependencies gets the full upgrade path.
} | ||
}); | ||
|
||
Object.keys(pjson.devDependencies).forEach(function (key) { |
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 probably needs peerDependencies as well?
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.
(it wasn't necessary before because peerDependencies was only added in 0.17)
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.
Done.
target.exactName = target.exactName.replace('github:jspm/nodelibs-', 'npm:jspm-nodelibs-'); | ||
target.exactNameEncoded = target.exactNameEncoded.replace('github:jspm/nodelibs-', 'npm:jspm-nodelibs-'); | ||
target.setVersion('0.2.0'); | ||
return target; |
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.
Rather than this manual modification, we can use target.setVersion
, target.setRegistry
and target.setPackage
.
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.
Done.
if (key == target.name.substr(21)) | ||
delete curMap[key]; | ||
else | ||
installRequired = true; |
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 should probably just be at the top of the entire block?
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.
I am not exactly sure what you mean here.
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 original version of this code was designed to have two separate branches:
- If the submap name matches the node core lib name (
fs: github:jspm-nodelibs-fs@...
) then it deletes the key entirely. This is for the beta upgrade path so we turn Node core dependencies from normal dependencies into peer dependencies. - If the submap name doesn't match (the else above in the original code) then update the target version (
custom-fs-name: github:nodelibs-fs@...
). That's a very rare case for jspm-only workflows but what this was designed for in the original code to handle this upgrade comprehensively.
In the adjusted code above installRequired
is now set on the else path only, and target
is always updated on all paths due to the lack of curly braces on the conditional.
So there are two problems here:
- The code above is malformed, at least from a tabbing perspective.
- We probably do need another flag to indicate the difference between the beta upgrade path and the nodelibs upgrade path. In the first case we want the original behaviour to be maintained. In the second case we just need to do replacement (the target update line below), and probably don't even need the conditional above.
Let me know if that makes sense.
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.
Alright. I wasn't aware of this distinction.
How do you propose to detect the difference between the beta upgrade path and the nodelibs upgrade path? I am not familiar enough with the code base to come up with something reasonable.
@@ -74,6 +74,71 @@ exports.getLoaderConfig = function() { | |||
return cfg; | |||
}; | |||
|
|||
function updateNodelibTarget(target) { |
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.
There should probably be a second argument here - range
as boolean. We can then use setVersion('^0.2.0)
for the package.json dependencies to ensure we get semver upgrade paths. While the depMap set will be range: 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.
Done.
All github:jspm/nodelibs-* dependencies are being replaced with npm:jspm-nodelibs-* dependencies.
4ccab73
to
33c5b86
Compare
Thanks for the updates here. Were you able to test out the upgrade path again? |
Not yet. But will try to test it later today! |
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.
That sort of structure should handle it I think.
@@ -74,6 +74,79 @@ exports.getLoaderConfig = function() { | |||
return cfg; | |||
}; | |||
|
|||
function updateNodelibTarget(target, range) { |
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.
function (target, range, upgrade)
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.
I guess you meant
function processNodelibs(loader, pjson, upgrade)
?
delete config.pjson.devDependencies[key]; | ||
} | ||
}); | ||
processNodelibs(config.loader, config.pjson); |
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.
processNodelibs(config.loader, config.pjson, true)
@@ -312,6 +343,16 @@ exports.load = function(prompts, allowNoConfig) { | |||
}); | |||
})) | |||
.then(function(initInstalls) { | |||
var installRequired = processNodelibs(config.loader, config.pjson); |
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.
processNodelibs(config.loader, config.pjson, false)
Object.keys(curMap).forEach(function (key) { | ||
var target = curMap[key]; | ||
|
||
if (upgrade) { |
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.
I think this should be if (!upgrade)
.
Yeah that's it, just check the one comment there. |
I just tested the changes but it does not seem to work yet. |
Ok, I can look at this, but it will just take me a while to find the time. |
👍 Merged manually, and made some minor corrections in ffadde5. The main issue I think was also bumping the npm registry cache version to ensure we don't use previously cached dependency values (jspm/npm@7e03fea). |
Great! 👍 |
Another issue here was we missed the transitive deps - jspm/nodelibs-path@366c5b0. I think that's all the cases now. |
All github:jspm/nodelibs-* dependencies are being
replaced with npm:jspm-nodelibs-* dependencies.
Resolves #1071 (comment)