Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bootstrap] No longer build TS refs automatically #91234

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/dashboard_embeddable_examples/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route, RouteComponentProps, withRouter } from 'react-router-dom';
import { Route, RouteComponentProps, withRouter } from 'react-router';
import { BrowserRouter as Router } from 'react-router-dom';

import {
EuiPage,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"kbn:watch": "node scripts/kibana --dev --logging.json=false",
"build:types": "rm -rf ./target/types && tsc --p tsconfig.types.json",
"docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
"kbn:bootstrap": "node scripts/build_ts_refs",
"spec_to_console": "node scripts/spec_to_console",
"backport-skip-ci": "backport --prDescription \"[skip-ci]\"",
"storybook": "node scripts/storybook",
Expand Down Expand Up @@ -760,6 +759,7 @@
"postcss-loader": "^3.0.0",
"postcss-prefix-selector": "^1.7.2",
"prettier": "^2.2.0",
"pretty-format": "^26.6.2",
"pretty-ms": "5.0.0",
"proxyquire": "1.8.0",
"querystring": "^0.2.0",
Expand Down Expand Up @@ -833,8 +833,8 @@
"val-loader": "^1.1.1",
"vega": "^5.19.1",
"vega-lite": "^4.17.0",
"vega-spec-injector": "^0.0.2",
"vega-schema-url-parser": "^2.1.0",
"vega-spec-injector": "^0.0.2",
"vega-tooltip": "^0.25.0",
"venn.js": "0.2.20",
"vinyl-fs": "^3.0.3",
Expand Down
4 changes: 0 additions & 4 deletions packages/elastic-eslint-config-kibana/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ module.exports = {
from: 'x-pack',
toRelative: 'x-pack',
},
{
from: 'react-router',
to: 'react-router-dom',
},
{
from: '@kbn/ui-shared-deps/monaco',
to: '@kbn/monaco',
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8984,6 +8984,7 @@ const BootstrapCommand = {
_utils_log__WEBPACK_IMPORTED_MODULE_2__["log"].success(`[${project.name}] bootstrap complete`);
}
});
_utils_log__WEBPACK_IMPORTED_MODULE_2__["log"].info('For IDE TypeScript support run `node scripts/build_ts_refs`');
}

};
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-pm/src/commands/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,7 @@ export const BootstrapCommand: ICommand = {
log.success(`[${project.name}] bootstrap complete`);
}
});

log.info('For IDE TypeScript support run `node scripts/build_ts_refs`');
},
};
17 changes: 14 additions & 3 deletions src/dev/typescript/build_ts_refs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@ export async function buildAllTsRefs(log: ToolingLog) {
for (const path of REF_CONFIG_PATHS) {
const relative = Path.relative(REPO_ROOT, path);
log.debug(`Building TypeScript projects refs for ${relative}...`);
await execa(require.resolve('typescript/bin/tsc'), ['-b', relative, '--pretty'], {
cwd: REPO_ROOT,
});
await execa(
'node',
[
'--preserve-symlinks',
'--preserve-symlinks-main',
'./node_modules/typescript/bin/tsc',
'-b',
relative,
'--pretty',
],
{
cwd: REPO_ROOT,
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { withRouter, RouteComponentProps } from 'react-router';

import { EuiFlexGroup, EuiFlexItem, EuiPanel } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React, { useEffect, useState } from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { withRouter, RouteComponentProps } from 'react-router';

import { IndexPattern } from '../../../../../../plugins/data/public';
import { getEditFieldBreadcrumbs, getCreateFieldBreadcrumbs } from '../../breadcrumbs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { filter } from 'lodash';
import React, { useEffect, useState, useCallback } from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { withRouter, RouteComponentProps } from 'react-router';
import {
EuiFlexGroup,
EuiFlexItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React, { useEffect, useState } from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { withRouter, RouteComponentProps } from 'react-router';
import { IndexPattern } from '../../../../../plugins/data/public';
import { useKibana } from '../../../../../plugins/kibana_react/public';
import { IndexPatternManagmentContext } from '../../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { withRouter, RouteComponentProps } from 'react-router';
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiText, EuiTitle } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n/react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { withRouter, RouteComponentProps } from 'react-router';
import React, { useState, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import { reactRouterNavigate, useKibana } from '../../../../../plugins/kibana_react/public';
Expand Down
6 changes: 6 additions & 0 deletions test/scripts/checks/build_ts_refs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

source src/dev/ci_setup/setup_env.sh

checks-reporter-with-killswitch "Build Typescript Refs" \
node --preserve-symlinks --preserve-symlinks-main scripts/build_ts_refs
2 changes: 1 addition & 1 deletion test/scripts/checks/type_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
source src/dev/ci_setup/setup_env.sh

checks-reporter-with-killswitch "Check Types" \
node scripts/type_check
node --preserve-symlinks scripts/type_check
1 change: 1 addition & 0 deletions test/scripts/jenkins_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if [[ -z "$CODE_COVERAGE" ]] ; then
./test/scripts/checks/ts_projects.sh
./test/scripts/checks/jest_configs.sh
./test/scripts/checks/doc_api_changes.sh
./test/scripts/checks/build_ts_refs.sh
./test/scripts/checks/type_check.sh
./test/scripts/checks/bundle_limits.sh
./test/scripts/checks/i18n.sh
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.refs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"compilerOptions": {
"preserveSymlinks": true
},
"include": [],
"references": [
{ "path": "./src/core/tsconfig.json" },
Expand Down
1 change: 1 addition & 0 deletions vars/tasks.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def check() {
kibanaPipeline.scriptTask('Check TypeScript Projects', 'test/scripts/checks/ts_projects.sh'),
kibanaPipeline.scriptTask('Check Jest Configs', 'test/scripts/checks/jest_configs.sh'),
kibanaPipeline.scriptTask('Check Doc API Changes', 'test/scripts/checks/doc_api_changes.sh'),
kibanaPipeline.scriptTask('Build Typescript Refs', 'test/scripts/checks/build_ts_refs.sh'),
kibanaPipeline.scriptTask('Check Types', 'test/scripts/checks/type_check.sh'),
kibanaPipeline.scriptTask('Check Bundle Limits', 'test/scripts/checks/bundle_limits.sh'),
kibanaPipeline.scriptTask('Check i18n', 'test/scripts/checks/i18n.sh'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { EuiEmptyPrompt, EuiFlexGroup, EuiFlexItem, EuiPageContent } from '@elastic/eui';
import React from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { withRouter, RouteComponentProps } from 'react-router';

interface LayoutProps extends RouteComponentProps {
children: React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { get } from 'lodash';
import React from 'react';

import { EuiLink } from '@elastic/eui';
import { Link, withRouter, RouteComponentProps } from 'react-router-dom';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { Link } from 'react-router-dom';

interface ConnectedLinkComponent extends RouteComponentProps {
location: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { parse, stringify } from 'query-string';
import React from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { withRouter, RouteComponentProps } from 'react-router';
import { FlatObject } from '../frontend_types';
import { RendererFunction } from '../utils/typed_react';

Expand Down
18 changes: 17 additions & 1 deletion x-pack/plugins/observability/public/utils/test_helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { AppMountParameters, CoreStart } from 'kibana/public';
import React from 'react';
import { IntlProvider } from 'react-intl';
import { of } from 'rxjs';
import { queries, Queries, BoundFunction } from '@testing-library/dom';
import { OptionsReceived as PrettyFormatOptions } from 'pretty-format';
import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public';
import translations from '../../../translations/translations/ja-JP.json';
import { PluginContext } from '../context/plugin_context';
Expand All @@ -18,6 +20,20 @@ import { EuiThemeProvider } from '../../../../../src/plugins/kibana_react/common

const appMountParameters = ({ setHeaderActionMenu: () => {} } as unknown) as AppMountParameters;

// from node_modules/@testing-library/react/types/index.d.ts
type RenderResult<Q extends Queries = typeof queries> = {
container: HTMLElement;
baseElement: HTMLElement;
debug: (
baseElement?: HTMLElement | DocumentFragment | Array<HTMLElement | DocumentFragment>,
maxLength?: number,
options?: PrettyFormatOptions
) => void;
rerender: (ui: React.ReactElement) => void;
unmount: () => boolean;
asFragment: () => DocumentFragment;
} & { [P in keyof Q]: BoundFunction<Q[P]> };

export const core = ({
http: {
basePath: {
Expand All @@ -34,7 +50,7 @@ const plugins = ({
data: { query: { timefilter: { timefilter: { setTime: jest.fn() } } } },
} as unknown) as ObservabilityPluginSetupDeps;

export const render = (component: React.ReactNode) => {
export const render = (component: React.ReactNode): RenderResult => {
return testLibRender(
<IntlProvider locale="en-US" messages={translations.messages}>
<KibanaContextProvider services={{ ...core }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { Router } from 'react-router-dom';
// eslint-disable-next-line @kbn/eslint/module_migration
import routeData from 'react-router';
type Action = 'PUSH' | 'POP' | 'REPLACE';
const pop: Action = 'POP';
Expand Down