Skip to content

[Feature] Add --scope to LsCommand to determine which packages are being depended upon#384

Closed
Steven-Evans wants to merge 5 commits intolerna:masterfrom
Steven-Evans:feature-lsscope
Closed

[Feature] Add --scope to LsCommand to determine which packages are being depended upon#384
Steven-Evans wants to merge 5 commits intolerna:masterfrom
Steven-Evans:feature-lsscope

Conversation

@Steven-Evans
Copy link
Copy Markdown

@Steven-Evans Steven-Evans commented Oct 19, 2016

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.

Steven Evans added 3 commits October 18, 2016 14:54
…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
Comment thread src/PackageUtilities.js Outdated
dependencies = filteredGraph.get(pkg).dependencies;

dependencies.forEach((dependency) => {
if (!~dependentPackages.indexOf(dependency) && !~fringe.indexOf(dependency)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using !~ in these three places could you do this instead:

dependentPackages.indexOf(dependency) < 0

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jamiebuilds
Copy link
Copy Markdown
Contributor

Instead of using scope it makes more sense of me to use:

lerna ls [package]

@lukebatchelor
Copy link
Copy Markdown
Contributor

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 ls [package] performed a different function. Do you think this could be a separate command? lerna deps [package] maybe?

Happy to change my PR, I only need the bootstrap --scope support but the refactoring made it nice to deduplicate repeated logic and inconsistent handling.

@lukebatchelor
Copy link
Copy Markdown
Contributor

I'm about to start work on #388 and the filterNonDependentPackages function looks like it will be super useful for that, so I'm probably going to merge this into that.

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

Comment thread src/PackageUtilities.js

return packages.filter((pkg) =>
dependentPackages.indexOf(pkg.name) >= 0
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to slice here so we always return a copy (as in the other filter functions)

Comment thread src/commands/LsCommand.js
export default class LsCommand extends Command {
initialize(callback) {
// Nothing to do...
if (this.input.length) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jamiebuilds jamiebuilds changed the title Add --scope to LsCommand to determine which packages are being depended upon [Feature] Add --scope to LsCommand to determine which packages are being depended upon Nov 16, 2016
@hzoo
Copy link
Copy Markdown
Contributor

hzoo commented Jan 26, 2017

I guess this was done in #386 already? Thanks for the work thou!

@hzoo hzoo closed this Jan 26, 2017
@lock
Copy link
Copy Markdown

lock Bot commented Dec 27, 2018

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.

@lock lock Bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants