Skip to content

Commit 2e204af

Browse files
committed
feat(list): Improve scriptability with several new options
BREAKING CHANGE: The default output of `lerna ls` no longer shows version strings or private packages. * The new alias `lerna la` resembles the old output, with the addition of relative path to the package * The new alias `lerna ll` is a shortcut for the new `--long` option * A new `--parseable` option has been added to aid magical piping incantations
1 parent 8b97394 commit 2e204af

12 files changed

Lines changed: 519 additions & 179 deletions

File tree

‎commands/list/README.md‎

Lines changed: 86 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,108 @@
44
55
## Usage
66

7+
The `list` subcommand is aliased to several convenient shorthands (similar to [`npm ls`](https://docs.npmjs.com/cli/ls)):
8+
9+
* `lerna ls`: Identical to `lerna list`, which is itself analogous to the `ls` command
10+
* `lerna ll`: Equivalent to `lerna ls -l`, showing [long](#--long) output
11+
* `lerna la`: Equivalent to `lerna ls -la`, showing [all](#--all) packages (including private ones)
12+
713
```sh
8-
# The following commands are identical:
9-
$ lerna list
1014
$ lerna ls
15+
package-1
16+
package-2
1117
```
1218

13-
List all of the public packages in the current Lerna repo.
19+
You might notice extra logging from `lerna` when running these commands in your shell.
20+
Rest assured they will not infect your piped incantations,
21+
as all logs are emitted to `stderr`, not `stdout`.
22+
23+
In any case, you can always pass `--loglevel silent` to create pristine chains of magical shell wizardry.
1424

1525
## Options
1626

1727
`lerna ls` respects the `--ignore` and `--scope` flags (see [Filter Flags](https://www.npmjs.com/package/@lerna/filter-options)).
1828

1929
### --json
2030

31+
Show information as a JSON array.
32+
2133
```sh
2234
$ lerna ls --json
23-
```
24-
25-
When run with this flag, `ls` will return an array of objects in the following format:
26-
27-
```json
2835
[
2936
{
30-
"name": "package",
37+
"name": "package-1",
38+
"version": "1.0.0",
39+
"private": false,
40+
"location": "/path/to/packages/pkg-1/"
41+
},
42+
{
43+
"name": "package-2",
3144
"version": "1.0.0",
32-
"private": false
45+
"private": false,
46+
"location": "/path/to/packages/pkg-2/"
3347
}
3448
]
3549
```
50+
51+
**Tip:** Pipe to the [`json`](http://trentm.com/json/) utility to pick out individual properties:
52+
53+
```sh
54+
$ lerna ls --json --all | json -a -c 'this.private === true' name
55+
package-3
56+
```
57+
58+
### --all
59+
60+
Alias: `-a`
61+
62+
Show private packages that are hidden by default.
63+
64+
```sh
65+
$ lerna ls --all
66+
package-1
67+
package-2
68+
package-3 (private)
69+
```
70+
71+
### --long
72+
73+
Alias: `-l`
74+
75+
Show extended information.
76+
77+
```sh
78+
$ lerna ls --long
79+
package-1 v1.0.1 packages/pkg-1
80+
package-2 v1.0.2 packages/pkg-2
81+
82+
$ lerna ls -la
83+
package-1 v1.0.1 packages/pkg-1
84+
package-2 v1.0.2 packages/pkg-2
85+
package-3 v1.0.3 packages/pkg-3 (private)
86+
```
87+
88+
### --parseable
89+
90+
Alias: `-p`
91+
92+
Show parseable output instead of columnified view.
93+
94+
By default, each line of the output is an absolute path to a package.
95+
96+
In `--long` output, each line is a `:`-separated list: `<fullpath>:<name>:<version>[:flags..]`
97+
98+
```sh
99+
$ lerna ls --parseable
100+
/path/to/packages/pkg-1
101+
/path/to/packages/pkg-2
102+
103+
$ lerna ls -pl
104+
/path/to/packages/pkg-1:package-1:1.0.1
105+
/path/to/packages/pkg-2:package-2:1.0.2
106+
107+
$ lerna ls -pla
108+
/path/to/packages/pkg-1:package-1:1.0.1
109+
/path/to/packages/pkg-2:package-2:1.0.2
110+
/path/to/packages/pkg-3:package-3:1.0.3:PRIVATE
111+
```

‎commands/list/__tests__/__snapshots__/list-command.test.js.snap‎

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)