Skip to content

Commit

Permalink
feat(ls): rename virtual flag to package-lock-only
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Jun 14, 2021
1 parent d6d15d7 commit 509f0fb
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 37 deletions.
10 changes: 5 additions & 5 deletions lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class LS extends ArboristWorkspaceCmd {
'depth',
'omit',
'link',
'virtual',
'package-lock-only',
'unicode',
...super.params,
]
Expand Down Expand Up @@ -80,7 +80,7 @@ class LS extends ArboristWorkspaceCmd {
const prod = this.npm.config.get('prod')
const production = this.npm.config.get('production')
const unicode = this.npm.config.get('unicode')
const virtual = this.npm.config.get('virtual')
const packageLockOnly = this.npm.config.get('package-lock-only')

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

Expand All @@ -90,7 +90,7 @@ class LS extends ArboristWorkspaceCmd {
legacyPeerDeps: false,
path,
})
const tree = await this.initTree({arb, args, virtual })
const tree = await this.initTree({arb, args, packageLockOnly })

// filters by workspaces nodes when using -w <workspace-name>
// We only have to filter the first layer of edges, so we don't
Expand Down Expand Up @@ -218,9 +218,9 @@ class LS extends ArboristWorkspaceCmd {
}
}

async initTree ({ arb, args, virtual }) {
async initTree ({ arb, args, packageLockOnly }) {
const tree = await (
virtual
packageLockOnly
? arb.loadVirtual()
: arb.loadActual()
)
Expand Down
19 changes: 8 additions & 11 deletions lib/utils/config/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1333,8 +1333,14 @@ define('package-lock-only', {
default: false,
type: Boolean,
description: `
If set to true, it will update only the \`package-lock.json\`, instead of
checking \`node_modules\` and downloading dependencies.
If set to true, the current operation will only use the \`package-lock.json\`,
ignoring \`node_modules\`.
For \`update\` this means only the \`package-lock.json\` will be updated,
instead of checking \`node_modules\` and downloading dependencies.
For \`list\` this means the output will be based on the tree described by the
\`package-lock.json\`, rather than the contents of \`node_modules\`.
`,
flatten,
})
Expand Down Expand Up @@ -2054,15 +2060,6 @@ define('viewer', {
`,
})

define('virtual', {
default: false,
type: Boolean,
description: `
Operates in "virtual" mode, meaning that the dependency tree is based off
the lockfile rather than the contents of \`node_modules\`.
`,
})

define('which', {
default: null,
hint: '<fundingSourceNumber>',
Expand Down
4 changes: 2 additions & 2 deletions tap-snapshots/test/lib/load-all-commands.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ npm ll [[<@scope>/]<pkg> ...]
Options:
[-a|--all] [--json] [-l|--long] [-p|--parseable] [-g|--global] [--depth <depth>]
[--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]] [--link]
[--virtual] [--unicode]
[--package-lock-only] [--unicode]
[-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
[-ws|--workspaces]
Expand Down Expand Up @@ -588,7 +588,7 @@ npm ls npm ls [[<@scope>/]<pkg> ...]
Options:
[-a|--all] [--json] [-l|--long] [-p|--parseable] [-g|--global] [--depth <depth>]
[--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]] [--link]
[--virtual] [--unicode]
[--package-lock-only] [--unicode]
[-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
[-ws|--workspaces]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ Array [
"version",
"versions",
"viewer",
"virtual",
"which",
"workspace",
"workspaces",
Expand Down
18 changes: 8 additions & 10 deletions tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,14 @@ package-locks disabled use \`npm prune\`.
* Default: false
* Type: Boolean
If set to true, it will update only the \`package-lock.json\`, instead of
checking \`node_modules\` and downloading dependencies.
If set to true, the current operation will only use the \`package-lock.json\`,
ignoring \`node_modules\`.
For \`update\` this means only the \`package-lock.json\` will be updated,
instead of checking \`node_modules\` and downloading dependencies.
For \`list\` this means the output will be based on the tree described by the
\`package-lock.json\`, rather than the contents of \`node_modules\`.
#### \`parseable\`
Expand Down Expand Up @@ -1211,14 +1217,6 @@ The program to use to view help content.
Set to \`"browser"\` to view html help content in the default web browser.
#### \`virtual\`
* Default: false
* Type: Boolean
Operates in "virtual" mode, meaning that the dependency tree is based off
the lockfile rather than the contents of \`node_modules\`.
#### \`which\`
* Default: null
Expand Down
4 changes: 2 additions & 2 deletions tap-snapshots/test/lib/utils/npm-usage.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ All commands:
Options:
[-a|--all] [--json] [-l|--long] [-p|--parseable] [-g|--global] [--depth <depth>]
[--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]] [--link]
[--virtual] [--unicode]
[--package-lock-only] [--unicode]
[-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
[-ws|--workspaces]
Expand Down Expand Up @@ -683,7 +683,7 @@ All commands:
Options:
[-a|--all] [--json] [-l|--long] [-p|--parseable] [-g|--global] [--depth <depth>]
[--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]] [--link]
[--virtual] [--unicode]
[--package-lock-only] [--unicode]
[-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
[-ws|--workspaces]
Expand Down
12 changes: 6 additions & 6 deletions test/lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const config = {
only: null,
parseable: false,
production: false,
virtual: false,
'package-lock-only': false,
}
const flatOptions = {
}
Expand Down Expand Up @@ -4154,9 +4154,9 @@ t.test('ls --json', (t) => {
t.end()
})

t.test('ls --virtual', (t) => {
config.virtual = true
t.test('ls --virtual --json', (t) => {
t.test('ls --package-lock-only', (t) => {
config['package-lock-only'] = true
t.test('ls --package-lock-only --json', (t) => {
t.beforeEach(cleanUpResult)
config.json = true
config.parseable = false
Expand Down Expand Up @@ -4724,15 +4724,15 @@ t.test('ls --virtual', (t) => {
name: 'test-npm-ls',
version: '1.0.0',
problems: [
'invalid: foo@1.0.0 {CWD}/tap-testdir-ls-ls---virtual-ls---virtual---json-missing-invalid-extraneous/node_modules/foo',
'invalid: foo@1.0.0 {CWD}/tap-testdir-ls-ls---package-lock-only-ls---package-lock-only---json-missing-invalid-extraneous/node_modules/foo',
'missing: ipsum@^1.0.0, required by test-npm-ls@1.0.0',
],
dependencies: {
foo: {
version: '1.0.0',
invalid: true,
problems: [
'invalid: foo@1.0.0 {CWD}/tap-testdir-ls-ls---virtual-ls---virtual---json-missing-invalid-extraneous/node_modules/foo',
'invalid: foo@1.0.0 {CWD}/tap-testdir-ls-ls---package-lock-only-ls---package-lock-only---json-missing-invalid-extraneous/node_modules/foo',
],
dependencies: {
dog: {
Expand Down

0 comments on commit 509f0fb

Please sign in to comment.