Skip to content

Commit

Permalink
chore(NA): upgrades bazel rules nodejs to v5 (#129522)
Browse files Browse the repository at this point in the history
* chore(NA): upgrade bazel into v5

* chore(NA): initial work to upgrade to rules v5

* chore(NA): remove @elastic/datemath jest unit test for eslint plugin imports

* chore(NA): removed packager tsc_wrapped added my mistake
  • Loading branch information
mistic authored Apr 8, 2022
1 parent 5dbd177 commit eb0ef19
Show file tree
Hide file tree
Showing 139 changed files with 183 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ module.exports = {
*/
{
files: [
'packages/elastic-datemath/**/*.{js,mjs,ts,tsx}',
'packages/elastic-eslint-config-kibana/**/*.{js,mjs,ts,tsx}',
'packages/kbn-datemath/**/*.{js,mjs,ts,tsx}',
],
rules: {
'@kbn/eslint/require-license-header': [
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
/examples/field_formats_example/ @elastic/kibana-app-services
/examples/partial_results_example/ @elastic/kibana-app-services
/examples/search_examples/ @elastic/kibana-app-services
/packages/elastic-datemath/ @elastic/kibana-app-services
/packages/kbn-datemath/ @elastic/kibana-app-services
/packages/kbn-interpreter/ @elastic/kibana-app-services
/packages/kbn-react-field/ @elastic/kibana-app-services
/packages/kbn-es-query/ @elastic/kibana-app-services
Expand Down
16 changes: 8 additions & 8 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Fetch Node.js rules
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "8a7c981217239085f78acc9898a1f7ba99af887c1996ceb3b4504655383a2c3c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.0.0/rules_nodejs-4.0.0.tar.gz"],
sha256 = "523da2d6b50bc00eaf14b00ed28b1a366b3ab456e14131e9812558b26599125c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.3.1/rules_nodejs-5.3.1.tar.gz"],
)

# Now that we have the rules let's import from them to complete the work
load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version", "node_repositories", "yarn_install")
# Build Node.js rules dependencies
load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
build_bazel_rules_nodejs_dependencies()

# Assure we have at least a given rules_nodejs version
check_rules_nodejs_version(minimum_version_string = "4.0.0")
# Now that we have the rules let's import from them to complete the work
load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")

# Setup the Node.js toolchain for the architectures we want to support
#
Expand All @@ -38,14 +39,13 @@ node_repositories(
node_urls = [
"https://nodejs.org/dist/v{version}/{filename}",
],
yarn_repositories = {
yarn_releases = {
"1.21.1": ("yarn-v1.21.1.tar.gz", "yarn-v1.21.1", "d1d9f4a0f16f5ed484e814afeb98f39b82d4728c6c8beaafb5abc99c02db6674"),
},
yarn_version = "1.21.1",
yarn_urls = [
"https://github.com/yarnpkg/yarn/releases/download/v{version}/{filename}",
],
package_json = ["//:package.json"],
)

# Run yarn_install rule to take care of dependencies
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/getting-started/monorepo-packages.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ yarn kbn watch
[discrete]
=== List of Already Migrated Packages to Bazel

- @elastic/datemath
- @elastic/eslint-config-kibana
- @elastic/safer-lodash-set
- @kbn/ace
Expand All @@ -64,6 +63,7 @@ yarn kbn watch
- @kbn/config
- @kbn/config-schema
- @kbn/crypto
- @kbn/datemath
- @kbn/dev-utils
- @kbn/docs-utils
- @kbn/es
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"@elastic/apm-rum-react": "^1.3.4",
"@elastic/apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace",
"@elastic/charts": "45.1.1",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/datemath": "5.0.3",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@8.2.0-canary.2",
"@elastic/ems-client": "8.2.0",
"@elastic/eui": "53.0.1",
Expand Down Expand Up @@ -140,6 +140,7 @@
"@kbn/config": "link:bazel-bin/packages/kbn-config",
"@kbn/config-schema": "link:bazel-bin/packages/kbn-config-schema",
"@kbn/crypto": "link:bazel-bin/packages/kbn-crypto",
"@kbn/datemath": "link:bazel-bin/packages/kbn-datemath",
"@kbn/doc-links": "link:bazel-bin/packages/kbn-doc-links",
"@kbn/es-query": "link:bazel-bin/packages/kbn-es-query",
"@kbn/eslint-plugin-imports": "link:bazel-bin/packages/kbn-eslint-plugin-imports",
Expand Down Expand Up @@ -455,7 +456,7 @@
"@babel/traverse": "^7.17.3",
"@babel/types": "^7.17.0",
"@bazel/ibazel": "^0.16.2",
"@bazel/typescript": "4.0.0",
"@bazel/typescript": "5.3.1",
"@cypress/code-coverage": "^3.9.12",
"@cypress/snapshot": "^2.1.7",
"@cypress/webpack-preprocessor": "^5.6.0",
Expand Down Expand Up @@ -545,7 +546,6 @@
"@types/delete-empty": "^2.0.0",
"@types/ejs": "^3.0.6",
"@types/elastic__apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace/npm_module_types",
"@types/elastic__datemath": "link:bazel-bin/packages/elastic-datemath/npm_module_types",
"@types/enzyme": "^3.10.8",
"@types/eslint": "^7.28.0",
"@types/express": "^4.17.13",
Expand Down Expand Up @@ -595,6 +595,7 @@
"@types/kbn__config": "link:bazel-bin/packages/kbn-config/npm_module_types",
"@types/kbn__config-schema": "link:bazel-bin/packages/kbn-config-schema/npm_module_types",
"@types/kbn__crypto": "link:bazel-bin/packages/kbn-crypto/npm_module_types",
"@types/kbn__datemath": "link:bazel-bin/packages/kbn-datemath/npm_module_types",
"@types/kbn__dev-utils": "link:bazel-bin/packages/kbn-dev-utils/npm_module_types",
"@types/kbn__doc-links": "link:bazel-bin/packages/kbn-doc-links/npm_module_types",
"@types/kbn__docs-utils": "link:bazel-bin/packages/kbn-docs-utils/npm_module_types",
Expand Down
4 changes: 2 additions & 2 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ filegroup(
srcs = [
"//packages/elastic-analytics:build",
"//packages/elastic-apm-synthtrace:build",
"//packages/elastic-datemath:build",
"//packages/elastic-eslint-config-kibana:build",
"//packages/elastic-safer-lodash-set:build",
"//packages/kbn-ace:build",
Expand All @@ -30,6 +29,7 @@ filegroup(
"//packages/kbn-config-schema:build",
"//packages/kbn-config:build",
"//packages/kbn-crypto:build",
"//packages/kbn-datemath:build",
"//packages/kbn-dev-utils:build",
"//packages/kbn-doc-links:build",
"//packages/kbn-docs-utils:build",
Expand Down Expand Up @@ -102,7 +102,6 @@ filegroup(
srcs = [
"//packages/elastic-analytics:build_types",
"//packages/elastic-apm-synthtrace:build_types",
"//packages/elastic-datemath:build_types",
"//packages/elastic-safer-lodash-set:build_types",
"//packages/kbn-ace:build_types",
"//packages/kbn-alerts:build_types",
Expand All @@ -116,6 +115,7 @@ filegroup(
"//packages/kbn-config-schema:build_types",
"//packages/kbn-config:build_types",
"//packages/kbn-crypto:build_types",
"//packages/kbn-datemath:build_types",
"//packages/kbn-dev-utils:build_types",
"//packages/kbn-doc-links:build_types",
"//packages/kbn-docs-utils:build_types",
Expand Down
4 changes: 2 additions & 2 deletions packages/elastic-apm-synthtrace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ NPM_MODULE_EXTRA_FILES = [
]

RUNTIME_DEPS = [
"//packages/elastic-datemath",
"//packages/kbn-datemath",
"@npm//@elastic/elasticsearch",
"@npm//lodash",
"@npm//moment",
Expand All @@ -36,7 +36,7 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/elastic-datemath:npm_module_types",
"//packages/kbn-datemath:npm_module_types",
"@npm//@elastic/elasticsearch",
"@npm//@types/jest",
"@npm//@types/lodash",
Expand Down
2 changes: 1 addition & 1 deletion packages/elastic-apm-synthtrace/src/scripts/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import datemath from '@elastic/datemath';
import datemath from '@kbn/datemath';
import yargs from 'yargs/yargs';
import { Argv } from 'yargs';
import { intervalToMs } from './utils/interval_to_ms';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "ts_project", "pkg_npm", "pkg_npm_types")

PKG_BASE_NAME = "elastic-datemath"
PKG_REQUIRE_NAME = "@elastic/datemath"
PKG_BASE_NAME = "kbn-datemath"
PKG_REQUIRE_NAME = "@kbn/datemath"

SOURCE_FILES = glob([
"src/index.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# datemath

Datemath string parser used in Kibana. This is published to NPM for use in a limited number of locations outside of Kibana, but is not regularly updated and may get seriously out of date.
Datemath string parser used in Kibana. This is published to NPM under (@elastic/datemath) for use in a limited number of locations outside of Kibana, but is not regularly updated and may get seriously out of date.

If you file an issue in elastic/kibana we can probably update it for you if needed, though you probably shouldn't depend on this package for anything important.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/elastic-datemath'],
roots: ['<rootDir>/packages/kbn-datemath'],
testEnvironment: 'jsdom',
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elastic/datemath",
"version": "5.0.3",
"name": "@kbn/datemath",
"version": "5.0.4",
"description": "elasticsearch datemath parser, used in kibana",
"license": "Apache-2.0",
"main": "./target_node/index.js",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/kbn-docs-utils/src/api_docs/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const log = new ToolingLog({
});

it('getFileName', () => {
expect(getFileName('@elastic/datemath')).toBe('elastic_datemath');
expect(getFileName('@kbn/datemath')).toBe('kbn_datemath');
});

it('test getPluginForPath', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ describe('standard import formats', () => {
});

it('resolves @elastic/ imports', () => {
expect(resolveKibanaImport('@elastic/datemath', pkg('kbn-dev-utils/src')))
.toMatchInlineSnapshot(`
Object {
"absolute": <absolute path>/node_modules/@elastic/datemath/target_node/index.js,
"nodeModule": "@elastic/datemath",
"type": "file",
}
`);

expect(resolveKibanaImport('@elastic/eui', pkg('kbn-dev-utils/src'))).toMatchInlineSnapshot(`
Object {
"absolute": <absolute path>/node_modules/@elastic/eui/lib/index.js,
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8949,7 +8949,7 @@ const BootstrapCommand = {
await time('force install dependencies', async () => {
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["removeYarnIntegrityFileIfExists"])(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(kibanaProjectPath, 'node_modules'));
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["runBazel"])(['clean']);
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["runBazel"])(['run', '@nodejs//:yarn'], runOffline, {
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["runBazel"])(['run', '@yarn//:yarn'], runOffline, {
env: {
SASS_BINARY_SITE: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-sass',
RE2_DOWNLOAD_MIRROR: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2'
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/src/commands/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const BootstrapCommand: ICommand = {
await time('force install dependencies', async () => {
await removeYarnIntegrityFileIfExists(resolve(kibanaProjectPath, 'node_modules'));
await runBazel(['clean']);
await runBazel(['run', '@nodejs//:yarn'], runOffline, {
await runBazel(['run', '@yarn//:yarn'], runOffline, {
env: {
SASS_BINARY_SITE:
'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-sass',
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-securitysolution-autocomplete/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ NPM_MODULE_EXTRA_FILES = [
]

RUNTIME_DEPS = [
"//packages/elastic-datemath",
"//packages/kbn-datemath",
"//packages/kbn-es-query",
"//packages/kbn-i18n",
"//packages/kbn-securitysolution-io-ts-list-types",
Expand All @@ -46,7 +46,7 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/elastic-datemath:npm_module_types",
"//packages/kbn-datemath:npm_module_types",
"//packages/kbn-es-query:npm_module_types",
"//packages/kbn-i18n:npm_module_types",
"//packages/kbn-securitysolution-io-ts-list-types:npm_module_types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import dateMath from '@elastic/datemath';
import dateMath from '@kbn/datemath';
import { DataViewFieldBase } from '@kbn/es-query';
import { checkEmptyValue } from '../check_empty_value';

Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-securitysolution-io-ts-utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ NPM_MODULE_EXTRA_FILES = [
]

RUNTIME_DEPS = [
"//packages/elastic-datemath",
"//packages/kbn-datemath",
"@npm//fp-ts",
"@npm//io-ts",
"@npm//lodash",
Expand All @@ -37,7 +37,7 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/elastic-datemath:npm_module_types",
"//packages/kbn-datemath:npm_module_types",
"@npm//fp-ts",
"@npm//io-ts",
"@npm//moment",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import moment from 'moment';
import dateMath from '@elastic/datemath';
import dateMath from '@kbn/datemath';

export const parseScheduleDates = (time: string): moment.Moment | null => {
const isValidDateString = !isNaN(Date.parse(time));
Expand Down
5 changes: 2 additions & 3 deletions packages/kbn-type-summarizer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("@rules_nodejs//nodejs:directory_file_path.bzl", "directory_file_path")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "nodejs_binary")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
load("@build_bazel_rules_nodejs//internal/node:node.bzl", "nodejs_binary")
load("@build_bazel_rules_nodejs//:index.bzl", "directory_file_path")

PKG_BASE_NAME = "kbn-type-summarizer"
PKG_REQUIRE_NAME = "@kbn/type-summarizer"
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-ui-shared-deps-npm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ NPM_MODULE_EXTRA_FILES = [
]

RUNTIME_DEPS = [
"//packages/elastic-datemath",
"@npm//@babel/runtime",
"@npm//@elastic/charts",
"@npm//@elastic/eui",
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-ui-shared-deps-src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ NPM_MODULE_EXTRA_FILES = [
]

RUNTIME_DEPS = [
"//packages/elastic-datemath",
"//packages/elastic-safer-lodash-set",
"//packages/kbn-analytics",
"//packages/kbn-babel-preset",
"//packages/kbn-datemath",
"//packages/kbn-flot-charts",
"//packages/kbn-i18n",
"//packages/kbn-i18n-react",
Expand All @@ -42,9 +42,9 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/elastic-datemath:npm_module_types",
"//packages/elastic-safer-lodash-set:npm_module_types",
"//packages/kbn-analytics:npm_module_types",
"//packages/kbn-datemath:npm_module_types",
"//packages/kbn-i18n:npm_module_types",
"//packages/kbn-i18n-react:npm_module_types",
"//packages/kbn-monaco:npm_module_types",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-ui-shared-deps-src/src/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const externals = {
numeral: '__kbnSharedDeps__.ElasticNumeral',
'@elastic/numeral': '__kbnSharedDeps__.ElasticNumeral',
'@elastic/charts': '__kbnSharedDeps__.ElasticCharts',
'@kbn/datemath': '__kbnSharedDeps__.KbnDatemath',
'@elastic/eui': '__kbnSharedDeps__.ElasticEui',
'@elastic/eui/lib/services': '__kbnSharedDeps__.ElasticEuiLibServices',
'@elastic/eui/lib/services/format': '__kbnSharedDeps__.ElasticEuiLibServicesFormat',
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-ui-shared-deps-src/src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const ElasticEui = require('@elastic/eui');
export const ElasticEuiLibServices = require('@elastic/eui/lib/services');
export const ElasticEuiLibServicesFormat = require('@elastic/eui/lib/services/format');
export const ElasticEuiChartsTheme = require('@elastic/eui/dist/eui_charts_theme');
export const ElasticDatemath = require('@elastic/datemath');
export const KbnDatemath = require('@kbn/datemath');
export const ReactBeautifulDnD = require('react-beautiful-dnd');

export const Lodash = require('lodash');
Expand Down
2 changes: 1 addition & 1 deletion src/dev/bazel/pkg_npm_types.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pkg_npm_types = rule(
"_packager": attr.label(
doc = "Target that executes the npm types package assembler binary",
executable = True,
cfg = "host",
cfg = "exec",
default = Label("//packages/kbn-type-summarizer:bazel-cli"),
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { memoize } from 'lodash';
import dateMath from '@elastic/datemath';
import dateMath from '@kbn/datemath';
import { buildEsQuery } from '@kbn/es-query';

import { TimeRange } from '../../../../data/public';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/common/query/timefilter/get_time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import dateMath from '@elastic/datemath';
import dateMath from '@kbn/datemath';
import { omitBy } from 'lodash';
import { buildRangeFilter } from '@kbn/es-query';
import type { Moment } from 'moment';
Expand Down
Loading

0 comments on commit eb0ef19

Please sign in to comment.