Skip to content

restore npm_config_user_agent env variable #1919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ const npm = module.exports = new class extends EventEmitter {
await this.config.load()
this.argv = this.config.parsedArgv.remain

setUserAgent(this.config)

this.color = setupLog(this.config, this)
process.env.COLOR = this.color ? '1' : '0'

Expand Down Expand Up @@ -279,7 +277,6 @@ const startMetrics = require('./utils/metrics.js').start

const which = promisify(require('which'))

const setUserAgent = require('./utils/set-user-agent.js')
const deref = require('./utils/deref-command.js')
const setupLog = require('./utils/setup-log.js')
const cleanUpLogFiles = require('./utils/cleanup-log-files.js')
Expand Down
163 changes: 79 additions & 84 deletions lib/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const {
}
} = require('@npmcli/config')

const { version: npmVersion } = require('../../package.json')

const ciDetect = require('@npmcli/ci-detect')
const ciName = ciDetect()

const isWindows = require('./is-windows.js')

Expand Down Expand Up @@ -45,74 +48,64 @@ const defaults = {
access: null,
all: false,
'allow-same-version': false,
'always-auth': false,
also: null,
'always-auth': false,
audit: true,
'audit-level': null,
'auth-type': 'legacy',

before: null,
'bin-links': true,
browser: null,

ca: null,
cafile: null,

cache,

'cache-lock-stale': 60000,
'cache-lock-retries': 10,
'cache-lock-stale': 60000,
'cache-lock-wait': 10000,

'cache-max': Infinity,
'cache-min': 10,

cafile: null,
call: '',
cert: null,

'ci-name': ciName || null,
cidr: null,

color: process.env.NO_COLOR == null,
call: '',
'commit-hooks': true,
depth: null,
description: true,
dev: false,
'dry-run': false,
editor,
'engine-strict': false,
force: false,
'format-package-lock': true,

fund: true,

'fetch-retries': 2,
'fetch-retry-factor': 10,
'fetch-retry-mintimeout': 10000,
'fetch-retry-maxtimeout': 60000,
'fetch-retry-mintimeout': 10000,
'fetch-timeout': 5 * 60 * 1000,

force: false,
'format-package-lock': true,
fund: true,
git: 'git',
'git-tag-version': true,
'commit-hooks': true,

global: false,
'global-style': false,
// `globalconfig` has its default defined outside of this module
heading: 'npm',
'https-proxy': null,
'if-present': false,
include: [],
'include-staged': false,
'ignore-prepublish': false,
'ignore-scripts': false,
'init-module': '~/.npm-init.js',
'init-author-name': '',
include: [],
'include-staged': false,
'init-author-email': '',
'init-author-name': '',
'init-author-url': '',
'init-version': '1.0.0',
'init-license': 'ISC',
'init-module': '~/.npm-init.js',
'init-version': '1.0.0',
json: false,
key: null,
'legacy-bundling': false,
'legacy-peer-deps': false,
'strict-peer-deps': false,
link: false,
'local-address': undefined,
loglevel: 'notice',
Expand All @@ -123,6 +116,8 @@ const defaults = {
'metrics-registry': null,
'node-options': null,
'node-version': process.version,
noproxy: null,
'npm-version': npmVersion,
offline: false,
omit: [],
only: null,
Expand All @@ -134,17 +129,11 @@ const defaults = {
parseable: false,
'prefer-offline': false,
'prefer-online': false,
// `prefix` has its default defined outside of this module
preid: '',
production: process.env.NODE_ENV === 'production',
progress: !ciDetect(),
progress: !ciName,
proxy: null,
'https-proxy': null,
noproxy: null,
'user-agent': 'npm/{npm-version} ' +
'node/{node-version} ' +
'{platform} ' +
'{arch} ' +
'{ci}',
'read-only': false,
'rebuild-bundle': true,
registry: 'https://registry.npmjs.org/',
Expand All @@ -159,9 +148,9 @@ const defaults = {
scope: '',
'script-shell': null,
'scripts-prepend-node-path': 'warn-only',
searchopts: '',
searchexclude: null,
searchlimit: 20,
searchopts: '',
searchstaleness: 15 * 60,
'send-metrics': false,
shell,
Expand All @@ -170,16 +159,22 @@ const defaults = {
'sign-git-tag': false,
'sso-poll-frequency': 500,
'sso-type': 'oauth',
'strict-peer-deps': false,
'strict-ssl': true,
tag: 'latest',
'tag-version-prefix': 'v',
timing: false,
tmp: tmpdir(),
umask: process.umask ? process.umask() : 0o22,
unicode,
'update-notifier': true,
usage: false,
'user-agent': 'npm/{npm-version} ' +
'node/{node-version} ' +
'{platform} ' +
'{arch} ' +
'{ci}',
userconfig: '~/.npmrc',
umask: process.umask ? process.umask() : 0o22,
version: false,
versions: false,
viewer: isWindows ? 'browser' : 'man'
Expand All @@ -189,66 +184,64 @@ const types = {
access: [null, 'restricted', 'public'],
all: Boolean,
'allow-same-version': Boolean,
'always-auth': Boolean,
also: [null, 'dev', 'development'],
'always-auth': Boolean,
audit: Boolean,
'audit-level': ['low', 'moderate', 'high', 'critical', 'none', null],
'auth-type': ['legacy', 'sso', 'saml', 'oauth'],
before: [null, Date],
'bin-links': Boolean,
browser: [null, Boolean, String],
ca: [null, String, Array],
cafile: path,
cache: path,
'cache-lock-stale': Number,
'cache-lock-retries': Number,
'cache-lock-stale': Number,
'cache-lock-wait': Number,
'cache-max': Number,
'cache-min': Number,
cafile: path,
call: String,
cert: [null, String],
'ci-name': [null, String],
cidr: [null, String, Array],
color: ['always', Boolean],
call: String,
'commit-hooks': Boolean,
depth: [null, Number],
description: Boolean,
dev: Boolean,
'dry-run': Boolean,
editor: String,
'engine-strict': Boolean,
force: Boolean,
fund: Boolean,
'format-package-lock': Boolean,
'fetch-retries': Number,
'fetch-retry-factor': Number,
'fetch-retry-mintimeout': Number,
'fetch-retry-maxtimeout': Number,
'fetch-retry-mintimeout': Number,
'fetch-timeout': Number,
force: Boolean,
'format-package-lock': Boolean,
fund: Boolean,
git: String,
'git-tag-version': Boolean,
'commit-hooks': Boolean,
global: Boolean,
globalconfig: path,
'global-style': Boolean,
group: [Number, String],
'https-proxy': [null, url],
'user-agent': String,
globalconfig: path,
heading: String,
'https-proxy': [null, url],
'if-present': Boolean,
include: [Array, 'prod', 'dev', 'optional', 'peer'],
'include-staged': Boolean,
'ignore-prepublish': Boolean,
'ignore-scripts': Boolean,
'init-module': path,
'init-author-name': String,
include: [Array, 'prod', 'dev', 'optional', 'peer'],
'include-staged': Boolean,
'init-author-email': String,
'init-author-name': String,
'init-author-url': ['', url],
'init-license': String,
'init-module': path,
'init-version': semver,
json: Boolean,
key: [null, String],
'legacy-bundling': Boolean,
'legacy-peer-deps': Boolean,
'strict-peer-deps': Boolean,
link: Boolean,
'local-address': getLocalAddresses(),
loglevel: [
Expand All @@ -270,6 +263,7 @@ const types = {
'node-options': [null, String],
'node-version': [null, semver],
noproxy: [null, String, Array],
'npm-version': semver,
offline: Boolean,
omit: [Array, 'dev', 'optional', 'peer'],
only: [null, 'dev', 'development', 'prod', 'production'],
Expand Down Expand Up @@ -300,9 +294,9 @@ const types = {
scope: String,
'script-shell': [null, String],
'scripts-prepend-node-path': [Boolean, 'auto', 'warn-only'],
searchopts: String,
searchexclude: [null, String],
searchlimit: Number,
searchopts: String,
searchstaleness: Number,
'send-metrics': Boolean,
shell: String,
Expand All @@ -311,61 +305,62 @@ const types = {
'sign-git-tag': Boolean,
'sso-poll-frequency': Number,
'sso-type': [null, 'oauth', 'saml'],
'strict-peer-deps': Boolean,
'strict-ssl': Boolean,
tag: String,
'tag-version-prefix': String,
timing: Boolean,
tmp: path,
umask: Umask,
unicode: Boolean,
'update-notifier': Boolean,
usage: Boolean,
'user-agent': String,
userconfig: path,
umask: Umask,
version: Boolean,
'tag-version-prefix': String,
versions: Boolean,
viewer: String
}

const shorthands = {
'?': ['--usage'],
a: ['--all'],
'enjoy-by': ['--before'],
B: ['--save-bundle'],
C: ['--prefix'],
c: ['--call'],
s: ['--loglevel', 'silent'],
D: ['--save-dev'],
d: ['--loglevel', 'info'],
dd: ['--loglevel', 'verbose'],
ddd: ['--loglevel', 'silly'],
noreg: ['--no-registry'],
N: ['--no-registry'],
reg: ['--registry'],
'no-reg': ['--no-registry'],
silent: ['--loglevel', 'silent'],
verbose: ['--loglevel', 'verbose'],
quiet: ['--loglevel', 'warn'],
q: ['--loglevel', 'warn'],
h: ['--usage'],
desc: ['--description'],
E: ['--save-exact'],
'enjoy-by': ['--before'],
f: ['--force'],
g: ['--global'],
H: ['--usage'],
'?': ['--usage'],
h: ['--usage'],
help: ['--usage'],
v: ['--version'],
f: ['--force'],
desc: ['--description'],
'no-desc': ['--no-description'],
local: ['--no-global'],
l: ['--long'],
local: ['--no-global'],
m: ['--message'],
n: ['--no-yes'],
'no-desc': ['--no-description'],
'no-reg': ['--no-registry'],
noreg: ['--no-registry'],
O: ['--save-optional'],
P: ['--save-prod'],
p: ['--parseable'],
porcelain: ['--parseable'],
q: ['--loglevel', 'warn'],
quiet: ['--loglevel', 'warn'],
readonly: ['--read-only'],
g: ['--global'],
reg: ['--registry'],
S: ['--save'],
D: ['--save-dev'],
E: ['--save-exact'],
O: ['--save-optional'],
P: ['--save-prod'],
y: ['--yes'],
n: ['--no-yes'],
B: ['--save-bundle'],
C: ['--prefix']
s: ['--loglevel', 'silent'],
silent: ['--loglevel', 'silent'],
v: ['--version'],
verbose: ['--loglevel', 'verbose'],
y: ['--yes']
}

module.exports = { defaults, types, shorthands }
15 changes: 0 additions & 15 deletions lib/utils/set-user-agent.js

This file was deleted.

Loading