kibana/packages
Pierre Gayvallet 3e1e047bc4
[7.x] Migrate joi to 17.4.0 and adapt the codebase (#99899) (#100378)
* Migrate `joi` to `17.4.0` and adapt the codebase  (#99899)

* bump joi to 17.4.0, start adapting stuff

* remove custom validation rule, adapt instead

* fix error handling

* fix error handling again

* fix strings type & validation

* fix buffers and arrays

* fix bytes

* fix bytes_size type

* update conditional_type error messages in tests

* fix duration and map types

* first attempt to fix union type error messages

* revert conditional type assertions back to master state

* fix object type

* fix record type

* fix stream types

* rename test files to match sources

* fix union type tests

* temporary adapt feature/home usages of Joi

* fix lint

* adapt test assertion

* fix http config schema validation

* fix @kbn/test Config class

* fix config again

* fix reporting schema tests

* fix security solution schema

* adapt url tests

* remove useless comment

* remove space

* typo

* review comments
# Conflicts:
#	src/core/server/http/__snapshots__/http_config.test.ts.snap

* allow '0' value for server.host

* fix config def

* update snapshots
2021-05-20 09:04:31 -04:00
..
elastic-datemath
elastic-eslint-config-kibana [kbn/test] move types/ftr into src (#99555) (#100228) 2021-05-17 14:49:48 -04:00
elastic-safer-lodash-set
kbn-ace [packages] Move @kbn/ace to Bazel (#99129) (#99528) 2021-05-06 20:53:39 +00:00
kbn-analytics
kbn-apm-config-loader
kbn-apm-utils
kbn-babel-code-parser
kbn-babel-preset
kbn-cli-dev-mode chore(NA): moving @kbn/server-http-tools into bazel (#100153) (#100168) 2021-05-14 18:13:53 -04:00
kbn-config [7.x] Do not mutate config in place during deprecations (#99629) (#99763) 2021-05-11 15:25:57 +00:00
kbn-config-schema [7.x] Migrate joi to 17.4.0 and adapt the codebase (#99899) (#100378) 2021-05-20 09:04:31 -04:00
kbn-crypto [kbn-crypto] Fix typo in package name (#99935) (#99964) 2021-05-12 14:58:16 -04:00
kbn-dev-utils
kbn-docs-utils chore(NA): moving @kbn/docs-utils into bazel (#100051) (#100071) 2021-05-13 17:32:24 -04:00
kbn-es [kbn-es] Allow overriding of Java heap (#99517) (#99794) 2021-05-11 12:31:37 -04:00
kbn-es-archiver
kbn-eslint-import-resolver-kibana
kbn-eslint-plugin-eslint
kbn-expect
kbn-i18n refact(NA): remove extra pkg_npm target and add specific target folders for @kbn/i18n on Bazel (#100271) (#100304) 2021-05-18 19:46:44 -04:00
kbn-interpreter chore(NA): moving @kbn/i18n into bazel (#99390) (#100169) 2021-05-14 18:18:53 -04:00
kbn-io-ts-utils
kbn-legacy-logging fix-typo: Use of than instead of then (#100030) (#100093) 2021-05-13 23:35:58 +00:00
kbn-logging
kbn-monaco chore(NA): moving @kbn/i18n into bazel (#99390) (#100169) 2021-05-14 18:18:53 -04:00
kbn-optimizer [7.x] [Screenshot mode] Create plugin to provide "screenshot mode" awareness (#99627) (#100331) 2021-05-20 07:58:50 -04:00
kbn-plugin-generator chore(NA): moving @kbn/plugin-generator into bazel (#99646) (#99854) 2021-05-11 19:58:31 -04:00
kbn-plugin-helpers
kbn-pm
kbn-rule-data-utils [RAC] Decouple registry from alerts-as-data client (#98935) (#100041) 2021-05-13 13:07:02 -04:00
kbn-securitysolution-constants [Security Solutions][Lists] (Phase 1) Pulls constants from lists and security solutions plugin into its own kbn package (#99149) (#99298) 2021-05-04 21:42:25 -04:00
kbn-securitysolution-es-utils [Security Solutions] Replaces most deprecated io-ts alerting and list types (#100234) (#100246) 2021-05-18 03:23:28 -04:00
kbn-securitysolution-io-ts-alerting-types [Security Solutions] Replaces most deprecated io-ts alerting and list types (#100234) (#100246) 2021-05-18 03:23:28 -04:00
kbn-securitysolution-io-ts-list-types [Security Solutions] Re-arranges and adds more packages to remove copied code (#100310) (#100369) 2021-05-19 19:56:33 -04:00
kbn-securitysolution-io-ts-types [Security Solutions] Replaces most deprecated io-ts alerting and list types (#100234) (#100246) 2021-05-18 03:23:28 -04:00
kbn-securitysolution-io-ts-utils [Security Solutions] Breaks down the io-ts packages to decrease plugin size (#100058) (#100094) 2021-05-13 19:34:08 -04:00
kbn-securitysolution-list-utils [Security Solutions] Re-arranges and adds more packages to remove copied code (#100310) (#100369) 2021-05-19 19:56:33 -04:00
kbn-securitysolution-utils [Security Solutions] Removes circular dependencies and introduces kbn-security-solution-es-utils package (#99828) (#100001) 2021-05-12 19:53:45 -04:00
kbn-server-http-tools chore(NA): moving @kbn/server-http-tools into bazel (#100153) (#100168) 2021-05-14 18:13:53 -04:00
kbn-server-route-repository
kbn-spec-to-console
kbn-std
kbn-storybook Storybook theme switcher (#97201) (#99545) 2021-05-06 18:21:58 -04:00
kbn-telemetry-tools [packages] Move @kbn/telemetry-tools to Bazel (#99726) (#99929) 2021-05-14 16:26:59 +00:00
kbn-test [7.x] Migrate joi to 17.4.0 and adapt the codebase (#99899) (#100378) 2021-05-20 09:04:31 -04:00
kbn-test-subj-selector
kbn-tinymath
kbn-ui-framework
kbn-ui-shared-deps chore(NA): moving @kbn/i18n into bazel (#99390) (#100169) 2021-05-14 18:18:53 -04:00
kbn-utility-types
kbn-utils
BUILD.bazel [Security Solutions] Re-arranges and adds more packages to remove copied code (#100310) (#100369) 2021-05-19 19:56:33 -04:00
README.md

Kibana-related packages

This folder contains packages that are intended for use in Kibana and Kibana plugins.

tl;dr:

  • Don't publish to npm registry
  • Always use the @kbn namespace
  • Always set "private": true in package.json

Using these packages

We no longer publish these packages to the npm registry. Now, instead of specifying a version when including these packages, we rely on yarn workspaces, which sets up a symlink to the package.

For example if you want to use the @kbn/i18n package in Kibana itself, you can specify the dependency like this:

"@kbn/i18n": "1.0.0"

However, if you want to use this from a Kibana plugin, you need to use a link: dependency and account for the relative location of the Kibana repo, so it would instead be:

"@kbn/i18n": "link:../../kibana/packages/kbn-i18n"

How all of this works is described in more detail in the @kbn/pm docs.

Creating a new package

Create a new sub-folder. The name of the folder should mirror the name in the package's package.json. E.g. if the name is @kbn/i18n the folder name should be kbn-i18n.

All new packages should use the @kbn namespace, and should be marked with "private": true.

Unit tests for a package

Currently there is only one tool being used in order to test packages which is Jest. Below we will explain how it should be done.

Jest

A package should follow the pattern of having .test.js files as siblings of the source code files, and these run by Jest.

A package using the .test.js naming convention will have those tests automatically picked up by Jest and run by the unit test runner, currently mapped to the Kibana test script in the root package.json.

  • yarn test or yarn grunt test runs all unit tests.
  • yarn jest runs all Jest tests in Kibana.

In order for the plugin or package to use Jest, a jest.config.js file must be present in it's root. However, there are safeguards for this in CI should a test file be added without a corresponding config file.


Each package can also specify its own test script in the package's package.json, for cases where you'd prefer to run the tests from the local package directory.