[timelion] Move grammar to package (#111881)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Jonathan Budzenski 2021-09-15 19:22:15 -05:00 committed by GitHub
parent 6435a81561
commit 17a4186ce8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 62 additions and 1795 deletions

View file

@ -21,7 +21,6 @@ snapshots.js
# plugin overrides
/src/core/lib/kbn_internal_native_observable
/src/plugins/data/common/es_query/kuery/ast/_generated_/**
/src/plugins/vis_types/timelion/common/_generated_/**
/x-pack/plugins/canvas/canvas_plugin
/x-pack/plugins/canvas/shareable_runtime/build
/x-pack/plugins/canvas/storybook/build

View file

@ -154,6 +154,7 @@
"@kbn/server-http-tools": "link:bazel-bin/packages/kbn-server-http-tools",
"@kbn/server-route-repository": "link:bazel-bin/packages/kbn-server-route-repository",
"@kbn/std": "link:bazel-bin/packages/kbn-std",
"@kbn/timelion-grammar": "link:bazel-bin/packages/kbn-timelion-grammar",
"@kbn/tinymath": "link:bazel-bin/packages/kbn-tinymath",
"@kbn/typed-react-router-config": "link:bazel-bin/packages/kbn-typed-react-router-config",
"@kbn/ui-framework": "link:bazel-bin/packages/kbn-ui-framework",

View file

@ -58,6 +58,7 @@ filegroup(
"//packages/kbn-telemetry-tools:build",
"//packages/kbn-test:build",
"//packages/kbn-test-subj-selector:build",
"//packages/kbn-timelion-grammar:build",
"//packages/kbn-tinymath:build",
"//packages/kbn-typed-react-router-config:build",
"//packages/kbn-ui-framework:build",

View file

@ -0,0 +1,46 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("@npm//peggy:index.bzl", "peggy")
PKG_BASE_NAME = "kbn-timelion-grammar"
PKG_REQUIRE_NAME = "@kbn/timelion-grammar"
NPM_MODULE_EXTRA_FILES = [
"package.json",
]
peggy(
name = "grammar",
data = [
":grammar/chain.peggy"
],
output_dir = True,
args = [
"-o",
"$(@D)/chain.js",
"./%s/grammar/chain.peggy" % package_name()
],
)
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES + [
":grammar"
],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
]
)
filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,7 @@
{
"name": "@kbn/timelion-grammar",
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": true,
"main": "grammar/chain.js"
}

View file

@ -3,10 +3,4 @@
Contains the timelion visualization and the timelion backend.
# Generate a parser
If your grammar was changed in `public/chain.peg` you need to re-generate the static parser. You could use a grunt task:
```
grunt peg:timelion_chain
```
The generated parser will be appeared at `public/_generated_` folder, which is included in `.eslintignore`
If your grammar was changed in `packages/@kbn-timelion-grammar` you need to re-generate the static parser. You can do this with `yarn kbn build`.

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@
*/
// @ts-ignore
import { parse } from './_generated_/chain';
import { parse } from '@kbn/timelion-grammar';
export interface ExpressionLocation {
min: number;

View file

@ -6,9 +6,4 @@
* Side Public License, v 1.
*/
module.exports = {
timelion_chain: {
src: 'src/plugins/vis_types/timelion/common/chain.peg',
dest: 'src/plugins/vis_types/timelion/common/_generated_/chain.js',
},
};
module.exports = {};

View file

@ -2909,6 +2909,10 @@
version "0.0.0"
uid ""
"@kbn/timelion-grammar@link:bazel-bin/packages/kbn-timelion-grammar":
version "0.0.0"
uid ""
"@kbn/tinymath@link:bazel-bin/packages/kbn-tinymath":
version "0.0.0"
uid ""