Add TS projects for src/plugins & x-pack/plugins (#78440)

* bump query-string version to remove manual type definitions

* remove manual type declaration

* add kibana_utils tsconfig

* add refs to kibana_utils tsconfig

* add kibana_utils to the project list

* add kibana_react project

* add support for x-pack/tsconfig.refs.json

* add ts project for x-pack licensing plugins

* add glob for ts projects in src/plugins & x-pack/plugins

* add refs to projects in examples

* fix ref paths in x-pack/test

* address mistic comments

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Mikhail Shustov 2020-09-30 16:02:41 +03:00 committed by GitHub
parent 272e850483
commit ae8f8e1d10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 141 additions and 29 deletions

View file

@ -13,6 +13,7 @@
],
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
{ "path": "../../src/core/tsconfig.json" },
{ "path": "../../src/plugins/kibana_react/tsconfig.json" },
]
}

View file

@ -14,6 +14,7 @@
],
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
{ "path": "../../src/core/tsconfig.json" },
{ "path": "../../src/plugins/kibana_react/tsconfig.json" },
]
}

View file

@ -14,6 +14,8 @@
],
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
{ "path": "../../src/core/tsconfig.json" },
{ "path": "../../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../../src/plugins/kibana_react/tsconfig.json" },
]
}

View file

@ -13,6 +13,7 @@
],
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
{ "path": "../../src/core/tsconfig.json" },
{ "path": "../../src/plugins/kibana_react/tsconfig.json" },
]
}

View file

@ -12,6 +12,7 @@
],
"exclude": [],
"references": [
{ "path": "../../src/core/tsconfig.json" }
{ "path": "../../src/core/tsconfig.json" },
{ "path": "../../src/plugins/kibana_react/tsconfig.json" },
]
}

View file

@ -65,7 +65,7 @@
"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 && node scripts/register_git_hook",
"kbn:bootstrap": "node scripts/build_ts_refs --project tsconfig.refs.json && node scripts/register_git_hook",
"spec_to_console": "node scripts/spec_to_console",
"backport-skip-ci": "backport --prDescription \"[skip-ci]\"",
"storybook": "node scripts/storybook",

View file

@ -18,12 +18,18 @@
*/
import execa from 'execa';
import Path from 'path';
import { run, ToolingLog } from '@kbn/dev-utils';
export async function buildRefs(log: ToolingLog) {
export async function buildAllRefs(log: ToolingLog) {
await buildRefs(log, 'tsconfig.refs.json');
await buildRefs(log, Path.join('x-pack', 'tsconfig.refs.json'));
}
async function buildRefs(log: ToolingLog, projectPath: string) {
try {
log.info('Building TypeScript projects refs...');
await execa(require.resolve('typescript/bin/tsc'), ['-b', 'tsconfig.refs.json']);
log.debug(`Building TypeScript projects refs for ${projectPath}...`);
await execa(require.resolve('typescript/bin/tsc'), ['-b', projectPath]);
} catch (e) {
log.error(e);
process.exit(1);
@ -31,7 +37,18 @@ export async function buildRefs(log: ToolingLog) {
}
export async function runBuildRefs() {
run(async ({ log }) => {
await buildRefs(log);
});
run(
async ({ log, flags }) => {
await buildRefs(log, flags.project as string);
},
{
description: 'Build TypeScript projects',
flags: {
string: ['project'],
help: `
--project Required, path to the tsconfig.refs.file
`,
},
}
);
}

View file

@ -24,11 +24,11 @@ import { Project } from './project';
export const PROJECTS = [
new Project(resolve(REPO_ROOT, 'tsconfig.json')),
new Project(resolve(REPO_ROOT, 'src/test_utils/tsconfig.json')),
new Project(resolve(REPO_ROOT, 'src/core/tsconfig.json')),
new Project(resolve(REPO_ROOT, 'test/tsconfig.json'), { name: 'kibana/test' }),
new Project(resolve(REPO_ROOT, 'x-pack/tsconfig.json')),
new Project(resolve(REPO_ROOT, 'x-pack/test/tsconfig.json'), { name: 'x-pack/test' }),
new Project(resolve(REPO_ROOT, 'src/test_utils/tsconfig.json')),
new Project(resolve(REPO_ROOT, 'src/core/tsconfig.json')),
new Project(resolve(REPO_ROOT, 'x-pack/plugins/security_solution/cypress/tsconfig.json'), {
name: 'security_solution/cypress',
}),
@ -47,6 +47,12 @@ export const PROJECTS = [
...glob
.sync('packages/*/tsconfig.json', { cwd: REPO_ROOT })
.map((path) => new Project(resolve(REPO_ROOT, path))),
...glob
.sync('src/plugins/*/tsconfig.json', { cwd: REPO_ROOT })
.map((path) => new Project(resolve(REPO_ROOT, path))),
...glob
.sync('x-pack/plugins/*/tsconfig.json', { cwd: REPO_ROOT })
.map((path) => new Project(resolve(REPO_ROOT, path))),
...glob
.sync('examples/*/tsconfig.json', { cwd: REPO_ROOT })
.map((path) => new Project(resolve(REPO_ROOT, path))),

View file

@ -24,7 +24,7 @@ import getopts from 'getopts';
import { execInProjects } from './exec_in_projects';
import { filterProjectsByFlag } from './projects';
import { buildRefs } from './build_refs';
import { buildAllRefs } from './build_refs';
export async function runTypeCheckCli() {
const extraFlags: string[] = [];
@ -80,7 +80,7 @@ export async function runTypeCheckCli() {
process.exit();
}
await buildRefs(log);
await buildAllRefs(log);
const tscArgs = [
// composite project cannot be used with --noEmit

View file

@ -2,5 +2,6 @@
"id": "kibanaReact",
"version": "kibana",
"ui": true,
"server": false,
"requiredBundles": ["kibanaUtils"]
}

View file

@ -0,0 +1,17 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"public/**/*",
"../../../typings/**/*"
],
"references": [
{ "path": "../kibana_utils/tsconfig.json" }
]
}

View file

@ -2,6 +2,7 @@
"id": "kibanaUtils",
"version": "kibana",
"ui": true,
"server": false,
"extraPublicDirs": [
"common",
"demos/state_containers/todomvc",

View file

@ -0,0 +1,22 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"common/**/*",
"demos/**/*",
"public/**/*",
"server/**/*",
"index.ts",
"../../../typings/**/*"
],
"references": [
{ "path": "../../test_utils/tsconfig.json" },
{ "path": "../../core/tsconfig.json" }
]
}

View file

@ -18,6 +18,8 @@
"interpreter_functional/plugins/**/*"
],
"references": [
{ "path": "../src/core/tsconfig.json" }
{ "path": "../src/core/tsconfig.json" },
{ "path": "../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../src/plugins/kibana_react/tsconfig.json" }
]
}

View file

@ -12,7 +12,9 @@
"exclude": [
"src/**/__fixtures__/**/*",
"src/test_utils/**/*",
"src/core/**/*"
"src/core/**/*",
"src/plugins/kibana_utils/**/*",
"src/plugins/kibana_react/**/*"
// In the build we actually exclude **/public/**/* from this config so that
// we can run the TSC on both this and the .browser version of this config
// file, but if we did it during development IDEs would not be able to find
@ -21,6 +23,8 @@
],
"references": [
{ "path": "./src/test_utils/tsconfig.json" },
{ "path": "./src/core/tsconfig.json" }
{ "path": "./src/core/tsconfig.json" },
{ "path": "./src/plugins/kibana_utils/tsconfig.json" },
{ "path": "./src/plugins/kibana_react/tsconfig.json" }
]
}

View file

@ -1,7 +1,9 @@
{
"include": [],
"references": [
{ "path": "./src/test_utils" },
{ "path": "./src/core" },
{ "path": "./src/test_utils/tsconfig.json" },
{ "path": "./src/core/tsconfig.json" },
{ "path": "./src/plugins/kibana_utils/tsconfig.json" },
{ "path": "./src/plugins/kibana_react/tsconfig.json" },
]
}

View file

@ -13,6 +13,8 @@
],
"exclude": [],
"references": [
{ "path": "../../../src/core/tsconfig.json" }
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../../../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../../../src/plugins/kibana_react/tsconfig.json" },
]
}

View file

@ -6,7 +6,7 @@
"license": "Elastic-License",
"scripts": {
"kbn": "node ../scripts/kbn",
"kbn:bootstrap": "node plugins/canvas/scripts/storybook --clean",
"kbn:bootstrap": "node ../scripts/build_ts_refs --project tsconfig.refs.json && node plugins/canvas/scripts/storybook --clean",
"start": "node ../scripts/kibana --dev",
"build": "gulp build",
"testonly": "echo 'Deprecated, use `yarn test`' && gulp test",

View file

@ -0,0 +1,20 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"public/**/*",
"server/**/*",
"common/**/*",
"../../../typings/**/*"
],
"references": [
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../../../src/plugins/kibana_react/tsconfig.json" }
]
}

View file

@ -1,3 +0,0 @@
{
"extends": "../../tsconfig.json",
}

View file

@ -17,6 +17,9 @@
"../typings/jest.d.ts"
],
"references": [
{ "path": "../../src/core/tsconfig.json" }
{ "path": "../../src/core/tsconfig.json" },
{ "path": "../../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../plugins/licensing/tsconfig.json" }
]
}

View file

@ -11,7 +11,8 @@
"test/**/*",
"plugins/security_solution/cypress/**/*",
"plugins/apm/e2e/cypress/**/*",
"plugins/apm/scripts/**/*"
"plugins/apm/scripts/**/*",
"plugins/licensing/**/*"
],
"compilerOptions": {
"outDir": ".",
@ -24,5 +25,10 @@
// overhead is too significant
"incremental": false
},
"references": [{ "path": "../src/core/tsconfig.json" }]
"references": [
{ "path": "../src/core/tsconfig.json" },
{ "path": "../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../src/plugins/kibana_react/tsconfig.json" },
{ "path": "./plugins/licensing/tsconfig.json" }
]
}

View file

@ -0,0 +1,6 @@
{
"include": [],
"references": [
{ "path": "./plugins/licensing/tsconfig.json" }
]
}