[APM] Fix optimize-tsconfig script (#91487)

- Removes x-pack/plugins/apm/tsconfig.json file
- Make optimisation opt-in for precommit script
This commit is contained in:
Dario Gieselaar 2021-02-17 09:06:23 +01:00 committed by GitHub
parent 673b0e98ba
commit a168fe41e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 8 deletions

3
.gitignore vendored
View file

@ -61,9 +61,6 @@ npm-debug.log*
.ci/bash_standard_lib.sh
.gradle
# apm plugin
/x-pack/plugins/apm/tsconfig.json
apm.tsconfig.json
## @cypress/snapshot from apm plugin
snapshots.js

View file

@ -16,6 +16,7 @@ const { omit } = require('lodash');
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
const unlink = promisify(fs.unlink);
const {
xpackRoot,
@ -72,6 +73,10 @@ async function setIgnoreChanges() {
}
}
async function deleteApmTsConfig() {
await unlink(path.resolve(kibanaRoot, 'x-pack/plugins/apm', 'tsconfig.json'));
}
async function optimizeTsConfig() {
await unoptimizeTsConfig();
@ -79,6 +84,8 @@ async function optimizeTsConfig() {
await addApmFilesToXpackTsConfig();
await deleteApmTsConfig();
await setIgnoreChanges();
// eslint-disable-next-line no-console
console.log(

View file

@ -16,6 +16,7 @@ const filesToIgnore = [
path.resolve(xpackRoot, 'tsconfig.json'),
path.resolve(kibanaRoot, 'tsconfig.json'),
path.resolve(kibanaRoot, 'tsconfig.base.json'),
path.resolve(kibanaRoot, 'x-pack/plugins/apm', 'tsconfig.json'),
];
module.exports = {

View file

@ -11,10 +11,24 @@
const execa = require('execa');
const Listr = require('listr');
const { resolve } = require('path');
const { argv } = require('yargs');
const cwd = resolve(__dirname, '../../../..');
const root = resolve(__dirname, '../../../..');
const execaOpts = { cwd, stderr: 'inherit' };
const execaOpts = { cwd: root, stderr: 'pipe' };
const useOptimizedTsConfig = !!argv.optimizeTs;
const tsconfig = useOptimizedTsConfig
? resolve(root, 'x-pack/tsconfig.json')
: resolve(root, 'x-pack/plugins/apm/tsconfig.json');
console.log(
resolve(
__dirname,
useOptimizedTsConfig ? './optimize-tsonfig.js' : './unoptimize-tsconfig.js'
)
);
const tasks = new Listr(
[
@ -37,9 +51,27 @@ const tasks = new Listr(
title: 'Typescript',
task: () =>
execa(
require.resolve('typescript/bin/tsc'),
['--project', resolve(__dirname, '../tsconfig.json'), '--pretty'],
'node',
[
resolve(
__dirname,
useOptimizedTsConfig
? './optimize-tsconfig.js'
: './unoptimize-tsconfig.js'
),
],
execaOpts
).then(() =>
execa(
require.resolve('typescript/bin/tsc'),
[
'--project',
tsconfig,
'--pretty',
...(useOptimizedTsConfig ? ['--noEmit'] : []),
],
execaOpts
)
),
},
{
@ -47,7 +79,7 @@ const tasks = new Listr(
task: () => execa('node', [resolve(__dirname, 'eslint.js')], execaOpts),
},
],
{ exitOnError: false, concurrent: true }
{ exitOnError: true, concurrent: true }
);
tasks.run().catch((error) => {