kibana/x-pack/gulp_helpers/get_plugins.js
Spencer 8a7ed713fd
[6.x] [npm] upgrade to RxJS 6 (#18885) (#20006)
* [npm] upgrade to RxJS 6 (#18885)

This PR upgrades RxJS to version 6 and switches to a fork of `stream-to-observable` which includes an updated version of `any-observable` that supports RxJS 6 until https://github.com/jamestalmage/stream-to-observable/pull/10 is merged. The primary change in this version of RxJS is the movement of stream operators from `Obersable.prototype` to the `rxjs/operators` module. Some of the operators, like `catch` and `do`, have been renamed (`catchError`, and `tap`). The Obsevable factories have also been moved from static methods on the `Observable` class to named exports of the root `rxjs` module. Some of those factories have also changed slightly, like `fromEvent` which now emits arrays if the event handler is called with multiple arguments.

```js
// import the Rx namespace to get the Observable factories
import * as Rx from 'rxjs';
// import the operators as named imports
import { map, tap, switchMap } from 'rxjs/operators';
```

* [rxjs/dev-utils] fix old operator usage

* [rxjs/dev-utils] remove one more old operator
2018-06-18 12:47:51 -07:00

47 lines
1.5 KiB
JavaScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
const path = require('path');
const yargs = require('yargs');
const glob = require('glob');
const { toArray } = require('rxjs/operators');
const { findPluginSpecs } = require('../../src/plugin_discovery');
/*
Usage:
Specifying which plugins to run tests can be done with the --plugins flag.
One of more plugins can be specified, and each one should be comman separated, like so:
gulp testserver --plugins monitoring,reporting
If using with yarn:
yarn test:server --plugins graph
*/
const argv = yargs
.describe('plugins', 'Comma-separated list of plugins')
.argv;
const allPlugins = glob.sync('*', { cwd: path.resolve(__dirname, '..', 'plugins') });
export function getPlugins() {
const plugins = argv.plugins && argv.plugins.split(',');
if (!Array.isArray(plugins) || plugins.length === 0) {
return allPlugins;
}
return plugins;
}
const { spec$ } = findPluginSpecs({
plugins: { paths: [path.resolve(__dirname, '../')] }
});
export async function getEnabledPlugins() {
const plugins = argv.plugins && argv.plugins.split(',');
if (!Array.isArray(plugins) || plugins.length === 0) {
const enabledPlugins = await spec$.pipe(toArray()).toPromise();
return enabledPlugins.map(spec => spec.getId());
}
return plugins;
}