kibana/packages/kbn-dependency-ownership
Tomasz Kajtoch 26dc21021d
[9.0] Add conditional switching between EUI releases (#219818) (#221917)
# Backport

This will backport the following commits from `main` to `9.0`:
- [Add conditional switching between EUI releases
(#219818)](https://github.com/elastic/kibana/pull/219818)

<!--- Backport version: 10.0.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Tomasz
Kajtoch","email":"tomasz.kajtoch@elastic.co"},"sourceCommit":{"committedDate":"2025-05-28T13:41:19Z","message":"Add
conditional switching between EUI releases (#219818)\n\n##
Summary\n\nThis PR simplifies the weekly EUI upgrade and backport
process by\nconditionally aliasing `@elastic/eui` in shared deps
webpack\nconfigurations.\n\n# Backstory\n\nThe EUI team
(@elastic/eui-team) is responsible for keeping EUI up to\ndate in
Kibana. Historically, this has been a relatively straightforward\n(yet
time-consuming) process, however, due to `8.x` backport\ncomplexities
caused by it using a different theme, it has become way\nmore demanding
on everybody involved.\n\nEUI is released on weekly basis. Each week, we
release official EUI\nversions tagged `latest` in npmjs and get a PR
open that updates the\npackage in kibana `main`.\n\nOur upgrade PRs tend
to require anywhere between 2 and 25 codeowner\nreviews due to the
number of snapshots we need to update while working\non the EUI upgrade
PRs. These snapshot changes are 99% of the time\nharmless, yet it still
takes 2+ full workdays to ping teams and get all\nreviews necessary to
get the PR merged. Generally speaking, we aim to\nhave the upgrade PR
open on Monday and merged by Friday.\n\n## The issue with `8.x`
backports\n\nKibana 8.x uses the Amsterdam theme instead of Borealis,
which is used\nin Kibana 9.0 and up. To keep 8.x up to date, for each
official EUI\nrelease we prepare another special Kibana 8.x only release
of EUI (e.g.,\n`101.2.0-amsterdam.0`). These special releases have the
theme hardcoded\nto Amsterdam at compile-time to avoid any initial theme
errors Kibana\ncould otherwise experience. This is done primarily
because some areas in\nKibana read EUI theme values outside of React
components, and we have no\nstable way to determine what the active
theme is since there's no\ncontext information. This is where we need to
fall back to Amsterdam in\n8.x and Borealis in 9.x.\n\n**Since there are
two different EUI versions - one for Kibana `main` and\n9.0, and another
for 8.x branches, we cannot use the automated backports\nfeature**.
Instead, we open two separate PRs and configure backport\nlabels
accordingly. Having two PRs is far from ideal since codeowners\nneed to
review our changes twice, and we're more likely to make\nmistakes.\n\n#
Our proposal\n\nFollowing the recently introduced React version
switching logic, we want\nto conditionally switch between two
`@elastic/eui` releases depending on\nthe kibana branch/version while
keeping automated backports possible.\n\nTo achieve that, I added a
dependency alias `@elastic/eui-amsterdam`\nthat points to the Amsterdam
EUI release and configured `resolve.alias`\nin shared deps to resolve
the correct dependency based on the optional\n`EUI_AMSTERDAM`
environment variable. When this change is merged to\n`main` and
backported to `9.0` and `8.19`, I'll open a follow-up PR to\nthe `8.19`
branch updating the default value of `EUI_AMSTERDAM` to\n`\"true\"`.
This should result in no conflicts and be easy to follow.\n\nSince 8.19
[uses the Amsterdam release
of\n`@elastic/eui`](https://github.com/elastic/kibana/blob/8.19/package.json#L126)\n(e.g.,
`101.2.0-amsterdam.0`), there's no risk backporting this PR
as-is\nwithout `EUI_AMSTERDAM` configured beforehand.\n\n## What does it
change?\n\nWith this setup, we'll be able to update versions of
`@elastic/eui` and\n`@elastic/eui-amsterdam` at the same time in a
single PR and make use of\nautomated kibana backports. There will be
only one set of changes to\nreview by codeowners, and if there are any
failing tests when\nbackporting to `8.19` due to, for example, changed
color values, we can\nfollow the regular kibana procedures and fix them
right in the created\nbackport PR. It'll simplify our workflow quite
drastically while keeping\nthe same level of
quality.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"ac3fc27a5397456630f974f84bee64f597500b55","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","v9.1.0","v8.19.0","v9.0.3"],"title":"Add
conditional switching between EUI
releases","number":219818,"url":"https://github.com/elastic/kibana/pull/219818","mergeCommit":{"message":"Add
conditional switching between EUI releases (#219818)\n\n##
Summary\n\nThis PR simplifies the weekly EUI upgrade and backport
process by\nconditionally aliasing `@elastic/eui` in shared deps
webpack\nconfigurations.\n\n# Backstory\n\nThe EUI team
(@elastic/eui-team) is responsible for keeping EUI up to\ndate in
Kibana. Historically, this has been a relatively straightforward\n(yet
time-consuming) process, however, due to `8.x` backport\ncomplexities
caused by it using a different theme, it has become way\nmore demanding
on everybody involved.\n\nEUI is released on weekly basis. Each week, we
release official EUI\nversions tagged `latest` in npmjs and get a PR
open that updates the\npackage in kibana `main`.\n\nOur upgrade PRs tend
to require anywhere between 2 and 25 codeowner\nreviews due to the
number of snapshots we need to update while working\non the EUI upgrade
PRs. These snapshot changes are 99% of the time\nharmless, yet it still
takes 2+ full workdays to ping teams and get all\nreviews necessary to
get the PR merged. Generally speaking, we aim to\nhave the upgrade PR
open on Monday and merged by Friday.\n\n## The issue with `8.x`
backports\n\nKibana 8.x uses the Amsterdam theme instead of Borealis,
which is used\nin Kibana 9.0 and up. To keep 8.x up to date, for each
official EUI\nrelease we prepare another special Kibana 8.x only release
of EUI (e.g.,\n`101.2.0-amsterdam.0`). These special releases have the
theme hardcoded\nto Amsterdam at compile-time to avoid any initial theme
errors Kibana\ncould otherwise experience. This is done primarily
because some areas in\nKibana read EUI theme values outside of React
components, and we have no\nstable way to determine what the active
theme is since there's no\ncontext information. This is where we need to
fall back to Amsterdam in\n8.x and Borealis in 9.x.\n\n**Since there are
two different EUI versions - one for Kibana `main` and\n9.0, and another
for 8.x branches, we cannot use the automated backports\nfeature**.
Instead, we open two separate PRs and configure backport\nlabels
accordingly. Having two PRs is far from ideal since codeowners\nneed to
review our changes twice, and we're more likely to make\nmistakes.\n\n#
Our proposal\n\nFollowing the recently introduced React version
switching logic, we want\nto conditionally switch between two
`@elastic/eui` releases depending on\nthe kibana branch/version while
keeping automated backports possible.\n\nTo achieve that, I added a
dependency alias `@elastic/eui-amsterdam`\nthat points to the Amsterdam
EUI release and configured `resolve.alias`\nin shared deps to resolve
the correct dependency based on the optional\n`EUI_AMSTERDAM`
environment variable. When this change is merged to\n`main` and
backported to `9.0` and `8.19`, I'll open a follow-up PR to\nthe `8.19`
branch updating the default value of `EUI_AMSTERDAM` to\n`\"true\"`.
This should result in no conflicts and be easy to follow.\n\nSince 8.19
[uses the Amsterdam release
of\n`@elastic/eui`](https://github.com/elastic/kibana/blob/8.19/package.json#L126)\n(e.g.,
`101.2.0-amsterdam.0`), there's no risk backporting this PR
as-is\nwithout `EUI_AMSTERDAM` configured beforehand.\n\n## What does it
change?\n\nWith this setup, we'll be able to update versions of
`@elastic/eui` and\n`@elastic/eui-amsterdam` at the same time in a
single PR and make use of\nautomated kibana backports. There will be
only one set of changes to\nreview by codeowners, and if there are any
failing tests when\nbackporting to `8.19` due to, for example, changed
color values, we can\nfollow the regular kibana procedures and fix them
right in the created\nbackport PR. It'll simplify our workflow quite
drastically while keeping\nthe same level of
quality.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"ac3fc27a5397456630f974f84bee64f597500b55"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.0"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219818","number":219818,"mergeCommit":{"message":"Add
conditional switching between EUI releases (#219818)\n\n##
Summary\n\nThis PR simplifies the weekly EUI upgrade and backport
process by\nconditionally aliasing `@elastic/eui` in shared deps
webpack\nconfigurations.\n\n# Backstory\n\nThe EUI team
(@elastic/eui-team) is responsible for keeping EUI up to\ndate in
Kibana. Historically, this has been a relatively straightforward\n(yet
time-consuming) process, however, due to `8.x` backport\ncomplexities
caused by it using a different theme, it has become way\nmore demanding
on everybody involved.\n\nEUI is released on weekly basis. Each week, we
release official EUI\nversions tagged `latest` in npmjs and get a PR
open that updates the\npackage in kibana `main`.\n\nOur upgrade PRs tend
to require anywhere between 2 and 25 codeowner\nreviews due to the
number of snapshots we need to update while working\non the EUI upgrade
PRs. These snapshot changes are 99% of the time\nharmless, yet it still
takes 2+ full workdays to ping teams and get all\nreviews necessary to
get the PR merged. Generally speaking, we aim to\nhave the upgrade PR
open on Monday and merged by Friday.\n\n## The issue with `8.x`
backports\n\nKibana 8.x uses the Amsterdam theme instead of Borealis,
which is used\nin Kibana 9.0 and up. To keep 8.x up to date, for each
official EUI\nrelease we prepare another special Kibana 8.x only release
of EUI (e.g.,\n`101.2.0-amsterdam.0`). These special releases have the
theme hardcoded\nto Amsterdam at compile-time to avoid any initial theme
errors Kibana\ncould otherwise experience. This is done primarily
because some areas in\nKibana read EUI theme values outside of React
components, and we have no\nstable way to determine what the active
theme is since there's no\ncontext information. This is where we need to
fall back to Amsterdam in\n8.x and Borealis in 9.x.\n\n**Since there are
two different EUI versions - one for Kibana `main` and\n9.0, and another
for 8.x branches, we cannot use the automated backports\nfeature**.
Instead, we open two separate PRs and configure backport\nlabels
accordingly. Having two PRs is far from ideal since codeowners\nneed to
review our changes twice, and we're more likely to make\nmistakes.\n\n#
Our proposal\n\nFollowing the recently introduced React version
switching logic, we want\nto conditionally switch between two
`@elastic/eui` releases depending on\nthe kibana branch/version while
keeping automated backports possible.\n\nTo achieve that, I added a
dependency alias `@elastic/eui-amsterdam`\nthat points to the Amsterdam
EUI release and configured `resolve.alias`\nin shared deps to resolve
the correct dependency based on the optional\n`EUI_AMSTERDAM`
environment variable. When this change is merged to\n`main` and
backported to `9.0` and `8.19`, I'll open a follow-up PR to\nthe `8.19`
branch updating the default value of `EUI_AMSTERDAM` to\n`\"true\"`.
This should result in no conflicts and be easy to follow.\n\nSince 8.19
[uses the Amsterdam release
of\n`@elastic/eui`](https://github.com/elastic/kibana/blob/8.19/package.json#L126)\n(e.g.,
`101.2.0-amsterdam.0`), there's no risk backporting this PR
as-is\nwithout `EUI_AMSTERDAM` configured beforehand.\n\n## What does it
change?\n\nWith this setup, we'll be able to update versions of
`@elastic/eui` and\n`@elastic/eui-amsterdam` at the same time in a
single PR and make use of\nautomated kibana backports. There will be
only one set of changes to\nreview by codeowners, and if there are any
failing tests when\nbackporting to `8.19` due to, for example, changed
color values, we can\nfollow the regular kibana procedures and fix them
right in the created\nbackport PR. It'll simplify our workflow quite
drastically while keeping\nthe same level of
quality.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"ac3fc27a5397456630f974f84bee64f597500b55"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
2025-05-30 20:33:19 +02:00
..
bin Dependency Ownership CLI (#201773) 2024-11-29 17:18:36 +01:00
src [9.0] Add conditional switching between EUI releases (#219818) (#221917) 2025-05-30 20:33:19 +02: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.