-
-
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
Changes from 3 commits
f33afd4
33c5b86
9f64cb5
aada617
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,86 @@ exports.getLoaderConfig = function() { | |
return cfg; | ||
}; | ||
|
||
function updateNodelibTarget(target, range) { | ||
target.setRegistry('npm'); | ||
target.setVersion(range ? '^0.2.0' : '0.2.0'); | ||
target.setPackage(target.package.replace('jspm/nodelibs-', 'jspm-nodelibs-')); | ||
return target; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than this manual modification, we can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
} | ||
|
||
function processNodelibs(loader, pjson, upgrade) { | ||
var installRequired = false; | ||
Object.keys(loader.baseMap).forEach(function (key) { | ||
var target = loader.baseMap[key]; | ||
|
||
if (target.name.substr(0, 21) == 'github:jspm/nodelibs-') { | ||
target = updateNodelibTarget(target, false); | ||
installRequired = true; | ||
} | ||
}); | ||
|
||
Object.keys(loader.depMap).forEach(function (key) { | ||
var curMap = loader.depMap[key]; | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be |
||
if (target.name.substr(0, 21) == 'github:jspm/nodelibs-') { | ||
installRequired = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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:
In the adjusted code above So there are two problems here:
Let me know if that makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright. I wasn't aware of this distinction. |
||
target = updateNodelibTarget(target, false); | ||
} | ||
} else { | ||
if (target.name.substr(0, 21) == 'github:jspm/nodelibs-') { | ||
installRequired = true; | ||
if (key == target.name.substr(21)) | ||
delete curMap[key]; | ||
else | ||
target = updateNodelibTarget(target, false); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
Object.keys(pjson.dependencies).forEach(function (key) { | ||
var target = pjson.dependencies[key]; | ||
|
||
if (target.name.substr(0, 21) == 'github:jspm/nodelibs-') { | ||
target = updateNodelibTarget(target, true); | ||
installRequired = true; | ||
|
||
pjson.peerDependencies[key] = target; | ||
delete pjson.dependencies[key]; | ||
} | ||
}); | ||
|
||
Object.keys(pjson.devDependencies).forEach(function (key) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
var target = pjson.devDependencies[key]; | ||
|
||
if (target.name.substr(0, 21) == 'github:jspm/nodelibs-') { | ||
target = updateNodelibTarget(target, true); | ||
installRequired = true; | ||
|
||
pjson.peerDependencies[key] = target; | ||
delete pjson.devDependencies[key]; | ||
} | ||
}); | ||
|
||
Object.keys(pjson.peerDependencies).forEach(function (key) { | ||
var target = pjson.peerDependencies[key]; | ||
|
||
if (target.name.substr(0, 21) == 'github:jspm/nodelibs-') { | ||
target = updateNodelibTarget(target, true); | ||
installRequired = true; | ||
|
||
pjson.peerDependencies[key] = target; | ||
delete pjson.peerDependencies[key]; | ||
} | ||
}); | ||
|
||
return installRequired; | ||
} | ||
|
||
var loadPromise; | ||
exports.loaded = false; | ||
exports.allowNoConfig = false; | ||
|
@@ -176,49 +256,7 @@ exports.load = function(prompts, allowNoConfig) { | |
|
||
ui.log('info', 'Upgrading jspm 0.16 Node core libraries to jspm 0.17 universal implementations...\n'); | ||
|
||
Object.keys(config.loader.baseMap).forEach(function(key) { | ||
var target = config.loader.baseMap[key]; | ||
|
||
if (target.name.substr(0, 21) == 'github:jspm/nodelibs-') | ||
target.setVersion('0.2.0-alpha'); | ||
}); | ||
|
||
Object.keys(config.loader.depMap).forEach(function(key) { | ||
var curMap = config.loader.depMap[key]; | ||
|
||
Object.keys(curMap).forEach(function(key) { | ||
var target = curMap[key]; | ||
|
||
if (target.name.substr(0, 21) == 'github:jspm/nodelibs-') { | ||
if (key == target.name.substr(21)) | ||
delete curMap[key]; | ||
else | ||
target.setVersion('0.2.0-alpha'); | ||
} | ||
}); | ||
}); | ||
|
||
Object.keys(config.pjson.dependencies).forEach(function(key) { | ||
var target = config.pjson.dependencies[key]; | ||
|
||
if (target.name.substr(0, 21) == 'github:jspm/nodelibs-') { | ||
target.setVersion('^0.2.0-alpha'); | ||
|
||
config.pjson.peerDependencies[key] = target; | ||
delete config.pjson.dependencies[key]; | ||
} | ||
}); | ||
|
||
Object.keys(config.pjson.devDependencies).forEach(function(key) { | ||
var target = config.pjson.devDependencies[key]; | ||
|
||
if (target.name.substr(0, 21) == 'github:jspm/nodelibs-') { | ||
target.setVersion('^0.2.0-alpha'); | ||
|
||
config.pjson.peerDependencies[key] = target; | ||
delete config.pjson.devDependencies[key]; | ||
} | ||
}); | ||
processNodelibs(config.loader, config.pjson, true); | ||
|
||
ui.log('info', 'Checking all overrides into the package.json file to ensure reproducibility independent of the jspm registry...\n'); | ||
|
||
|
@@ -311,6 +349,16 @@ exports.load = function(prompts, allowNoConfig) { | |
}); | ||
}); | ||
})) | ||
.then(function(initInstalls) { | ||
var installRequired = processNodelibs(config.loader, config.pjson, false); | ||
if (installRequired) { | ||
return require('../install').install(true).then(function () { | ||
return initInstalls; | ||
}); | ||
} else { | ||
return initInstalls; | ||
} | ||
}) | ||
.then(function(initInstalls) { | ||
config.loaded = 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.
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
?