Skip to content

Commit

Permalink
run buildRefs before type check to ensure the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Aug 31, 2020
1 parent 50bdcd8 commit 3279a2b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@
"uiFramework:createComponent": "cd packages/kbn-ui-framework && yarn createComponent",
"uiFramework:documentComponent": "cd packages/kbn-ui-framework && yarn documentComponent",
"kbn:watch": "node scripts/kibana --dev --logging.json=false",
"build:refs": "tsc -b tsconfig.refs.json",
"build:types": "tsc --p tsconfig.types.json",
"docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
"kbn:bootstrap": "yarn build:refs && node scripts/register_git_hook",
"kbn:bootstrap": "node scripts/build_ts_refs && node scripts/register_git_hook",
"spec_to_console": "node scripts/spec_to_console",
"backport-skip-ci": "backport --prDescription \"[skip-ci]\"",
"storybook": "node scripts/storybook",
Expand Down
20 changes: 20 additions & 0 deletions scripts/build_ts_refs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
require('../src/setup_node_env');
require('../src/dev/typescript/build_refs').runBuildRefs();
37 changes: 37 additions & 0 deletions src/dev/typescript/build_refs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import execa from 'execa';
import { run, ToolingLog } from '@kbn/dev-utils';

export async function buildRefs(log: ToolingLog) {
try {
log.info('Building TypeScript projects refs...');
await execa(require.resolve('typescript/bin/tsc'), ['-b', 'tsconfig.refs.json']);
} catch (e) {
log.error(e);
process.exit(1);
}
}

export async function runBuildRefs() {
run(async ({ log }) => {
await buildRefs(log);
});
}
5 changes: 4 additions & 1 deletion src/dev/typescript/run_type_check_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import getopts from 'getopts';

import { execInProjects } from './exec_in_projects';
import { filterProjectsByFlag } from './projects';
import { buildRefs } from './build_refs';

export function runTypeCheckCli() {
export async function runTypeCheckCli() {
const extraFlags: string[] = [];
const opts = getopts(process.argv.slice(2), {
boolean: ['skip-lib-check', 'help'],
Expand Down Expand Up @@ -79,6 +80,8 @@ export function runTypeCheckCli() {
process.exit();
}

await buildRefs(log);

const tscArgs = [
// composite project cannot be used with --noEmit
...['--composite', 'false'],
Expand Down

0 comments on commit 3279a2b

Please sign in to comment.