Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
111e284
[email protected]
ruyadorno Mar 18, 2021
33c8536
[email protected]
ruyadorno Mar 18, 2021
af7eaac
[email protected]
ruyadorno Mar 18, 2021
9166230
@npmcli/[email protected]
ruyadorno Mar 18, 2021
f06c12e
[email protected]
ruyadorno Mar 18, 2021
966057c
[email protected]
ruyadorno Mar 18, 2021
b395763
[email protected]
ruyadorno Mar 18, 2021
46e14bd
chore(config): remove flatOptions references
wraithgar Mar 9, 2021
8cce428
fix(publish): handle case where multiple config list is present
kenrick95 Mar 15, 2021
6598bfe
New consolidated config definitions
isaacs Mar 15, 2021
68db124
Auto-generate 'npm help 7 config' from actual definitions
isaacs Mar 15, 2021
f52c51d
@npmcli/[email protected]
isaacs Mar 15, 2021
7c89e74
update lib/*.js to use new config structures
isaacs Mar 15, 2021
aaafab8
Remove old config definitions and flattening logic
isaacs Mar 16, 2021
a8d0751
[email protected]
isaacs Mar 18, 2021
41facf6
feat(help): refactor npm help/help-search
wraithgar Mar 11, 2021
ad65bd9
docs(configuring-npm): Fix broken link
Mar 13, 2021
0a331ac
bump version in v7 bug template
jansepke Mar 15, 2021
78cb830
docs: add asdf-nodejs as a viable version manager
augustobmoura Mar 15, 2021
7e99515
chore: fix rebuild win tests
ruyadorno Mar 18, 2021
fc8a1ff
fix(tests): go back to mockNpm in test
wraithgar Mar 18, 2021
b419bfb
Update test-coverage command
chowkapow Mar 15, 2021
8a38afe
docs(package-json): document default main behavior
klausbayrhammer Mar 16, 2021
33c4189
feat: add run-script workspaces
ruyadorno Mar 7, 2021
d98edd1
restore npm.flatOptions.npmCommand
isaacs Mar 18, 2021
e94a458
fix(suggestions): clarify Unknown command output
wraithgar Mar 19, 2021
629aaf3
[email protected]
wraithgar Mar 22, 2021
b876442
fix(usage): tie usage to config
wraithgar Mar 19, 2021
e1b3b31
feat: add exec workspaces
ruyadorno Mar 7, 2021
93a061d
fix(usage): add action items to error output
wraithgar Mar 22, 2021
15ee1ae
fix: yes config
ruyadorno Mar 22, 2021
b7b4491
fix: which config
ruyadorno Mar 22, 2021
4fb6e2f
fix: npm birthday
ruyadorno Mar 22, 2021
1924eb4
[email protected]
wraithgar Mar 23, 2021
8e4621d
fix(run-script): remove log.disableProgress
ruyadorno Mar 23, 2021
f76e7c2
[email protected]
ruyadorno Mar 23, 2021
4928512
[email protected]
ruyadorno Mar 23, 2021
7b5606b
@npmcli/[email protected]
ruyadorno Mar 23, 2021
b043bf9
fix docs generation for yes config
ruyadorno Mar 23, 2021
7706557
docs: changelog for v7.7.0
ruyadorno Mar 23, 2021
0364be0
update AUTHORS
ruyadorno Mar 23, 2021
581b60b
7.7.0
ruyadorno Mar 23, 2021
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
Prev Previous commit
Next Next commit
chore(config): remove flatOptions references
Iterative change moving us towards a more unified config.
No longer pulling config from flatOptions where we don't have to.

PR-URL: #2892
Credit: @wraithgar
Close: #2892
Reviewed-by: @ruyadorno
  • Loading branch information
wraithgar authored and isaacs committed Mar 18, 2021
commit 46e14bd0ff566f94e8f86f9d972bf089c000da52
2 changes: 1 addition & 1 deletion lib/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Access extends BaseCommand {
if (!subcommands.includes(cmd) || !this[cmd])
throw this.usageError(`${cmd} is not a recognized subcommand.`)

return this[cmd](args, { ...this.npm.flatOptions })
return this[cmd](args, this.npm.flatOptions)
}

public ([pkg], opts) {
Expand Down
13 changes: 6 additions & 7 deletions lib/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,22 @@ class Audit extends BaseCommand {
}

async audit (args) {
const arb = new Arborist({
const reporter = this.npm.config.get('json') ? 'json' : 'detail'
const opts = {
...this.npm.flatOptions,
audit: true,
path: this.npm.prefix,
})
reporter,
}
const arb = new Arborist(opts)
const fix = args[0] === 'fix'
await arb.audit({ fix })
if (fix)
await reifyFinish(this.npm, arb)
else {
// will throw if there's an error, because this is an audit command
auditError(this.npm, arb.auditReport)
const reporter = this.npm.flatOptions.json ? 'json' : 'detail'
const result = auditReport(arb.auditReport, {
...this.npm.flatOptions,
reporter,
})
const result = auditReport(arb.auditReport, opts)
process.exitCode = process.exitCode || result.exitCode
this.npm.output(result.report)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Bin extends BaseCommand {
async bin (args) {
const b = this.npm.bin
this.npm.output(b)
if (this.npm.flatOptions.global && !envPath.includes(b))
if (this.npm.config.get('global') && !envPath.includes(b))
console.error('(not in PATH env variable)')
}
}
Expand Down
5 changes: 2 additions & 3 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Cache extends BaseCommand {
throw new Error('npm cache clear does not accept arguments')

const cachePath = path.join(this.npm.cache, '_cacache')
if (!this.npm.flatOptions.force) {
if (!this.npm.config.get('force')) {
throw new Error(`As of npm@5, the npm cache self-heals from corruption issues
by treating integrity mismatches as cache misses. As a result,
data extracted from the cache is guaranteed to be valid. If you
Expand Down Expand Up @@ -100,15 +100,14 @@ with --force.`)
throw Object.assign(new Error(usage), { code: 'EUSAGE' })

log.silly('cache add', 'spec', spec)
const opts = { ...this.npm.flatOptions }

// we ask pacote for the thing, and then just throw the data
// away so that it tee-pipes it into the cache like it does
// for a normal request.
await pacote.tarball.stream(spec, stream => {
stream.resume()
return stream.promise()
}, opts)
}, this.npm.flatOptions)
}

async verify () {
Expand Down
5 changes: 3 additions & 2 deletions lib/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ class CI extends BaseCommand {
}

async ci () {
if (this.npm.flatOptions.global) {
if (this.npm.config.get('global')) {
const err = new Error('`npm ci` does not work for global packages')
err.code = 'ECIGLOBAL'
throw err
}

const where = this.npm.prefix
const { scriptShell, ignoreScripts } = this.npm.flatOptions
const arb = new Arborist({ ...this.npm.flatOptions, path: where })

await Promise.all([
Expand All @@ -54,6 +53,7 @@ class CI extends BaseCommand {
// npm ci should never modify the lockfile or package.json
await arb.reify({ ...this.npm.flatOptions, save: false })

const ignoreScripts = this.npm.config.get('ignore-scripts')
// run the same set of scripts that `npm install` runs.
if (!ignoreScripts) {
const scripts = [
Expand All @@ -65,6 +65,7 @@ class CI extends BaseCommand {
'prepare',
'postprepare',
]
const scriptShell = this.npm.config.get('script-shell') || undefined
for (const event of scripts) {
await runScript({
path: where,
Expand Down
7 changes: 4 additions & 3 deletions lib/dedupe.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ class Dedupe extends BaseCommand {

const dryRun = this.npm.config.get('dry-run')
const where = this.npm.prefix
const arb = new Arborist({
const opts = {
...this.npm.flatOptions,
path: where,
dryRun,
})
await arb.dedupe(this.npm.flatOptions)
}
const arb = new Arborist(opts)
await arb.dedupe(opts)
await reifyFinish(this.npm, arb)
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Diff extends BaseCommand {

get where () {
const globalTop = resolve(this.npm.globalDir, '..')
const { global } = this.npm.flatOptions
const global = this.npm.config.get('global')
return global ? globalTop : this.npm.prefix
}

Expand All @@ -39,7 +39,7 @@ class Diff extends BaseCommand {
}

async diff (args) {
const specs = this.npm.flatOptions.diff.filter(d => d)
const specs = this.npm.config.get('diff').filter(d => d)
if (specs.length > 2) {
throw new TypeError(
'Can\'t use more than two --diff arguments.\n\n' +
Expand Down Expand Up @@ -91,7 +91,7 @@ class Diff extends BaseCommand {
}

return [
`${pkgName}@${this.npm.flatOptions.defaultTag}`,
`${pkgName}@${this.npm.config.get('tag')}`,
`file:${this.npm.prefix}`,
]
}
Expand Down
2 changes: 1 addition & 1 deletion lib/dist-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class DistTag extends BaseCommand {
async add (spec, tag, opts) {
spec = npa(spec || '')
const version = spec.rawSpec
const defaultTag = tag || opts.defaultTag
const defaultTag = tag || this.npm.config.get('tag')

log.verbose('dist-tag add', defaultTag, 'to', spec.name + '@' + version)

Expand Down
11 changes: 7 additions & 4 deletions lib/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const BaseCommand = require('./base-command.js')
//
// npm x -p pkg@version -- foo --registry=/dev/null
//
// const pkg = npm.flatOptions.package || getPackageFrom(args[0])
// const pkg = npm.config.get('package') || getPackageFrom(args[0])
// const cmd = getCommand(pkg, args[0])
// --> npm x -c 'cmd ...args.slice(1)'
//
Expand Down Expand Up @@ -66,7 +66,10 @@ class Exec extends BaseCommand {
// When commands go async and we can dump the boilerplate exec methods this
// can be named correctly
async _exec (args) {
const { package: packages, call, shell } = this.npm.flatOptions
const call = this.npm.config.get('call')
const shell = this.npm.config.get('shell')
// dereferenced because we manipulate it later
const packages = [...this.npm.config.get('package')]

if (call && args.length)
throw this.usage
Expand Down Expand Up @@ -165,9 +168,9 @@ class Exec extends BaseCommand {

// no need to install if already present
if (add.length) {
if (!this.npm.flatOptions.yes) {
if (!this.npm.config.get('yes')) {
// set -n to always say no
if (this.npm.flatOptions.yes === false)
if (this.npm.config.get('yes') === false)
throw 'canceled'

if (!process.stdin.isTTY || ciDetect()) {
Expand Down
25 changes: 10 additions & 15 deletions lib/fund.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ class Fund extends BaseCommand {
}

async fund (args) {
const opts = this.npm.flatOptions
const spec = args[0]
const numberArg = opts.which
const numberArg = this.npm.config.get('which')

const fundingSourceNumber = numberArg && parseInt(numberArg, 10)

Expand All @@ -58,14 +57,14 @@ class Fund extends BaseCommand {
throw err
}

if (opts.global) {
if (this.npm.config.get('global')) {
const err = new Error('`npm fund` does not support global packages')
err.code = 'EFUNDGLOBAL'
throw err
}

const where = this.npm.prefix
const arb = new Arborist({ ...opts, path: where })
const arb = new Arborist({ ...this.npm.flatOptions, path: where })
const tree = await arb.loadActual()

if (spec) {
Expand All @@ -78,23 +77,19 @@ class Fund extends BaseCommand {
return
}

const print = opts.json
? this.printJSON
: this.printHuman

this.npm.output(
print(
getFundingInfo(tree),
opts
)
)
if (this.npm.config.get('json'))
this.npm.output(this.printJSON(getFundingInfo(tree)))
else
this.npm.output(this.printHuman(getFundingInfo(tree)))
}

printJSON (fundingInfo) {
return JSON.stringify(fundingInfo, null, 2)
}

printHuman (fundingInfo, { color, unicode }) {
printHuman (fundingInfo) {
const color = !!this.npm.color
const unicode = this.npm.config.get('unicode')
const seenUrls = new Map()

const tree = obj =>
Expand Down
4 changes: 2 additions & 2 deletions lib/help-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class HelpSearch extends BaseCommand {
out.push(' '.repeat((Math.max(1, cols - out.join(' ').length - r.length - 1))))
out.push(r)

if (!this.npm.flatOptions.long)
if (!this.npm.config.get('long'))
return out.join('')

out.unshift('\n\n')
Expand Down Expand Up @@ -198,7 +198,7 @@ class HelpSearch extends BaseCommand {
return out.join('')
}).join('\n')

const finalOut = results.length && !this.npm.flatOptions.long
const finalOut = results.length && !this.npm.config.get('long')
? 'Top hits for ' + (args.map(JSON.stringify).join(' ')) + '\n' +
'—'.repeat(cols - 1) + '\n' +
out + '\n' +
Expand Down
2 changes: 1 addition & 1 deletion lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Init extends BaseCommand {
this.npm.log.pause()
this.npm.log.disableProgress()
const initFile = this.npm.config.get('init-module')
if (!this.npm.flatOptions.yes && !this.npm.flatOptions.force) {
if (!this.npm.config.get('yes') && !this.npm.config.get('force')) {
this.npm.output([
'This utility will walk you through creating a package.json file.',
'It only covers the most common items, and tries to guess sensible defaults.',
Expand Down
5 changes: 3 additions & 2 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class Install extends BaseCommand {
async install (args) {
// the /path/to/node_modules/..
const globalTop = resolve(this.npm.globalDir, '..')
const { ignoreScripts, global: isGlobalInstall } = this.npm.flatOptions
const ignoreScripts = this.npm.config.get('ignore-scripts')
const isGlobalInstall = this.npm.config.get('global')
const where = isGlobalInstall ? globalTop : this.npm.prefix

// don't try to install the prefix into itself
Expand All @@ -122,7 +123,7 @@ class Install extends BaseCommand {
add: args,
})
if (!args.length && !isGlobalInstall && !ignoreScripts) {
const { scriptShell } = this.npm.flatOptions
const scriptShell = this.npm.config.get('script-shell') || undefined
const scripts = [
'preinstall',
'install',
Expand Down
8 changes: 7 additions & 1 deletion lib/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ class Link extends BaseCommand {
// npm link should not save=true by default unless you're
// using any of --save-dev or other types
const save =
Boolean(this.npm.config.find('save') !== 'default' || this.npm.flatOptions.saveType)
Boolean(
this.npm.config.find('save') !== 'default' ||
this.npm.config.get('save-optional') ||
this.npm.config.get('save-peer') ||
this.npm.config.get('save-dev') ||
this.npm.config.get('save-prod')
)

// create a new arborist instance for the local prefix and
// reify all the pending names as symlinks there
Expand Down
5 changes: 3 additions & 2 deletions lib/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ class Logout extends BaseCommand {
}

async logout (args) {
const { registry, scope } = this.npm.flatOptions
const registry = this.npm.config.get('registry')
const scope = this.npm.config.get('scope')
const regRef = scope ? `${scope}:registry` : 'registry'
const reg = this.npm.flatOptions[regRef] || registry
const reg = this.npm.config.get(regRef) || registry

const auth = getAuth(reg, this.npm.flatOptions)

Expand Down
22 changes: 10 additions & 12 deletions lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,22 @@ class LS extends BaseCommand {
}

async ls (args) {
const {
all,
color,
depth,
json,
long,
global,
parseable,
prefix,
unicode,
} = this.npm.flatOptions
const path = global ? resolve(this.npm.globalDir, '..') : prefix
const all = this.npm.config.get('all')
const color = !!this.npm.color
const depth = this.npm.config.get('depth')
const dev = this.npm.config.get('dev')
const development = this.npm.config.get('development')
const global = this.npm.config.get('global')
const json = this.npm.config.get('json')
const link = this.npm.config.get('link')
const long = this.npm.config.get('long')
const only = this.npm.config.get('only')
const parseable = this.npm.config.get('parseable')
const prod = this.npm.config.get('prod')
const production = this.npm.config.get('production')
const unicode = this.npm.config.get('unicode')

const path = global ? resolve(this.npm.globalDir, '..') : this.npm.prefix

const arb = new Arborist({
global,
Expand Down
Loading