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

Install plugin #4406

Merged
merged 14 commits into from
Jul 15, 2015
Merged

Install plugin #4406

merged 14 commits into from
Jul 15, 2015

Conversation

BigFunger
Copy link
Contributor

Addresses #4204
Creates the Kibana plugin install cli.

  • Removes the startup specific logic from the kibana.js file.
  • Moves the commander configuration for the default command into its own file
  • Moves the actual startup logic into its own file
  • Adds the plugin subcommand and all related logic
  • Adds unit test coverage for the majority of the new plugin subcommand logic

To use:
from the src/server/bin folder, type:

node kibana plugin -h

expect(errorStub.called).to.be(true);
expect(errorStub.lastCall.args[0].message).to.match(/This is unexpected./);

fs.statSync.restore();
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a feeling this is causing issues. If you put .restore() calls within a test they are likely to not run

@@ -9,6 +9,7 @@ set NODE=%DIR%\node\node.exe
set SERVER=%DIR%\src\bin\kibana.js
set NODE_ENV="production"
set CONFIG_PATH=%DIR%\config\kibana.yml
set NPM=npm
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you are signaling to the installer what command to use for npm install. Seems like the default is already npm, but anyway many of the machines where this will run won't have npm or node in the path.

We should use the npm bundled with the node instance we are current running in, or depend on it and use the version installed locally. To find the npm bundled with the current node executable use:

resolve(dirname(process.execPath), '../lib/node_modules/npm')

PS: I learned that resolve properly handles / conversion. Exciting!!
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I applied this change, however the path needed to be slightly different for me. Please review and let me know if that path will work for all instances, or if that is a windows-specific nuance.

@spalger
Copy link
Contributor

spalger commented Jul 11, 2015

Should we be seeing this "Error extracting the plugin archive" error at the end of the output? I would have expected that before "Plugin installation was unsuccessful". Perhaps it's a timing issue with the errors emitted from the streams?

image

Just checked and I think it's just the error message that ends up in the log. I like that bug maybe it should be formatted to describe that. Maybe Plugin installation was unsuccessful due to error "${err.message}"


rimraf.sync(settings.pluginPath);
} catch (ex) {
logger.error(ex.message);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we log something more informative here, maybe:
Unable to remove plugin "${settings.package}" because of error: "${ex.message}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change applied.

@spalger
Copy link
Contributor

spalger commented Jul 11, 2015

We should include some more information about how the --install argument is formatted in the help text. My question was "How do I specify a specific tag or branch for github?" but the help text didn't offer any guidance or even hint that using github was possible. A little blurb titled which outlines some of the more common scenarios would be helpful (es with/without version, github with/without, custom url).

var cmd = (process.env.NPM) ? process.env.NPM : 'npm';
cmd += ' install';

var child = exec(cmd, { cwd: dest });
Copy link
Contributor

Choose a reason for hiding this comment

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

The output of this command needs to be ignored when the --silent option is specified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified the --silent option so that it applies to both log and error messages per a conversation with @rashidkpc.

@spalger
Copy link
Contributor

spalger commented Jul 11, 2015

Functionality is looking great! For posterity, here are the things I checked manually:

  • latest from download.elastic.co/kibana --install kibana/test-plugin
  • latest(master) from github--install spalger/test-plugin
  • branch from github --install spalger/test-plugin/invalid
  • tag from github --install spalger/test-plugin/v0.0.1
  • custom url without name --url https://codeload.github.com/spalger/test-plugin/tar.gz/master
  • custom url --url https://codeload.github.com/spalger/test-plugin/tar.gz/master --install thing1
  • plugin with bad npm dep --install spalger/test-plugin/invalid
  • plugin postinstall task fails --install spalger/test-plugin/failed-build-script
  • command canceled mid download, properly runs next time
  • command canceled mid install, properly runs next time
  • run install while another install in progress, fails as long as npm fails
  • run with both --install and --remove arguments, fails with helpful error
  • run with --silent, produces no output (see Install plugin #4406 (comment) Install plugin #4406 (comment) )

@spalger spalger removed their assignment Jul 11, 2015
@spalger spalger assigned jbudz and unassigned BigFunger Jul 14, 2015
@spalger
Copy link
Contributor

spalger commented Jul 14, 2015

Couple more comments, but looking great! I'm 99% ready to merge. Time for someone else to give it a spin. @jbudz?

.description('Maintain Plugins')
.option('-i, --install <org>/<plugin>/<version>', installDesc)
.option('-r, --remove <plugin>', 'The plugin to remove')
.option('-s, --silent', 'Disable process messaging')
Copy link
Member

Choose a reason for hiding this comment

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

Thoughts on --silent vs --quiet without the plugin command?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch @jbudz, I like the idea of supporting both on both commands at some point.

  • --silent would block absolutely all output
  • --quiet would block everything but errors

@jbudz
Copy link
Member

jbudz commented Jul 14, 2015

Works well, code looks good. I made a minor comment on an option name.

The grunt tasks seem to be processing plugins//node_modules/, running grunt test after installing a plugin can fail on jshint/jscs.

@jbudz jbudz assigned BigFunger and unassigned jbudz Jul 14, 2015
@BigFunger BigFunger assigned spalger and unassigned BigFunger Jul 15, 2015
spalger added a commit that referenced this pull request Jul 15, 2015
@spalger spalger merged commit 9d69b97 into elastic:master Jul 15, 2015
@spalger spalger mentioned this pull request Jul 15, 2015
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants