Skip to content

Commit

Permalink
Remove legacy plugins support (elastic#77599)
Browse files Browse the repository at this point in the history
* remove ALL the things.

* adapt some types and tests

* restore ensureValidConfiguration

* fix legacy service tests

* adapt uiRender mixin

* remove legacy types

* update generated doc

* restore legacy plugin schema

* update generated doc

* remove remaining code of x-pack/legacy

* adapt imports due to merge

* cleanup CODEOWNERS

* cleanup gitignore & i18nrc

* cleanup tsconfig.json

* remove unused i18n keys

* add back `"legacy/plugins/**/*",` to tsconfig until legacy space plugin is deleted

* fix create_jest_config

* remove references from eslintrc

* more eslint cleanup

* remove `x-pack/index.js`

* fix xpack gulp scripts

* fix bug with default + named imports from boom

* remove rules from eslintrc

* remove LegacyInternals

* review comments

* update generated doc

* cleanup legacy metadatas

* revert changes to eslintrc

* update generated doc
# Conflicts:
#	.github/CODEOWNERS
#	x-pack/.i18nrc.json
#	x-pack/dev-tools/jest/create_jest_config.js
#	x-pack/legacy/plugins/xpack_main/index.js
#	x-pack/legacy/server/lib/constants/index.ts
#	x-pack/legacy/server/lib/key_case_converter.js
#	x-pack/legacy/server/lib/watch_status_and_license_to_initialize.js
  • Loading branch information
pgayvallet committed Sep 23, 2020
1 parent 99bc56d commit 71bc314
Show file tree
Hide file tree
Showing 219 changed files with 294 additions and 9,662 deletions.
64 changes: 9 additions & 55 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
* under the License.
*/

const { readdirSync } = require('fs');
const { resolve } = require('path');

const APACHE_2_0_LICENSE_HEADER = `
/*
* Licensed to Elasticsearch B.V. under one or more contributor
Expand Down Expand Up @@ -294,7 +291,7 @@ module.exports = {
},
{
target: [
'(src|x-pack)/legacy/**/*',
'src/legacy/**/*',
'(src|x-pack)/plugins/**/(public|server)/**/*',
'examples/**/*',
],
Expand Down Expand Up @@ -325,14 +322,11 @@ module.exports = {
},
{
target: [
'(src|x-pack)/legacy/**/*',
'src/legacy/**/*',
'(src|x-pack)/plugins/**/(public|server)/**/*',
'examples/**/*',
'!(src|x-pack)/**/*.test.*',
'!(x-pack/)?test/**/*',
// next folder contains legacy browser tests which can't be migrated to jest
// which import np files
'!src/legacy/core_plugins/kibana/public/__tests__/**/*',
],
from: [
'(src|x-pack)/plugins/**/(public|server)/**/*',
Expand All @@ -347,14 +341,6 @@ module.exports = {
'(src|x-pack)/plugins/**/*',
'!(src|x-pack)/plugins/**/server/**/*',

'src/legacy/core_plugins/**/*',
'!src/legacy/core_plugins/**/server/**/*',
'!src/legacy/core_plugins/**/index.{js,mjs,ts,tsx}',

'x-pack/legacy/plugins/**/*',
'!x-pack/legacy/plugins/**/server/**/*',
'!x-pack/legacy/plugins/**/index.{js,mjs,ts,tsx}',

'examples/**/*',
'!examples/**/server/**/*',
],
Expand All @@ -374,12 +360,7 @@ module.exports = {
},
{
target: ['src/core/**/*'],
from: [
'plugins/**/*',
'src/plugins/**/*',
'src/legacy/core_plugins/**/*',
'src/legacy/ui/**/*',
],
from: ['plugins/**/*', 'src/plugins/**/*', 'src/legacy/ui/**/*'],
errorMessage: 'The core cannot depend on any plugins.',
},
{
Expand All @@ -392,12 +373,6 @@ module.exports = {
target: [
'test/plugin_functional/plugins/**/public/np_ready/**/*',
'test/plugin_functional/plugins/**/server/np_ready/**/*',
'src/legacy/core_plugins/**/public/np_ready/**/*',
'src/legacy/core_plugins/vis_type_*/public/**/*',
'!src/legacy/core_plugins/vis_type_*/public/legacy*',
'src/legacy/core_plugins/**/server/np_ready/**/*',
'x-pack/legacy/plugins/**/public/np_ready/**/*',
'x-pack/legacy/plugins/**/server/np_ready/**/*',
],
allowSameFolder: true,
errorMessage:
Expand Down Expand Up @@ -447,22 +422,14 @@ module.exports = {
settings: {
// instructs import/no-extraneous-dependencies to treat certain modules
// as core modules, even if they aren't listed in package.json
'import/core-modules': ['plugins', 'legacy/ui'],
'import/core-modules': ['plugins'],

'import/resolver': {
'@kbn/eslint-import-resolver-kibana': {
forceNode: false,
rootPackageName: 'kibana',
kibanaPath: '.',
pluginMap: readdirSync(resolve(__dirname, 'x-pack/legacy/plugins')).reduce(
(acc, name) => {
if (!name.startsWith('_')) {
acc[name] = `x-pack/legacy/plugins/${name}`;
}
return acc;
},
{}
),
pluginMap: {},
},
},
},
Expand Down Expand Up @@ -768,16 +735,6 @@ module.exports = {
},
},

/**
* GIS overrides
*/
{
files: ['x-pack/legacy/plugins/maps/**/*.js'],
rules: {
'react/prefer-stateless-function': [0, { ignorePureComponents: false }],
},
},

/**
* ML overrides
*/
Expand Down Expand Up @@ -816,7 +773,7 @@ module.exports = {
},
{
// typescript only for front and back end
files: ['x-pack/{,legacy/}plugins/security_solution/**/*.{ts,tsx}'],
files: ['x-pack/plugins/security_solution/**/*.{ts,tsx}'],
rules: {
// This will be turned on after bug fixes are complete
// '@typescript-eslint/explicit-member-accessibility': 'warn',
Expand Down Expand Up @@ -862,7 +819,7 @@ module.exports = {
// },
{
// typescript and javascript for front and back end
files: ['x-pack/{,legacy/}plugins/security_solution/**/*.{js,mjs,ts,tsx}'],
files: ['x-pack/plugins/security_solution/**/*.{js,mjs,ts,tsx}'],
plugins: ['eslint-plugin-node', 'react'],
env: {
mocha: true,
Expand Down Expand Up @@ -1093,7 +1050,7 @@ module.exports = {
{
// typescript only for front and back end
files: [
'x-pack/{,legacy/}plugins/{alerts,alerting_builtins,actions,task_manager,event_log}/**/*.{ts,tsx}',
'x-pack/plugins/{alerts,alerting_builtins,actions,task_manager,event_log}/**/*.{ts,tsx}',
],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
Expand Down Expand Up @@ -1242,10 +1199,7 @@ module.exports = {
* TSVB overrides
*/
{
files: [
'src/plugins/vis_type_timeseries/**/*.{js,mjs,ts,tsx}',
'src/legacy/core_plugins/vis_type_timeseries/**/*.{js,mjs,ts,tsx}',
],
files: ['src/plugins/vis_type_timeseries/**/*.{js,mjs,ts,tsx}'],
rules: {
'import/no-default-export': 'error',
},
Expand Down
5 changes: 0 additions & 5 deletions kibana.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export { Public, Server };
/**
* All exports from TS ambient definitions (where types are added for JS source in a .d.ts file).
*/
import * as LegacyKibanaPluginSpec from './src/legacy/plugin_discovery/plugin_spec/plugin_spec_options';
import * as LegacyKibanaServer from './src/legacy/server/kbn_server';

/**
Expand All @@ -39,8 +38,4 @@ export namespace Legacy {
export type Request = LegacyKibanaServer.Request;
export type ResponseToolkit = LegacyKibanaServer.ResponseToolkit;
export type Server = LegacyKibanaServer.Server;

export type InitPluginFunction = LegacyKibanaPluginSpec.InitPluginFunction;
export type UiExports = LegacyKibanaPluginSpec.UiExports;
export type PluginSpecOptions = LegacyKibanaPluginSpec.PluginSpecOptions;
}
16 changes: 1 addition & 15 deletions src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ const CAN_CLUSTER = canRequire(CLUSTER_MANAGER_PATH);
const REPL_PATH = resolve(__dirname, '../repl');
const CAN_REPL = canRequire(REPL_PATH);

// xpack is installed in both dev and the distributable, it's optional if
// install is a link to the source, not an actual install
const XPACK_DIR = resolve(__dirname, '../../../x-pack');
const XPACK_INSTALLED = canRequire(XPACK_DIR);

const pathCollector = function () {
const paths = [];
return function (path) {
Expand Down Expand Up @@ -137,16 +132,7 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) {
if (opts.logFile) set('logging.dest', opts.logFile);

set('plugins.scanDirs', _.compact([].concat(get('plugins.scanDirs'), opts.pluginDir)));
set(
'plugins.paths',
_.compact(
[].concat(
get('plugins.paths'),
opts.pluginPath,
XPACK_INSTALLED && !opts.oss ? [XPACK_DIR] : []
)
)
);
set('plugins.paths', _.compact([].concat(get('plugins.paths'), opts.pluginPath)));

merge(extraCliOptions);
merge(readKeystore());
Expand Down
25 changes: 0 additions & 25 deletions src/core/public/injected_metadata/injected_metadata_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ export interface InjectedMetadataParams {
uiPlugins: InjectedPluginMetadata[];
anonymousStatusPage: boolean;
legacyMetadata: {
app: {
id: string;
title: string;
};
bundleId: string;
version: string;
branch: string;
buildNum: number;
buildSha: string;
basePath: string;
serverName: string;
devMode: boolean;
category?: AppCategory;
uiSettings: {
defaults: Record<string, UiSettingsParams>;
user?: Record<string, UserProvidedValues>;
Expand Down Expand Up @@ -167,18 +154,6 @@ export interface InjectedMetadataSetup {
getPlugins: () => InjectedPluginMetadata[];
getAnonymousStatusPage: () => boolean;
getLegacyMetadata: () => {
app: {
id: string;
title: string;
};
bundleId: string;
version: string;
branch: string;
buildNum: number;
buildSha: string;
basePath: string;
serverName: string;
devMode: boolean;
uiSettings: {
defaults: Record<string, UiSettingsParams>;
user?: Record<string, UserProvidedValues> | undefined;
Expand Down
9 changes: 1 addition & 8 deletions src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,7 @@ export {
SavedObjectsMigrationVersion,
} from './types';

export {
LegacyServiceSetupDeps,
LegacyServiceStartDeps,
LegacyServiceDiscoverPlugins,
LegacyConfig,
LegacyUiExports,
LegacyInternals,
} from './legacy';
export { LegacyServiceSetupDeps, LegacyServiceStartDeps, LegacyConfig } from './legacy';

export {
CoreStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,12 @@ describe('ensureValidConfiguration', () => {
configService as any,
{
settings: 'settings',
pluginSpecs: 'pluginSpecs',
disabledPluginSpecs: 'disabledPluginSpecs',
pluginExtendedConfig: 'pluginExtendedConfig',
uiExports: 'uiExports',
legacyConfig: 'pluginExtendedConfig',
} as any
);
expect(getUnusedConfigKeys).toHaveBeenCalledTimes(1);
expect(getUnusedConfigKeys).toHaveBeenCalledWith({
coreHandledConfigPaths: ['core', 'elastic'],
pluginSpecs: 'pluginSpecs',
disabledPluginSpecs: 'disabledPluginSpecs',
settings: 'settings',
legacyConfig: 'pluginExtendedConfig',
});
Expand Down
8 changes: 3 additions & 5 deletions src/core/server/legacy/config/ensure_valid_configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@

import { getUnusedConfigKeys } from './get_unused_config_keys';
import { ConfigService } from '../../config';
import { LegacyServiceDiscoverPlugins } from '../types';
import { CriticalError } from '../../errors';
import { LegacyServiceSetupConfig } from '../types';

export async function ensureValidConfiguration(
configService: ConfigService,
{ pluginSpecs, disabledPluginSpecs, pluginExtendedConfig, settings }: LegacyServiceDiscoverPlugins
{ legacyConfig, settings }: LegacyServiceSetupConfig
) {
const unusedConfigKeys = await getUnusedConfigKeys({
coreHandledConfigPaths: await configService.getUsedPaths(),
pluginSpecs,
disabledPluginSpecs,
settings,
legacyConfig: pluginExtendedConfig,
legacyConfig,
});

if (unusedConfigKeys.length > 0) {
Expand Down
Loading

0 comments on commit 71bc314

Please sign in to comment.