mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Allow custom build target via --build-destination flag (elastic/kibana-plugin-helpers#30)
* pass buildTarget into createBuild allow override from options * add cli option to override build destination --build-destination * fix tests * resolve build destination from plugin.root this allows both relative and absolute paths to be used * add short option * update the help Original commit: elastic/kibana-plugin-helpers@6c9fb3464e
This commit is contained in:
parent
efa7302364
commit
d258d24b13
5 changed files with 22 additions and 7 deletions
|
@ -34,10 +34,12 @@ program
|
|||
.command('build [files...]')
|
||||
.description('Build a distributable archive')
|
||||
.on('--help', docs('build'))
|
||||
.option('-d, --build-destination <path>', 'Target path for the build output, absolute or relative to the plugin root')
|
||||
.option('-b, --build-version <version>', 'Version for the build output')
|
||||
.option('-k, --kibana-version <version>', 'Kibana version for the build output')
|
||||
.action(taskRunner(function (command, files) {
|
||||
run('build', {
|
||||
buildDestination: command.buildDestination,
|
||||
buildVersion: command.buildVersion,
|
||||
kibanaVersion: command.kibanaVersion,
|
||||
files: files,
|
||||
|
|
|
@ -7,3 +7,13 @@ be found at:
|
|||
```
|
||||
build/{pkg.name}-{pkg.version}.zip
|
||||
```
|
||||
|
||||
If you use the `--build-destination` flag, the resulting build will be found
|
||||
in that directory.
|
||||
|
||||
```
|
||||
plugin-helpers build --build-destination build/some/child/path
|
||||
|
||||
# This will place the resulting build at:
|
||||
build/some/child/path/{pkg.name}-{pkg.version}.zip
|
||||
```
|
|
@ -1,3 +1,5 @@
|
|||
var join = require('path').join;
|
||||
var resolve = require('path').resolve;
|
||||
var inquirer = require('inquirer');
|
||||
|
||||
var createBuild = require('./create_build');
|
||||
|
@ -7,6 +9,7 @@ module.exports = function (plugin, run, options) {
|
|||
var buildVersion = plugin.version;
|
||||
var kibanaVersion = (plugin.pkg.kibana && plugin.pkg.kibana.version) || plugin.pkg.version;
|
||||
var buildFiles = plugin.buildSourcePatterns;
|
||||
var buildTarget = join(plugin.root, 'build');
|
||||
|
||||
// allow source files to be overridden
|
||||
if (options.files && options.files.length) {
|
||||
|
@ -14,15 +17,16 @@ module.exports = function (plugin, run, options) {
|
|||
}
|
||||
|
||||
// allow options to override plugin info
|
||||
if (options.buildDestination) buildTarget = resolve(plugin.root, options.buildDestination);
|
||||
if (options.buildVersion) buildVersion = options.buildVersion;
|
||||
if (options.kibanaVersion) kibanaVersion = options.kibanaVersion;
|
||||
|
||||
if (kibanaVersion === 'kibana') {
|
||||
return askForKibanaVersion().then(function (customKibanaVersion) {
|
||||
return createBuild(plugin, buildVersion, customKibanaVersion, buildFiles);
|
||||
return createBuild(plugin, buildTarget, buildVersion, customKibanaVersion, buildFiles);
|
||||
});
|
||||
} else {
|
||||
return createBuild(plugin, buildVersion, kibanaVersion, buildFiles);
|
||||
return createBuild(plugin, buildTarget, buildVersion, kibanaVersion, buildFiles);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ describe('build_action', () => {
|
|||
|
||||
return buildAction(PLUGIN, noop, options).then(() => {
|
||||
expect(mockBuild.mock.calls).toHaveLength(1);
|
||||
const [ plugin, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0];
|
||||
const [ plugin, buildTarget, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0];
|
||||
expect(buildVersion).toBe('1.2.3');
|
||||
expect(kibanaVersion).toBe('4.5.6');
|
||||
});
|
||||
|
@ -53,7 +53,7 @@ describe('build_action', () => {
|
|||
it('uses default file list without files option', function () {
|
||||
return buildAction(PLUGIN).then(() => {
|
||||
expect(mockBuild.mock.calls).toHaveLength(1);
|
||||
const [ plugin, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0];
|
||||
const [ plugin, buildTarget, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0];
|
||||
PLUGIN.buildSourcePatterns.forEach(file => expect(files).toContain(file));
|
||||
});
|
||||
});
|
||||
|
@ -70,7 +70,7 @@ describe('build_action', () => {
|
|||
|
||||
return buildAction(PLUGIN, noop, options).then(() => {
|
||||
expect(mockBuild.mock.calls).toHaveLength(1);
|
||||
const [ plugin, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0];
|
||||
const [ plugin, buildTarget, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0];
|
||||
options.files.forEach(file => expect(files).toContain(file));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,10 +5,9 @@ var zip = require('gulp-zip');
|
|||
var map = require('through2-map').obj;
|
||||
var rename = require('gulp-rename');
|
||||
|
||||
module.exports = function createBuild(plugin, buildVersion, kibanaVersion, files) {
|
||||
module.exports = function createBuild(plugin, buildTarget, buildVersion, kibanaVersion, files) {
|
||||
var buildId = `${plugin.id}-${buildVersion}`;
|
||||
var buildSource = plugin.root;
|
||||
var buildTarget = join(plugin.root, 'build');
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
vfs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue