-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Dependency usage CLI #198920
Dependency usage CLI #198920
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on this so far. I like your structure and formatting of the CLI options, and I found it particularly useful to switch between the two implementations when reviewing. I left feedback based on my initial testing.
ea06915
to
e7140e0
Compare
/ci |
3 similar comments
/ci |
/ci |
/ci |
@elasticmachine merge upstream |
merge conflict between base and head |
a5d8bfa
to
5d82424
Compare
/ci |
1 similar comment
/ci |
ad02e21
to
f825ee3
Compare
/ci |
1 similar comment
/ci |
d1dc9c5
to
60103aa
Compare
/ci |
60103aa
to
17ee705
Compare
/ci |
@elasticmachine merge upstream |
/ci |
1 similar comment
/ci |
/ci |
59285f1
to
dd8fade
Compare
💚 Build Succeeded
Metrics [docs]Unknown metric groupsAPI count
ESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
|
…bana into 196767-dependency-usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the additional feature! This is awesome.
@elasticmachine merge upstream |
export const excludePaths = [ | ||
'(^|/)target($|/)', | ||
'^kbn', | ||
'^@kbn', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these excluded from searches? don't we use kbn-* packages often as wrappers around dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just excludes the outbound vertex of the dependency graph while aggregating results, since we are not interested in listing internal packages for the main output.
If we want to know which external packages the kbn-* package has we can still run
bash scripts/dependency_usage.sh -p packages/kbn-some-package
don't we use kbn-* packages often as wrappers around dependencies
Not every package is a wrapper, sometimes it's just types or development only package, like kbn-dev-utils
, kbn-eslint-*
etc
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/12010686533 |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
## Summary [dependency-cruiser](https://github.com/sverweij/dependency-cruiser/tree/main) is used for building dependency graph. ### Show all dependencies for a specific package/plugin or directory #### Run for all plugins ```bash bash scripts/dependency_usage.sh -p x-pack/plugins -o ./tmp/deps-result-all.json ``` #### Run for single plugin ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -o ./tmp/deps-result-single.json ``` #### Run for multiple plugins ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution x-pack/plugins/security -o ./tmp/deps-result-multiple.json ``` #### Run for `x-pack/packages` ```bash bash scripts/dependency_usage.sh -p x-pack/packages -o ./tmp/deps-packages-1.json ``` #### Run for `packages` ```bash bash scripts/dependency_usage.sh -p packages -o ./tmp/deps-packages-2.json ``` #### Benchmark | Analysis | Real Time | User Time | Sys Time | |-----------------------|-------------|-------------|------------| | All plugins | 7m 21.126s | 7m 53.099s | 20.581s | | Single plugin | 31.360s | 45.352s | 2.208s | | Multiple plugins | 36.403s | 50.563s | 2.814s | | x-pack/packages | 6.638s | 12.646s | 0.654s | | packages | 25.744s | 39.073s | 2.191s | #### Show all packages/plugins within a directory that use a specific dependency ```sh bash scripts/dependency_usage.sh -d rxjs -p x-pack/plugins/security_solution ``` --- #### Show all packages/plugins within a directory grouped by code owner ```sh bash scripts/dependency_usage.sh -d rxjs -p x-pack/plugins -g owner ``` --- #### Group by code owner with adjustable collapse depth for fine-grained grouping **Fine-grained grouping**: ```sh bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -g owner --collapse-depth 4 ``` **Collapsed grouping**: groups the results under a higher-level owner (e.g., `security_solution` as a single group). ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -g owner --collapse-depth 1 ``` --- #### Show all dependencies matching a pattern (e.g., `react-*`) within a package ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -d 'react-*' -o ./tmp/result.json ``` ### Checklist - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios __Related: https://github.com/elastic/kibana/issues/196767__ --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit 34bf83b) # Conflicts: # .github/CODEOWNERS
## Summary Backport of #198920
## Summary [dependency-cruiser](https://github.com/sverweij/dependency-cruiser/tree/main) is used for building dependency graph. ### Show all dependencies for a specific package/plugin or directory #### Run for all plugins ```bash bash scripts/dependency_usage.sh -p x-pack/plugins -o ./tmp/deps-result-all.json ``` #### Run for single plugin ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -o ./tmp/deps-result-single.json ``` #### Run for multiple plugins ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution x-pack/plugins/security -o ./tmp/deps-result-multiple.json ``` #### Run for `x-pack/packages` ```bash bash scripts/dependency_usage.sh -p x-pack/packages -o ./tmp/deps-packages-1.json ``` #### Run for `packages` ```bash bash scripts/dependency_usage.sh -p packages -o ./tmp/deps-packages-2.json ``` #### Benchmark | Analysis | Real Time | User Time | Sys Time | |-----------------------|-------------|-------------|------------| | All plugins | 7m 21.126s | 7m 53.099s | 20.581s | | Single plugin | 31.360s | 45.352s | 2.208s | | Multiple plugins | 36.403s | 50.563s | 2.814s | | x-pack/packages | 6.638s | 12.646s | 0.654s | | packages | 25.744s | 39.073s | 2.191s | #### Show all packages/plugins within a directory that use a specific dependency ```sh bash scripts/dependency_usage.sh -d rxjs -p x-pack/plugins/security_solution ``` --- #### Show all packages/plugins within a directory grouped by code owner ```sh bash scripts/dependency_usage.sh -d rxjs -p x-pack/plugins -g owner ``` --- #### Group by code owner with adjustable collapse depth for fine-grained grouping **Fine-grained grouping**: ```sh bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -g owner --collapse-depth 4 ``` **Collapsed grouping**: groups the results under a higher-level owner (e.g., `security_solution` as a single group). ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -g owner --collapse-depth 1 ``` --- #### Show all dependencies matching a pattern (e.g., `react-*`) within a package ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -d 'react-*' -o ./tmp/result.json ``` ### Checklist - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios __Related: https://github.com/elastic/kibana/issues/196767__ --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
Backported in #201815 |
## Summary [dependency-cruiser](https://github.com/sverweij/dependency-cruiser/tree/main) is used for building dependency graph. ### Show all dependencies for a specific package/plugin or directory #### Run for all plugins ```bash bash scripts/dependency_usage.sh -p x-pack/plugins -o ./tmp/deps-result-all.json ``` #### Run for single plugin ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -o ./tmp/deps-result-single.json ``` #### Run for multiple plugins ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution x-pack/plugins/security -o ./tmp/deps-result-multiple.json ``` #### Run for `x-pack/packages` ```bash bash scripts/dependency_usage.sh -p x-pack/packages -o ./tmp/deps-packages-1.json ``` #### Run for `packages` ```bash bash scripts/dependency_usage.sh -p packages -o ./tmp/deps-packages-2.json ``` #### Benchmark | Analysis | Real Time | User Time | Sys Time | |-----------------------|-------------|-------------|------------| | All plugins | 7m 21.126s | 7m 53.099s | 20.581s | | Single plugin | 31.360s | 45.352s | 2.208s | | Multiple plugins | 36.403s | 50.563s | 2.814s | | x-pack/packages | 6.638s | 12.646s | 0.654s | | packages | 25.744s | 39.073s | 2.191s | #### Show all packages/plugins within a directory that use a specific dependency ```sh bash scripts/dependency_usage.sh -d rxjs -p x-pack/plugins/security_solution ``` --- #### Show all packages/plugins within a directory grouped by code owner ```sh bash scripts/dependency_usage.sh -d rxjs -p x-pack/plugins -g owner ``` --- #### Group by code owner with adjustable collapse depth for fine-grained grouping **Fine-grained grouping**: ```sh bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -g owner --collapse-depth 4 ``` **Collapsed grouping**: groups the results under a higher-level owner (e.g., `security_solution` as a single group). ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -g owner --collapse-depth 1 ``` --- #### Show all dependencies matching a pattern (e.g., `react-*`) within a package ```bash bash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -d 'react-*' -o ./tmp/result.json ``` ### Checklist - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios __Related: https://github.com/elastic/kibana/issues/196767__ --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
Summary
dependency-cruiser is used for building dependency graph.
Show all dependencies for a specific package/plugin or directory
Run for all plugins
Run for single plugin
Run for multiple plugins
Run for
x-pack/packages
Run for
packages
Benchmark
Show all packages/plugins within a directory that use a specific dependency
Show all packages/plugins within a directory grouped by code owner
Group by code owner with adjustable collapse depth for fine-grained grouping
Fine-grained grouping:
Collapsed grouping: groups the results under a higher-level owner (e.g.,
security_solution
as a single group).Show all dependencies matching a pattern (e.g.,
react-*
) within a packagebash scripts/dependency_usage.sh -p x-pack/plugins/security_solution -d 'react-*' -o ./tmp/result.json
Checklist
Related: #196767