From c81864f652a9118e9a41c0e124634956ea278825 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 10 May 2021 15:16:47 +0100 Subject: [PATCH 1/3] chore(NA): moving @kbn/plugin-generator into bazel --- package.json | 2 +- packages/BUILD.bazel | 1 + packages/kbn-plugin-generator/BUILD.bazel | 91 +++++++++++++++++++ packages/kbn-plugin-generator/package.json | 6 +- .../kbn-plugin-generator/scripts/build.js | 32 ------- packages/kbn-plugin-generator/tsconfig.json | 2 +- yarn.lock | 2 +- 7 files changed, 96 insertions(+), 40 deletions(-) create mode 100644 packages/kbn-plugin-generator/BUILD.bazel delete mode 100644 packages/kbn-plugin-generator/scripts/build.js diff --git a/package.json b/package.json index 070fde2f64c45..9f56eecd8d5b0 100644 --- a/package.json +++ b/package.json @@ -453,7 +453,7 @@ "@kbn/eslint-plugin-eslint": "link:bazel-bin/packages/kbn-eslint-plugin-eslint/npm_module", "@kbn/expect": "link:bazel-bin/packages/kbn-expect/npm_module", "@kbn/optimizer": "link:packages/kbn-optimizer", - "@kbn/plugin-generator": "link:packages/kbn-plugin-generator", + "@kbn/plugin-generator": "link:bazel-bin/packages/kbn-plugin-generator/npm_module", "@kbn/plugin-helpers": "link:packages/kbn-plugin-helpers", "@kbn/pm": "link:packages/kbn-pm", "@kbn/storybook": "link:packages/kbn-storybook", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index 8b483f54344e2..e33b3d85b44ef 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -22,6 +22,7 @@ filegroup( "//packages/kbn-expect:build", "//packages/kbn-legacy-logging:build", "//packages/kbn-logging:build", + "//packages/kbn-plugin-generator:build", "//packages/kbn-securitysolution-constants:build", "//packages/kbn-securitysolution-io-ts-utils:build", "//packages/kbn-securitysolution-utils:build", diff --git a/packages/kbn-plugin-generator/BUILD.bazel b/packages/kbn-plugin-generator/BUILD.bazel new file mode 100644 index 0000000000000..48b38659357b9 --- /dev/null +++ b/packages/kbn-plugin-generator/BUILD.bazel @@ -0,0 +1,91 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") + +PKG_BASE_NAME = "kbn-plugin-generator" +PKG_REQUIRE_NAME = "@kbn/plugin-generator" + +SOURCE_FILES = glob([ + "src/**/*.ts" +]) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", + "README.md", +] + +SRC_DEPS = [ + "//packages/kbn-utils", + "//packages/kbn-dev-utils", + "@npm//del", + "@npm//ejs", + "@npm//execa", + "@npm//globby", + "@npm//inquirer", + "@npm//minimatch", + "@npm//prettier", + "@npm//vinyl-fs", +] + +TYPES_DEPS = [ + "@npm//@types/ejs", + "@npm//@types/inquirer", + "@npm//@types/jest", + "@npm//@types/minimatch", + "@npm//@types/node", + "@npm//@types/prettier", + "@npm//@types/vinyl-fs", +] + +DEPS = SRC_DEPS + TYPES_DEPS + +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, + incremental = True, + out_dir = "target", + source_map = True, + root_dir = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_BASE_NAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = [":tsc"] + 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"], +) diff --git a/packages/kbn-plugin-generator/package.json b/packages/kbn-plugin-generator/package.json index 583085430d915..298373afd2f24 100644 --- a/packages/kbn-plugin-generator/package.json +++ b/packages/kbn-plugin-generator/package.json @@ -4,9 +4,5 @@ "private": true, "license": "SSPL-1.0 OR Elastic License 2.0", "main": "target/index.js", - "types": "target/index.d.ts", - "scripts": { - "kbn:bootstrap": "node scripts/build", - "kbn:watch": "node scripts/build --watch" - } + "types": "target/index.d.ts" } \ No newline at end of file diff --git a/packages/kbn-plugin-generator/scripts/build.js b/packages/kbn-plugin-generator/scripts/build.js deleted file mode 100644 index e17f564bc482c..0000000000000 --- a/packages/kbn-plugin-generator/scripts/build.js +++ /dev/null @@ -1,32 +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 Path = require('path'); - -const { run } = require('@kbn/dev-utils'); -const del = require('del'); -const execa = require('execa'); - -run( - async ({ flags }) => { - await del(Path.resolve(__dirname, '../target')); - - await execa(require.resolve('typescript/bin/tsc'), flags.watch ? ['--watch'] : [], { - cwd: Path.resolve(__dirname, '..'), - stdio: 'inherit', - }); - }, - { - flags: { - boolean: ['watch'], - help: ` - --watch Watch files and rebuild on changes - `, - }, - } -); diff --git a/packages/kbn-plugin-generator/tsconfig.json b/packages/kbn-plugin-generator/tsconfig.json index 5e885527a7608..9165fd21ebea0 100644 --- a/packages/kbn-plugin-generator/tsconfig.json +++ b/packages/kbn-plugin-generator/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "incremental": false, + "incremental": true, "outDir": "target", "target": "ES2019", "declaration": true, diff --git a/yarn.lock b/yarn.lock index a8f040d8d4066..ffe83b7ae21a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2686,7 +2686,7 @@ version "0.0.0" uid "" -"@kbn/plugin-generator@link:packages/kbn-plugin-generator": +"@kbn/plugin-generator@link:bazel-bin/packages/kbn-plugin-generator/npm_module": version "0.0.0" uid "" From 0670fa8630016d730eca8b0aafdb88a3f657709e Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 10 May 2021 17:30:20 +0100 Subject: [PATCH 2/3] chore(NA): add templates to build file --- packages/kbn-plugin-generator/BUILD.bazel | 21 ++++++++++++++++++--- plugins/.empty | 0 2 files changed, 18 insertions(+), 3 deletions(-) delete mode 100644 plugins/.empty diff --git a/packages/kbn-plugin-generator/BUILD.bazel b/packages/kbn-plugin-generator/BUILD.bazel index 48b38659357b9..e22d41076db00 100644 --- a/packages/kbn-plugin-generator/BUILD.bazel +++ b/packages/kbn-plugin-generator/BUILD.bazel @@ -4,9 +4,14 @@ load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") PKG_BASE_NAME = "kbn-plugin-generator" PKG_REQUIRE_NAME = "@kbn/plugin-generator" -SOURCE_FILES = glob([ - "src/**/*.ts" -]) +SOURCE_FILES = glob( + [ + "src/**/*.ts", + ], + exclude = [ + "**/integration_tests/**/*", + ], +) SRCS = SOURCE_FILES @@ -15,9 +20,19 @@ filegroup( srcs = SRCS, ) +filegroup( + name = "template", + srcs = glob( + [ + "template/**/*", + ], + ), +) + NPM_MODULE_EXTRA_FILES = [ "package.json", "README.md", + ":template", ] SRC_DEPS = [ diff --git a/plugins/.empty b/plugins/.empty deleted file mode 100644 index e69de29bb2d1d..0000000000000 From b983a92abd381f87a3cd92eb0bf5b94d66a7d1c8 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 10 May 2021 17:32:39 +0100 Subject: [PATCH 3/3] chore(NA): restore plugins empty file --- plugins/.empty | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 plugins/.empty diff --git a/plugins/.empty b/plugins/.empty new file mode 100644 index 0000000000000..e69de29bb2d1d