chore(NA): moving @kbn/es into bazel (#99371)

* chore(NA): moving @kbn/es into bazel

* chore(NA): remove build scripts from pkg json

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tiago Costa 2021-05-05 20:52:01 +01:00 committed by GitHub
parent 24734a39d1
commit 43d3a97f5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 104 additions and 70 deletions

View file

@ -73,6 +73,7 @@ yarn kbn watch-bazel
- @kbn/config-schema
- @kbn/crypto
- @kbn/dev-utils
- @kbn/es
- @kbn/eslint-import-resolver-kibana
- @kbn/eslint-plugin-eslint
- @kbn/expect

View file

@ -447,7 +447,7 @@
"@kbn/cli-dev-mode": "link:packages/kbn-cli-dev-mode",
"@kbn/dev-utils": "link:bazel-bin/packages/kbn-dev-utils/npm_module",
"@kbn/docs-utils": "link:packages/kbn-docs-utils",
"@kbn/es": "link:packages/kbn-es",
"@kbn/es": "link:bazel-bin/packages/kbn-es/npm_module",
"@kbn/es-archiver": "link:packages/kbn-es-archiver",
"@kbn/eslint-import-resolver-kibana": "link:bazel-bin/packages/kbn-eslint-import-resolver-kibana/npm_module",
"@kbn/eslint-plugin-eslint": "link:bazel-bin/packages/kbn-eslint-plugin-eslint/npm_module",

View file

@ -15,6 +15,7 @@ filegroup(
"//packages/kbn-config-schema:build",
"//packages/kbn-crypto:build",
"//packages/kbn-dev-utils:build",
"//packages/kbn-es:build",
"//packages/kbn-eslint-import-resolver-kibana:build",
"//packages/kbn-eslint-plugin-eslint:build",
"//packages/kbn-expect:build",

3
packages/kbn-es/.babelrc Normal file
View file

@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}

View file

@ -0,0 +1,90 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("@npm//@babel/cli:index.bzl", "babel")
PKG_BASE_NAME = "kbn-es"
PKG_REQUIRE_NAME = "@kbn/es"
SOURCE_FILES = glob(
[
"src/**/*",
],
exclude = [
"**/*.test.*",
"**/integration_tests/**",
"**/__fixtures__/**",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
"README.md",
]
DEPS = [
"//packages/kbn-babel-preset",
"@npm//@elastic/elasticsearch",
"@npm//abort-controller",
"@npm//chalk",
"@npm//dedent",
"@npm//del",
"@npm//execa",
"@npm//getopts",
"@npm//glob",
"@npm//node-fetch",
"@npm//simple-git",
"@npm//tar-fs",
"@npm//tree-kill",
"@npm//yauzl",
"@npm//zlib"
]
babel(
name = "target",
data = [
":srcs",
".babelrc",
] + DEPS,
output_dir = True,
# the following arg paths includes $(execpath) as babel runs on the sandbox root
args = [
"./%s/src" % package_name(),
"--config-file",
"./%s/.babelrc" % package_name(),
"--out-dir",
"$(@D)",
"--extensions",
".ts,.js",
"--copy-files",
"--quiet"
],
)
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = [":target"] + DEPS,
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

@ -6,10 +6,5 @@
"private": true,
"kibana": {
"devOnly": true
},
"scripts": {
"build": "node scripts/build",
"kbn:bootstrap": "node scripts/build",
"kbn:watch": "node scripts/build --watch"
}
}

View file

@ -1,60 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
const { resolve } = require('path');
const del = require('del');
const { run, withProcRunner } = require('@kbn/dev-utils');
const ROOT_DIR = resolve(__dirname, '..');
const BUILD_DIR = resolve(ROOT_DIR, 'target');
run(
async ({ log, flags }) => {
await withProcRunner(log, async (proc) => {
log.info('Deleting old output');
await del(BUILD_DIR);
const cwd = ROOT_DIR;
log.info(`Starting babel${flags.watch ? ' in watch mode' : ''}`);
await proc.run(`babel`, {
cmd: 'babel',
args: [
'src',
'--no-babelrc',
'--presets',
require.resolve('@kbn/babel-preset/node_preset'),
'--extensions',
'.ts,.js',
'--copy-files',
'--out-dir',
BUILD_DIR,
...(flags.watch ? ['--watch'] : ['--quiet']),
...(!flags['source-maps'] || !!process.env.CODE_COVERAGE
? []
: ['--source-maps', 'inline']),
],
wait: true,
cwd,
});
log.success('Complete');
});
},
{
description: 'Simple build tool for @kbn/es package',
flags: {
boolean: ['watch', 'source-maps'],
help: `
--watch Run in watch mode
--source-maps Include sourcemaps
`,
},
}
);

View file

@ -14,7 +14,6 @@
"devOnly": true
},
"dependencies": {
"@kbn/es": "link:../kbn-es",
"@kbn/i18n": "link:../kbn-i18n",
"@kbn/optimizer": "link:../kbn-optimizer"
}

View file

@ -27,7 +27,6 @@
"yarn": "^1.21.1"
},
"devDependencies": {
"@kbn/es": "link:../packages/kbn-es",
"@kbn/plugin-helpers": "link:../packages/kbn-plugin-helpers",
"@kbn/storybook": "link:../packages/kbn-storybook",
"@kbn/test": "link:../packages/kbn-test"

View file

@ -2635,7 +2635,7 @@
version "0.0.0"
uid ""
"@kbn/es@link:packages/kbn-es":
"@kbn/es@link:bazel-bin/packages/kbn-es/npm_module":
version "0.0.0"
uid ""
@ -2692,11 +2692,17 @@
uid ""
"@kbn/securitysolution-constants@link:bazel-bin/packages/kbn-securitysolution-constants/npm_module":
"@kbn/securitysolution-utils@link:bazel-bin/packages/kbn-securitysolution-utils/npm_module":
version "0.0.0"
uid ""
"@kbn/securitysolution-io-ts-utils@link:bazel-bin/packages/kbn-securitysolution-io-ts-utils/npm_module":
version "0.0.0"
uid ""
"@kbn/securitysolution-utils@link:bazel-bin/packages/kbn-securitysolution-utils/npm_module":
version "0.0.0"
uid ""
"@kbn/server-http-tools@link:packages/kbn-server-http-tools":
version "0.0.0"
uid ""