From 9d75a4257c02bd033589362ba4c3d175b28fca45 Mon Sep 17 00:00:00 2001 From: Steve Gill Date: Mon, 19 Oct 2015 14:16:12 -0700 Subject: [PATCH] CB-9824 removed plugin download counter code from lib --- cordova-lib/src/plugman/registry/registry.js | 82 -------------------- 1 file changed, 82 deletions(-) diff --git a/cordova-lib/src/plugman/registry/registry.js b/cordova-lib/src/plugman/registry/registry.js index 5624c4e58..e5f22cea6 100644 --- a/cordova-lib/src/plugman/registry/registry.js +++ b/cordova-lib/src/plugman/registry/registry.js @@ -21,11 +21,9 @@ var npm = require('npm'), path = require('path'), - url = require('url'), fs = require('fs'), rc = require('rc'), Q = require('q'), - request = require('request'), npmhelper = require('../../util/npm-helper'), home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE, events = require('cordova-common').events, @@ -171,84 +169,6 @@ function initThenLoadSettingsWithRestore(useEmptySettings, promises) { }); } -// Send a message to the registry to update download counts. -function bumpCounter(info, client) { - // Update the download count for this plugin. - // Fingers crossed that the timestamps are unique, and that no plugin is downloaded - // twice in a single millisecond. - // - // This is acceptable, because the failure mode is Couch gracefully rejecting the second one - // (for lacking a _rev), and dropped a download count is not important. - var settings = module.exports.settings; - var now = new Date(); - var message = { - day: now.getUTCFullYear() + '-' + (now.getUTCMonth()+1) + '-' + now.getUTCDate(), - pkg: info.name, - client: client, - version: info.version - }; - var remote = settings.registry + '/downloads'; - - makeRequest('POST', remote, message, function (err, res, body) { - // ignore errors - }); -} - - -function makeRequest (method, where, what, cb_) { - var settings = module.exports.settings; - var remote = url.parse(where); - if (typeof cb_ !== 'function') { - cb_ = what; - what = null; - } - var cbCalled = false; - function cb () { - if (cbCalled) return; - cbCalled = true; - cb_.apply(null, arguments); - } - - var strict = settings['strict-ssl']; - if (strict === undefined) strict = true; - var opts = { url: remote - , method: method - , ca: settings.ca - , strictSSL: strict - }; - - var headers = opts.headers = {}; - - headers.accept = 'application/json'; - - headers['user-agent'] = settings['user-agent'] || - 'node/' + process.version; - - var p = settings.proxy; - var sp = settings['https-proxy'] || p; - opts.proxy = remote.protocol === 'https:' ? sp : p; - - // figure out wth 'what' is - if (what) { - if (Buffer.isBuffer(what) || typeof what === 'string') { - opts.body = what; - headers['content-type'] = 'application/json'; - headers['content-length'] = Buffer.byteLength(what); - } else { - opts.json = what; - } - } - - var req = request(opts, cb); - - req.on('error', cb); - req.on('socket', function (s) { - s.on('error', cb); - }); - - return req; -} - /** * @param {Array} with one element - the plugin id or "id@version" * @param useNpmRegistry: {Boolean} - to use the npm registry @@ -267,8 +187,6 @@ function fetchPlugin(plugin, client, useNpmRegistry) { events.emit('log', 'Fetching plugin "' + plugin + '" via ' + registryName); 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');