Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose topological sorting of packages via command or option #1652

Closed
jonrgold opened this issue Sep 4, 2018 · 3 comments · Fixed by opencomponents/base-templates#370 or JetBrains/ring-ui#525

Comments

@jonrgold
Copy link

jonrgold commented Sep 4, 2018

I'm hoping that we may be able to provide either a new command or a flag to ls to expose the topologically sorting of artifacts to a consumer.

Expected Behavior

  • lerna ls --toposort (or similar) could return a list of artifacts but in the topologically sorted behavior

Current Behavior

Currently exec / run support topological sorting, but there doesn't seem to be an easy way to the topologically sorted dependency structure via a command.

Right now to get that structure, we're using lerna exec $LERNA_PACKAGE_NAME.

Possible Solution

Context

We have a few use cases:

  1. Getting a high level view of the dependency structure in our mono-repo to assist in refactoring.
  2. Piping packages from this command into our own org-specific publish script that would already be sorted.

I think this is kind of similar to #610 . Was hoping it might be somewhat simple for me to create a PR where the results of batchPackages could be used to display this to user.

@evocateur
Copy link
Member

Yeah, totally. batchPackages is exactly the ticket, I would imagine a conditional between these two steps:

    chain = chain.then(() => getFilteredPackages(this.packageGraph, this.execOpts, this.options));

    if (this.options.toposort) {
      chain = chain.then(filteredPackages =>
        batchPackages(filteredPackages)
          // flatten batched packages for display
          .reduce((arr, batch) => arr.concat(batch), [])
      );
    }

    chain = chain.then(filteredPackages => {
      this.result = listable.format(filteredPackages, this.options);
    });

@morewry
Copy link

morewry commented Oct 19, 2018

This would be useful for me right now :-) I'm having an issue where a build is failing. In logs it appears that lerna run is moving on / concurrently running a dependent's build before its dependency's build is complete. Be nice to verify whether the sort is right to help rule things out.

For others, this modification of the command shared by OP worked:

npx lerna exec -- echo \$LERNA_PACKAGE_NAME

@lock
Copy link

lock bot commented Mar 7, 2019

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 Mar 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.