[plugin-helpers] allow opt-ing out of dependency installation (#16816)

* [kbn-plugin-helpers] allow opt-ing out of dependency installation

* [plugin-helpers] rename buildIgnoreDependencies to skipInstallDependencies

* [plugin-helpers] use noop3 for test

* [plugin-helpers] fix test description

* [plugin-helpers] fix assertion
This commit is contained in:
Spencer 2018-02-20 16:28:22 -07:00 committed by GitHub
parent 4a2a4511ac
commit d8b3ca27ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 1 deletions

View file

@ -69,5 +69,6 @@ Setting | Description
------- | -----------
`skipArchive` | Don't create the zip file, leave the build path alone
`buildDestination` | Target path for the build output, absolute or relative to the plugin root
`skipInstallDependencies` | Don't install dependencies defined in package.json into build output
`buildVersion` | Version for the build output
`kibanaVersion` | Kibana version for the build output (added to package.json)

View file

@ -20,6 +20,7 @@ module.exports = function (root) {
kibanaRoot: resolve(root, '../../kibana'),
serverTestPatterns: ['server/**/__tests__/**/*.js'],
buildSourcePatterns: buildSourcePatterns,
skipInstallDependencies: false,
id: pkg.name,
pkg: pkg,
version: pkg.version,

View file

@ -5,7 +5,7 @@
"version": "6.0.0"
},
"dependencies": {
"noop3": "999.999.999"
},
"devDependencies": {

View file

@ -53,6 +53,10 @@ module.exports = function createBuild(plugin, buildTarget, buildVersion, kibanaV
});
})
.then(function () {
if (plugin.skipInstallDependencies) {
return;
}
// install packages in build
const options = {
cwd: buildRoot,

View file

@ -1,4 +1,5 @@
const { resolve } = require('path');
const { readdirSync } = require('fs');
const del = require('del');
const createBuild = require('./create_build');
@ -37,4 +38,30 @@ describe('creating the build', () => {
expect(pkg.build.git).not.toBeUndefined();
expect(pkg.build.date).not.toBeUndefined();
});
describe('skipInstallDependencies = false', () => {
it('installs node_modules as a part of build', async () => {
expect(PLUGIN.skipInstallDependencies).toBe(false);
await createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles);
expect(readdirSync(resolve(PLUGIN_BUILD_TARGET))).toContain('node_modules');
expect(readdirSync(resolve(PLUGIN_BUILD_TARGET, 'node_modules'))).toContain('noop3');
});
});
describe('skipInstallDependencies = true', () => {
// set skipInstallDependencies to true for these tests
beforeEach(() => PLUGIN.skipInstallDependencies = true);
// set it back to false after
afterEach(() => PLUGIN.skipInstallDependencies = false);
it('does not install node_modules as a part of build', async () => {
expect(PLUGIN.skipInstallDependencies).toBe(true);
await createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles);
expect(readdirSync(resolve(PLUGIN_BUILD_TARGET))).not.toContain('node_modules');
});
});
});