-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[packages] Migrate @kbn/test to Bazel (#103122)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
ff47516
commit bed5b6d
Showing
18 changed files
with
198 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") | ||
load("@npm//@babel/cli:index.bzl", "babel") | ||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") | ||
|
||
PKG_BASE_NAME = "kbn-test" | ||
PKG_REQUIRE_NAME = "@kbn/test" | ||
|
||
SOURCE_FILES = glob( | ||
[ | ||
"src/**/*" | ||
], | ||
exclude = [ | ||
"**/*.test.*", | ||
"**/*.snap", | ||
"**/__fixture__/**", | ||
"**/__fixtures__/**", | ||
"**/__snapshots__/**", | ||
] | ||
) | ||
|
||
SRCS = SOURCE_FILES | ||
|
||
filegroup( | ||
name = "srcs", | ||
srcs = SRCS, | ||
) | ||
|
||
NPM_MODULE_EXTRA_FILES = [ | ||
"jest/package.json", | ||
"jest-preset.js", | ||
"jest.config.js", | ||
"README.md", | ||
"package.json", | ||
] | ||
|
||
SRC_DEPS = [ | ||
"//packages/kbn-dev-utils", | ||
"//packages/kbn-i18n", | ||
"//packages/kbn-std", | ||
"//packages/kbn-utils", | ||
"@npm//@elastic/elasticsearch", | ||
"@npm//axios", | ||
"@npm//@babel/traverse", | ||
"@npm//chance", | ||
"@npm//del", | ||
"@npm//enzyme", | ||
"@npm//execa", | ||
"@npm//exit-hook", | ||
"@npm//form-data", | ||
"@npm//globby", | ||
"@npm//history", | ||
"@npm//jest", | ||
"@npm//jest-cli", | ||
"@npm//jest-snapshot", | ||
"@npm//@jest/reporters", | ||
"@npm//joi", | ||
"@npm//mustache", | ||
"@npm//parse-link-header", | ||
"@npm//prettier", | ||
"@npm//react-dom", | ||
"@npm//react-redux", | ||
"@npm//react-router-dom", | ||
"@npm//redux", | ||
"@npm//rxjs", | ||
"@npm//strip-ansi", | ||
"@npm//xmlbuilder", | ||
"@npm//xml2js", | ||
] | ||
|
||
TYPES_DEPS = [ | ||
"@npm//@types/chance", | ||
"@npm//@types/enzyme", | ||
"@npm//@types/history", | ||
"@npm//@types/jest", | ||
"@npm//@types/joi", | ||
"@npm//@types/lodash", | ||
"@npm//@types/mustache", | ||
"@npm//@types/node", | ||
"@npm//@types/parse-link-header", | ||
"@npm//@types/prettier", | ||
"@npm//@types/react-dom", | ||
"@npm//@types/react-redux", | ||
"@npm//@types/react-router-dom", | ||
"@npm//@types/xml2js", | ||
] | ||
|
||
DEPS = SRC_DEPS + TYPES_DEPS | ||
|
||
babel( | ||
name = "target_node", | ||
data = DEPS + [ | ||
":srcs", | ||
"babel.config.js", | ||
], | ||
output_dir = True, | ||
# the following arg paths includes $(execpath) as babel runs on the sandbox root | ||
args = [ | ||
"./%s/src" % package_name(), | ||
"--config-file", | ||
"./%s/babel.config.js" % package_name(), | ||
"--out-dir", | ||
"$(@D)", | ||
"--extensions", | ||
".ts,.js,.tsx", | ||
"--quiet" | ||
], | ||
) | ||
|
||
ts_config( | ||
name = "tsconfig", | ||
src = "tsconfig.json", | ||
deps = [ | ||
"//:tsconfig.base.json", | ||
], | ||
) | ||
|
||
ts_project( | ||
name = "tsc", | ||
args = ['--pretty'], | ||
srcs = SRCS, | ||
deps = DEPS, | ||
declaration = True, | ||
declaration_map = True, | ||
declaration_dir = "target_types", | ||
emit_declaration_only = True, | ||
incremental = True, | ||
source_map = True, | ||
root_dir = "src", | ||
tsconfig = ":tsconfig", | ||
) | ||
|
||
js_library( | ||
name = PKG_BASE_NAME, | ||
srcs = NPM_MODULE_EXTRA_FILES, | ||
deps = DEPS + [":target_node", ":tsc"], | ||
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"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"main": "../target/jest", | ||
"types": "../target/types/jest/index.d.ts" | ||
"main": "../target_node/jest", | ||
"types": "../target_types/jest/index.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.