Skip to content
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

feat(config): warn on deprecated configs #4740

Merged
merged 2 commits into from
Apr 13, 2022
Merged
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
2 changes: 0 additions & 2 deletions lib/auth/sso.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ function sleep (time) {
}

const login = async (npm, { creds, registry, scope }) => {
log.warn('deprecated', 'SSO --auth-type is deprecated')

const opts = { ...npm.flatOptions, creds, registry, scope }
const { ssoType } = opts

Expand Down
11 changes: 1 addition & 10 deletions lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class Install extends ArboristWorkspaceCmd {
const isGlobalInstall = this.npm.config.get('global')
const where = isGlobalInstall ? globalTop : this.npm.prefix
const forced = this.npm.config.get('force')
const isDev = this.npm.config.get('dev')
const scriptShell = this.npm.config.get('script-shell') || undefined

// be very strict about engines when trying to update npm itself
Expand Down Expand Up @@ -140,14 +139,6 @@ class Install extends ArboristWorkspaceCmd {
args = ['.']
}

// TODO: Add warnings for other deprecated flags? or remove this one?
if (isDev) {
log.warn(
'install',
'Usage of the `--dev` option is deprecated. Use `--include=dev` instead.'
)
}

const opts = {
...this.npm.flatOptions,
auditLevel: null,
Expand All @@ -163,7 +154,7 @@ class Install extends ArboristWorkspaceCmd {
'preinstall',
'install',
'postinstall',
'prepublish', // XXX should we remove this finally??
'prepublish', // XXX(npm9) should we remove this finally??
'preprepare',
'prepare',
'postprepare',
Expand Down
5 changes: 2 additions & 3 deletions node_modules/@npmcli/config/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,9 @@ class Config {
}

[_checkDeprecated] (key, where, obj, kv) {
// XXX a future npm version will make this a warning.
// An even more future npm version will make this an error.
// XXX(npm9+) make this throw an error
if (this.deprecated[key]) {
log.verbose('config', key, this.deprecated[key])
log.warn('config', key, this.deprecated[key])
}
}

Expand Down
6 changes: 3 additions & 3 deletions node_modules/@npmcli/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@npmcli/config",
"version": "4.0.2",
"version": "4.1.0",
"files": [
"bin/",
"lib/"
Expand Down Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "3.2.2",
"@npmcli/template-oss": "3.3.2",
"tap": "^16.0.1"
},
"dependencies": {
Expand All @@ -49,6 +49,6 @@
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "3.2.2"
"version": "3.3.2"
}
}
14 changes: 7 additions & 7 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"@isaacs/string-locale-compare": "^1.1.0",
"@npmcli/arborist": "^5.0.4",
"@npmcli/ci-detect": "^2.0.0",
"@npmcli/config": "^4.0.2",
"@npmcli/config": "^4.1.0",
"@npmcli/fs": "^2.1.0",
"@npmcli/map-workspaces": "^2.0.2",
"@npmcli/package-json": "^2.0.0",
Expand Down Expand Up @@ -858,9 +858,9 @@
}
},
"node_modules/@npmcli/config": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@npmcli/config/-/config-4.0.2.tgz",
"integrity": "sha512-UqD4h4LgyNOb7xRmAK7QXiMu0/k2x7wEzrEqXZ1wGIQVmCl3vamsAprDjAhi7IKlgRulg09hpwYs2/57OP22xw==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/@npmcli/config/-/config-4.1.0.tgz",
"integrity": "sha512-cPQmIQ2Q0vuOfrenrA3isikdMFMAHgzlXV+EmvZ8f2JeJsU5xTU2bG7ipXECiMvPF9nM+QDnMLuIg8QLw9H4xg==",
"inBundle": true,
"dependencies": {
"@npmcli/map-workspaces": "^2.0.2",
Expand Down Expand Up @@ -10504,9 +10504,9 @@
"version": "2.0.0"
},
"@npmcli/config": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@npmcli/config/-/config-4.0.2.tgz",
"integrity": "sha512-UqD4h4LgyNOb7xRmAK7QXiMu0/k2x7wEzrEqXZ1wGIQVmCl3vamsAprDjAhi7IKlgRulg09hpwYs2/57OP22xw==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/@npmcli/config/-/config-4.1.0.tgz",
"integrity": "sha512-cPQmIQ2Q0vuOfrenrA3isikdMFMAHgzlXV+EmvZ8f2JeJsU5xTU2bG7ipXECiMvPF9nM+QDnMLuIg8QLw9H4xg==",
"requires": {
"@npmcli/map-workspaces": "^2.0.2",
"ini": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@isaacs/string-locale-compare": "^1.1.0",
"@npmcli/arborist": "^5.0.4",
"@npmcli/ci-detect": "^2.0.0",
"@npmcli/config": "^4.0.2",
"@npmcli/config": "^4.1.0",
"@npmcli/fs": "^2.1.0",
"@npmcli/map-workspaces": "^2.0.2",
"@npmcli/package-json": "^2.0.0",
Expand Down
17 changes: 0 additions & 17 deletions test/lib/auth/sso.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const t = require('tap')

let log = ''
let warn = ''

const _flatOptions = {
ssoType: 'oauth',
Expand All @@ -15,9 +14,6 @@ const sso = t.mock('../../../lib/auth/sso.js', {
info: (...msgs) => {
log += msgs.join(' ') + '\n'
},
warn: (...msgs) => {
warn += msgs.join(' ')
},
},
'npm-profile': profile,
'npm-registry-fetch': npmFetch,
Expand All @@ -44,15 +40,8 @@ t.test('empty login', async (t) => {
'should throw if no sso-type defined in flatOptions'
)

t.equal(
warn,
'deprecated SSO --auth-type is deprecated',
'should print deprecation warning'
)

_flatOptions.ssoType = 'oauth'
log = ''
warn = ''
})

t.test('simple login', async (t) => {
Expand Down Expand Up @@ -104,7 +93,6 @@ t.test('simple login', async (t) => {
)

log = ''
warn = ''
delete profile.loginCouch
delete npmFetch.json
})
Expand Down Expand Up @@ -151,7 +139,6 @@ t.test('polling retry', async (t) => {
})

log = ''
warn = ''
delete profile.loginCouch
delete npmFetch.json
})
Expand All @@ -174,7 +161,6 @@ t.test('polling error', async (t) => {
)

log = ''
warn = ''
delete profile.loginCouch
delete npmFetch.json
})
Expand All @@ -193,7 +179,6 @@ t.test('no token retrieved from loginCouch', async (t) => {
)

log = ''
warn = ''
delete profile.loginCouch
})

Expand All @@ -211,7 +196,6 @@ t.test('no sso url retrieved from loginCouch', async (t) => {
)

log = ''
warn = ''
delete profile.loginCouch
})

Expand Down Expand Up @@ -247,7 +231,6 @@ t.test('scoped login', async (t) => {
)

log = ''
warn = ''
delete profile.loginCouch
delete npmFetch.json
})
7 changes: 2 additions & 5 deletions test/lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ t.test('with args, dev=true', async t => {
let REIFY_CALLED = false
let ARB_OBJ = null

const { npm, logs } = await loadMockNpm(t, {
const { npm } = await loadMockNpm(t, {
'@npmcli/run-script': ({ event }) => {
SCRIPTS.push(event)
},
Expand Down Expand Up @@ -41,10 +41,7 @@ t.test('with args, dev=true', async t => {
npm.prefix = path.resolve(t.testdir({}))

await npm.exec('install', ['fizzbuzz'])
t.match(
logs.warn,
[['install', 'Usage of the `--dev` option is deprecated. Use `--include=dev` instead.']]
)

t.match(
ARB_ARGS,
{ global: false, path: npm.prefix, auditLevel: null },
Expand Down