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/12/05 02:13:13 UTC
cordova-lib git commit: CB-9957 removed CPR fetching code
Repository: cordova-lib
Updated Branches:
refs/heads/master 42f727f8a -> 46305f17f
CB-9957 removed CPR fetching code
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/46305f17
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/46305f17
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/46305f17
Branch: refs/heads/master
Commit: 46305f17fbde50795657c55f1d3e510e62fcda4c
Parents: 42f727f
Author: Steve Gill <st...@gmail.com>
Authored: Fri Dec 4 16:20:24 2015 -0800
Committer: Steve Gill <st...@gmail.com>
Committed: Fri Dec 4 16:47:35 2015 -0800
----------------------------------------------------------------------
cordova-lib/package.json | 1 -
cordova-lib/spec-plugman/fetch.spec.js | 5 --
cordova-lib/src/plugman/fetch.js | 4 +-
cordova-lib/src/plugman/registry/registry.js | 102 +++-------------------
4 files changed, 13 insertions(+), 99 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/46305f17/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index ff0fded..77b690b 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -58,7 +58,6 @@
"plist": "^1.2.0",
"properties-parser": "0.2.3",
"q": "1.0.1",
- "rc": "0.5.2",
"request": "2.47.0",
"semver": "^4.3.x",
"shelljs": "0.3.0",
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/46305f17/cordova-lib/spec-plugman/fetch.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/fetch.spec.js b/cordova-lib/spec-plugman/fetch.spec.js
index aa8de0d..e521006 100644
--- a/cordova-lib/spec-plugman/fetch.spec.js
+++ b/cordova-lib/spec-plugman/fetch.spec.js
@@ -259,11 +259,6 @@ describe('fetch', function() {
});
- it('should get a plugin from registry and set the right client when argument is not a folder nor URL', function(done) {
- wrapper(fetch(pluginId, temp, {client: 'plugman'}), done, function() {
- expect(sFetch).toHaveBeenCalledWith([pluginId], 'plugman');
- });
- });
it('should fail when the expected ID doesn\'t match', function(done) {
fetch(pluginId, temp, { expected_id: 'wrongID' })
.then(function() {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/46305f17/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index 9fe0b24..8c89fe2 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -134,10 +134,10 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
// If not found in local search path, fetch from the registry.
var newID = pluginMapperotn[plugin_src];
if(newID) {
- events.emit('warn', 'Notice: ' + plugin_src + ' has been automatically converted to ' + newID + ' and fetched from npm. This is due to our old plugins registry shutting down.');
+ events.emit('warn', 'Notice: ' + plugin_src + ' has been automatically converted to ' + newID + ' to be fetched from npm. This is due to our old plugins registry shutting down.');
plugin_src = newID;
}
- return registry.fetch([plugin_src], options.client)
+ return registry.fetch([plugin_src])
.fail(function (error) {
var message = 'Failed to fetch plugin ' + plugin_src + ' via registry.' +
'\nProbably this is either a connection problem, or plugin spec is incorrect.' +
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/46305f17/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 e5f22ce..fd633ab 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -21,17 +21,10 @@
var npm = require('npm'),
path = require('path'),
- fs = require('fs'),
- rc = require('rc'),
Q = require('q'),
npmhelper = require('../../util/npm-helper'),
- home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE,
events = require('cordova-common').events,
- unpack = require('../../util/unpack'),
- // if PLUGMAN_HOME env var is specified use it as config directory (see CB-8190)
- plugmanConfigDir = process.env.PLUGMAN_HOME || path.resolve(home, '.plugman'),
- plugmanCacheDir = path.resolve(plugmanConfigDir, 'cache'),
- oneDay = 3600*24;
+ unpack = require('../../util/unpack');
module.exports = {
settings: null,
@@ -78,20 +71,14 @@ module.exports = {
* @param {Array} with one element - the plugin id or "id@version"
* @return {Promise.<string>} Promised path to fetched package.
*/
- fetch: function(plugin, client) {
+ fetch: function(plugin) {
plugin = plugin.shift();
return Q.fcall(function() {
//fetch from npm
- return fetchPlugin(plugin, client, true);
+ return fetchPlugin(plugin);
})
.fail(function(error) {
- //check to see if pluginID is reverse domain name style
- if(isValidCprName(plugin)) {
- //fetch from CPR
- return fetchPlugin(plugin, client, false);
- } else {
- return Q.reject(error);
- }
+ return Q.reject(error);
});
},
@@ -102,8 +89,7 @@ module.exports = {
*/
info: function(plugin) {
plugin = plugin.shift();
- return initSettings()
- .then(Q.nbind(npm.load, npm))
+ return (Q.nbind(npm.load, npm))
.then(function() {
// Set cache timout limits to 0 to force npm to call the registry
// even when it has a recent .cache.json file.
@@ -122,69 +108,21 @@ module.exports = {
};
/**
- * @param {Boolean} determines if we are using the npm registry
- * @return {Promise.<Object>} Promised settings.
- */
-function initSettings(returnEmptySettings) {
- var settings = module.exports.settings;
-
- // check if settings already set
- if(settings !== null) {
- return Q(returnEmptySettings ? {} : 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.cordova.io',
- logstream: fs.createWriteStream(path.resolve(plugmanConfigDir, 'plugman.log')),
- userconfig: path.resolve(plugmanConfigDir, 'config'),
- 'cache-min': oneDay
- });
-
- return Q(returnEmptySettings ? {} : settings);
-}
-
-/**
- * @description Calls initSettings(), then npmhelper.loadWithSettingsThenRestore, which initializes npm.config with
+ * @description Calls npmhelper.loadWithSettingsThenRestore, which initializes npm.config with
* settings, executes the promises, then restores npm.config. Use this rather than passing settings to npm.load, since
* that only works the first time you try to load npm.
*/
-function initThenLoadSettingsWithRestore(useEmptySettings, promises) {
- if (typeof useEmptySettings === 'function') {
- promises = useEmptySettings;
- useEmptySettings = false;
- }
-
- return initSettings(useEmptySettings).then(function (settings) {
- return npmhelper.loadWithSettingsThenRestore(settings, promises);
- });
+function initThenLoadSettingsWithRestore(promises) {
+ return npmhelper.loadWithSettingsThenRestore({}, promises);
}
/**
* @param {Array} with one element - the plugin id or "id@version"
-* @param useNpmRegistry: {Boolean} - to use the npm registry
* @return {Promise.<string>} Promised path to fetched package.
*/
-function fetchPlugin(plugin, client, useNpmRegistry) {
- //set registry variable to use in log messages below
- var registryName;
- if(useNpmRegistry){
- registryName = 'npm';
- } else {
- registryName = 'cordova plugins registry';
- }
-
- return initThenLoadSettingsWithRestore(useNpmRegistry, function () {
- events.emit('log', 'Fetching plugin "' + plugin + '" via ' + registryName);
+function fetchPlugin(plugin) {
+ return initThenLoadSettingsWithRestore(function () {
+ events.emit('log', 'Fetching plugin "' + plugin + '" via npm');
return Q.ninvoke(npm.commands, 'cache', ['add', plugin])
.then(function (info) {
var pluginDir = path.resolve(npm.cache, info.name, info.version, 'package');
@@ -194,21 +132,3 @@ function fetchPlugin(plugin, client, useNpmRegistry) {
});
});
}
-
-/**
- * @param {Array} with one element - the plugin id or "id@version"
- * @return {Boolean} if plugin id is reverse domain name style.
- */
-function isValidCprName(plugin) {
- // Split @Version from the plugin id if it exists.
- var splitVersion = plugin.split('@');
-
- //Create regex that checks for at least two dots with any characters except @ to determine if it is reverse domain name style.
- var matches = /([^@]*\.[^@]*\.[^@]*)/.exec(splitVersion[0]);
-
- //If matches equals null, plugin is not reverse domain name style
- if(matches === null) {
- return false;
- }
- return true;
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org