mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Enable Prettier for more packages (#17763)
This commit is contained in:
parent
403889416c
commit
ef900fd42d
42 changed files with 420 additions and 261 deletions
|
@ -18,10 +18,14 @@ module.exports = {
|
|||
{
|
||||
files: [
|
||||
'.eslintrc.js',
|
||||
'packages/eslint-plugin-kibana-custom/**/*',
|
||||
'packages/kbn-pm/**/*',
|
||||
'packages/kbn-es/**/*',
|
||||
'packages/kbn-datemath/**/*.js',
|
||||
'packages/kbn-datemath/**/*',
|
||||
'packages/kbn-dev-utils/**/*',
|
||||
'packages/kbn-plugin-helpers/**/*',
|
||||
'packages/kbn-plugin-generator/**/*',
|
||||
'packages/kbn-test-subj-selector/**/*',
|
||||
'packages/kbn-eslint-import-resolver-kibana/**/*',
|
||||
],
|
||||
plugins: ['prettier'],
|
||||
|
|
|
@ -16,20 +16,22 @@ import { observeReadable } from './observe_readable';
|
|||
export function observeLines(readable) {
|
||||
const done$ = observeReadable(readable).share();
|
||||
|
||||
const scan$ = Rx.Observable
|
||||
.fromEvent(readable, 'data')
|
||||
.scan(({ buffer }, chunk) => {
|
||||
buffer += chunk;
|
||||
const scan$ = Rx.Observable.fromEvent(readable, 'data')
|
||||
.scan(
|
||||
({ buffer }, chunk) => {
|
||||
buffer += chunk;
|
||||
|
||||
let match;
|
||||
const lines = [];
|
||||
while (match = buffer.match(SEP)) {
|
||||
lines.push(buffer.slice(0, match.index));
|
||||
buffer = buffer.slice(match.index + match[0].length);
|
||||
}
|
||||
let match;
|
||||
const lines = [];
|
||||
while ((match = buffer.match(SEP))) {
|
||||
lines.push(buffer.slice(0, match.index));
|
||||
buffer = buffer.slice(match.index + match[0].length);
|
||||
}
|
||||
|
||||
return { buffer, lines };
|
||||
}, { buffer: '' })
|
||||
return { buffer, lines };
|
||||
},
|
||||
{ buffer: '' }
|
||||
)
|
||||
// stop if done completes or errors
|
||||
.takeUntil(done$.materialize());
|
||||
|
||||
|
@ -38,8 +40,7 @@ export function observeLines(readable) {
|
|||
done$,
|
||||
|
||||
// merge in the "lines" from each step
|
||||
scan$
|
||||
.mergeMap(({ lines }) => lines),
|
||||
scan$.mergeMap(({ lines }) => lines),
|
||||
|
||||
// inject the "unsplit" data at the end
|
||||
scan$
|
||||
|
|
|
@ -9,16 +9,13 @@ import Rx from 'rxjs/Rx';
|
|||
* @return {Rx.Observable}
|
||||
*/
|
||||
export function observeReadable(readable) {
|
||||
return Rx.Observable
|
||||
.race(
|
||||
Rx.Observable
|
||||
.fromEvent(readable, 'end')
|
||||
.first()
|
||||
.ignoreElements(),
|
||||
return Rx.Observable.race(
|
||||
Rx.Observable.fromEvent(readable, 'end')
|
||||
.first()
|
||||
.ignoreElements(),
|
||||
|
||||
Rx.Observable
|
||||
.fromEvent(readable, 'error')
|
||||
.first()
|
||||
.map(err => Rx.Observable.throw(err))
|
||||
);
|
||||
Rx.Observable.fromEvent(readable, 'error')
|
||||
.first()
|
||||
.map(err => Rx.Observable.throw(err))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@ export function observeSignals(process) {
|
|||
return Rx.Observable.merge(
|
||||
Rx.Observable.fromEvent(process, 'exit').mapTo('exit'),
|
||||
Rx.Observable.fromEvent(process, 'SIGINT').mapTo('SIGINT'),
|
||||
Rx.Observable.fromEvent(process, 'SIGTERM').mapTo('SIGTERM'),
|
||||
Rx.Observable.fromEvent(process, 'SIGTERM').mapTo('SIGTERM')
|
||||
);
|
||||
}
|
||||
|
|
|
@ -20,10 +20,9 @@ async function withTimeout(attempt, ms, onTimeout) {
|
|||
try {
|
||||
await Promise.race([
|
||||
attempt(),
|
||||
new Promise((resolve, reject) => setTimeout(
|
||||
() => reject(TIMEOUT),
|
||||
STOP_TIMEOUT
|
||||
))
|
||||
new Promise((resolve, reject) =>
|
||||
setTimeout(() => reject(TIMEOUT), STOP_TIMEOUT)
|
||||
),
|
||||
]);
|
||||
} catch (error) {
|
||||
if (error === TIMEOUT) {
|
||||
|
@ -91,7 +90,7 @@ export function createProc(name, { cmd, args, cwd, env, stdin }) {
|
|||
.mergeMap(err => Rx.Observable.throw(err));
|
||||
|
||||
return Rx.Observable.race(exit$, error$);
|
||||
}).share()
|
||||
}).share();
|
||||
|
||||
outcomePromise = Rx.Observable.merge(
|
||||
this.lines$.ignoreElements(),
|
||||
|
@ -105,7 +104,9 @@ export function createProc(name, { cmd, args, cwd, env, stdin }) {
|
|||
},
|
||||
STOP_TIMEOUT,
|
||||
async () => {
|
||||
log.warning(`Proc "${name}" was sent "${signal}" and didn't exit after ${STOP_TIMEOUT} ms, sending SIGKILL`);
|
||||
log.warning(
|
||||
`Proc "${name}" was sent "${signal}" and didn't exit after ${STOP_TIMEOUT} ms, sending SIGKILL`
|
||||
);
|
||||
await treeKillAsync(childProcess.pid, 'SIGKILL');
|
||||
}
|
||||
);
|
||||
|
@ -120,7 +121,9 @@ export function createProc(name, { cmd, args, cwd, env, stdin }) {
|
|||
},
|
||||
STOP_TIMEOUT,
|
||||
async () => {
|
||||
throw new Error(`Proc "${name}" was stopped but never emiited either the "exit" or "error" event after ${STOP_TIMEOUT} ms`);
|
||||
throw new Error(
|
||||
`Proc "${name}" was stopped but never emiited either the "exit" or "error" event after ${STOP_TIMEOUT} ms`
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@ export class ProcRunner {
|
|||
this._closing = false;
|
||||
this._procs = [];
|
||||
this._signalSubscription = observeSignals(process).subscribe({
|
||||
next: async (signal) => {
|
||||
next: async signal => {
|
||||
await this.teardown(signal);
|
||||
if (signal !== 'exit') {
|
||||
// resend the signal
|
||||
process.kill(process.pid, signal);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ export class ProcRunner {
|
|||
cwd = process.cwd(),
|
||||
stdin = null,
|
||||
wait = false,
|
||||
env = process.env
|
||||
env = process.env,
|
||||
} = options;
|
||||
|
||||
if (this._closing) {
|
||||
|
@ -74,7 +74,9 @@ export class ProcRunner {
|
|||
.first()
|
||||
.catch(err => {
|
||||
if (err.name !== 'EmptyError') {
|
||||
throw createCliError(`[${name}] exitted without matching pattern: ${wait}`);
|
||||
throw createCliError(
|
||||
`[${name}] exitted without matching pattern: ${wait}`
|
||||
);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
|
@ -116,9 +118,7 @@ export class ProcRunner {
|
|||
* @return {Promise<undefined>}
|
||||
*/
|
||||
async waitForAllToStop() {
|
||||
await Promise.all(
|
||||
this._procs.map(proc => proc.closedPromise)
|
||||
);
|
||||
await Promise.all(this._procs.map(proc => proc.closedPromise));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,9 +144,7 @@ export class ProcRunner {
|
|||
}
|
||||
|
||||
const stopWith = signal === 'exit' ? 'SIGKILL' : signal;
|
||||
await Promise.all(
|
||||
this._procs.map(proc => proc.stop(stopWith))
|
||||
);
|
||||
await Promise.all(this._procs.map(proc => proc.stop(stopWith)));
|
||||
}
|
||||
|
||||
_getProc(name) {
|
||||
|
@ -164,14 +162,19 @@ export class ProcRunner {
|
|||
|
||||
// tie into proc outcome$, remove from _procs on compete
|
||||
proc.outcome$.subscribe({
|
||||
next: (code) => {
|
||||
next: code => {
|
||||
const duration = moment.duration(Date.now() - startMs);
|
||||
log.info('[%s] exitted with %s after %s', name, code, duration.humanize());
|
||||
log.info(
|
||||
'[%s] exitted with %s after %s',
|
||||
name,
|
||||
code,
|
||||
duration.humanize()
|
||||
);
|
||||
},
|
||||
complete: () => {
|
||||
remove();
|
||||
},
|
||||
error: (error) => {
|
||||
error: error => {
|
||||
if (this._closing) {
|
||||
log.error(error);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ export async function createPromiseFromStreams(streams) {
|
|||
}
|
||||
|
||||
let finalChunk;
|
||||
last.on('data', (chunk) => {
|
||||
last.on('data', chunk => {
|
||||
finalChunk = chunk;
|
||||
});
|
||||
last.on('end', () => {
|
||||
|
@ -59,7 +59,7 @@ export async function createPromiseFromStreams(streams) {
|
|||
// to both finish writing and providing values to read
|
||||
await Promise.race([
|
||||
anyStreamFailure,
|
||||
Promise.all([lastFinishedWriting, lastFinishedReading])
|
||||
Promise.all([lastFinishedWriting, lastFinishedReading]),
|
||||
]);
|
||||
|
||||
// return the final chunk read from the last stream
|
||||
|
|
|
@ -56,6 +56,6 @@ export function createReduceStream(reducer, initial) {
|
|||
}
|
||||
|
||||
callback();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -89,8 +89,7 @@ describe('parseLogLevel(logLevel).flags', () => {
|
|||
// by specifying a long length
|
||||
const level = chance.word({ length: 10 });
|
||||
|
||||
expect(() => parseLogLevel(level))
|
||||
.to.throwError(level);
|
||||
expect(() => parseLogLevel(level)).to.throwError(level);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
const LEVELS = [
|
||||
'silent',
|
||||
'error',
|
||||
'warning',
|
||||
'info',
|
||||
'debug',
|
||||
'verbose',
|
||||
];
|
||||
const LEVELS = ['silent', 'error', 'warning', 'info', 'debug', 'verbose'];
|
||||
|
||||
export function pickLevelFromFlags(flags) {
|
||||
if (flags.verbose) return 'verbose';
|
||||
|
@ -19,10 +12,8 @@ export function parseLogLevel(name) {
|
|||
const i = LEVELS.indexOf(name);
|
||||
|
||||
if (i === -1) {
|
||||
const msg = (
|
||||
`Invalid log level "${name}" ` +
|
||||
`(expected one of ${LEVELS.join(',')})`
|
||||
);
|
||||
const msg =
|
||||
`Invalid log level "${name}" ` + `(expected one of ${LEVELS.join(',')})`;
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,11 +68,16 @@ export function createToolingLog(initialLogLevelName = 'silent') {
|
|||
}
|
||||
|
||||
write(...args) {
|
||||
format(...args).split('\n').forEach((line, i) => {
|
||||
const subLineIndent = i === 0 ? '' : ' ';
|
||||
const indent = !indentString ? '' : indentString.slice(0, -1) + (i === 0 && line[0] === '-' ? '└' : '│');
|
||||
super.write(`${indent}${subLineIndent}${line}\n`);
|
||||
});
|
||||
format(...args)
|
||||
.split('\n')
|
||||
.forEach((line, i) => {
|
||||
const subLineIndent = i === 0 ? '' : ' ';
|
||||
const indent = !indentString
|
||||
? ''
|
||||
: indentString.slice(0, -1) +
|
||||
(i === 0 && line[0] === '-' ? '└' : '│');
|
||||
super.write(`${indent}${subLineIndent}${line}\n`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const nodeMajorVersion = parseFloat(process.version.replace(/^v(\d+)\..+/, '$1'));
|
||||
const nodeMajorVersion = parseFloat(
|
||||
process.version.replace(/^v(\d+)\..+/, '$1')
|
||||
);
|
||||
if (nodeMajorVersion < 6) {
|
||||
console.error('FATAL: kibana-plugin-helpers requires node 6+');
|
||||
process.exit(1);
|
||||
|
|
|
@ -5,34 +5,46 @@ const createCommanderAction = require('./lib/commander_action');
|
|||
const docs = require('./lib/docs');
|
||||
const enableCollectingUnknownOptions = require('./lib/enable_collecting_unknown_options');
|
||||
|
||||
program
|
||||
.version(pkg.version);
|
||||
program.version(pkg.version);
|
||||
|
||||
enableCollectingUnknownOptions(
|
||||
program
|
||||
.command('start')
|
||||
.description('Start kibana and have it include this plugin')
|
||||
.on('--help', docs('start'))
|
||||
.action(createCommanderAction('start', (command) => ({
|
||||
flags: command.unknownOptions
|
||||
})))
|
||||
.action(
|
||||
createCommanderAction('start', command => ({
|
||||
flags: command.unknownOptions,
|
||||
}))
|
||||
)
|
||||
);
|
||||
|
||||
program
|
||||
.command('build [files...]')
|
||||
.description('Build a distributable archive')
|
||||
.on('--help', docs('build'))
|
||||
.option('--skip-archive', 'Don\'t create the zip file, leave the build path alone')
|
||||
.option('-d, --build-destination <path>', 'Target path for the build output, absolute or relative to the plugin root')
|
||||
.option(
|
||||
'--skip-archive',
|
||||
"Don't create the zip file, leave the build path alone"
|
||||
)
|
||||
.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(createCommanderAction('build', (command, files) => ({
|
||||
buildDestination: command.buildDestination,
|
||||
buildVersion: command.buildVersion,
|
||||
kibanaVersion: command.kibanaVersion,
|
||||
skipArchive: Boolean(command.skipArchive),
|
||||
files: files,
|
||||
})));
|
||||
.option(
|
||||
'-k, --kibana-version <version>',
|
||||
'Kibana version for the build output'
|
||||
)
|
||||
.action(
|
||||
createCommanderAction('build', (command, files) => ({
|
||||
buildDestination: command.buildDestination,
|
||||
buildVersion: command.buildVersion,
|
||||
kibanaVersion: command.kibanaVersion,
|
||||
skipArchive: Boolean(command.skipArchive),
|
||||
files: files,
|
||||
}))
|
||||
);
|
||||
|
||||
program
|
||||
.command('test')
|
||||
|
@ -44,24 +56,28 @@ program
|
|||
.command('test:browser')
|
||||
.description('Run the browser tests in a real web browser')
|
||||
.option('--dev', 'Enable dev mode, keeps the test server running')
|
||||
.option('-p, --plugins <plugin-ids>', 'Manually specify which plugins\' test bundles to run')
|
||||
.option(
|
||||
'-p, --plugins <plugin-ids>',
|
||||
"Manually specify which plugins' test bundles to run"
|
||||
)
|
||||
.on('--help', docs('test/browser'))
|
||||
.action(createCommanderAction('testBrowser', (command) => ({
|
||||
dev: Boolean(command.dev),
|
||||
plugins: command.plugins,
|
||||
})));
|
||||
.action(
|
||||
createCommanderAction('testBrowser', command => ({
|
||||
dev: Boolean(command.dev),
|
||||
plugins: command.plugins,
|
||||
}))
|
||||
);
|
||||
|
||||
program
|
||||
.command('test:server [files...]')
|
||||
.description('Run the server tests using mocha')
|
||||
.on('--help', docs('test/server'))
|
||||
.action(createCommanderAction('testServer', (command, files) => ({
|
||||
files: files
|
||||
})));
|
||||
.action(
|
||||
createCommanderAction('testServer', (command, files) => ({
|
||||
files: files,
|
||||
}))
|
||||
);
|
||||
|
||||
program
|
||||
.command('postinstall')
|
||||
.action(createCommanderAction('postinstall'));
|
||||
program.command('postinstall').action(createCommanderAction('postinstall'));
|
||||
|
||||
program
|
||||
.parse(process.argv);
|
||||
program.parse(process.argv);
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
const run = require('./run');
|
||||
|
||||
module.exports = function createCommanderAction(taskName, getOptions = () => {}) {
|
||||
module.exports = function createCommanderAction(
|
||||
taskName,
|
||||
getOptions = () => {}
|
||||
) {
|
||||
return async (...args) => {
|
||||
try {
|
||||
// command is the last arg passed by commander, but we move it to the front of the list
|
||||
const command = args.pop();
|
||||
await run(taskName, getOptions(command, ...args));
|
||||
} catch (error) {
|
||||
process.stderr.write(`Task "${taskName}" failed:\n\n${error.stack || error.message}\n`);
|
||||
process.stderr.write(
|
||||
`Task "${taskName}" failed:\n\n${error.stack || error.message}\n`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
const resolve = require('path').resolve;
|
||||
const readFileSync = require('fs').readFileSync;
|
||||
|
||||
const configFiles = [ '.kibana-plugin-helpers.json', '.kibana-plugin-helpers.dev.json' ];
|
||||
const configFiles = [
|
||||
'.kibana-plugin-helpers.json',
|
||||
'.kibana-plugin-helpers.dev.json',
|
||||
];
|
||||
const configCache = {};
|
||||
|
||||
module.exports = function (root) {
|
||||
module.exports = function(root) {
|
||||
if (!root) root = process.cwd();
|
||||
|
||||
if (configCache[root]) {
|
||||
|
@ -12,9 +15,9 @@ module.exports = function (root) {
|
|||
}
|
||||
|
||||
// config files to read from, in the order they are merged together
|
||||
let config = configCache[root] = {};
|
||||
let config = (configCache[root] = {});
|
||||
|
||||
configFiles.forEach(function (configFile) {
|
||||
configFiles.forEach(function(configFile) {
|
||||
try {
|
||||
const content = JSON.parse(readFileSync(resolve(root, configFile)));
|
||||
config = Object.assign(config, content);
|
||||
|
@ -26,24 +29,22 @@ module.exports = function (root) {
|
|||
}
|
||||
});
|
||||
|
||||
const deprecationMsg = 'has been removed from `@kbn/plugin-helpers`. ' +
|
||||
const deprecationMsg =
|
||||
'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.\n';
|
||||
|
||||
if (config.kibanaRoot) {
|
||||
throw new Error(
|
||||
'The `kibanaRoot` config option ' + deprecationMsg
|
||||
);
|
||||
throw new Error('The `kibanaRoot` config option ' + deprecationMsg);
|
||||
}
|
||||
if (process.env.KIBANA_ROOT) {
|
||||
throw new Error(
|
||||
'The `KIBANA_ROOT` environment variable ' + deprecationMsg
|
||||
);
|
||||
throw new Error('The `KIBANA_ROOT` environment variable ' + deprecationMsg);
|
||||
}
|
||||
|
||||
// use resolve to ensure correct resolution of paths
|
||||
const { includePlugins } = config;
|
||||
if (includePlugins) config.includePlugins = includePlugins.map(path => resolve(root, path));
|
||||
if (includePlugins)
|
||||
config.includePlugins = includePlugins.map(path => resolve(root, path));
|
||||
|
||||
return config;
|
||||
};
|
||||
|
|
|
@ -2,14 +2,17 @@ const resolve = require('path').resolve;
|
|||
const readFileSync = require('fs').readFileSync;
|
||||
|
||||
function indent(txt, n) {
|
||||
const space = (new Array(n + 1)).join(' ');
|
||||
const space = new Array(n + 1).join(' ');
|
||||
return space + txt.split('\n').join('\n' + space);
|
||||
}
|
||||
|
||||
module.exports = function docs(name) {
|
||||
const md = readFileSync(resolve(__dirname, '../tasks', name, 'README.md'), 'utf8');
|
||||
const md = readFileSync(
|
||||
resolve(__dirname, '../tasks', name, 'README.md'),
|
||||
'utf8'
|
||||
);
|
||||
|
||||
return function () {
|
||||
return function() {
|
||||
console.log('\n Docs:');
|
||||
console.log('');
|
||||
console.log(indent(md, 4));
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
module.exports = function enableCollectingUnknownOptions(command) {
|
||||
const origParse = command.parseOptions;
|
||||
command.allowUnknownOption();
|
||||
command.parseOptions = function (argv) {
|
||||
command.parseOptions = function(argv) {
|
||||
const opts = origParse.call(this, argv);
|
||||
this.unknownOptions = opts.unknown;
|
||||
return opts;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
const run = require('./run');
|
||||
const utils = require('./utils');
|
||||
|
||||
module.exports = function () {
|
||||
module.exports = function() {
|
||||
console.error(
|
||||
'running tasks with the default export of @kbn/plugin-helpers is deprecated.' +
|
||||
'use `require(\'@kbn/plugin-helpers\').run()` instead'
|
||||
"use `require('@kbn/plugin-helpers').run()` instead"
|
||||
);
|
||||
|
||||
return run.apply(this, arguments);
|
||||
};
|
||||
|
||||
Object.assign(module.exports, { run: run }, utils);
|
||||
Object.assign(module.exports, { run: run }, utils);
|
||||
|
|
|
@ -2,7 +2,7 @@ const resolve = require('path').resolve;
|
|||
const readFileSync = require('fs').readFileSync;
|
||||
const configFile = require('./config_file');
|
||||
|
||||
module.exports = function (root) {
|
||||
module.exports = function(root) {
|
||||
if (!root) root = process.cwd();
|
||||
|
||||
const pkg = JSON.parse(readFileSync(resolve(root, 'package.json')));
|
||||
|
@ -15,14 +15,17 @@ module.exports = function (root) {
|
|||
'{lib,public,server,webpackShims,translations}/**/*',
|
||||
];
|
||||
|
||||
return Object.assign({
|
||||
root: root,
|
||||
kibanaRoot: resolve(root, '../../kibana'),
|
||||
serverTestPatterns: ['server/**/__tests__/**/*.js'],
|
||||
buildSourcePatterns: buildSourcePatterns,
|
||||
skipInstallDependencies: false,
|
||||
id: pkg.name,
|
||||
pkg: pkg,
|
||||
version: pkg.version,
|
||||
}, config);
|
||||
return Object.assign(
|
||||
{
|
||||
root: root,
|
||||
kibanaRoot: resolve(root, '../../kibana'),
|
||||
serverTestPatterns: ['server/**/__tests__/**/*.js'],
|
||||
buildSourcePatterns: buildSourcePatterns,
|
||||
skipInstallDependencies: false,
|
||||
id: pkg.name,
|
||||
pkg: pkg,
|
||||
version: pkg.version,
|
||||
},
|
||||
config
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/*eslint-env jest*/
|
||||
|
||||
jest.mock('./plugin_config', () => () => (
|
||||
{ id: 'testPlugin' }
|
||||
));
|
||||
jest.mock('./plugin_config', () => () => ({ id: 'testPlugin' }));
|
||||
|
||||
jest.mock('./tasks', () => {
|
||||
return { testTask: jest.fn() };
|
||||
|
@ -13,14 +11,14 @@ const run = require('./run');
|
|||
describe('lib/run', () => {
|
||||
beforeEach(() => jest.resetAllMocks());
|
||||
|
||||
it('throw given an invalid task', function () {
|
||||
it('throw given an invalid task', function() {
|
||||
const invalidTaskName = 'thisisnotavalidtasknameandneverwillbe';
|
||||
const runner = () => run(invalidTaskName);
|
||||
|
||||
expect(runner).toThrow(/invalid task/i);
|
||||
});
|
||||
|
||||
it('runs specified task with plugin and runner', function () {
|
||||
it('runs specified task with plugin and runner', function() {
|
||||
run('testTask');
|
||||
|
||||
const { testTask } = require('./tasks');
|
||||
|
@ -31,7 +29,7 @@ describe('lib/run', () => {
|
|||
expect(args[1]).toBe(run);
|
||||
});
|
||||
|
||||
it('returns value returned by task', function () {
|
||||
it('returns value returned by task', function() {
|
||||
const { testTask } = require('./tasks');
|
||||
|
||||
const symbol = Symbol('foo');
|
||||
|
|
|
@ -11,5 +11,5 @@ module.exports = {
|
|||
testAll: testAllTask,
|
||||
testBrowser: testBrowserTask,
|
||||
testServer: testServerTask,
|
||||
postinstall: postinstallTask
|
||||
};
|
||||
postinstall: postinstallTask,
|
||||
};
|
||||
|
|
|
@ -23,7 +23,9 @@ function resolveKibanaPath(path) {
|
|||
}
|
||||
|
||||
function readFtrConfigFile(log, path, settingOverrides) {
|
||||
return require(resolveKibanaPath('src/functional_test_runner')).readConfigFile(log, path, settingOverrides);
|
||||
return require(resolveKibanaPath(
|
||||
'src/functional_test_runner'
|
||||
)).readConfigFile(log, path, settingOverrides);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
module.exports = kibana => new kibana.Plugin({
|
||||
uiExports: {
|
||||
hacks: [
|
||||
'plugins/test_plugin/hack.js'
|
||||
]
|
||||
}
|
||||
});
|
||||
module.exports = kibana =>
|
||||
new kibana.Plugin({
|
||||
uiExports: {
|
||||
hacks: ['plugins/test_plugin/hack.js'],
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
console.log('this is my hack');
|
||||
console.log('this is my hack');
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
module.exports = kibana => new kibana.Plugin({
|
||||
uiExports: {
|
||||
hacks: [
|
||||
'plugins/test_plugin/hack.js'
|
||||
]
|
||||
}
|
||||
});
|
||||
module.exports = kibana =>
|
||||
new kibana.Plugin({
|
||||
uiExports: {
|
||||
hacks: ['plugins/test_plugin/hack.js'],
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
console.log('this is my hack');
|
||||
console.log('this is my hack');
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
module.exports = kibana => new kibana.Plugin({
|
||||
uiExports: {
|
||||
hacks: [
|
||||
'plugins/test_plugin/hack.js'
|
||||
]
|
||||
}
|
||||
});
|
||||
module.exports = kibana =>
|
||||
new kibana.Plugin({
|
||||
uiExports: {
|
||||
hacks: ['plugins/test_plugin/hack.js'],
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
console.log('this is my hack');
|
||||
console.log('this is my hack');
|
||||
|
|
|
@ -5,10 +5,11 @@ const inquirer = require('inquirer');
|
|||
const createBuild = require('./create_build');
|
||||
const createPackage = require('./create_package');
|
||||
|
||||
module.exports = function (plugin, run, options) {
|
||||
module.exports = function(plugin, run, options) {
|
||||
options = options || {};
|
||||
let buildVersion = plugin.version;
|
||||
let kibanaVersion = (plugin.pkg.kibana && plugin.pkg.kibana.version) || plugin.pkg.version;
|
||||
let kibanaVersion =
|
||||
(plugin.pkg.kibana && plugin.pkg.kibana.version) || plugin.pkg.version;
|
||||
let buildFiles = plugin.buildSourcePatterns;
|
||||
let buildTarget = join(plugin.root, 'build');
|
||||
|
||||
|
@ -18,34 +19,48 @@ module.exports = function (plugin, run, options) {
|
|||
}
|
||||
|
||||
// allow options to override plugin info
|
||||
if (options.buildDestination) buildTarget = resolve(plugin.root, options.buildDestination);
|
||||
if (options.buildDestination)
|
||||
buildTarget = resolve(plugin.root, options.buildDestination);
|
||||
if (options.buildVersion) buildVersion = options.buildVersion;
|
||||
if (options.kibanaVersion) kibanaVersion = options.kibanaVersion;
|
||||
|
||||
let buildStep;
|
||||
if (kibanaVersion === 'kibana') {
|
||||
buildStep = askForKibanaVersion().then(function (customKibanaVersion) {
|
||||
return createBuild(plugin, buildTarget, buildVersion, customKibanaVersion, buildFiles);
|
||||
buildStep = askForKibanaVersion().then(function(customKibanaVersion) {
|
||||
return createBuild(
|
||||
plugin,
|
||||
buildTarget,
|
||||
buildVersion,
|
||||
customKibanaVersion,
|
||||
buildFiles
|
||||
);
|
||||
});
|
||||
} else {
|
||||
buildStep = createBuild(plugin, buildTarget, buildVersion, kibanaVersion, buildFiles);
|
||||
buildStep = createBuild(
|
||||
plugin,
|
||||
buildTarget,
|
||||
buildVersion,
|
||||
kibanaVersion,
|
||||
buildFiles
|
||||
);
|
||||
}
|
||||
|
||||
return buildStep
|
||||
.then(function () {
|
||||
if (options.skipArchive) return;
|
||||
return createPackage(plugin, buildTarget, buildVersion);
|
||||
});
|
||||
return buildStep.then(function() {
|
||||
if (options.skipArchive) return;
|
||||
return createPackage(plugin, buildTarget, buildVersion);
|
||||
});
|
||||
};
|
||||
|
||||
function askForKibanaVersion() {
|
||||
return inquirer.prompt([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'kibanaVersion',
|
||||
message: 'What version of Kibana are you building for?'
|
||||
}
|
||||
]).then(function (answers) {
|
||||
return answers.kibanaVersion;
|
||||
});
|
||||
return inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'kibanaVersion',
|
||||
message: 'What version of Kibana are you building for?',
|
||||
},
|
||||
])
|
||||
.then(function(answers) {
|
||||
return answers.kibanaVersion;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,7 +2,10 @@ const resolve = require('path').resolve;
|
|||
const fs = require('fs');
|
||||
const del = require('del');
|
||||
|
||||
const PLUGIN_FIXTURE = resolve(__dirname, '__fixtures__/build_action_test_plugin');
|
||||
const PLUGIN_FIXTURE = resolve(
|
||||
__dirname,
|
||||
'__fixtures__/build_action_test_plugin'
|
||||
);
|
||||
const PLUGIN_BUILD_DIR = resolve(PLUGIN_FIXTURE, 'build');
|
||||
const PLUGIN = require('../../lib/plugin_config')(PLUGIN_FIXTURE);
|
||||
const noop = () => {};
|
||||
|
@ -16,7 +19,10 @@ describe('creating build zip', () => {
|
|||
it('creates a zip in the build directory', async () => {
|
||||
await buildAction(PLUGIN);
|
||||
|
||||
const buildFile = resolve(PLUGIN_BUILD_DIR, PLUGIN.id + '-' + PLUGIN.version + '.zip');
|
||||
const buildFile = resolve(
|
||||
PLUGIN_BUILD_DIR,
|
||||
PLUGIN.id + '-' + PLUGIN.version + '.zip'
|
||||
);
|
||||
if (!fs.existsSync(buildFile)) {
|
||||
throw new Error('Build file not found: ' + buildFile);
|
||||
}
|
||||
|
@ -25,7 +31,10 @@ describe('creating build zip', () => {
|
|||
it('skips zip creation based on flag', async () => {
|
||||
await buildAction(PLUGIN, noop, { skipArchive: true });
|
||||
|
||||
const buildFile = resolve(PLUGIN_BUILD_DIR, PLUGIN.id + '-' + PLUGIN.version + '.zip');
|
||||
const buildFile = resolve(
|
||||
PLUGIN_BUILD_DIR,
|
||||
PLUGIN.id + '-' + PLUGIN.version + '.zip'
|
||||
);
|
||||
if (fs.existsSync(buildFile)) {
|
||||
throw new Error('Build file not found: ' + buildFile);
|
||||
}
|
||||
|
@ -52,8 +61,14 @@ describe('calling create_build', () => {
|
|||
await buildAction(PLUGIN, noop, options);
|
||||
|
||||
expect(mockBuild.mock.calls).toHaveLength(1);
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [ plugin, buildTarget, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0];
|
||||
|
||||
const [
|
||||
plugin, // eslint-disable-line no-unused-vars
|
||||
buildTarget, // eslint-disable-line no-unused-vars
|
||||
buildVersion,
|
||||
kibanaVersion,
|
||||
files, // eslint-disable-line no-unused-vars
|
||||
] = mockBuild.mock.calls[0];
|
||||
expect(buildVersion).toBe('1.2.3');
|
||||
expect(kibanaVersion).toBe('4.5.6');
|
||||
});
|
||||
|
@ -62,8 +77,14 @@ describe('calling create_build', () => {
|
|||
await buildAction(PLUGIN);
|
||||
|
||||
expect(mockBuild.mock.calls).toHaveLength(1);
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [ plugin, buildTarget, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0];
|
||||
|
||||
const [
|
||||
plugin, // eslint-disable-line no-unused-vars
|
||||
buildTarget, // eslint-disable-line no-unused-vars
|
||||
buildVersion, // eslint-disable-line no-unused-vars
|
||||
kibanaVersion, // eslint-disable-line no-unused-vars
|
||||
files,
|
||||
] = mockBuild.mock.calls[0];
|
||||
PLUGIN.buildSourcePatterns.forEach(file => expect(files).toContain(file));
|
||||
});
|
||||
|
||||
|
@ -73,15 +94,21 @@ describe('calling create_build', () => {
|
|||
'index.js',
|
||||
'LICENSE.txt',
|
||||
'plugins/**/*',
|
||||
'{server,public}/**/*'
|
||||
]
|
||||
'{server,public}/**/*',
|
||||
],
|
||||
};
|
||||
|
||||
await buildAction(PLUGIN, noop, options);
|
||||
|
||||
expect(mockBuild.mock.calls).toHaveLength(1);
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [ plugin, buildTarget, buildVersion, kibanaVersion, files ] = mockBuild.mock.calls[0];
|
||||
|
||||
const [
|
||||
plugin, // eslint-disable-line no-unused-vars
|
||||
buildTarget, // eslint-disable-line no-unused-vars
|
||||
buildVersion, // eslint-disable-line no-unused-vars
|
||||
kibanaVersion, // eslint-disable-line no-unused-vars
|
||||
files,
|
||||
] = mockBuild.mock.calls[0];
|
||||
options.files.forEach(file => expect(files).toContain(file));
|
||||
});
|
||||
|
||||
|
@ -90,6 +117,8 @@ describe('calling create_build', () => {
|
|||
throw new Error('foo bar');
|
||||
});
|
||||
|
||||
await expect(buildAction(PLUGIN, noop)).rejects.toThrowErrorMatchingSnapshot();
|
||||
await expect(
|
||||
buildAction(PLUGIN, noop)
|
||||
).rejects.toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -29,30 +29,44 @@ function removeSymlinkDependencies(root) {
|
|||
});
|
||||
}
|
||||
|
||||
module.exports = function createBuild(plugin, buildTarget, buildVersion, kibanaVersion, files) {
|
||||
module.exports = function createBuild(
|
||||
plugin,
|
||||
buildTarget,
|
||||
buildVersion,
|
||||
kibanaVersion,
|
||||
files
|
||||
) {
|
||||
const buildSource = plugin.root;
|
||||
const buildRoot = join(buildTarget, 'kibana', plugin.id);
|
||||
|
||||
return del(buildTarget)
|
||||
.then(function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
.then(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
vfs
|
||||
.src(files, { cwd: buildSource, base: buildSource, allowEmpty: true })
|
||||
// modify the package.json file
|
||||
.pipe(rewritePackageJson(buildSource, buildVersion, kibanaVersion))
|
||||
|
||||
// put all files inside the correct directories
|
||||
.pipe(rename(function nestFileInDir(path) {
|
||||
const nonRelativeDirname = path.dirname.replace(/^(\.\.\/?)+/g, '');
|
||||
path.dirname = join(relative(buildTarget, buildRoot), nonRelativeDirname);
|
||||
}))
|
||||
.pipe(
|
||||
rename(function nestFileInDir(path) {
|
||||
const nonRelativeDirname = path.dirname.replace(
|
||||
/^(\.\.\/?)+/g,
|
||||
''
|
||||
);
|
||||
path.dirname = join(
|
||||
relative(buildTarget, buildRoot),
|
||||
nonRelativeDirname
|
||||
);
|
||||
})
|
||||
)
|
||||
|
||||
.pipe(vfs.dest(buildTarget))
|
||||
.on('end', resolve)
|
||||
.on('error', reject);
|
||||
});
|
||||
})
|
||||
.then(function () {
|
||||
.then(function() {
|
||||
if (plugin.skipInstallDependencies) {
|
||||
return;
|
||||
}
|
||||
|
@ -63,13 +77,22 @@ module.exports = function createBuild(plugin, buildTarget, buildVersion, kibanaV
|
|||
stdio: ['ignore', 'ignore', 'pipe'],
|
||||
};
|
||||
|
||||
execFileSync(winCmd('yarn'), ['install', '--production', '--pure-lockfile'], options);
|
||||
execFileSync(
|
||||
winCmd('yarn'),
|
||||
['install', '--production', '--pure-lockfile'],
|
||||
options
|
||||
);
|
||||
})
|
||||
.then(function () {
|
||||
.then(function() {
|
||||
const buildFiles = [relative(buildTarget, buildRoot) + '/**/*'];
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
vfs.src(buildFiles, { cwd: buildTarget, base: buildTarget, resolveSymlinks: false })
|
||||
vfs
|
||||
.src(buildFiles, {
|
||||
cwd: buildTarget,
|
||||
base: buildTarget,
|
||||
resolveSymlinks: false,
|
||||
})
|
||||
.pipe(removeSymlinkDependencies(buildRoot))
|
||||
.on('finish', resolve)
|
||||
.on('error', reject);
|
||||
|
|
|
@ -3,7 +3,10 @@ const { readdirSync } = require('fs');
|
|||
const del = require('del');
|
||||
const createBuild = require('./create_build');
|
||||
|
||||
const PLUGIN_FIXTURE = resolve(__dirname, '__fixtures__/create_build_test_plugin');
|
||||
const PLUGIN_FIXTURE = resolve(
|
||||
__dirname,
|
||||
'__fixtures__/create_build_test_plugin'
|
||||
);
|
||||
const PLUGIN = require('../../lib/plugin_config')(PLUGIN_FIXTURE);
|
||||
const PLUGIN_BUILD_DIR = resolve(PLUGIN_FIXTURE, 'build');
|
||||
const PLUGIN_BUILD_TARGET = resolve(PLUGIN_BUILD_DIR, 'kibana', PLUGIN.id);
|
||||
|
@ -21,7 +24,13 @@ describe('creating the build', () => {
|
|||
expect(PLUGIN.pkg.scripts).not.toBeUndefined();
|
||||
expect(PLUGIN.pkg.devDependencies).not.toBeUndefined();
|
||||
|
||||
await createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles);
|
||||
await createBuild(
|
||||
PLUGIN,
|
||||
buildTarget,
|
||||
buildVersion,
|
||||
kibanaVersion,
|
||||
buildFiles
|
||||
);
|
||||
|
||||
const pkg = require(resolve(PLUGIN_BUILD_TARGET, 'package.json'));
|
||||
expect(pkg).not.toHaveProperty('scripts');
|
||||
|
@ -31,7 +40,13 @@ describe('creating the build', () => {
|
|||
it('adds build metadata to package.json', async () => {
|
||||
expect(PLUGIN.pkg.build).toBeUndefined();
|
||||
|
||||
await createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles);
|
||||
await createBuild(
|
||||
PLUGIN,
|
||||
buildTarget,
|
||||
buildVersion,
|
||||
kibanaVersion,
|
||||
buildFiles
|
||||
);
|
||||
|
||||
const pkg = require(resolve(PLUGIN_BUILD_TARGET, 'package.json'));
|
||||
expect(pkg).toHaveProperty('build');
|
||||
|
@ -43,25 +58,43 @@ describe('creating the build', () => {
|
|||
it('installs node_modules as a part of build', async () => {
|
||||
expect(PLUGIN.skipInstallDependencies).toBe(false);
|
||||
|
||||
await createBuild(PLUGIN, buildTarget, buildVersion, kibanaVersion, buildFiles);
|
||||
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');
|
||||
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);
|
||||
beforeEach(() => (PLUGIN.skipInstallDependencies = true));
|
||||
// set it back to false after
|
||||
afterEach(() => PLUGIN.skipInstallDependencies = false);
|
||||
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);
|
||||
await createBuild(
|
||||
PLUGIN,
|
||||
buildTarget,
|
||||
buildVersion,
|
||||
kibanaVersion,
|
||||
buildFiles
|
||||
);
|
||||
|
||||
expect(readdirSync(resolve(PLUGIN_BUILD_TARGET))).not.toContain('node_modules');
|
||||
expect(readdirSync(resolve(PLUGIN_BUILD_TARGET))).not.toContain(
|
||||
'node_modules'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,17 +9,17 @@ module.exports = function createPackage(plugin, buildTarget, buildVersion) {
|
|||
const buildRoot = join(buildTarget, 'kibana', plugin.id);
|
||||
|
||||
// zip up the package
|
||||
return new Promise(function (resolve, reject) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
const buildFiles = [relative(buildTarget, buildRoot) + '/**/*'];
|
||||
|
||||
vfs.src(buildFiles, { cwd: buildTarget, base: buildTarget })
|
||||
vfs
|
||||
.src(buildFiles, { cwd: buildTarget, base: buildTarget })
|
||||
.pipe(zip(`${buildId}.zip`))
|
||||
.pipe(vfs.dest(buildTarget))
|
||||
.on('end', resolve)
|
||||
.on('error', reject);
|
||||
})
|
||||
.then(function () {
|
||||
// clean up the build path
|
||||
return del(join(buildTarget, 'kibana'));
|
||||
});
|
||||
};
|
||||
}).then(function() {
|
||||
// clean up the build path
|
||||
return del(join(buildTarget, 'kibana'));
|
||||
});
|
||||
};
|
||||
|
|
|
@ -4,7 +4,10 @@ const del = require('del');
|
|||
const createBuild = require('./create_build');
|
||||
const createPackage = require('./create_package');
|
||||
|
||||
const PLUGIN_FIXTURE = resolve(__dirname, '__fixtures__/create_package_test_plugin');
|
||||
const PLUGIN_FIXTURE = resolve(
|
||||
__dirname,
|
||||
'__fixtures__/create_package_test_plugin'
|
||||
);
|
||||
const PLUGIN = require('../../lib/plugin_config')(PLUGIN_FIXTURE);
|
||||
const PLUGIN_BUILD_DIR = resolve(PLUGIN_FIXTURE, 'build-custom');
|
||||
|
||||
|
@ -18,7 +21,13 @@ afterAll(() => del(PLUGIN_BUILD_DIR));
|
|||
|
||||
describe('creating the package', () => {
|
||||
it('creates zip file in build target path', async () => {
|
||||
await createBuild(PLUGIN, PLUGIN_BUILD_DIR, buildVersion, kibanaVersion, buildFiles);
|
||||
await createBuild(
|
||||
PLUGIN,
|
||||
PLUGIN_BUILD_DIR,
|
||||
buildVersion,
|
||||
kibanaVersion,
|
||||
buildFiles
|
||||
);
|
||||
await createPackage(PLUGIN, PLUGIN_BUILD_DIR, buildVersion);
|
||||
|
||||
const zipFile = resolve(PLUGIN_BUILD_DIR, packageFile);
|
||||
|
|
|
@ -8,11 +8,15 @@ module.exports = function gitInfo(rootPath) {
|
|||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
encoding: 'utf8',
|
||||
});
|
||||
const logLine = execFileSync('git', ['log', '--pretty=%h' + LOG_SEPARATOR + '%cD', '-n', '1'], {
|
||||
cwd: rootPath,
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
encoding: 'utf8',
|
||||
}).split(LOG_SEPARATOR);
|
||||
const logLine = execFileSync(
|
||||
'git',
|
||||
['log', '--pretty=%h' + LOG_SEPARATOR + '%cD', '-n', '1'],
|
||||
{
|
||||
cwd: rootPath,
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
encoding: 'utf8',
|
||||
}
|
||||
).split(LOG_SEPARATOR);
|
||||
|
||||
return {
|
||||
count: commitCount.trim(),
|
||||
|
@ -22,4 +26,4 @@ module.exports = function gitInfo(rootPath) {
|
|||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
const map = require('through2-map').obj;
|
||||
const gitInfo = require('./git_info');
|
||||
|
||||
module.exports = function rewritePackage(buildSource, buildVersion, kibanaVersion) {
|
||||
return map(function (file) {
|
||||
module.exports = function rewritePackage(
|
||||
buildSource,
|
||||
buildVersion,
|
||||
kibanaVersion
|
||||
) {
|
||||
return map(function(file) {
|
||||
if (file.basename === 'package.json' && file.dirname === buildSource) {
|
||||
const pkg = JSON.parse(file.contents.toString('utf8'));
|
||||
|
||||
|
@ -15,7 +19,7 @@ module.exports = function rewritePackage(buildSource, buildVersion, kibanaVersio
|
|||
// append build info
|
||||
pkg.build = {
|
||||
git: gitInfo(buildSource),
|
||||
date: new Date().toString()
|
||||
date: new Date().toString(),
|
||||
};
|
||||
|
||||
// remove development properties from the package file
|
||||
|
@ -37,4 +41,4 @@ function toBuffer(string) {
|
|||
// of Buffer.from(string, encoding)
|
||||
return new Buffer(string, 'utf8');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
const resolve = require('path').resolve;
|
||||
const statSync = require('fs').statSync;
|
||||
|
||||
module.exports = function (plugin) {
|
||||
module.exports = function(plugin) {
|
||||
if (
|
||||
fileExists(resolve(plugin.root, '../kibana/package.json')) &&
|
||||
!fileExists(resolve(plugin.root, '../../kibana/package.json'))
|
||||
) {
|
||||
process.stdout.write(
|
||||
'\nWARNING: Kibana now requires that plugins must be located in ' +
|
||||
'`../kibana-extra/{pluginName}` relative to the Kibana folder ' +
|
||||
'during development. We found a Kibana in `../kibana`, but not in ' +
|
||||
'`../../kibana`.\n'
|
||||
'`../kibana-extra/{pluginName}` relative to the Kibana folder ' +
|
||||
'during development. We found a Kibana in `../kibana`, but not in ' +
|
||||
'`../../kibana`.\n'
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
const execFileSync = require('child_process').execFileSync;
|
||||
const { join } = require('path');
|
||||
const { join } = require('path');
|
||||
const split = require('argv-split');
|
||||
|
||||
module.exports = function (plugin, run, options) {
|
||||
module.exports = function(plugin, run, options) {
|
||||
options = options || {};
|
||||
|
||||
const cmd = 'node';
|
||||
const script = join('scripts', 'kibana.js');
|
||||
const nodeOptions = split(process.env.NODE_OPTIONS || '');
|
||||
|
||||
let args = nodeOptions.concat([script, '--dev', '--plugin-path', plugin.root]);
|
||||
let args = nodeOptions.concat([
|
||||
script,
|
||||
'--dev',
|
||||
'--plugin-path',
|
||||
plugin.root,
|
||||
]);
|
||||
|
||||
if (Array.isArray(plugin.includePlugins)) {
|
||||
plugin.includePlugins.forEach((path) => {
|
||||
plugin.includePlugins.forEach(path => {
|
||||
args = args.concat(['--plugin-path', path]);
|
||||
});
|
||||
}
|
||||
|
@ -23,6 +28,6 @@ module.exports = function (plugin, run, options) {
|
|||
|
||||
execFileSync(cmd, args, {
|
||||
cwd: plugin.kibanaRoot,
|
||||
stdio: ['ignore', 1, 2]
|
||||
stdio: ['ignore', 1, 2],
|
||||
});
|
||||
};
|
||||
|
|
|
@ -4,9 +4,7 @@ const winCmd = require('../../../lib/win_cmd');
|
|||
module.exports = function testBrowserAction(plugin, run, options) {
|
||||
options = options || {};
|
||||
|
||||
const kbnServerArgs = [
|
||||
'--kbnServer.plugin-path=' + plugin.root
|
||||
];
|
||||
const kbnServerArgs = ['--kbnServer.plugin-path=' + plugin.root];
|
||||
|
||||
if (options.plugins) {
|
||||
kbnServerArgs.push('--kbnServer.tests_bundle.pluginId=' + options.plugins);
|
||||
|
@ -14,11 +12,10 @@ module.exports = function testBrowserAction(plugin, run, options) {
|
|||
kbnServerArgs.push('--kbnServer.tests_bundle.pluginId=' + plugin.id);
|
||||
}
|
||||
|
||||
const task = (options.dev) ? 'test:dev' : 'test:browser';
|
||||
const task = options.dev ? 'test:dev' : 'test:browser';
|
||||
const args = [task].concat(kbnServerArgs);
|
||||
execFileSync(winCmd('yarn'), args, {
|
||||
cwd: plugin.kibanaRoot,
|
||||
stdio: ['ignore', 1, 2]
|
||||
stdio: ['ignore', 1, 2],
|
||||
});
|
||||
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@ const delimiter = require('path').delimiter;
|
|||
const execFileSync = require('child_process').execFileSync;
|
||||
const winCmd = require('../../../lib/win_cmd');
|
||||
|
||||
module.exports = function (plugin, run, options) {
|
||||
module.exports = function(plugin, run, options) {
|
||||
options = options || {};
|
||||
const kibanaBins = resolve(plugin.kibanaRoot, 'node_modules/.bin');
|
||||
const mochaSetupJs = resolve(plugin.kibanaRoot, 'test/mocha_setup.js');
|
||||
|
@ -23,7 +23,7 @@ module.exports = function (plugin, run, options) {
|
|||
cwd: plugin.root,
|
||||
stdio: ['ignore', 1, 2],
|
||||
env: Object.assign({}, process.env, {
|
||||
PATH: path
|
||||
})
|
||||
PATH: path,
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
|
|
@ -15,7 +15,12 @@ module.exports = function testSubjSelector(selector) {
|
|||
while (terms.length) {
|
||||
const term = terms.shift();
|
||||
// split each term by joins/& and map to css selectors
|
||||
cssSelectors.push(term.split('&').map(termToCssSelector).join(''));
|
||||
cssSelectors.push(
|
||||
term
|
||||
.split('&')
|
||||
.map(termToCssSelector)
|
||||
.join('')
|
||||
);
|
||||
}
|
||||
|
||||
return cssSelectors.join(' ');
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
const testSubjSelector = require('../');
|
||||
const expect = require('expect.js');
|
||||
|
||||
describe('testSubjSelector()', function () {
|
||||
it('converts subjectSelectors to cssSelectors', function () {
|
||||
expect(testSubjSelector('foo bar')).to.eql('[data-test-subj~="foo"] [data-test-subj~="bar"]');
|
||||
expect(testSubjSelector('foo&bar')).to.eql('[data-test-subj~="foo"][data-test-subj~="bar"]');
|
||||
expect(testSubjSelector('foo & bar')).to.eql('[data-test-subj~="foo"][data-test-subj~="bar"]');
|
||||
describe('testSubjSelector()', function() {
|
||||
it('converts subjectSelectors to cssSelectors', function() {
|
||||
expect(testSubjSelector('foo bar')).to.eql(
|
||||
'[data-test-subj~="foo"] [data-test-subj~="bar"]'
|
||||
);
|
||||
expect(testSubjSelector('foo&bar')).to.eql(
|
||||
'[data-test-subj~="foo"][data-test-subj~="bar"]'
|
||||
);
|
||||
expect(testSubjSelector('foo & bar')).to.eql(
|
||||
'[data-test-subj~="foo"][data-test-subj~="bar"]'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue