Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

frederikschubert
Copy link
Contributor

All github:jspm/nodelibs-* dependencies are being
replaced with npm:jspm-nodelibs-* dependencies.

Resolves #1071 (comment)

@frederikschubert
Copy link
Contributor Author

@guybedford I tried it locally but it did only change some of my nodelibs-* dependencies to the npm packages.

@codecov-io
Copy link

codecov-io commented Oct 11, 2016

Current coverage is 34.59% (diff: 3.77%)

Merging #2120 into 0.17 will decrease coverage by 0.25%

@@               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          

Powered by Codecov. Last update 78da833...aada617

Copy link
Member

@guybedford guybedford left a 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) {
Copy link
Member

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?

Copy link
Member

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)

Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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;
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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:

  1. The code above is malformed, at least from a tabbing perspective.
  2. 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.

Copy link
Contributor Author

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) {
Copy link
Member

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.

Copy link
Contributor Author

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.
@guybedford
Copy link
Member

Thanks for the updates here. Were you able to test out the upgrade path again?

@frederikschubert
Copy link
Contributor Author

Not yet. But will try to test it later today!

Copy link
Member

@guybedford guybedford left a 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function (target, range, upgrade)

Copy link
Contributor Author

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);
Copy link
Member

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);
Copy link
Member

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) {
Copy link
Member

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).

@guybedford
Copy link
Member

Yeah that's it, just check the one comment there.

@frederikschubert
Copy link
Contributor Author

I just tested the changes but it does not seem to work yet.

@guybedford
Copy link
Member

Ok, I can look at this, but it will just take me a while to find the time.

@guybedford
Copy link
Member

👍

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).

@guybedford guybedford closed this Oct 25, 2016
@frederikschubert
Copy link
Contributor Author

Great! 👍

@guybedford
Copy link
Member

Another issue here was we missed the transitive deps - jspm/nodelibs-path@366c5b0. I think that's all the cases now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants