You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ka...@apache.org on 2014/05/14 23:36:32 UTC
[3/3] git commit: Remove --force from default npm settings for plugin
registry
Remove --force from default npm settings for plugin registry
Changed to setting --force specifically for (un)publish where it's needed
and removed it from the default settings.
For publish --force is needed when overwriting an already published version.
Otherwise the registry will reply with a 409 HTTP response.
For unpublishing the registry only allows to unpublish specific versions,
if you want to remove the entire thing with all the published version
--force is needed.
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/2f3493e2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/2f3493e2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/2f3493e2
Branch: refs/heads/master
Commit: 2f3493e210fa19a3a3b3c3d1476962381648fa5c
Parents: 7195393
Author: Mark Koudritsky <ka...@gmail.com>
Authored: Wed May 14 16:36:26 2014 -0400
Committer: Mark Koudritsky <ka...@gmail.com>
Committed: Wed May 14 17:34:40 2014 -0400
----------------------------------------------------------------------
cordova-lib/spec-plugman/registry/registry.spec.js | 1 +
cordova-lib/src/plugman/registry/registry.js | 16 +++++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/2f3493e2/cordova-lib/spec-plugman/registry/registry.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/registry/registry.spec.js b/cordova-lib/spec-plugman/registry/registry.spec.js
index 95c4f86..c48e839 100644
--- a/cordova-lib/spec-plugman/registry/registry.spec.js
+++ b/cordova-lib/spec-plugman/registry/registry.spec.js
@@ -90,6 +90,7 @@ describe('registry', function() {
});
npm.commands = fakeNPMCommands;
+ npm.config.set = function(){};
});
it('should run config', function() {
var params = ['set', 'registry', 'http://registry.cordova.io'];
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/2f3493e2/cordova-lib/src/plugman/registry/registry.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/registry/registry.js b/cordova-lib/src/plugman/registry/registry.js
index 108a8f6..e7c00c9 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -70,6 +70,9 @@ module.exports = {
.then(function() {
return Q.ninvoke(npm, 'load', settings);
}).then(function() {
+ // With no --force we'll get a 409 (conflict) when trying to
+ // overwrite an existing package@version.
+ npm.config.set('force', true);
return Q.ninvoke(npm.commands, 'publish', args)
}).fin(function() {
fs.unlink(path.resolve(args[0], 'package.json'));
@@ -101,8 +104,16 @@ module.exports = {
.then(function(settings) {
return Q.ninvoke(npm, 'load', settings);
}).then(function() {
+ // --force is required to delete an entire plugin with all versions.
+ // Without --force npm can only unpublish a specific version.
+ npm.config.set('force', true);
+ // Note, npm.unpublish does not report back errors (at least some)
+ // e.g.: `unpublish non.existent.plugin`
+ // will complete with no errors.
return Q.ninvoke(npm.commands, 'unpublish', args);
}).then(function() {
+ // npm.unpublish removes the cache for the unpublished package
+ // cleaning the entire cache might not be necessary.
return Q.ninvoke(npm.commands, 'cache', ["clean"]);
});
},
@@ -117,8 +128,6 @@ module.exports = {
return initSettings()
.then(Q.nbind(npm.load, npm))
.then(function() {
- // With no --force, npm won't re-download if appropriate version is already cached.
- npm.config.set('force', false);
return Q.ninvoke(npm.commands, 'cache', ['add', plugin]);
})
.then(function(info) {
@@ -139,8 +148,6 @@ module.exports = {
return initSettings()
.then(Q.nbind(npm.load, npm))
.then(function() {
- // --force is not needed
- npm.config.set('force', false);
// Set cache timout limits to 0 to force npm to call the registry
// even when it has a recent .cache.json file.
npm.config.set('cache-min', 0);
@@ -177,7 +184,6 @@ function initSettings() {
module.exports.settings =
rc('plugman', {
cache: plugmanCacheDir,
- force: true,
registry: 'http://registry.cordova.io',
logstream: fs.createWriteStream(path.resolve(plugmanConfigDir, 'plugman.log')),
userconfig: path.resolve(plugmanConfigDir, 'config')