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

[kbn/generate] add basic package generator #127095

Merged
merged 9 commits into from
Mar 9, 2022

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Mar 8, 2022

Adds a script for generating packages which uses the template at packages/kbn-generate/templates/package. The package CLI is pretty simple right now and has the following --help text:

$ node scripts/generate --help

  node scripts/generate [command] [...args]

  Run generators for different components in Kibana

  Commands:
     node scripts/generate package [name]
      Generate a basic package

      Options:
        --dev          Generate a package which is intended for dev-only use and can access things like devDependencies
        --web          Build webpack-compatible version of sources for this package
        --dir          Directory where this package will live, defaults to [./packages]
        --force        If the packageDir already exists, delete it before generation


  Global options:
    --help             Show this message

  To show the help information about a specific command run:
    node scripts/generate help [command]

The template at packages/kbn-generate/templates/package is used to create the package source files. After they're written to disk the package.json file is updated to include references to the new plugin (location based on the --dev flag), and then the packages/BUILD.bazel file is regenerated by discovering all the packages in the repo and producing the new file.

See @kbn/packages, a new package that I generated with this script and updated to discover packages and generate the shared packages/BUILD.bazel file.

@spalger spalger force-pushed the implement/kbn-generate-cli branch from b373423 to 4562a65 Compare March 8, 2022 02:10
@spalger spalger force-pushed the implement/kbn-generate-cli branch from 5f5882f to cb5e5e1 Compare March 8, 2022 15:28
@spalger spalger added auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:Operations Team label for Operations Team v8.1.0 v8.2.0 labels Mar 8, 2022
@spalger spalger marked this pull request as ready for review March 8, 2022 19:09
@spalger spalger requested a review from a team as a code owner March 8, 2022 19:09
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

Copy link
Member

@jbudz jbudz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the BUILD.bazel file didn't get updates / templates didn't get written.

~/dev/kibana (pr/127095) » node scripts/generate package @kbn/test123                                                                                                                                  1 ↵ jon@xps
 info Wrote plugin files to /home/jon/dev/kibana/packages/kbn-test123
 info Updated package.json file
 info Updated packages/BUILD.bazel
 succ Generated @kbn/test123! Please bootstrap to make sure it works.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
~/dev/kibana (pr/127095*) » git status                                                                                                                                                                     jon@xps
On branch pr/127095
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   package.json

no changes added to commit (use "git add" and/or "git commit -a")
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
~/dev/kibana (pr/127095*) » ls packages/kbn-test123                                                                                                                                                        jon@xps
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
~/dev/kibana (pr/127095*) »    

Copy link
Member

@jbudz jbudz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to include these in the default template based on the tsconfig.json:

TYPES_DEPS = [
  "@npm//@types/jest",
  "@npm//@types/node",
]

Overall though LGTM

@spalger
Copy link
Contributor Author

spalger commented Mar 8, 2022

Sounds good, thanks!

@spalger spalger enabled auto-merge (squash) March 9, 2022 00:16
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/dev-utils 203 205 +2
@kbn/generate - 1 +1
@kbn/packages - 3 +3
total +6

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/packages - 1 +1
Unknown metric groups

API count

id before after diff
@kbn/dev-utils 281 283 +2
@kbn/generate - 1 +1
@kbn/packages - 3 +3
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@spalger spalger merged commit ad0eb60 into elastic:main Mar 9, 2022
@spalger spalger deleted the implement/kbn-generate-cli branch March 9, 2022 01:04
@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.1 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.1:
- Update babel (main) (#126871)
- Remove ts refs build from bootstrap (#125314)

Manual backport

To create the backport manually run:

node scripts/backport --pr 127095

Questions ?

Please refer to the Backport tool documentation

spalger pushed a commit to spalger/kibana that referenced this pull request Mar 9, 2022
(cherry picked from commit ad0eb60)

# Conflicts:
#	packages/BUILD.bazel
#	packages/kbn-pm/dist/index.js
#	packages/kbn-type-summarizer/src/lib/bazel_cli_config.ts
spalger pushed a commit that referenced this pull request Mar 9, 2022
* [kbn/generate] add basic package generator (#127095)

(cherry picked from commit ad0eb60)

# Conflicts:
#	packages/BUILD.bazel
#	packages/kbn-pm/dist/index.js
#	packages/kbn-type-summarizer/src/lib/bazel_cli_config.ts

* regenerate packages/BUILD.bazel file
jloleysens added a commit to jloleysens/kibana that referenced this pull request Mar 9, 2022
…re-browser-errors

* 'main' of github.com:elastic/kibana: (46 commits)
  [Reporting] Capture Kibana stopped error (elastic#127017)
  add updatedAt to SimpleSavedObject (elastic#126359)
  Remove deprecated & unused `ElasticsearchServiceStart.legacy` (elastic#127050)
  remove opacity for fitting line series (elastic#127176)
  Remove deprecated & unused `HttpServiceSetup.auth` (elastic#127056)
  [Lens] Show underlying data editor navigation (elastic#125983)
  Bump dependencies (elastic#127238)
  Remove deprecated & unused `public-AsyncPlugin` (elastic#127048)
  Remove deprecated & unused `SavedObjectsImportFailure.title` (elastic#127043)
  skip flaky suite (elastic#123372)
  [kbn/generate] add basic package generator (elastic#127095)
  [build] Up compression quality (elastic#127064)
  Made fix to broken test. Deleted all existing pipelines before test starts. FLAKY: elastic#118593 (elastic#127102)
  Increase timeout for Jest integration tests (elastic#127220)
  skip failing test suite (elastic#126949)
  [DOCS] Adds note for data source performance impact (elastic#127184)
  [Security Solution] Adds CCS privileges warning enable switch in advanced settings (elastic#124459)
  [App Search] Move to tabbed single tabbed JSON flyout with upload and paste options and refactor cards (elastic#127162)
  Update dependency chromedriver to v99 (elastic#127079)
  [kbn/pm] add timings for more parts of bootstrap (elastic#127157)
  ...

# Conflicts:
#	x-pack/plugins/reporting/common/errors/index.ts
#	x-pack/plugins/reporting/server/lib/tasks/execute_report.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:Operations Team label for Operations Team v8.1.0 v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants