Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(NA): splits types from code on @kbn/dev-utils #120531

Merged
merged 5 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,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__dev-utils": "link:bazel-bin/packages/kbn-dev-utils/npm_module_types",
"@types/kbn__docs-utils": "link:bazel-bin/packages/kbn-docs-utils/npm_module_types",
"@types/kbn__i18n": "link:bazel-bin/packages/kbn-i18n/npm_module_types",
"@types/kbn__i18n-react": "link:bazel-bin/packages/kbn-i18n-react/npm_module_types",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ filegroup(
"//packages/kbn-config:build_types",
"//packages/kbn-config-schema:build_types",
"//packages/kbn-crypto:build_types",
"//packages/kbn-dev-utils:build_types",
"//packages/kbn-docs-utils:build_types",
"//packages/kbn-i18n:build_types",
"//packages/kbn-i18n-react:build_types",
Expand Down
2 changes: 1 addition & 1 deletion packages/elastic-eslint-config-kibana/react.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const semver = require('semver');
const { kibanaPackageJson: PKG } = require('@kbn/dev-utils');
const { kibanaPackageJson: PKG } = require('@kbn/utils');

module.exports = {
plugins: [
Expand Down
2 changes: 1 addition & 1 deletion packages/elastic-eslint-config-kibana/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// as this package was moved from typescript-eslint-parser to @typescript-eslint/parser

const semver = require('semver');
const { kibanaPackageJson: PKG } = require('@kbn/dev-utils');
const { kibanaPackageJson: PKG } = require('@kbn/utils');

const eslintConfigPrettierTypescriptEslintRules = require('eslint-config-prettier/@typescript-eslint').rules;

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-cli-dev-mode/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"//packages/kbn-config:npm_module_types",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-dev-utils",
"//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-logging",
"//packages/kbn-optimizer",
"//packages/kbn-server-http-tools",
Expand Down
8 changes: 3 additions & 5 deletions packages/kbn-cli-dev-mode/src/cli_dev_mode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

import Path from 'path';
import * as Rx from 'rxjs';
import {
REPO_ROOT,
createAbsolutePathSerializer,
createAnyInstanceSerializer,
} from '@kbn/dev-utils';
import { createAbsolutePathSerializer, createAnyInstanceSerializer } from '@kbn/dev-utils';

import { REPO_ROOT } from '@kbn/utils';

import { TestLog } from './log';
import { CliDevMode, SomeCliArgs } from './cli_dev_mode';
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-cli-dev-mode/src/cli_dev_mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
takeUntil,
} from 'rxjs/operators';
import { CliArgs } from '@kbn/config';
import { REPO_ROOT, CiStatsReporter } from '@kbn/dev-utils';
import { CiStatsReporter } from '@kbn/dev-utils';
import { REPO_ROOT } from '@kbn/utils';

import { Log, CliLog } from './log';
import { Optimizer } from './optimizer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import Path from 'path';

import { REPO_ROOT, createAbsolutePathSerializer } from '@kbn/dev-utils';
import { createAbsolutePathSerializer } from '@kbn/dev-utils';
import { REPO_ROOT } from '@kbn/utils';

import { getServerWatchPaths } from './get_server_watch_paths';

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-cli-dev-mode/src/get_server_watch_paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Path from 'path';
import Fs from 'fs';

import { REPO_ROOT } from '@kbn/dev-utils';
import { REPO_ROOT } from '@kbn/utils';

interface Options {
pluginPaths: string[];
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-crypto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-dev-utils",
"//packages/kbn-dev-utils:npm_module_types",
"@npm//@types/flot",
"@npm//@types/jest",
"@npm//@types/node",
Expand Down
28 changes: 22 additions & 6 deletions packages/kbn-dev-utils/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
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", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_BASE_NAME = "kbn-dev-utils"
PKG_REQUIRE_NAME = "@kbn/dev-utils"
TYPES_PKG_REQUIRE_NAME = "@types/kbn__dev-utils"

SOURCE_FILES = glob(
[
Expand Down Expand Up @@ -43,7 +44,6 @@ NPM_MODULE_EXTRA_FILES = [
]

RUNTIME_DEPS = [
"//packages/kbn-std",
"//packages/kbn-utils",
"@npm//@babel/core",
"@npm//axios",
Expand All @@ -66,7 +66,6 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-std",
"//packages/kbn-utils",
"@npm//@babel/parser",
"@npm//@babel/types",
Expand Down Expand Up @@ -124,7 +123,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
deps = RUNTIME_DEPS + [":target_node"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand All @@ -143,3 +142,20 @@ filegroup(
],
visibility = ["//visibility:public"],
)

pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = TYPES_PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)

filegroup(
name = "build_types",
srcs = [
":npm_module_types",
],
visibility = ["//visibility:public"],
)
1 change: 0 additions & 1 deletion packages/kbn-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts",
"kibana": {
"devOnly": true
}
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-dev-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

export * from '@kbn/utils';
export { withProcRunner, ProcRunner } from './proc_runner';
export * from './tooling_log';
export * from './serializers';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-docs-utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"//packages/kbn-config:npm_module_types",
"//packages/kbn-dev-utils",
"//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-utils",
"@npm//ts-morph",
"@npm//@types/dedent",
Expand Down
5 changes: 3 additions & 2 deletions packages/kbn-docs-utils/src/api_docs/build_api_docs_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import Fs from 'fs';
import Path from 'path';

import { REPO_ROOT, run, CiStatsReporter, createFlagError } from '@kbn/dev-utils';
import { run, CiStatsReporter, createFlagError } from '@kbn/dev-utils';
import { REPO_ROOT } from '@kbn/utils';
import { Project } from 'ts-morph';

import { writePluginDocs } from './mdx/write_plugin_mdx_docs';
Expand Down Expand Up @@ -241,7 +242,7 @@ export function runBuildApiDocsCli() {
boolean: ['references'],
help: `
--plugin Optionally, run for only a specific plugin
--stats Optionally print API stats. Must be one or more of: any, comments or exports.
--stats Optionally print API stats. Must be one or more of: any, comments or exports.
--references Collect references for API items
`,
},
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-docs-utils/src/api_docs/find_plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import globby from 'globby';
import loadJsonFile from 'load-json-file';

import { getPluginSearchPaths } from '@kbn/config';
import { simpleKibanaPlatformPluginDiscovery, REPO_ROOT } from '@kbn/dev-utils';
import { simpleKibanaPlatformPluginDiscovery } from '@kbn/dev-utils';
import { REPO_ROOT } from '@kbn/utils';
import { ApiScope, PluginOrPackage } from './types';

export function findPlugins(): PluginOrPackage[] {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-es-archiver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-dev-utils",
"//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-test",
"//packages/kbn-utils",
"@npm//@elastic/elasticsearch",
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-es-archiver/src/actions/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import { resolve, relative } from 'path';
import { createReadStream } from 'fs';
import { Readable } from 'stream';
import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
import { ToolingLog } from '@kbn/dev-utils';
import { REPO_ROOT } from '@kbn/utils';
import { KbnClient } from '@kbn/test';
import type { Client } from '@elastic/elasticsearch';
import { createPromiseFromStreams, concatStreamProviders } from '@kbn/utils';
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-es-archiver/src/actions/rebuild_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { resolve, relative } from 'path';
import { Stats, createReadStream, createWriteStream } from 'fs';
import { stat, rename } from 'fs/promises';
import { Readable, Writable } from 'stream';
import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
import { createPromiseFromStreams } from '@kbn/utils';
import { ToolingLog } from '@kbn/dev-utils';
import { createPromiseFromStreams, REPO_ROOT } from '@kbn/utils';
import {
prioritizeMappings,
readDirectory,
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-es-archiver/src/actions/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { resolve, relative } from 'path';
import { createWriteStream, mkdirSync } from 'fs';
import { Readable, Writable } from 'stream';
import type { Client } from '@elastic/elasticsearch';
import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
import { createListStream, createPromiseFromStreams } from '@kbn/utils';
import { ToolingLog } from '@kbn/dev-utils';
import { createListStream, createPromiseFromStreams, REPO_ROOT } from '@kbn/utils';

import {
createStats,
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-es-archiver/src/actions/unload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { resolve, relative } from 'path';
import { createReadStream } from 'fs';
import { Readable, Writable } from 'stream';
import type { Client } from '@elastic/elasticsearch';
import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
import { ToolingLog } from '@kbn/dev-utils';
import { KbnClient } from '@kbn/test';
import { createPromiseFromStreams } from '@kbn/utils';
import { createPromiseFromStreams, REPO_ROOT } from '@kbn/utils';

import {
isGzip,
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-es-archiver/src/es_archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Fs from 'fs';
import Path from 'path';

import type { Client } from '@elastic/elasticsearch';
import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
import { ToolingLog } from '@kbn/dev-utils';
import { REPO_ROOT } from '@kbn/utils';
import { KbnClient } from '@kbn/test';

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
* Side Public License, v 1.
*/

import { ToolingLog } from '@kbn/dev-utils';

import {
createListStream,
createPromiseFromStreams,
createConcatStream,
createMapStream,
ToolingLog,
} from '@kbn/dev-utils';
} from '@kbn/utils';

import { createGenerateDocRecordsStream } from './generate_doc_records_stream';
import { Progress } from '../progress';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
* Side Public License, v 1.
*/

import {
createListStream,
createPromiseFromStreams,
ToolingLog,
createRecursiveSerializer,
} from '@kbn/dev-utils';
import { ToolingLog, createRecursiveSerializer } from '@kbn/dev-utils';

import { createListStream, createPromiseFromStreams } from '@kbn/utils';

import { Progress } from '../progress';
import { createIndexDocRecordsStream } from './index_doc_records_stream';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-eslint-plugin-eslint/helpers/exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
const Fs = require('fs');
const Path = require('path');
const ts = require('typescript');
const { REPO_ROOT } = require('@kbn/dev-utils');
const { REPO_ROOT } = require('@kbn/utils');
const { ExportSet } = require('./export_set');

/** @typedef {import("@typescript-eslint/types").TSESTree.ExportAllDeclaration} ExportAllDeclaration */
Expand Down
6 changes: 5 additions & 1 deletion packages/kbn-optimizer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ RUNTIME_DEPS = [
"//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-ui-shared-deps-src",
"//packages/kbn-utils",
"@npm//@babel/core",
"@npm//chalk",
"@npm//clean-webpack-plugin",
"@npm//compression-webpack-plugin",
"@npm//cpy",
"@npm//dedent",
"@npm//del",
"@npm//execa",
"@npm//jest-diff",
Expand All @@ -64,7 +66,7 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"//packages/kbn-config:npm_module_types",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-dev-utils",
"//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-std",
"//packages/kbn-ui-shared-deps-npm",
"//packages/kbn-ui-shared-deps-src",
Expand All @@ -79,7 +81,9 @@ TYPES_DEPS = [
"@npm//pirates",
"@npm//rxjs",
"@npm//zlib",
"@npm//@types/babel__core",
"@npm//@types/compression-webpack-plugin",
"@npm//@types/dedent",
"@npm//@types/jest",
"@npm//@types/json-stable-stringify",
"@npm//@types/js-yaml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import Path from 'path';

import { run, REPO_ROOT } from '@kbn/dev-utils';
import { run } from '@kbn/dev-utils';
import { REPO_ROOT } from '@kbn/utils';

import { OptimizerConfig } from '../optimizer';
import { parseStats, inAnyEntryChunk } from './parse_stats';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Crypto from 'crypto';

import * as babel from '@babel/core';
import { addHook } from 'pirates';
import { REPO_ROOT, UPSTREAM_BRANCH } from '@kbn/dev-utils';
import { REPO_ROOT, UPSTREAM_BRANCH } from '@kbn/utils';
import sourceMapSupport from 'source-map-support';

import { Cache } from './cache';
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-optimizer/src/optimizer/get_changes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
jest.mock('execa');

import { getChanges } from './get_changes';
import { REPO_ROOT, createAbsolutePathSerializer } from '@kbn/dev-utils';
import { createAbsolutePathSerializer } from '@kbn/dev-utils';
import { REPO_ROOT } from '@kbn/utils';

const execa: jest.Mock = jest.requireMock('execa');

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/src/optimizer/get_changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Path from 'path';

import execa from 'execa';

import { REPO_ROOT } from '@kbn/dev-utils';
import { REPO_ROOT } from '@kbn/utils';

export type Changes = Map<string, 'modified' | 'deleted'>;

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-plugin-generator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"//packages/kbn-utils",
"//packages/kbn-dev-utils",
"//packages/kbn-dev-utils:npm_module_types",
"@npm//del",
"@npm//execa",
"@npm//globby",
Expand Down
Loading