[Feature] Add --scope to LsCommand to determine which packages are being depended upon#384
[Feature] Add --scope to LsCommand to determine which packages are being depended upon#384Steven-Evans wants to merge 5 commits intolerna:masterfrom
--scope to LsCommand to determine which packages are being depended upon#384Conversation
…pe depends on Useful for scripting and deciding which packages are needed for a particular package instead of bootstrapping all packages in a monorepo. Uses a breadth-first search on the package graph to determine the dependencies.
Removing Set requires this check be added
| dependencies = filteredGraph.get(pkg).dependencies; | ||
|
|
||
| dependencies.forEach((dependency) => { | ||
| if (!~dependentPackages.indexOf(dependency) && !~fringe.indexOf(dependency)) { |
There was a problem hiding this comment.
Instead of using !~ in these three places could you do this instead:
dependentPackages.indexOf(dependency) < 0There was a problem hiding this comment.
Yep. It's definitely less cryptic than !~.
Any plans to use ES7? It includes Array.prototype.includes which would be the ideal solution to checking for existence.
|
Instead of using scope it makes more sense of me to use: lerna ls [package] |
|
Ah, I commented on #381 and didnt even think about it when I was doing #386, so these would be conflicting. I added --scope and --ignore support for bootstrap, exec, run, clean and ls to make them more consistent. As the original ls command listed packages I would find it strange that Happy to change my PR, I only need the |
|
I'm about to start work on #388 and the I'm a little hesitant to do more work based on non-merged PRs but I think #384, #386, and #365 all look like they make sense, so hopefully are accepted |
|
|
||
| return packages.filter((pkg) => | ||
| dependentPackages.indexOf(pkg.name) >= 0 | ||
| ); |
There was a problem hiding this comment.
You probably want to slice here so we always return a copy (as in the other filter functions)
| export default class LsCommand extends Command { | ||
| initialize(callback) { | ||
| // Nothing to do... | ||
| if (this.input.length) { |
There was a problem hiding this comment.
I'm not sure why you need to do all this work. You should already have the package graph which will allow you to find the tree of dependencies of a single package.
--scope to LsCommand to determine which packages are being depended upon--scope to LsCommand to determine which packages are being depended upon
|
I guess this was done in #386 already? Thanks for the work thou! |
|
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Issue: #381
Previous PR: #382
Uses breadth-first search on the packageGraph to determine dependent packages.
Removed dashes from output for easier cli parsing.
Removed quiet flag from previous pull request. It would have silenced the lerna version line of output but that should be it's own feature.