kibana/scripts
Rudolf Meijering 5c457972d4
Generate core API docs from TSDoc comments (#32148)
* Generate core API docs from TSDoc comments

Uses api-extractor and api-documenter to generate documentation for
the Kibana core API from TSDoc comments in the source code.

Documentation can be generated using `npm run docs:api`.

I used --no-verify to ignore the following pre-commit hook errors:
1. Filenames MUST use snake_case - api-extractor.json
   It's possible to specify a different config file, but I prefer to keep the "standard" config file name.
2. UNHANDLED ERROR: Unable to find tsconfig.json file selecting "common/core_api_review/kibana.api.ts". Ensure one exists and it is listed in "src/dev/typescript/projects.ts"
   This is not a source file, so safe to ignore.

* Flesh out API docs a little bit

* Ignore snake_case check for api-extractor.json

* Ignore api-extractor's review file from pre-commit check

* Try to fix build failing by using masters yarn.lock

* I'm being stupid

* Found a better home for ignoring common/core_api_review/kibana.api.ts

* Node script for detecting core API changes

I initially wanted to include this as a precommit hook, but it takes
quite long to execute (~12s) so might be better suited as a test or
as part of the release process.

The script currently fails because api-extractor uses an older version
of typescript.

* Fix tslint precommit hook ignore condition

* Write tsdoc-metadata.json into ./build

* Add LogMeta and ElasticSearch to exported types & docs

* Suppress logging when running api-extractor from script

* Improve check_core_api_changes script and run as test

* Inline api-extractor.json config

* Fix check_core_api_changes --help flag

* LogMeta TSDoc comments

* check_core_api_changes: fail if api-extractor produces warnings or errors

And print more useful messages to the console

* Move ignored ts files list into dev/file

* Add back build:types since api-exporter cannot operate on source files

* Upgrade api-exporter/documenter

* api-extractor: independantly analyze core/public and core/server

Becasue of https://github.com/Microsoft/web-build-tools/issues/1029
api-extractor can't use core/index.ts as a single entry point for
analyzing the public and server API's as isolated namespaces.

Instead we analyze these projects separately. This introduces other
problems like the api review files and documentation always being
called "kibana." from the package.json filename.

* Build types as part of build task

* Include types in typescript browser compilation

* Force inclusion of core/public for building types

* Fix api review filename in api-exporter errors

* Update docs and API review files

* Fix api-extractor warnings

* Remove ts file ignored list since it's no longer necessary

* Rename exported api package name

* Review comments

* Export other missing types

* Upgrade api-documenter to latest beta

* Export more missing types

* Fix warnings and add api-exporter to Jenkins tests

* Correctly handle runBuildTypes() exceptions

* Fix another swallowed exception

* Fix api-extractor warnings after master merge
2019-04-03 12:26:00 +02:00
..
backport.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
build.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
build_sass.js [dev] share sass build with script (#34323) 2019-04-02 11:53:48 -07:00
check_core_api_changes.js Generate core API docs from TSDoc comments (#32148) 2019-04-03 12:26:00 +02:00
check_file_casing.js Change check_file_casing to require setup_node_env (#19499) 2018-05-29 11:48:43 -04:00
check_ts_projects.js [ts] add script to verify that all ts is in a project (#32727) 2019-03-08 13:51:55 -08:00
docs.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
es.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
es_archiver.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
eslint.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
functional_test_runner.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
functional_tests.js adding runPipeline tests (#27015) 2019-03-21 07:12:25 +01:00
functional_tests_server.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
generate_plugin.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
i18n_check.js Integrate main i18n tool into build pipeline (#22254) 2018-08-29 11:55:34 +03:00
i18n_extract.js Add zh-CN.json translations and respective compatibility checks via i18n tools (#30378) 2019-02-11 14:39:59 +01:00
i18n_integrate.js Implement a build tool for locale files integration (#19826) 2018-12-22 13:06:40 +03:00
jest.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
jest_integration.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
kbn.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
kibana.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
kibana_keystore.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
kibana_plugin.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
makelogs.js Removed old package, fix import (#31428) 2019-02-19 12:23:03 +01:00
mocha.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
notice.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
precommit_hook.js chore(NA): remove node version validator from git pre-commit hook script. (#19950) 2018-06-15 16:14:48 +01:00
README.md Plugin test readme’s (#26632) 2018-12-04 15:23:23 -05:00
register_git_hook.js Remove husky (#24887) 2018-11-15 01:34:45 +00:00
sasslint.js Add SCSS linting (#27328) 2019-01-03 09:01:43 -07:00
tslint.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
type_check.js [TypeScript] add type-check script (#19325) 2018-08-09 17:19:24 -07:00

Kibana Dev Scripts

This directory contains scripts useful for interacting with Kibana tools in development. Use the node executable and --help flag to learn about how they work:

node scripts/{{script name}} --help

For Developers

This directory is excluded from the build and tools within it should help users discover their capabilities. Each script in this directory must:

  • require src/setup_node_env to bootstrap NodeJS environment
  • call out to source code in the src or packages directories
  • react to the --help flag
  • run everywhere OR check and fail fast when a required OS or toolchain is not available

Functional Test Scripts

node scripts/functional_tests [--config test/functional/config.js --config test/api_integration/config.js]

Runs all the functional tests: selenium tests and api integration tests. List configs with multiple --config arguments. Uses the @kbn/test library to run Elasticsearch and Kibana servers and tests against those servers, for multiple server+test setups. In particular, calls out to runTests(). Can be run on a single config.

node scripts/functional_tests_server [--config test/functional/config.js]

Starts just the Elasticsearch and Kibana servers given a single config, i.e. via --config test/functional/config.js or --config test/api_integration/config. Allows the user to start just the servers with this script, and keep them running while running tests against these servers. The idea is that the same config file configures both Elasticsearch and Kibana servers. Uses the startServers() method from @kbn/test library.

Example. Start servers and run tests, separately, but using the same config:

# Just the servers
node scripts/functional_tests_server --config path/to/config

In another terminal:

# Just the tests--against the running servers
node scripts/functional_test_runner --config path/to/config

For details on how the internal methods work, read this readme.

ES archiver

Loading data

If you wish to load up specific es archived data for your test, you can do so via:

node scripts/es_archiver.js load <archive> [--es-url=http://username:password@localhost:9200] [--kibana-url=http://username:password@localhost:5601/{basepath?}]

That will load the specified archive located in the archive directory specified by the default functional config file, located in test/functional/config.js. To load archives from other function config files you can pass --config path/to/config.js.

Note: The --es-url and --kibana-url options may or may not be neccessary depending on your current Kibana configuration settings, and their values may also change based on those settings (for example if you are not running with security you will not need the username:password portion).

Saving data

You can save existing data into an archive by using the save command:

node scripts/es_archiver.js save <archive name for kibana data> [space separated list of index patterns to include]

You may want to store the .kibana index separate from data. Since adding a lot of data will bloat our repo size, we have many tests that reuse the same data indices but use their own .kibana index.