You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2015/03/06 01:26:42 UTC
[06/27] cordova-lib git commit: plugins get fetched from npm,
then cordova registry if needed
plugins get fetched from npm, then cordova registry if 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/f9198205
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/f9198205
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/f9198205
Branch: refs/heads/master
Commit: f91982059fa412746b6b266d6312ee27e5b34bd8
Parents: 7db3df1
Author: Steve Gill <st...@gmail.com>
Authored: Fri Jan 23 17:19:43 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Mon Jan 26 16:59:29 2015 -0800
----------------------------------------------------------------------
cordova-lib/package.json | 9 +--
cordova-lib/src/plugman/registry/registry.js | 78 +++++++++++++++--------
2 files changed, 58 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/f9198205/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index 300da39..b44cf19 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -18,6 +18,9 @@
"engineStrict": true,
"dependencies": {
"bplist-parser": "0.0.6",
+ "cordova-js": "3.7.3",
+ "cordova-registry-mapper": "0.0.2",
+ "d8": "0.4.4",
"dep-graph": "1.1.0",
"elementtree": "0.1.5",
"glob": "4.0.6",
@@ -33,13 +36,11 @@
"semver": "2.0.11",
"shelljs": "0.3.0",
"tar": "1.0.2",
+ "through2": "0.6.3",
"underscore": "1.7.0",
- "xcode": "0.6.7",
- "cordova-js": "3.7.3",
- "d8": "0.4.4",
"unorm": "1.3.3",
"valid-identifier": "0.0.1",
- "through2": "0.6.3"
+ "xcode": "0.6.7"
},
"devDependencies": {
"istanbul": "^0.3.4",
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/f9198205/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 d6e86d0..f72c109 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -27,6 +27,7 @@ var npm = require('npm'),
rc = require('rc'),
Q = require('q'),
request = require('request'),
+ pluginMapper = require('cordova-registry-mapper');
home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE,
events = require('../../events'),
unpack = require('../../util/unpack'),
@@ -324,7 +325,6 @@ function makeRequest (method, where, what, cb_) {
* @return {Promise.<string>} Promised path to fetched package.
*/
function fetchNPM(plugin, client) {
- events.emit('log', 'Fetching plugin "' + plugin + '" via npm');
return initSettingsNPM()
.then(function (settings) {
return Q.nfcall(npm.load)
@@ -335,7 +335,35 @@ function fetchNPM(plugin, client) {
}
});
})
+ .then(function(){
+ //if plugin variable is in reverse domain name style, look up the package-name in cordova-registry-mapper module
+
+ //Create regex to for digits, words and dashes and three dots in plugin ids which excludes @VERSION.
+ var re = /([\w-]*\.[\w-]*\.[\w-]*\.[\w-]*[^@])/;
+ var pluginID = plugin.match(re);
+ //If true, pluginID is reverse domain style
+ if(pluginID != null) {
+ //grab the @VERSION from the end of the plugin string if it exists
+ re = /(@.*)/;
+ var versionStr = plugin.match(re);
+
+ //Check if a mapping exists for the pluginID
+ //if it does, set the plugin variable to your packageName
+ //if it doesn't, don't change the plugin variable
+ var packageName = pluginMapper[pluginID[0]];
+ if(packageName) {
+ //if @VERSION exists, concat it to packageName
+ if(versionStr != null) {
+ packageName += versionStr[0];
+ }
+ events.emit('verbose', 'Converted ' + plugin + ' to ' + packageName + ' for npm fetch');
+ plugin = packageName;
+ }
+ }
+ return true;
+ })
.then(function() {
+ events.emit('log', 'Fetching plugin "' + plugin + '" via npm');
return Q.ninvoke(npm.commands, 'cache', ['add', plugin]);
})
.then(function(info) {
@@ -355,30 +383,30 @@ function fetchNPM(plugin, client) {
* @return {Promise.<string>} Promised path to fetched package.
*/
function fetchPlugReg(plugin, client) {
- events.emit('log', 'Fetching plugin "' + plugin + '" via plugin registry');
- return initSettings()
- .then(function (settings) {
- return Q.nfcall(npm.load)
- // configure npm here instead of passing parameters to npm.load due to CB-7670
- .then(function () {
- for (var prop in settings){
- npm.config.set(prop, settings[prop]);
- }
- });
- })
- .then(function() {
- return Q.ninvoke(npm.commands, 'cache', ['add', plugin]);
- })
- .then(function(info) {
- var cl = (client === 'plugman' ? 'plugman' : 'cordova-cli');
- bumpCounter(info, cl);
- var pluginDir = path.resolve(npm.cache, info.name, info.version, 'package');
- // Unpack the plugin that was added to the cache (CB-8154)
- var package_tgz = path.resolve(npm.cache, info.name, info.version, 'package.tgz');
- return unpack.unpackTgz(package_tgz, pluginDir);
- })
- .fail(function() {
- events.emit('log', 'Fetching from plugin registry failed');
+ return initSettings()
+ .then(function (settings) {
+ return Q.nfcall(npm.load)
+ // configure npm here instead of passing parameters to npm.load due to CB-7670
+ .then(function () {
+ for (var prop in settings){
+ npm.config.set(prop, settings[prop]);
+ }
});
+ })
+ .then(function() {
+ events.emit('log', 'Fetching plugin "' + plugin + '" via plugin registry');
+ return Q.ninvoke(npm.commands, 'cache', ['add', plugin]);
+ })
+ .then(function(info) {
+ var cl = (client === 'plugman' ? 'plugman' : 'cordova-cli');
+ bumpCounter(info, cl);
+ var pluginDir = path.resolve(npm.cache, info.name, info.version, 'package');
+ // Unpack the plugin that was added to the cache (CB-8154)
+ var package_tgz = path.resolve(npm.cache, info.name, info.version, 'package.tgz');
+ return unpack.unpackTgz(package_tgz, pluginDir);
+ })
+ .fail(function() {
+ events.emit('log', 'Fetching from plugin registry failed');
+ });
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org