Skip to content

Commit

Permalink
feat(config): warn on deprecated configs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys authored and fritzy committed Apr 13, 2022
1 parent aa4a4da commit c057b90
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 34 deletions.
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
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

0 comments on commit c057b90

Please sign in to comment.