kibana/packages/kbn-dependency-ownership
Larry Gregory 395e49484e
Add check to fail CI if any dependencies are unowned (#206679)
## Summary
- Updates `scripts/dependency_ownership` to use the
`@kbn/dev-cli-runner` for consistency with other CI-related CLIs.
- Adds a new `failIfUnowned` flag to exit with an error code if any
dependencies are unowned.
- Adds a new dependency ownership check to `quick_checks` and `renovate`
CI steps.


From a CI run, the additional quick check executes successfully in 3
seconds:
```sh
info [quick-checks] Passed check: /opt/buildkite-agent/builds/bk-agent-prod-gcp-abc123/elastic/kibana-pull-request/kibana/.buildkite/scripts/steps/checks/dependencies_missing_owner.sh in 3s
```

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2025-01-16 09:59:04 -05:00
..
bin Dependency Ownership CLI (#201773) 2024-11-29 17:18:36 +01:00
src Add check to fail CI if any dependencies are unowned (#206679) 2025-01-16 09:59:04 -05:00
jest.config.js Dependency Ownership CLI (#201773) 2024-11-29 17:18:36 +01:00
kibana.jsonc Dependency Ownership CLI (#201773) 2024-11-29 17:18:36 +01:00
package.json Dependency Ownership CLI (#201773) 2024-11-29 17:18:36 +01:00
README.md Dependency Ownership CLI (#201773) 2024-11-29 17:18:36 +01:00
tsconfig.json Add check to fail CI if any dependencies are unowned (#206679) 2025-01-16 09:59:04 -05:00

@kbn/dependency-ownership

A CLI tool for analyzing package ownership.


Table of Contents

  1. Show all packages owned by a specific team
  2. Show who owns specific dependency
  3. List all dependencies with without owner
  4. Generate dependency ownership report

1. Show all packages owned by a specific team

Use this command to list all packages or plugins within a directory that use a specified dependency.

node scripts/dependency_ownership -o <owner>

or

node scripts/dependency_ownership --owner <owner>

Example:

node scripts/dependency_ownership -o @elastic/kibana-core
  • -o @elastic/kibana-core: Specifies the team.

Output: Lists dev and prod dependencies.

{
  "prodDependencies": [
    "<dependency_1>",
    "<dependency_2>",
    "<dependency_3>",
    //...
  ],
  "devDependencies": [
    "<dependency_1>",
    "<dependency_2>",
    //...
  ]
}

2. Show who owns specific dependency

Get the owner for a specific dependency.

node scripts/dependency_ownership -d <dependency>

or

node scripts/dependency_ownership --dependency <dependency>

Example:

node scripts/dependency_ownership -d rxjs
  • -d rxjs: Specifies the dependency.

Output: Lists owners for rxjs.

[
  "@elastic/kibana-core"
]

3. List all dependencies with without owner

To display all dependencies that do not have owner defined.

node scripts/dependency_ownership --missing-owner

Example:

node scripts/dependency_ownership --missing-owner

Output: Lists all dev and prod dependencies without owner.

{
  "prodDependencies": [
    "<dependency_1>",
    "<dependency_2>",
    //...
  ],
  "devDependencies": [
    "<dependency_1>",
    "<dependency_2>",
    //...
  ]
}

4. Generate dependency ownership report

Generates a comprehensive report with all dependencies with and without owner.

node scripts/dependency_ownership --missing-owner

Example:

node scripts/dependency_ownership --missing-owner

Output: Lists all covered dev and prod dependencies, uncovered dev and prod dependencies, dependencies aggregated by owner.

{
  "coveredProdDependencies": [ // Prod dependencies with owner
    "<dependency_1>",
    "<dependency_2>",
    //...
  ],
  "coveredDevDependencies": [ // Dev dependencies with owner
    "<dependency_1>",
    "<dependency_2>",
    //...
  ],
  "uncoveredProdDependencies": [ // Prod dependencies without owner
    "<dependency_1>",
    "<dependency_2>",
    //...
  ],
  "uncoveredDevDependencies": [ // Dev dependencies without owner
    "<dependency_1>",
    "<dependency_2>",
    //...
  ],
  "prodDependenciesByOwner": { // Prod dependencies aggregated by owner
    "@elastic/team_1": ["<dependency_1>"],
    "@elastic/team_2": ["<dependency_1>"],
  },
  "devDependenciesByOwner": { // Dev dependencies aggregated by owner
    "@elastic/team_1": ["<dependency_1>"],
    "@elastic/team_2": ["<dependency_1>"],
  },
}

For further information on additional flags and options, refer to the script's help command.