diff --git a/src/cli_plugin/install/__tests__/kibana.js b/src/cli_plugin/install/__tests__/kibana.js index f29fc6455f438..15d6b25d27410 100644 --- a/src/cli_plugin/install/__tests__/kibana.js +++ b/src/cli_plugin/install/__tests__/kibana.js @@ -59,7 +59,7 @@ describe('kibana cli', function () { expect(errorStub.called).to.be(false); }); - it('should throw an error if plugin does contain a version.', function () { + it('should throw an error if plugin is missing a kibana version.', function () { const errorStub = sinon.stub(); try { @@ -69,10 +69,10 @@ describe('kibana cli', function () { errorStub(err); } - expect(errorStub.firstCall.args[0]).to.match(/plugin version not found/i); + expect(errorStub.firstCall.args[0]).to.match(/plugin package\.json is missing both a version property/i); }); - it('should throw an error if plugin kibanaVersion does does not match kibana version', function () { + it('should throw an error if plugin kibanaVersion does not match kibana version', function () { const errorStub = sinon.stub(); settings.plugins[0].kibanaVersion = '1.2.3.4'; diff --git a/src/cli_plugin/install/__tests__/pack.js b/src/cli_plugin/install/__tests__/pack.js index 768c47db25997..39a61e58a93d6 100644 --- a/src/cli_plugin/install/__tests__/pack.js +++ b/src/cli_plugin/install/__tests__/pack.js @@ -21,6 +21,10 @@ describe('kibana cli', function () { let settings; beforeEach(function () { + //These tests are dependent on the file system, and I had some inconsistent + //behavior with rimraf.sync show up. Until these tests are re-written to not + //depend on the file system, I make sure that each test uses a different + //working directory. testNum += 1; testWorkingPath = join(workingPathRoot, testNum + ''); tempArchiveFilePath = join(testWorkingPath, 'archive.part'); diff --git a/src/cli_plugin/install/kibana.js b/src/cli_plugin/install/kibana.js index 789aa426149c8..86992fadf7a10 100644 --- a/src/cli_plugin/install/kibana.js +++ b/src/cli_plugin/install/kibana.js @@ -47,7 +47,7 @@ export async function rebuildCache(settings, logger) { export function assertVersion(settings) { if (!settings.plugins[0].kibanaVersion) { - throw new Error (`Plugin version not found. Check package.json in archive`); + throw new Error (`Plugin package.json is missing both a version property (required) and a kibana.version property (optional).`); } const actual = cleanVersion(settings.plugins[0].kibanaVersion); diff --git a/src/cli_plugin/install/pack.js b/src/cli_plugin/install/pack.js index d106a75b0d818..76056523a3121 100644 --- a/src/cli_plugin/install/pack.js +++ b/src/cli_plugin/install/pack.js @@ -57,7 +57,8 @@ function assertValidPackageName(plugin) { /** * Examine each package.json file to determine the plugin name, - * version, and platform. Mutates the package objects in the packages array + * version, kibanaVersion, and platform. Mutates the package objects + * in the packages array * @param {object} settings - a plugin installer settings object * @param {array} packages - array of package objects from listPackages() */ @@ -69,10 +70,12 @@ async function mergePackageData(settings, packages) { pkg.version = _.get(packageInfo, 'version'); pkg.name = _.get(packageInfo, 'name'); pkg.path = resolve(settings.pluginDir, pkg.name); - pkg.kibanaVersion = _.get(packageInfo, 'kibana.version'); - if (!pkg.kibanaVersion) { - pkg.kibanaVersion = pkg.version; - } + + // Plugins must specify their version, and by default that version should match + // the version of kibana down to the patch level. If these two versions need + // to diverge, they can specify a kibana.version to indicate the version of + // kibana the plugin is intended to work with. + pkg.kibanaVersion = _.get(packageInfo, 'kibana.version', pkg.version); const regExp = new RegExp(`${pkg.name}-(.+)`, 'i'); const matches = pkg.folder.match(regExp);