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/03 08:37:36 UTC
[01/12] cordova-lib git commit: plugins get fetched from npm,
then cordova registry if needed
Repository: cordova-lib
Updated Branches:
refs/heads/CB-8551 [created] 9370401b6
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/4cf298ca
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/4cf298ca
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/4cf298ca
Branch: refs/heads/CB-8551
Commit: 4cf298cab1af6b02ddb9ee96df597bfe5ef5b1d3
Parents: 049548a
Author: Steve Gill <st...@gmail.com>
Authored: Fri Jan 23 17:19:43 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Jan 23 17:20:15 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/4cf298ca/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index 70ded65..47543ae 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/4cf298ca/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 3643eb3..a9ce9ab 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -30,6 +30,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'),
@@ -327,7 +328,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)
@@ -338,7 +338,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) {
@@ -358,30 +386,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
[04/12] cordova-lib git commit: fixed minor errors so npm test runs
Posted by st...@apache.org.
fixed minor errors so npm test runs
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/6e24960f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/6e24960f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/6e24960f
Branch: refs/heads/CB-8551
Commit: 6e24960f06030c8f790f4bf03777a154e8ea6c0b
Parents: f919820
Author: Steve Gill <st...@gmail.com>
Authored: Fri Jan 23 17:31:37 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Mon Jan 26 16:59:29 2015 -0800
----------------------------------------------------------------------
cordova-lib/src/plugman/registry/registry.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/6e24960f/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 f72c109..7f9ff71 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -27,7 +27,7 @@ var npm = require('npm'),
rc = require('rc'),
Q = require('q'),
request = require('request'),
- pluginMapper = require('cordova-registry-mapper');
+ pluginMapper = require('cordova-registry-mapper'),
home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE,
events = require('../../events'),
unpack = require('../../util/unpack'),
@@ -342,7 +342,7 @@ function fetchNPM(plugin, client) {
var re = /([\w-]*\.[\w-]*\.[\w-]*\.[\w-]*[^@])/;
var pluginID = plugin.match(re);
//If true, pluginID is reverse domain style
- if(pluginID != null) {
+ if(pluginID !== null) {
//grab the @VERSION from the end of the plugin string if it exists
re = /(@.*)/;
var versionStr = plugin.match(re);
@@ -353,7 +353,7 @@ function fetchNPM(plugin, client) {
var packageName = pluginMapper[pluginID[0]];
if(packageName) {
//if @VERSION exists, concat it to packageName
- if(versionStr != null) {
+ if(versionStr !== null) {
packageName += versionStr[0];
}
events.emit('verbose', 'Converted ' + plugin + ' to ' + packageName + ' for npm fetch');
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[07/12] cordova-lib git commit: Merge branch 'npmfetch' of
https://github.com/stevengill/cordova-lib into npmfetch
Posted by st...@apache.org.
Merge branch 'npmfetch' of https://github.com/stevengill/cordova-lib into npmfetch
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/fee6daaf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/fee6daaf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/fee6daaf
Branch: refs/heads/CB-8551
Commit: fee6daaf5a1a68c954fe28404784510176b269ff
Parents: 6e24960 ba4d2a6
Author: Steve Gill <st...@gmail.com>
Authored: Mon Jan 26 17:00:27 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Mon Jan 26 17:00:27 2015 -0800
----------------------------------------------------------------------
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[12/12] cordova-lib git commit: Revert "added ability to remove
plugin via package-name"
Posted by st...@apache.org.
Revert "added ability to remove plugin via package-name"
This reverts commit 38a0afbdaef58dd2bc9cff88c76b0e382d835592.
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/9370401b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/9370401b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/9370401b
Branch: refs/heads/CB-8551
Commit: 9370401b67f32ab2e0a5a2edb64b167a65ed94d3
Parents: 9b36f20
Author: Steve Gill <st...@gmail.com>
Authored: Mon Mar 2 23:37:10 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Mon Mar 2 23:37:10 2015 -0800
----------------------------------------------------------------------
cordova-lib/src/cordova/plugin.js | 12 ------------
1 file changed, 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/9370401b/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index 0a8855f..77175bd 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -28,7 +28,6 @@ var cordova_util = require('./util'),
shell = require('shelljs'),
PluginInfoProvider = require('../PluginInfoProvider'),
plugman = require('../plugman/plugman'),
- pluginMapper = require('cordova-registry-mapper'),
events = require('../events');
// Returns a promise.
@@ -237,17 +236,6 @@ module.exports = function plugin(command, targets, opts) {
return hooksRunner.fire('before_plugin_rm', opts)
.then(function() {
return opts.plugins.reduce(function(soFar, target) {
- // Convert target from package-name to package-id if necessary
- var keys = Object.keys(pluginMapper);
- //Traverse through pluginMapper values to see if it equals our target.
- //Cordova-plugin-device would get changes to org.apache.cordova.device
- for (var i = 0; i < keys.length; i++) {
- var val = pluginMapper[keys[i]];
- if(val === target) {
- target = keys[i];
- }
- }
-
// Check if we have the plugin.
if (plugins.indexOf(target) < 0) {
return Q.reject(new CordovaError('Plugin "' + target + '" is not present in the project. See `'+cordova_util.binname+' plugin list`.'));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[11/12] cordova-lib git commit: CB-8551 Skip CPR if pluginID isn't
reverse domain name style
Posted by st...@apache.org.
CB-8551 Skip CPR if pluginID isn't reverse domain name style
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/9b36f209
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/9b36f209
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/9b36f209
Branch: refs/heads/CB-8551
Commit: 9b36f209427b46e8d199f535565815bcb3cfe4b0
Parents: db4d274
Author: Steve Gill <st...@gmail.com>
Authored: Thu Feb 26 19:57:17 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Thu Feb 26 19:57:17 2015 -0800
----------------------------------------------------------------------
cordova-lib/src/plugman/registry/registry.js | 42 ++++++++++++++++++++---
1 file changed, 38 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/9b36f209/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 2943a77..75e234c 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -167,9 +167,11 @@ module.exports = {
*/
fetch: function(plugin, client) {
plugin = plugin.shift();
- return fetchPlugReg(plugin, client)
+ return checkPluginID(plugin)
+ .then(function() {
+ return fetchPlugReg(plugin, client);
+ })
.fail(function() {
- events.emit('log', 'Fetching from cordova plugin registry failed');
module.exports.settings = null;
return fetchNPM(plugin,client);
});
@@ -352,7 +354,6 @@ function fetchNPM(plugin, client) {
return unpack.unpackTgz(package_tgz, pluginDir);
})
.fail(function(error) {
- //console.log(error)
events.emit('log', 'Fetching from npm registry failed');
return Q.reject(error)
});
@@ -386,6 +387,39 @@ function fetchPlugReg(plugin, client) {
// 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(error) {
+ events.emit('log', 'Fetching from cordova plugin registry failed');
+ return Q.reject(error)
+ });;
}
+/**
+ * @method checkPluginID
+ * @param {Array} with one element - the plugin id or "id@version"
+ * @return {Promise.<string>} Promised path to fetched package.
+ */
+function checkPluginID(plugin) {
+ //if plugin id is not reverse domain name style, skip CPR and fetch from npm
+
+ //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 pluginID equals null, plugin is not reverse domain name style
+ if(pluginID === null) {
+ events.emit('verbose', 'Skipping CPR');
+ //Q.reject will send us straight to the fail method which is where fetchNPM gets called.
+ return Q.reject();
+ } else {
+ //Reverse domain name style plugin ID
+ //Check if a mapping exists for the pluginID
+ //if it does, warn the users to use package-name
+ var packageName = pluginMapper[pluginID[0]];
+ if(packageName) {
+ events.emit('log', 'WARNING: ' + plugin + ' has been renamed to '
+ + packageName + ' and moved to npm. Please use `cordova plugin add '
+ + packageName + '` next time.');
+ }
+ }
+ return Q();
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[03/12] cordova-lib git commit: fixed minor errors so npm test runs
Posted by st...@apache.org.
fixed minor errors so npm test runs
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/ba4d2a6d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/ba4d2a6d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/ba4d2a6d
Branch: refs/heads/CB-8551
Commit: ba4d2a6d954001e16a73a6091cfe429fabf3fc8a
Parents: 4cf298c
Author: Steve Gill <st...@gmail.com>
Authored: Fri Jan 23 17:31:37 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Jan 23 17:31:37 2015 -0800
----------------------------------------------------------------------
cordova-lib/src/plugman/registry/registry.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ba4d2a6d/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 a9ce9ab..5b2a2b3 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -30,7 +30,7 @@ var npm = require('npm'),
rc = require('rc'),
Q = require('q'),
request = require('request'),
- pluginMapper = require('cordova-registry-mapper');
+ pluginMapper = require('cordova-registry-mapper'),
home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE,
events = require('../../events'),
unpack = require('../../util/unpack'),
@@ -345,7 +345,7 @@ function fetchNPM(plugin, client) {
var re = /([\w-]*\.[\w-]*\.[\w-]*\.[\w-]*[^@])/;
var pluginID = plugin.match(re);
//If true, pluginID is reverse domain style
- if(pluginID != null) {
+ if(pluginID !== null) {
//grab the @VERSION from the end of the plugin string if it exists
re = /(@.*)/;
var versionStr = plugin.match(re);
@@ -356,7 +356,7 @@ function fetchNPM(plugin, client) {
var packageName = pluginMapper[pluginID[0]];
if(packageName) {
//if @VERSION exists, concat it to packageName
- if(versionStr != null) {
+ if(versionStr !== null) {
packageName += versionStr[0];
}
events.emit('verbose', 'Converted ' + plugin + ' to ' + packageName + ' for npm fetch');
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[09/12] cordova-lib git commit: fixed merge conflict
Posted by st...@apache.org.
fixed merge conflict
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/2f91b4fa
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/2f91b4fa
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/2f91b4fa
Branch: refs/heads/CB-8551
Commit: 2f91b4fa1635654c123147247a2eb04a460544ae
Parents: 38a0afb 608977d
Author: Steve Gill <st...@gmail.com>
Authored: Wed Feb 25 14:17:16 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Wed Feb 25 14:17:16 2015 -0800
----------------------------------------------------------------------
.gitignore | 2 +
cordova-lib/.jshintignore | 2 +
cordova-lib/package.json | 3 +-
cordova-lib/spec-cordova/HooksRunner.spec.js | 4 +-
cordova-lib/spec-cordova/prepare.spec.js | 1 +
cordova-lib/spec-cordova/restore.spec.js | 71 ---
cordova-lib/spec-cordova/save.spec.js | 67 ---
cordova-lib/spec-plugman/.jshintrc | 11 +
cordova-lib/spec-plugman/add_platform.spec.js | 16 +-
cordova-lib/spec-plugman/common.js | 2 +-
cordova-lib/spec-plugman/fetch.spec.js | 26 +-
.../spec-plugman/install-browserify.spec.js | 37 +-
cordova-lib/spec-plugman/install.spec.js | 32 +-
cordova-lib/spec-plugman/platform.spec.js | 8 +-
.../platforms/amazon-fireos.spec.js | 2 +
.../spec-plugman/platforms/android.spec.js | 237 ++++----
.../spec-plugman/platforms/blackberry10.spec.js | 10 +-
.../spec-plugman/platforms/common.spec.js | 21 +-
cordova-lib/spec-plugman/platforms/ios.spec.js | 80 ++-
.../spec-plugman/platforms/tizen.spec.js | 15 +-
.../spec-plugman/platforms/windows.spec.js | 419 ++++++++++++++
.../spec-plugman/platforms/windows8.spec.js | 140 -----
cordova-lib/spec-plugman/platforms/wp8.spec.js | 10 +-
.../org.test.plugins.dummyplugin/extra.gradle | 1 +
.../plugin-lib/AndroidManifest.xml | 5 +
.../plugin-lib/libFile | 1 +
.../plugin-lib/project.properties | 1 +
.../org.test.plugins.dummyplugin/plugin.xml | 25 +-
.../src/windows/dummer.js | 1 +
.../src/windows/dummy1.dll | 0
.../src/windows/dummy1.vcxproj | 7 +
.../src/windows/dummy2.dll | 0
.../src/windows/dummy2.vcxproj | 7 +
.../src/windows/dummy3.dll | 0
.../src/windows/dummy3.vcxproj | 7 +
.../src/windows/dummy4.dll | 0
.../src/windows/dummy4.vcxproj | 7 +
.../src/windows8/dummer.js | 1 -
.../org.test.plugins.faultyplugin/plugin.xml | 14 +-
.../src/windows/faultyPlugin.js | 1 +
.../src/windows8/faultyPlugin.js | 1 -
cordova-lib/spec-plugman/prepare.spec.js | 9 +-
.../projects/android_install/local.properties | 1 +
.../projects/android_one/project.properties | 4 +
.../projects/android_uninstall/local.properties | 1 +
.../SampleApp.xcodeproj/project.pbxproj | 44 +-
.../SampleApp.xcodeproj/project.pbxproj | 44 +-
.../projects/windows/CordovaApp.Phone.jsproj | 99 ++++
.../projects/windows/CordovaApp.Windows.jsproj | 99 ++++
.../windows/CordovaApp.Windows80.jsproj | 93 ++++
.../projects/windows/CordovaApp.projitems | 32 ++
.../projects/windows/CordovaApp.shproj | 30 +
.../projects/windows/CordovaApp.sln | 134 +++++
.../projects/windows/CordovaApp.vs2012.sln | 64 +++
.../windows/CordovaApp_TemporaryKey.pfx | Bin 0 -> 2544 bytes
.../spec-plugman/projects/windows/VERSION | 1 +
.../spec-plugman/projects/windows/config.xml | 14 +
.../projects/windows/package.phone.appxmanifest | 57 ++
.../windows/package.windows.appxmanifest | 58 ++
.../windows/package.windows80.appxmanifest | 50 ++
.../spec-plugman/registry/registry.spec.js | 4 +-
.../spec-plugman/uninstall-browserify.spec.js | 33 +-
cordova-lib/spec-plugman/uninstall.spec.js | 47 +-
.../spec-plugman/util/action-stack.spec.js | 3 +-
.../spec-plugman/util/config-changes.spec.js | 10 +-
cordova-lib/spec-plugman/util/csproj.spec.js | 13 +-
.../spec-plugman/util/dependencies.spec.js | 20 +-
cordova-lib/spec-plugman/util/plugins.spec.js | 6 +-
.../spec-plugman/util/xml-helpers.spec.js | 34 +-
cordova-lib/spec-plugman/wrappers.spec.js | 5 +-
cordova-lib/src/PluginInfo.js | 27 +-
cordova-lib/src/configparser/ConfigParser.js | 22 +-
cordova-lib/src/cordova/compile.js | 6 +-
cordova-lib/src/cordova/cordova.js | 2 -
.../src/cordova/metadata/firefoxos_parser.js | 40 ++
cordova-lib/src/cordova/platform.js | 74 ++-
cordova-lib/src/cordova/platformsConfig.json | 8 +-
cordova-lib/src/cordova/plugin.js | 114 +++-
cordova-lib/src/cordova/prepare.js | 30 +-
cordova-lib/src/cordova/restore-util.js | 110 ++++
cordova-lib/src/cordova/restore.js | 104 ----
cordova-lib/src/cordova/save.js | 161 ------
cordova-lib/src/cordova/util.js | 18 +-
cordova-lib/src/plugman/createpackagejson.js | 57 ++
cordova-lib/src/plugman/init-defaults.js | 141 +++++
cordova-lib/src/plugman/install.js | 30 +-
cordova-lib/src/plugman/platforms/android.js | 76 ++-
cordova-lib/src/plugman/platforms/ios.js | 21 +-
cordova-lib/src/plugman/platforms/windows.js | 52 +-
cordova-lib/src/plugman/plugman.js | 11 +-
cordova-lib/src/plugman/prepare.js | 2 +-
cordova-lib/src/plugman/registry/manifest.js | 2 +-
cordova-lib/src/plugman/registry/registry.js | 21 +-
cordova-lib/src/plugman/uninstall.js | 25 +-
cordova-lib/src/plugman/util/action-stack.js | 14 +-
cordova-lib/src/plugman/util/android-project.js | 150 ++---
cordova-lib/src/util/windows/jsproj.js | 309 -----------
cordova-lib/src/util/windows/jsprojManager.js | 544 +++++++++++++++++++
98 files changed, 2975 insertions(+), 1500 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/2f91b4fa/cordova-lib/package.json
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/2f91b4fa/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/2f91b4fa/cordova-lib/src/plugman/registry/registry.js
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[08/12] cordova-lib git commit: added ability to remove plugin via
package-name
Posted by st...@apache.org.
added ability to remove plugin via package-name
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/38a0afbd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/38a0afbd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/38a0afbd
Branch: refs/heads/CB-8551
Commit: 38a0afbdaef58dd2bc9cff88c76b0e382d835592
Parents: fee6daa
Author: Steve Gill <st...@gmail.com>
Authored: Tue Jan 27 14:15:32 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Tue Jan 27 14:15:32 2015 -0800
----------------------------------------------------------------------
cordova-lib/src/cordova/plugin.js | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/38a0afbd/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index b044a2f..5c349bd 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -28,6 +28,7 @@ var cordova_util = require('./util'),
shell = require('shelljs'),
PluginInfoProvider = require('../PluginInfoProvider'),
plugman = require('../plugman/plugman'),
+ pluginMapper = require('cordova-registry-mapper'),
events = require('../events');
// Returns a promise.
@@ -178,6 +179,17 @@ module.exports = function plugin(command, targets, opts) {
return hooksRunner.fire('before_plugin_rm', opts)
.then(function() {
return opts.plugins.reduce(function(soFar, target) {
+ // Convert target from package-name to package-id if necessary
+ var keys = Object.keys(pluginMapper);
+ //Traverse through pluginMapper values to see if it equals our target.
+ //Cordova-plugin-device would get changes to org.apache.cordova.device
+ for (var i = 0; i < keys.length; i++) {
+ var val = pluginMapper[keys[i]];
+ if(val === target) {
+ target = keys[i];
+ }
+ }
+
// Check if we have the plugin.
if (plugins.indexOf(target) < 0) {
return Q.reject(new CordovaError('Plugin "' + target + '" is not present in the project. See `'+cordova_util.binname+' plugin list`.'));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[05/12] cordova-lib git commit: plugins get fetched from npm,
then cordova registry if needed
Posted by st...@apache.org.
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/CB-8551
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
[02/12] cordova-lib git commit: plugins are fetched from npm before
cordova registry
Posted by st...@apache.org.
plugins are fetched from npm before cordova registry
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/049548a5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/049548a5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/049548a5
Branch: refs/heads/CB-8551
Commit: 049548a5994d4efcd85560c81526bcd0cd4c3ed5
Parents: 75687fb
Author: Steve Gill <st...@gmail.com>
Authored: Fri Jan 23 15:25:33 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Jan 23 17:20:15 2015 -0800
----------------------------------------------------------------------
cordova-lib/src/plugman/fetch.js | 1 -
cordova-lib/src/plugman/registry/registry.js | 121 ++++++++++++++++++----
2 files changed, 99 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/049548a5/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index 1d4d0a4..136b849 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -128,7 +128,6 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
));
}
// If not found in local search path, fetch from the registry.
- events.emit('log', 'Fetching plugin "' + plugin_src + '" via plugin registry');
return registry.fetch([plugin_src], options.client)
.then(function(dir) {
return {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/049548a5/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 e3e0532..3643eb3 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -152,29 +152,15 @@ module.exports = {
*/
fetch: function(plugin, client) {
plugin = plugin.shift();
- 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);
+ return fetchNPM(plugin, client)
+ .fail(function() {
+ events.emit('log', 'Fetching from npm failed');
+ //reset settings to fetch from cordova registry
+ module.exports.settings = null;
+ return fetchPlugReg(plugin,client);
});
},
-
+
/**
* @method info
* @param {String} name Plugin name
@@ -195,7 +181,6 @@ module.exports = {
// Plugin info should be accessed as info[version]. If a version
// specifier like >=x.y.z was used when calling npm view, info
// can contain several versions, but we take the first one here.
- console.log(info);
var version = Object.keys(info)[0];
return info[version];
});
@@ -230,6 +215,33 @@ function initSettings() {
return Q(settings);
}
+/**
+ * @method initSettingsNPM
+ * @return {Promise.<Object>} Promised settings.
+ */
+function initSettingsNPM() {
+ var settings = module.exports.settings;
+ // check if settings already set
+ if(settings !== null) return Q(settings);
+
+ // setting up settings
+ // obviously if settings dir does not exist settings is going to be empty
+ if(!fs.existsSync(plugmanConfigDir)) {
+ fs.mkdirSync(plugmanConfigDir);
+ fs.mkdirSync(plugmanCacheDir);
+ }
+
+ settings =
+ module.exports.settings =
+ rc('plugman', {
+ cache: plugmanCacheDir,
+ registry: 'http://registry.npmjs.org',
+ logstream: fs.createWriteStream(path.resolve(plugmanConfigDir, 'plugman.log')),
+ 'cache-min': oneDay
+ });
+ return Q(settings);
+}
+
// Send a message to the registry to update download counts.
function bumpCounter(info, client) {
@@ -308,3 +320,68 @@ function makeRequest (method, where, what, cb_) {
return req;
}
+
+/**
+ * @method fetchNPM
+ * @param {Array} with one element - the plugin id or "id@version"
+ * @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)
+ // 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);
+ });
+}
+
+
+/**
+ * @method fetchPlugReg
+ * @param {Array} with one element - the plugin id or "id@version"
+ * @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');
+ });
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[10/12] cordova-lib git commit: CB-8551 added npm fetching as fallback
Posted by st...@apache.org.
CB-8551 added npm fetching as fallback
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/db4d274b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/db4d274b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/db4d274b
Branch: refs/heads/CB-8551
Commit: db4d274b6b46ec92c775c065ff2ec0c0439482b8
Parents: 2f91b4f
Author: Steve Gill <st...@gmail.com>
Authored: Wed Feb 25 22:53:52 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Wed Feb 25 22:53:52 2015 -0800
----------------------------------------------------------------------
cordova-lib/src/plugman/fetch.js | 5 +-
cordova-lib/src/plugman/registry/registry.js | 88 +++++++----------------
2 files changed, 29 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/db4d274b/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index dd78c84..416a7b6 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -133,7 +133,7 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
id: plugin_src
}
};
- });
+ })
}).then(function(result) {
options.plugin_src_dir = result.pinfo.dir;
return Q.when(copyPlugin(result.pinfo, plugins_dir, options.link && result.fetchJsonSource.type == 'local'))
@@ -146,6 +146,9 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
checkID(options.expected_id, result.pinfo);
metadata.save_fetch_metadata(plugins_dir, result.pinfo.id, { source: result.fetchJsonSource });
return result.dest;
+ })
+ .fail(function(error) {
+ return Q.reject(error);
});
}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/db4d274b/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 786cb6e..2943a77 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -91,7 +91,7 @@ module.exports = {
if(fs.existsSync(path.join(dir,'package.json'))) {
events.emit('verbose', 'temporarily moving existing package.json so we can create one to publish to the cordova plugins registry');
if(fs.existsSync(path.join(dir,'package.json1'))) {
- //package.json1 already exists, maybe due to an past failed attempt to publish
+ //package.json1 already exists, maybe due to a failed past attempt to publish
//we will assume that the rename has already happened.
events.emit('verbose', 'package.json1 already exists. Will use');
} else {
@@ -167,12 +167,11 @@ module.exports = {
*/
fetch: function(plugin, client) {
plugin = plugin.shift();
- return fetchNPM(plugin, client)
+ return fetchPlugReg(plugin, client)
.fail(function() {
- events.emit('log', 'Fetching from npm failed');
- //reset settings to fetch from cordova registry
+ events.emit('log', 'Fetching from cordova plugin registry failed');
module.exports.settings = null;
- return fetchPlugReg(plugin,client);
+ return fetchNPM(plugin,client);
});
},
@@ -204,10 +203,18 @@ module.exports = {
/**
* @method initSettings
+ * @param {Boolean} using npm registry
* @return {Promise.<Object>} Promised settings.
*/
-function initSettings() {
+function initSettings(npm) {
var settings = module.exports.settings;
+ var registryURL = 'http://registry.cordova.io';
+
+ //if npm is true, use npm registry
+ if(npm) {
+ registryURL = 'http://registry.npmjs.org';
+ }
+
// check if settings already set
if(settings !== null) return Q(settings);
@@ -222,42 +229,22 @@ function initSettings() {
module.exports.settings =
rc('plugman', {
cache: plugmanCacheDir,
- registry: 'http://registry.cordova.io',
+ registry: registryURL,
logstream: fs.createWriteStream(path.resolve(plugmanConfigDir, 'plugman.log')),
userconfig: path.resolve(plugmanConfigDir, 'config'),
'cache-min': oneDay
});
- return Q(settings);
-}
-
-/**
- * @method initSettingsNPM
- * @return {Promise.<Object>} Promised settings.
- */
-function initSettingsNPM() {
- var settings = module.exports.settings;
- // check if settings already set
- if(settings !== null) return Q(settings);
- // setting up settings
- // obviously if settings dir does not exist settings is going to be empty
- if(!fs.existsSync(plugmanConfigDir)) {
- fs.mkdirSync(plugmanConfigDir);
- fs.mkdirSync(plugmanCacheDir);
+ // if npm is true, use npm registry.
+ // ~/.plugman/config overides the above cofig if it exists.
+ // Need to reset the registry value in settings
+ if(npm) {
+ settings.registry = 'http://registry.npmjs.org';
}
- settings =
- module.exports.settings =
- rc('plugman', {
- cache: plugmanCacheDir,
- registry: 'http://registry.npmjs.org',
- logstream: fs.createWriteStream(path.resolve(plugmanConfigDir, 'plugman.log')),
- 'cache-min': oneDay
- });
return Q(settings);
}
-
// Send a message to the registry to update download counts.
function bumpCounter(info, client) {
// Update the download count for this plugin.
@@ -342,7 +329,7 @@ function makeRequest (method, where, what, cb_) {
* @return {Promise.<string>} Promised path to fetched package.
*/
function fetchNPM(plugin, client) {
- return initSettingsNPM()
+ return initSettings(true)
.then(function (settings) {
return Q.nfcall(npm.load)
// configure npm here instead of passing parameters to npm.load due to CB-7670
@@ -352,33 +339,6 @@ 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]);
@@ -390,6 +350,11 @@ function fetchNPM(plugin, client) {
// 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(error) {
+ //console.log(error)
+ events.emit('log', 'Fetching from npm registry failed');
+ return Q.reject(error)
});
}
@@ -421,9 +386,6 @@ function fetchPlugReg(plugin, client) {
// 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
[06/12] cordova-lib git commit: plugins are fetched from npm before
cordova registry
Posted by st...@apache.org.
plugins are fetched from npm before cordova registry
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/7db3df13
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/7db3df13
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/7db3df13
Branch: refs/heads/CB-8551
Commit: 7db3df134aba1bb5b5c1ea547ff919d621c30575
Parents: 8fe6b47
Author: Steve Gill <st...@gmail.com>
Authored: Fri Jan 23 15:25:33 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Mon Jan 26 16:59:29 2015 -0800
----------------------------------------------------------------------
cordova-lib/src/plugman/fetch.js | 1 -
cordova-lib/src/plugman/registry/registry.js | 121 ++++++++++++++++++----
2 files changed, 99 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7db3df13/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index e0f1cf4..dd78c84 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -124,7 +124,6 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
));
}
// If not found in local search path, fetch from the registry.
- events.emit('log', 'Fetching plugin "' + plugin_src + '" via plugin registry');
return registry.fetch([plugin_src], options.client)
.then(function(dir) {
return {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/7db3df13/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 7c33b27..d6e86d0 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -149,29 +149,15 @@ module.exports = {
*/
fetch: function(plugin, client) {
plugin = plugin.shift();
- 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);
+ return fetchNPM(plugin, client)
+ .fail(function() {
+ events.emit('log', 'Fetching from npm failed');
+ //reset settings to fetch from cordova registry
+ module.exports.settings = null;
+ return fetchPlugReg(plugin,client);
});
},
-
+
/**
* @method info
* @param {String} name Plugin name
@@ -192,7 +178,6 @@ module.exports = {
// Plugin info should be accessed as info[version]. If a version
// specifier like >=x.y.z was used when calling npm view, info
// can contain several versions, but we take the first one here.
- console.log(info);
var version = Object.keys(info)[0];
return info[version];
});
@@ -227,6 +212,33 @@ function initSettings() {
return Q(settings);
}
+/**
+ * @method initSettingsNPM
+ * @return {Promise.<Object>} Promised settings.
+ */
+function initSettingsNPM() {
+ var settings = module.exports.settings;
+ // check if settings already set
+ if(settings !== null) return Q(settings);
+
+ // setting up settings
+ // obviously if settings dir does not exist settings is going to be empty
+ if(!fs.existsSync(plugmanConfigDir)) {
+ fs.mkdirSync(plugmanConfigDir);
+ fs.mkdirSync(plugmanCacheDir);
+ }
+
+ settings =
+ module.exports.settings =
+ rc('plugman', {
+ cache: plugmanCacheDir,
+ registry: 'http://registry.npmjs.org',
+ logstream: fs.createWriteStream(path.resolve(plugmanConfigDir, 'plugman.log')),
+ 'cache-min': oneDay
+ });
+ return Q(settings);
+}
+
// Send a message to the registry to update download counts.
function bumpCounter(info, client) {
@@ -305,3 +317,68 @@ function makeRequest (method, where, what, cb_) {
return req;
}
+
+/**
+ * @method fetchNPM
+ * @param {Array} with one element - the plugin id or "id@version"
+ * @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)
+ // 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);
+ });
+}
+
+
+/**
+ * @method fetchPlugReg
+ * @param {Array} with one element - the plugin id or "id@version"
+ * @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');
+ });
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org