From b6541fe9ed5b804500bf6b75fa8ccff0d2a840fb Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 18 Nov 2022 21:21:21 -0600 Subject: [PATCH] use the entire basename in config file paths --- packages/kbn-es-query/BUILD.bazel | 2 +- .../{grammar.config.json => grammar.peggy.config.json} | 0 packages/kbn-interpreter/BUILD.bazel | 2 +- .../{grammar.config.json => grammar.peggy.config.json} | 0 packages/kbn-peggy/README.mdx | 2 +- packages/kbn-peggy/index.ts | 10 +--------- 6 files changed, 4 insertions(+), 12 deletions(-) rename packages/kbn-es-query/src/kuery/grammar/{grammar.config.json => grammar.peggy.config.json} (100%) rename packages/kbn-interpreter/src/common/lib/{grammar.config.json => grammar.peggy.config.json} (100%) diff --git a/packages/kbn-es-query/BUILD.bazel b/packages/kbn-es-query/BUILD.bazel index 2937972bfabcf..95e7dcdcbe3cc 100644 --- a/packages/kbn-es-query/BUILD.bazel +++ b/packages/kbn-es-query/BUILD.bazel @@ -8,7 +8,7 @@ PKG_REQUIRE_NAME = "@kbn/es-query" SOURCE_FILES = glob( [ "**/*.ts", - "**/grammar.config.json", + "**/grammar.peggy.config.json", "**/grammar.peggy", ], exclude = [ diff --git a/packages/kbn-es-query/src/kuery/grammar/grammar.config.json b/packages/kbn-es-query/src/kuery/grammar/grammar.peggy.config.json similarity index 100% rename from packages/kbn-es-query/src/kuery/grammar/grammar.config.json rename to packages/kbn-es-query/src/kuery/grammar/grammar.peggy.config.json diff --git a/packages/kbn-interpreter/BUILD.bazel b/packages/kbn-interpreter/BUILD.bazel index caa5b422dc647..26a359a89cbe6 100644 --- a/packages/kbn-interpreter/BUILD.bazel +++ b/packages/kbn-interpreter/BUILD.bazel @@ -9,7 +9,7 @@ SOURCE_FILES = glob( [ "**/*.ts", "**/*.js", - "**/grammar.config.json", + "**/grammar.peggy.config.json", "**/grammar.peggy", ], exclude = [ diff --git a/packages/kbn-interpreter/src/common/lib/grammar.config.json b/packages/kbn-interpreter/src/common/lib/grammar.peggy.config.json similarity index 100% rename from packages/kbn-interpreter/src/common/lib/grammar.config.json rename to packages/kbn-interpreter/src/common/lib/grammar.peggy.config.json diff --git a/packages/kbn-peggy/README.mdx b/packages/kbn-peggy/README.mdx index 1c9d536fe4791..5d9779976b15a 100644 --- a/packages/kbn-peggy/README.mdx +++ b/packages/kbn-peggy/README.mdx @@ -9,7 +9,7 @@ tags: ['kibana', 'dev', 'contributor', 'operations', 'peggy'] This package wraps the peggy package, exposing a synchronous and async version of the generator which includes two modifications: - 1. When a `path` is provided a `${basename}.config.json` file will be loaded if it exists and it expected to include peggy config options as defined in [the peggy docs](https://peggyjs.org/documentation.html#generating-a-parser-javascript-api). This config will be used when compiling this file + 1. When a `path` is provided a `${basename}.config.json` file will be loaded if it exists and is expected to include peggy config options as defined in [the peggy docs](https://peggyjs.org/documentation.html#generating-a-parser-javascript-api). This config will be used when compiling this file ## Plugins These types will automatically be included for plugins. diff --git a/packages/kbn-peggy/index.ts b/packages/kbn-peggy/index.ts index a8a6aafe7f5a8..b5b35f131d2ee 100644 --- a/packages/kbn-peggy/index.ts +++ b/packages/kbn-peggy/index.ts @@ -65,15 +65,7 @@ export interface Result { } export function findConfigFile(grammarPath: string): Config | undefined { - const extname = Path.extname(grammarPath); - if (extname !== '.peggy') { - throw new Error(`unexpected extension [${extname}], expected ".peggy"`); - } - - const path = Path.resolve( - Path.dirname(grammarPath), - `${Path.basename(grammarPath, extname)}.config.json` - ); + const path = Path.resolve(Path.dirname(grammarPath), `${Path.basename(grammarPath)}.config.json`); let source; let parsed;