This updated the `kbn:boostrap` scripts in the packages to use `--quiet` when bootstrapping. This prevents babel from logging every file it builds, but still logs errors if any occur. To make things a little simpler I also used the [`npm-run-all`](https://github.com/mysticatea/npm-run-all) package in `@kbn/i18n` to execute all the builds there in parallel and pass `--quiet`/`--watch` to all builds without duplicating the tasks or making them incompatible with windows. Before: ``` running `kbn:bootstrap` scripts @kbn/config-schema: $ yarn build @kbn/datemath: $ yarn build @kbn/i18n: $ yarn build @kbn/config-schema: $ tsc @kbn/datemath: $ babel src --out-dir target --copy-files @kbn/i18n: $ yarn build:web && yarn build:node && yarn build:types @kbn/i18n: $ cross-env BABEL_ENV=web babel src --config-file ./babel.config.js --out-dir target/web --extensions ".ts,.js,.tsx" @kbn/datemath: src/index.js -> target/index.js @kbn/i18n: Successfully compiled 18 files with Babel. @kbn/i18n: $ cross-env BABEL_ENV=node babel src --config-file ./babel.config.js --out-dir target/node --extensions ".ts,.js,.tsx" @kbn/i18n: Successfully compiled 18 files with Babel. @kbn/i18n: $ tsc --emitDeclarationOnly @kbn/dev-utils: $ yarn build @kbn/es-query: $ yarn build @kbn/dev-utils: $ babel src --out-dir target @kbn/es-query: $ babel src --out-dir target @kbn/dev-utils: src/index.js -> target/index.js @kbn/dev-utils: src/proc_runner/errors.js -> target/proc_runner/errors.js @kbn/dev-utils: src/proc_runner/index.js -> target/proc_runner/index.js @kbn/dev-utils: src/proc_runner/observe_lines.js -> target/proc_runner/observe_lines.js @kbn/dev-utils: src/proc_runner/observe_readable.js -> target/proc_runner/observe_readable.js @kbn/es-query: src/es_query/__tests__/_migrate_filter.js -> target/es_query/__tests__/_migrate_filter.js @kbn/dev-utils: src/proc_runner/observe_signals.js -> target/proc_runner/observe_signals.js @kbn/es-query: src/es_query/__tests__/build_es_query.js -> target/es_query/__tests__/build_es_query.js @kbn/es-query: src/es_query/__tests__/decorate_query.js -> target/es_query/__tests__/decorate_query.js @kbn/dev-utils: src/proc_runner/proc.js -> target/proc_runner/proc.js @kbn/es-query: src/es_query/__tests__/from_filters.js -> target/es_query/__tests__/from_filters.js @kbn/es-query: src/es_query/__tests__/from_kuery.js -> target/es_query/__tests__/from_kuery.js @kbn/es-query: src/es_query/__tests__/from_lucene.js -> target/es_query/__tests__/from_lucene.js @kbn/es-query: src/es_query/__tests__/lucene_string_to_dsl.js -> target/es_query/__tests__/lucene_string_to_dsl.js @kbn/dev-utils: src/proc_runner/proc_runner.js -> target/proc_runner/proc_runner.js @kbn/dev-utils: src/proc_runner/with_proc_runner.js -> target/proc_runner/with_proc_runner.js @kbn/dev-utils: src/proc_runner/with_proc_runner.test.js -> target/proc_runner/with_proc_runner.test.js @kbn/es-query: src/es_query/build_es_query.js -> target/es_query/build_es_query.js @kbn/dev-utils: src/serializers/absolute_path_serializer.js -> target/serializers/absolute_path_serializer.js @kbn/es-query: src/es_query/decorate_query.js -> target/es_query/decorate_query.js @kbn/dev-utils: src/serializers/index.js -> target/serializers/index.js @kbn/es-query: src/es_query/from_filters.js -> target/es_query/from_filters.js @kbn/dev-utils: src/streams/concat_stream.js -> target/streams/concat_stream.js @kbn/dev-utils: src/streams/index.js -> target/streams/index.js @kbn/dev-utils: src/streams/promise_from_streams.js -> target/streams/promise_from_streams.js @kbn/es-query: src/es_query/from_kuery.js -> target/es_query/from_kuery.js @kbn/dev-utils: src/streams/reduce_stream.js -> target/streams/reduce_stream.js @kbn/es-query: src/es_query/from_lucene.js -> target/es_query/from_lucene.js @kbn/dev-utils: src/tooling_log/index.js -> target/tooling_log/index.js @kbn/es-query: src/es_query/index.js -> target/es_query/index.js @kbn/dev-utils: src/tooling_log/log_levels.js -> target/tooling_log/log_levels.js @kbn/es-query: src/es_query/lucene_string_to_dsl.js -> target/es_query/lucene_string_to_dsl.js @kbn/dev-utils: src/tooling_log/log_levels.test.js -> target/tooling_log/log_levels.test.js @kbn/es-query: src/es_query/migrate_filter.js -> target/es_query/migrate_filter.js @kbn/dev-utils: src/tooling_log/tooling_log.js -> target/tooling_log/tooling_log.js @kbn/es-query: src/filters/__tests__/phrase.js -> target/filters/__tests__/phrase.js @kbn/es-query: src/filters/__tests__/query.js -> target/filters/__tests__/query.js @kbn/dev-utils: src/tooling_log/tooling_log.test.js -> target/tooling_log/tooling_log.test.js @kbn/dev-utils: src/tooling_log/tooling_log_text_writer.js -> target/tooling_log/tooling_log_text_writer.js @kbn/dev-utils: src/tooling_log/tooling_log_text_writer.test.js -> target/tooling_log/tooling_log_text_writer.test.js @kbn/es-query: src/filters/__tests__/range.js -> target/filters/__tests__/range.js @kbn/es-query: src/filters/exists.js -> target/filters/exists.js @kbn/es-query: src/filters/index.js -> target/filters/index.js @kbn/es-query: src/filters/phrase.js -> target/filters/phrase.js @kbn/es-query: src/filters/phrases.js -> target/filters/phrases.js @kbn/es-query: src/filters/query.js -> target/filters/query.js @kbn/es-query: src/filters/range.js -> target/filters/range.js @kbn/es-query: src/index.js -> target/index.js @kbn/es-query: src/kuery/ast/__tests__/ast.js -> target/kuery/ast/__tests__/ast.js @kbn/es-query: src/kuery/ast/ast.js -> target/kuery/ast/ast.js @kbn/es-query: src/kuery/ast/index.js -> target/kuery/ast/index.js @kbn/es-query: src/kuery/ast/kuery.js -> target/kuery/ast/kuery.js @kbn/es-query: src/kuery/ast/legacy_kuery.js -> target/kuery/ast/legacy_kuery.js @kbn/es-query: src/kuery/filter_migration/__tests__/exists.js -> target/kuery/filter_migration/__tests__/exists.js @kbn/es-query: src/kuery/filter_migration/__tests__/filter_to_kuery.js -> target/kuery/filter_migration/__tests__/filter_to_kuery.js @kbn/es-query: src/kuery/filter_migration/__tests__/geo_bounding_box.js -> target/kuery/filter_migration/__tests__/geo_bounding_box.js @kbn/es-query: src/kuery/filter_migration/__tests__/geo_polygon.js -> target/kuery/filter_migration/__tests__/geo_polygon.js @kbn/es-query: src/kuery/filter_migration/__tests__/phrase.js -> target/kuery/filter_migration/__tests__/phrase.js @kbn/es-query: src/kuery/filter_migration/__tests__/range.js -> target/kuery/filter_migration/__tests__/range.js @kbn/es-query: src/kuery/filter_migration/exists.js -> target/kuery/filter_migration/exists.js @kbn/es-query: src/kuery/filter_migration/filter_to_kuery.js -> target/kuery/filter_migration/filter_to_kuery.js @kbn/es-query: src/kuery/filter_migration/geo_bounding_box.js -> target/kuery/filter_migration/geo_bounding_box.js @kbn/es-query: src/kuery/filter_migration/geo_polygon.js -> target/kuery/filter_migration/geo_polygon.js @kbn/es-query: src/kuery/filter_migration/index.js -> target/kuery/filter_migration/index.js @kbn/es-query: src/kuery/filter_migration/phrase.js -> target/kuery/filter_migration/phrase.js @kbn/es-query: src/kuery/filter_migration/range.js -> target/kuery/filter_migration/range.js @kbn/es-query: src/kuery/functions/__tests__/and.js -> target/kuery/functions/__tests__/and.js @kbn/es-query: src/kuery/functions/__tests__/exists.js -> target/kuery/functions/__tests__/exists.js @kbn/es-query: src/kuery/functions/__tests__/geo_bounding_box.js -> target/kuery/functions/__tests__/geo_bounding_box.js @kbn/es-query: src/kuery/functions/__tests__/geo_polygon.js -> target/kuery/functions/__tests__/geo_polygon.js @kbn/es-query: src/kuery/functions/__tests__/is.js -> target/kuery/functions/__tests__/is.js @kbn/es-query: src/kuery/functions/__tests__/not.js -> target/kuery/functions/__tests__/not.js @kbn/es-query: src/kuery/functions/__tests__/or.js -> target/kuery/functions/__tests__/or.js @kbn/es-query: src/kuery/functions/__tests__/range.js -> target/kuery/functions/__tests__/range.js @kbn/es-query: src/kuery/functions/__tests__/utils/get_fields.js -> target/kuery/functions/__tests__/utils/get_fields.js @kbn/es-query: src/kuery/functions/and.js -> target/kuery/functions/and.js @kbn/es-query: src/kuery/functions/exists.js -> target/kuery/functions/exists.js @kbn/es-query: src/kuery/functions/geo_bounding_box.js -> target/kuery/functions/geo_bounding_box.js @kbn/es-query: src/kuery/functions/geo_polygon.js -> target/kuery/functions/geo_polygon.js @kbn/es-query: src/kuery/functions/index.js -> target/kuery/functions/index.js @kbn/es-query: src/kuery/functions/is.js -> target/kuery/functions/is.js @kbn/es-query: src/kuery/functions/not.js -> target/kuery/functions/not.js @kbn/es-query: src/kuery/functions/or.js -> target/kuery/functions/or.js @kbn/es-query: src/kuery/functions/range.js -> target/kuery/functions/range.js @kbn/es-query: src/kuery/functions/utils/get_fields.js -> target/kuery/functions/utils/get_fields.js @kbn/es-query: src/kuery/index.js -> target/kuery/index.js @kbn/es-query: src/kuery/node_types/__tests__/function.js -> target/kuery/node_types/__tests__/function.js @kbn/es-query: src/kuery/node_types/__tests__/literal.js -> target/kuery/node_types/__tests__/literal.js @kbn/es-query: src/kuery/node_types/__tests__/named_arg.js -> target/kuery/node_types/__tests__/named_arg.js @kbn/es-query: src/kuery/node_types/__tests__/wildcard.js -> target/kuery/node_types/__tests__/wildcard.js @kbn/es-query: src/kuery/node_types/function.js -> target/kuery/node_types/function.js @kbn/es-query: src/kuery/node_types/index.js -> target/kuery/node_types/index.js @kbn/es-query: src/kuery/node_types/literal.js -> target/kuery/node_types/literal.js @kbn/es-query: src/kuery/node_types/named_arg.js -> target/kuery/node_types/named_arg.js @kbn/es-query: src/kuery/node_types/wildcard.js -> target/kuery/node_types/wildcard.js @kbn/test: $ yarn build @kbn/test: $ babel src --out-dir target @kbn/test: src/es/es_test_cluster.js -> target/es/es_test_cluster.js @kbn/test: src/es/es_test_config.js -> target/es/es_test_config.js @kbn/test: src/es/index.js -> target/es/index.js @kbn/test: src/functional_tests/cli/index.js -> target/functional_tests/cli/index.js @kbn/test: src/functional_tests/cli/run_tests/args.js -> target/functional_tests/cli/run_tests/args.js @kbn/test: src/functional_tests/cli/run_tests/args.test.js -> target/functional_tests/cli/run_tests/args.test.js @kbn/test: src/functional_tests/cli/run_tests/cli.js -> target/functional_tests/cli/run_tests/cli.js @kbn/test: src/functional_tests/cli/run_tests/cli.test.js -> target/functional_tests/cli/run_tests/cli.test.js @kbn/test: src/functional_tests/cli/start_servers/args.js -> target/functional_tests/cli/start_servers/args.js @kbn/test: src/functional_tests/cli/start_servers/args.test.js -> target/functional_tests/cli/start_servers/args.test.js @kbn/test: src/functional_tests/cli/start_servers/cli.js -> target/functional_tests/cli/start_servers/cli.js @kbn/test: src/functional_tests/cli/start_servers/cli.test.js -> target/functional_tests/cli/start_servers/cli.test.js @kbn/test: src/functional_tests/lib/auth.js -> target/functional_tests/lib/auth.js @kbn/test: src/functional_tests/lib/index.js -> target/functional_tests/lib/index.js @kbn/test: src/functional_tests/lib/paths.js -> target/functional_tests/lib/paths.js @kbn/test: src/functional_tests/lib/run_cli.js -> target/functional_tests/lib/run_cli.js @kbn/test: src/functional_tests/lib/run_cli.test.js -> target/functional_tests/lib/run_cli.test.js @kbn/test: src/functional_tests/lib/run_elasticsearch.js -> target/functional_tests/lib/run_elasticsearch.js @kbn/test: src/functional_tests/lib/run_ftr.js -> target/functional_tests/lib/run_ftr.js @kbn/test: src/functional_tests/lib/run_kibana_server.js -> target/functional_tests/lib/run_kibana_server.js @kbn/test: src/functional_tests/tasks.js -> target/functional_tests/tasks.js @kbn/test: src/functional_tests/test_helpers.js -> target/functional_tests/test_helpers.js @kbn/test: src/index.js -> target/index.js @kbn/test: src/kbn/index.js -> target/kbn/index.js @kbn/test: src/kbn/kbn_test_config.js -> target/kbn/kbn_test_config.js @kbn/test: src/kbn/users.js -> target/kbn/users.js x-pack: $ gulp canvas:plugins:build x-pack: [13:22:34] /Users/spalger/kbn-dev/master/kibana/x-pack/plugins/canvas/canvas_plugin x-pack: [13:22:34] Using gulpfile ~/kbn-dev/master/kibana/x-pack/gulpfile.js x-pack: [13:22:34] Starting 'canvas:plugins:build'... x-pack: [13:22:50] canvas:plugins Plugins built in 15.75 seconds x-pack: [13:22:50] Finished 'canvas:plugins:build' after 16 s kibana: $ yarn build:types && node scripts/register_git_hook kibana: $ tsc --p tsconfig.types.json kibana: Registering Kibana pre-commit git hook... kibana: success Kibana pre-commit git hook was installed successfully. ``` (this will be even worse when we merge #26095) After: ``` running `kbn:bootstrap` scripts @kbn/config-schema: $ yarn build @kbn/datemath: $ yarn build --quiet @kbn/i18n: $ run-p 'build:babel:** --quiet' build:tsc @kbn/datemath: $ babel src --out-dir target --copy-files --quiet @kbn/config-schema: $ tsc @kbn/i18n: $ cross-env BABEL_ENV=node babel src --config-file ./babel.config.js --out-dir target/node --extensions ".ts,.js,.tsx" --quiet @kbn/i18n: $ cross-env BABEL_ENV=web babel src --config-file ./babel.config.js --out-dir target/web --extensions ".ts,.js,.tsx" --quiet @kbn/i18n: $ tsc --emitDeclarationOnly @kbn/i18n: Successfully compiled 18 files with Babel. @kbn/i18n: Successfully compiled 18 files with Babel. @kbn/dev-utils: $ yarn build --quiet @kbn/es-query: $ yarn build --quiet @kbn/dev-utils: $ babel src --out-dir target --quiet @kbn/es-query: $ babel src --out-dir target --quiet @kbn/test: $ yarn build --quiet @kbn/test: $ babel src --out-dir target --quiet x-pack: $ gulp canvas:plugins:build x-pack: [13:16:56] /Users/spalger/kbn-dev/master/kibana/x-pack/plugins/canvas/canvas_plugin x-pack: [13:16:56] Using gulpfile ~/kbn-dev/master/kibana/x-pack/gulpfile.js x-pack: [13:16:56] Starting 'canvas:plugins:build'... x-pack: [13:17:11] canvas:plugins Plugins built in 13.98 seconds x-pack: [13:17:11] Finished 'canvas:plugins:build' after 14 s kibana: $ yarn build:types && node scripts/register_git_hook kibana: $ tsc --p tsconfig.types.json kibana: Registering Kibana pre-commit git hook... kibana: success Kibana pre-commit git hook was installed successfully. ``` |
||
---|---|---|
.. | ||
eslint-config-kibana | ||
eslint-plugin-kibana-custom | ||
kbn-babel-preset | ||
kbn-config-schema | ||
kbn-datemath | ||
kbn-dev-utils | ||
kbn-es | ||
kbn-es-query | ||
kbn-eslint-import-resolver-kibana | ||
kbn-eslint-plugin-license-header | ||
kbn-i18n | ||
kbn-plugin-generator | ||
kbn-plugin-helpers | ||
kbn-pm | ||
kbn-system-loader | ||
kbn-test | ||
kbn-test-subj-selector | ||
kbn-ui-framework | ||
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
inpackage.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 link:
dependencies in Yarn, which sets up a symlink to the package.
For example if you want to use the @kbn/datemath
package in Kibana itself, you
can specify the dependency like this:
"@kbn/datemath": "link:packages/kbn-datemath"
However, if you want to use this from a Kibana plugin, you need to account for the relative location of the Kibana repo, so it would instead be:
"@kbn/datemath": "link:../../kibana/packages/kbn-datemath"
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/datemath
the folder name
should be kbn-datemath
.
All new packages should use the @kbn
namespace, and should be marked with
"private": true
.
Unit tests for a package
Currently there are two patterns used to test packages, one using Mocha and one using Jest. These patterns emerged out of convention and we'd like to make them more similar to each other in the near future.
1. Mocha
Today a package can follow the pattern of having a __tests__
directory in each source code directory of a package which contains the tests for that module. These are usually run by Mocha.
If a package's tests should be run with Mocha, you'll have to opt-in to run them by appending the package's test file pattern(s) to Kibana's tasks/config/simplemocha.js
file. These will then be run by the unit test runner.
yarn test
oryarn grunt test
runs all unit tests.node scripts/mocha
runs all Mocha tests.
2. Jest
A package can also 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
oryarn grunt test
runs all unit tests.node scripts/jest
runs all Jest tests in Kibana.
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.