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

Prefer third-party plugin development in ./plugins instead of ../kibana-extra #31748

Merged
merged 3 commits into from
Mar 7, 2019

Conversation

eliperelman
Copy link
Contributor

@eliperelman eliperelman commented Feb 21, 2019

Summary

This change switches preferred third-party plugin development from ../kibana-extra, instead favoring the plugins directory in the Kibana root. Relatedly this also renames the @kbn/pm --skip-kibana-extra to --skip-kibana-plugins.

Removing this directory and renaming the flag appear to be breaking changes, so I tagged this one as v8.0.0. Please revise if this is inaccurate.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

Dev-Docs

Prefer third-party plugin development in plugins instead of kibana-extra

This change switches preferred third-party plugin development from ../kibana-extra, instead favoring the plugins directory in the Kibana root. By association, @kbn/pm has the --skip-kibana-extra flag renamed to --skip-kibana-plugins.

@eliperelman eliperelman added review Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform v8.0.0 labels Feb 21, 2019
@eliperelman eliperelman self-assigned this Feb 21, 2019
@eliperelman eliperelman requested a review from a team as a code owner February 21, 2019 21:40
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@trevan
Copy link
Contributor

trevan commented Feb 21, 2019

I don't know the reason for this change but this feels like it could cause problems. Usually, a plugin will be in its own separate git repository and so you'll have a git repository (the plugin) inside of another git repository (kibana).

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@epixa
Copy link
Contributor

epixa commented Feb 21, 2019

@trevan The motivation for the change is that we want plugins to be able to reliably and consistently import static code from other plugins. Webpack aliases allow us to do this reliably on the client, but it's not consist since we can't use them on the server. Relative imports are a consistent way to do it, but they are only reliable if the relative location of plugins is similar between development and builds.

The root plugins directory has its contents hidden from git, so you should be able to safely check out your plugin repo into that directory.

@epixa epixa added Feature:Plugins release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. labels Feb 22, 2019
@epixa
Copy link
Contributor

epixa commented Feb 22, 2019

@eliperelman Can you add a section to the PR description for Dev Docs that describes the change for plugin developers? We extract the content from that section and publish it in a blog post for plugin developers for each release.

@trevan
Copy link
Contributor

trevan commented Feb 22, 2019

@epixa, is it possible to symlink your plugin into the plugins directory for development? I tried that back in the 5.x days and there were some issues I had but maybe the later node/babel/webpack/etc can handle that now.

@epixa
Copy link
Contributor

epixa commented Feb 22, 2019

That's a great question, and I don't know the answer. @eliperelman can you check that out?

If it is possible, or if it's easy to make it possible, then we can say that the recommended workflow is to clone your plugin repo inside /plugins, but you can always symlink your plugin directory in if you prefer to work elsewhere (e.g. in kibana-extra or as a sibling to kibana).

@eliperelman
Copy link
Contributor Author

I have updated the tests here to ensure that plugins symlinked into plugins work properly, and they do. 😃

@trevan
Copy link
Contributor

trevan commented Feb 22, 2019

@eliperelman, the issues I had dealt with importing code into the symlinked plugin. The file paths for importing didn't respect the symlink unless I had NODE_PRESERVE_SYMLINKS enabled and even then, there were weird issues.

@w33ble
Copy link
Contributor

w33ble commented Feb 22, 2019

The motivation for the change is that we want plugins to be able to reliably and consistently import static code from other plugins.

@epixa Interesting, I thought we were trying to explicitly avoid that in the New Platform and forcing plugins to expose the parts they intended to share. Did that change, or has my understanding just been wrong?

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@epixa
Copy link
Contributor

epixa commented Feb 22, 2019

@w33ble That is definitely still the desired route in the new platform, and I expect the static code sharing to be rare. But when it does need to happen, I don't want plugin authors to hack together a solution or be in a situation where some things work in oss but not in x-pack.

@epixa epixa added the v7.2.0 label Feb 24, 2019
@eliperelman
Copy link
Contributor Author

@azasypkin I have updated the PR to programmatically create the symlink which should work on Windows in the future.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@eliperelman
Copy link
Contributor Author

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@epixa
Copy link
Contributor

epixa commented Mar 5, 2019

@eliperelman Sorry for the churn here, but I've had a little bit of a change of heart and wanted to get your thoughts. I think we should update all the instructions as you did here and add the support for running in the plugins directory as planned, but we should preserve the existing support for plugins being developed in kibana-extra for a little while to give developers some time to switch over.

Anyone developing in kibana-extra wouldn't be able to reliably do relative imports and whatnot, but that's fine.

What do you think?

@eliperelman
Copy link
Contributor Author

Sure thing, I’ll see what I can do.

@epixa epixa removed the review label Mar 5, 2019
@eliperelman eliperelman force-pushed the move-from-extra-to-plugins branch 2 times, most recently from 8969b14 to 3acd6e1 Compare March 5, 2019 18:20
@eliperelman
Copy link
Contributor Author

@epixa I have revised, please let me know if you believe this is the correct direction based on your comments. Thanks!

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@eliperelman eliperelman changed the title Remove third-party plugin development from kibana-extra in favor of plugins/ Prefer third-party plugin development in ./plugins instead of ../kibana-extra Mar 6, 2019
Copy link
Contributor

@epixa epixa left a comment

Choose a reason for hiding this comment

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

This looks good overall, but when you make changes to kbn-pm, you also must build a new distribution of it and commit that. It's the only package that requires this. See https://github.com/elastic/kibana/tree/master/packages/kbn-pm#development

Copy link
Contributor

@epixa epixa left a comment

Choose a reason for hiding this comment

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

LGTM on green

@elasticmachine
Copy link
Contributor

💔 Build Failed

@eliperelman
Copy link
Contributor Author

retest

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@eliperelman eliperelman merged commit 78cbe42 into elastic:master Mar 7, 2019
eliperelman added a commit to eliperelman/kibana that referenced this pull request Mar 7, 2019
…na-extra (elastic#31748)

* Prefer third-party plugin development in plugins instead of kibana-extra

* Fix failing recursive directory creation and removal

* Add new built version of kbn-pm
eliperelman added a commit that referenced this pull request Mar 8, 2019
…na-extra (#31748) (#32724)

* Prefer third-party plugin development in plugins instead of kibana-extra

* Fix failing recursive directory creation and removal

* Add new built version of kbn-pm
@martijnrondeel
Copy link
Contributor

Should starting Kibana from inside a plugin in the plugins directory be working? I'm getting the following error:

yarn start
yarn run v1.16.0
$ plugin-helpers start
Task "start" failed:

Error: spawnSync node ENOENT
    at Object.spawnSync (internal/child_process.js:990:20)
    at spawnSync (child_process.js:601:24)
    at execFileSync (child_process.js:629:13)
    at module.exports (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/tasks/start/start_action.js:43:3)
    at run (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/lib/run.js:30:10)
    at Command.<anonymous> (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/lib/commander_action.js:27:13)
    at Command.listener (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/node_modules/commander/index.js:315:8)
    at Command.emit (events.js:189:13)
    at Command.parseArgs (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/node_modules/commander/index.js:654:12)
    at Command.parse (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/node_modules/commander/index.js:474:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Also adding "kibanaRoot": "../../" to .kibana-plugin-helpers.json (which I found solved this issue in past releases) yields the following (outdated) error message:

yarn start
yarn run v1.16.0
$ plugin-helpers start
Task "start" failed:

Error: The `kibanaRoot` config option has been removed from `@kbn/plugin-helpers`. During development your plugin must be located in `../kibana-extra/{pluginName}` relative to the Kibana directory to work with this package.

    at module.exports (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/lib/config_file.js:54:11)
    at module.exports (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/lib/plugin_config.js:28:18)
    at run (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/lib/run.js:29:18)
    at Command.<anonymous> (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/lib/commander_action.js:27:13)
    at Command.listener (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/node_modules/commander/index.js:315:8)
    at Command.emit (events.js:189:13)
    at Command.parseArgs (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/node_modules/commander/index.js:654:12)
    at Command.parse (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/node_modules/commander/index.js:474:21)
    at Object.<anonymous> (/home/martijn/Repos/kibana/packages/kbn-plugin-helpers/cli.js:93:9)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Running yarn start from the Kibana directory does work, but I rather have my plugin dir open in the IDE instead of Kibana and this worked in the past.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform Feature:Plugins release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. review Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.2.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants