Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKat Marchán <kzm@zkat.tech>2018-08-31 20:52:55 +0300
committerKat Marchán <kzm@zkat.tech>2018-12-11 02:30:29 +0300
commitec9fcc14f4e0e2f3967e2fd6ad8b8433076393cb (patch)
treeb1f83f24fddd2f1351953dee3e8749e80588d40b /lib
parentb24ed5fdc3a4395628465ae5273bad54eea274c8 (diff)
npm-registry-client: goodbye
Diffstat (limited to 'lib')
-rw-r--r--lib/config/figgy-config.js2
-rw-r--r--lib/config/pacote.js2
-rw-r--r--lib/config/reg-client.js29
-rw-r--r--lib/npm.js16
-rw-r--r--lib/org.js2
-rw-r--r--lib/utils/error-message.js3
-rw-r--r--lib/utils/get-publish-config.js29
-rw-r--r--lib/utils/map-to-registry.js103
8 files changed, 4 insertions, 182 deletions
diff --git a/lib/config/figgy-config.js b/lib/config/figgy-config.js
index 05a88ffd2..ae998272c 100644
--- a/lib/config/figgy-config.js
+++ b/lib/config/figgy-config.js
@@ -32,7 +32,7 @@ function mkConfig (...providers) {
includeDeprecated: false,
'npm-session': npmSession,
'project-scope': npm.projectScope,
- refer: npm.registry.refer,
+ refer: npm.refer,
dmode: npm.modes.exec,
fmode: npm.modes.file,
umask: npm.modes.umask,
diff --git a/lib/config/pacote.js b/lib/config/pacote.js
index aa573e13e..1131c8a05 100644
--- a/lib/config/pacote.js
+++ b/lib/config/pacote.js
@@ -40,7 +40,7 @@ function pacoteOpts (moreOpts) {
projectScope: npm.projectScope,
proxy: npm.config.get('https-proxy') || npm.config.get('proxy'),
noProxy: npm.config.get('noproxy'),
- refer: npm.registry.refer,
+ refer: npm.referer,
registry: npm.config.get('registry'),
retry: {
retries: npm.config.get('fetch-retries'),
diff --git a/lib/config/reg-client.js b/lib/config/reg-client.js
deleted file mode 100644
index d4e241709..000000000
--- a/lib/config/reg-client.js
+++ /dev/null
@@ -1,29 +0,0 @@
-'use strict'
-
-module.exports = regClientConfig
-function regClientConfig (npm, log, config) {
- return {
- proxy: {
- http: config.get('proxy'),
- https: config.get('https-proxy'),
- localAddress: config.get('local-address')
- },
- ssl: {
- certificate: config.get('cert'),
- key: config.get('key'),
- ca: config.get('ca'),
- strict: config.get('strict-ssl')
- },
- retry: {
- retries: config.get('fetch-retries'),
- factor: config.get('fetch-retry-factor'),
- minTimeout: config.get('fetch-retry-mintimeout'),
- maxTimeout: config.get('fetch-retry-maxtimeout')
- },
- userAgent: config.get('user-agent'),
- log: log,
- defaultTag: config.get('tag'),
- maxSockets: config.get('maxsockets'),
- scope: npm.projectScope
- }
-}
diff --git a/lib/npm.js b/lib/npm.js
index da5a36360..2ee9a9912 100644
--- a/lib/npm.js
+++ b/lib/npm.js
@@ -40,9 +40,7 @@
var which = require('which')
var glob = require('glob')
var rimraf = require('rimraf')
- var lazyProperty = require('lazy-property')
var parseJSON = require('./utils/parse-json.js')
- var clientConfig = require('./config/reg-client.js')
var aliases = require('./config/cmd-list').aliases
var cmdList = require('./config/cmd-list').cmdList
var plumbing = require('./config/cmd-list').plumbing
@@ -106,7 +104,6 @@
})
var registryRefer
- var registryLoaded
Object.keys(abbrevs).concat(plumbing).forEach(function addCommand (c) {
Object.defineProperty(npm.commands, c, { get: function () {
@@ -153,7 +150,7 @@
}).filter(function (arg) {
return arg && arg.match
}).join(' ')
- if (registryLoaded) npm.registry.refer = registryRefer
+ npm.referer = registryRefer
}
cmd.apply(npm, args)
@@ -357,17 +354,6 @@
npm.projectScope = config.get('scope') ||
scopeifyScope(getProjectScope(npm.prefix))
- // at this point the configs are all set.
- // go ahead and spin up the registry client.
- lazyProperty(npm, 'registry', function () {
- registryLoaded = true
- var RegClient = require('npm-registry-client')
- var registry = new RegClient(clientConfig(npm, log, npm.config))
- registry.version = npm.version
- registry.refer = registryRefer
- return registry
- })
-
startMetrics()
return cb(null, npm)
diff --git a/lib/org.js b/lib/org.js
index e838f615b..ea013cc3d 100644
--- a/lib/org.js
+++ b/lib/org.js
@@ -1,7 +1,5 @@
'use strict'
-const BB = require('bluebird')
-
const figgyPudding = require('figgy-pudding')
const liborg = require('libnpm/org')
const npmConfig = require('./config/figgy-config.js')
diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js
index 6e1489818..55c546345 100644
--- a/lib/utils/error-message.js
+++ b/lib/utils/error-message.js
@@ -103,8 +103,7 @@ function errorMessage (er) {
case 'EOTP':
case 'E401':
- // the E401 message checking is a hack till we replace npm-registry-client with something
- // OTP aware.
+ // E401 is for places where we accidentally neglect OTP stuff
if (er.code === 'EOTP' || /one-time pass/.test(er.message)) {
short.push(['', 'This operation requires a one-time password from your authenticator.'])
detail.push([
diff --git a/lib/utils/get-publish-config.js b/lib/utils/get-publish-config.js
deleted file mode 100644
index ac0ef0934..000000000
--- a/lib/utils/get-publish-config.js
+++ /dev/null
@@ -1,29 +0,0 @@
-'use strict'
-
-const clientConfig = require('../config/reg-client.js')
-const Conf = require('../config/core.js').Conf
-const log = require('npmlog')
-const npm = require('../npm.js')
-const RegClient = require('npm-registry-client')
-
-module.exports = getPublishConfig
-
-function getPublishConfig (publishConfig, defaultConfig, defaultClient) {
- let config = defaultConfig
- let client = defaultClient
- log.verbose('getPublishConfig', publishConfig)
- if (publishConfig) {
- config = new Conf(defaultConfig)
- config.save = defaultConfig.save.bind(defaultConfig)
-
- // don't modify the actual publishConfig object, in case we have
- // to set a login token or some other data.
- config.unshift(Object.keys(publishConfig).reduce(function (s, k) {
- s[k] = publishConfig[k]
- return s
- }, {}))
- client = new RegClient(clientConfig(npm, log, config))
- }
-
- return { config: config, client: client }
-}
diff --git a/lib/utils/map-to-registry.js b/lib/utils/map-to-registry.js
deleted file mode 100644
index d6e0a5b01..000000000
--- a/lib/utils/map-to-registry.js
+++ /dev/null
@@ -1,103 +0,0 @@
-var url = require('url')
-
-var log = require('npmlog')
-var npa = require('npm-package-arg')
-var config
-
-module.exports = mapToRegistry
-
-function mapToRegistry (name, config, cb) {
- log.silly('mapToRegistry', 'name', name)
- var registry
-
- // the name itself takes precedence
- var data = npa(name)
- if (data.scope) {
- // the name is definitely scoped, so escape now
- name = name.replace('/', '%2f')
-
- log.silly('mapToRegistry', 'scope (from package name)', data.scope)
-
- registry = config.get(data.scope + ':registry')
- if (!registry) {
- log.verbose('mapToRegistry', 'no registry URL found in name for scope', data.scope)
- }
- }
-
- // ...then --scope=@scope or --scope=scope
- var scope = config.get('scope')
- if (!registry && scope) {
- // I'm an enabler, sorry
- if (scope.charAt(0) !== '@') scope = '@' + scope
-
- log.silly('mapToRegistry', 'scope (from config)', scope)
-
- registry = config.get(scope + ':registry')
- if (!registry) {
- log.verbose('mapToRegistry', 'no registry URL found in config for scope', scope)
- }
- }
-
- // ...and finally use the default registry
- if (!registry) {
- log.silly('mapToRegistry', 'using default registry')
- registry = config.get('registry')
- }
-
- log.silly('mapToRegistry', 'registry', registry)
-
- var auth = config.getCredentialsByURI(registry)
-
- // normalize registry URL so resolution doesn't drop a piece of registry URL
- var normalized = registry.slice(-1) !== '/' ? registry + '/' : registry
- var uri
- log.silly('mapToRegistry', 'data', data)
- if (data.type === 'remote') {
- uri = data.fetchSpec
- } else {
- uri = url.resolve(normalized, name)
- }
-
- log.silly('mapToRegistry', 'uri', uri)
-
- cb(null, uri, scopeAuth(uri, registry, auth), normalized)
-}
-
-function scopeAuth (uri, registry, auth) {
- var cleaned = {
- scope: auth.scope,
- email: auth.email,
- alwaysAuth: auth.alwaysAuth,
- token: undefined,
- username: undefined,
- password: undefined,
- auth: undefined
- }
-
- var requestHost
- var registryHost
-
- if (auth.token || auth.auth || (auth.username && auth.password)) {
- requestHost = url.parse(uri).hostname
- registryHost = url.parse(registry).hostname
-
- if (requestHost === registryHost) {
- cleaned.token = auth.token
- cleaned.auth = auth.auth
- cleaned.username = auth.username
- cleaned.password = auth.password
- } else if (auth.alwaysAuth) {
- log.verbose('scopeAuth', 'alwaysAuth set for', registry)
- cleaned.token = auth.token
- cleaned.auth = auth.auth
- cleaned.username = auth.username
- cleaned.password = auth.password
- } else {
- log.silly('scopeAuth', uri, "doesn't share host with registry", registry)
- }
- if (!config) config = require('../npm').config
- if (config.get('otp')) cleaned.otp = config.get('otp')
- }
-
- return cleaned
-}