provide a way to list lerna deps as an adjacency matrix#1970
Closed
yacineb wants to merge 3 commits intolerna:masterfrom
Closed
provide a way to list lerna deps as an adjacency matrix#1970yacineb wants to merge 3 commits intolerna:masterfrom
yacineb wants to merge 3 commits intolerna:masterfrom
Conversation
Member
|
This seems a bit too special-cased to be a top-level CLI option, better suited for a third-party tool that reuses existing lerna packages. #!/usr/bin/env node
const { getPackages } = require('@lerna/project');
const PackageGraph = require('@lerna/package-graph');
(async function () {
const cwd = process.cwd(); // or process.argv?
const pkgs = await getPackages(cwd);
const graph = new PackageGraph(pkgs);
const json = {};
graph.forEach((node, name) => {
json[name] = [
...node.externalDependencies.keys(),
...node.localDependencies.keys(),
].sort();
});
console.log(JSON.stringify(json, null, 2));
})();Copy that code, paste it into a script file, and you can get output like this (when run on the lerna source): Adjacency graph of |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
For large monorepo there is a need to show packages dependencies , i added a 'graph' option to lerna 'list' command in order to print out a json showing dependencies for each package.
Dependency graph could then be rendered using a nice tool such as https://www.npmjs.com/package/dependo
Types of changes
Checklist: