kibana/packages/kbn-relocate
Gerard Soldevila 748193d0a7
Sustainable Kibana Architecture: Relocate script v2 (#203887)
## Summary

Commits titles are self-explanatory
2024-12-12 04:10:50 -06:00
..
constants.ts
index.ts
jest.config.js
kibana.jsonc
package.json
README.md
relocate.ts
transforms.ts
tsconfig.json
types.ts
utils.exec.ts
utils.git.ts
utils.logging.ts
utils.relocate.ts

@kbn/relocate

This package contains a CLI tool to help move modules (plugins and packages) into their intended folders, according to the _Sustainable Kibana Architecture.

Prerequisites

You must have gh CLI tool installed. You can install it by running:

brew install gh

You must also configure your "default" kibana repo in gh, so that it can find PRs.:

gh repo set-default elastic/kibana

You must have elastic/kibana remote configured under the name upstream.

You must have a remote named origin pointing to your fork of the Kibana repo.

Usage

First of all, you need to decide whether you want to contribute to an existing PR or to create a new one. Use the --pr flag to specify the PR you are trying to update:

node scripts/relocate --pr <prNumber>

Note that when specifying an existing PR, the logic will undo + rewrite history for that PR, by force-pushing changes.

To relocate modules for a given team, identify the "team handle" (e.g. @elastic/kibana-core), and run the following command from the root of the Kibana repo:

node scripts/relocate --pr <prNumber> --team <team_handle>

You can relocate modules by path, e.g. all modules that are under x-pack/plugins/observability_solution/:

node scripts/relocate --pr <prNumber> --path "x-pack/plugins/observability_solution/"

You can specify indivual packages by ID:

node scripts/relocate --pr <prNumber> --include "@kbn/data-forge" --include "@kbn/deeplinks-observability"

You can also specify combinations of the above filters, to include modules that match ANY of the criteria. Excluding modules explictly is also supported:

node scripts/relocate --pr <prNumber> --team "@elastic/obs-ux-management-team" --exclude "@kbn/data-forge"

Details

The script generates log / description files of the form relocate_YYYYMMDDhhmmss_<type>.out. You can inspect them if you encounter any errors.

In particular, the file relocate_YYYYMMDDhhmmss_description.out contains the auto-generated PR description. You can push it to the PR by running:

gh pr edit <prNumber> -F relocate_YYYYMMDDhhmmss_description.out -R elastic/kibana