Skip to content

Commit

Permalink
Add back build:types since api-exporter cannot operate on source files
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed Mar 19, 2019
1 parent e73167d commit a487c16
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 23 deletions.
3 changes: 2 additions & 1 deletion kibana.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
/**
* All exports from TS source files (where the implementation is actually done in TS).
*/
export { Public, Server } from 'src/core';
export * from 'target/types/public';
export * from 'target/types/server';

/**
* All exports from TS ambient definitions (where types are added for JS source in a .d.ts file).
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"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",
"kbn:bootstrap": "node scripts/register_git_hook"
"build:types": "tsc --p typings.tsconfig.json",
"kbn:bootstrap": "yarn build:types && node scripts/register_git_hook"
},
"repository": {
"type": "git",
Expand Down
55 changes: 34 additions & 21 deletions src/dev/run_check_core_api_changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const apiExtractorConfig: IExtractorConfig = {
rootFolder: '.',
},
project: {
entryPointSourceFile: 'target/types/type_exports.d.ts',
entryPointSourceFile: 'target/types/server/index.d.ts',
},
apiReviewFile: {
enabled: true,
Expand Down Expand Up @@ -161,36 +161,49 @@ const runApiExtractor = (acceptChanges: boolean = false) => {

log.info('Kibana Core API: checking for changes in API signature...');

await runBuildTypes();
await runBuildTypes().catch(e => {
if (e) {
log.error(e);
process.exit(1);
}
});

const { apiChanged, warnings, errors } = runApiExtractor(opts.accept);

if (apiChanged) {
if (opts.accept) {
log.warning('You have changed the public signature of the Kibana Core API');
log.warning(
'Please commit the updated API documentation and the review file in `common/core_api_review/kibana.api.ts` \n'
);
} else {
log.warning('You have changed the public signature of the Kibana Core API');
log.warning(
'To accept these changes run `node scripts/check_core_api_changes.js --accept` and then:\n' +
'\t 1. Commit the updated documentation and API review file `common/core_api_review/kibana.api.ts` \n' +
"\t 2. Describe the change in your PR including whether it's a major, minor or patch"
);

// If the API changed and we're not accepting the changes, exit process with error
process.exit(1);
}
} else {
if (apiChanged && opts.accept) {
log.warning('You have changed the public signature of the Kibana Core API');
log.warning(
'Please commit the updated API documentation and the review file in `common/core_api_review/kibana.api.ts` \n'
);
}

if (apiChanged && !opts.accept) {
log.warning('You have changed the public signature of the Kibana Core API');
log.warning(
'To accept these changes run `node scripts/check_core_api_changes.js --accept` and then:\n' +
'\t 1. Commit the updated documentation and API review file `common/core_api_review/kibana.api.ts` \n' +
"\t 2. Describe the change in your PR including whether it's a major, minor or patch"
);
}

if (!apiChanged) {
log.info('Kibana Core API: no changes detected ✔');
}

if (opts.accept || opts.docs) {
await runApiDocumenter();
await runApiDocumenter().catch(e => {
log.error(e);
process.exit(1);
});

log.info('Kibana Core API: updated documentation ✔');
}

// If the API changed and we're not accepting the changes, exit process with error
if (apiChanged && !opts.accept) {
process.exit(1);
}

// If any errors or warnings occured, exit with an error
if (errors.length > 0 || warnings.length > 0) {
log.error('Kibana Core API: api-extractor failed with the following errors or warnings:');
Expand Down
14 changes: 14 additions & 0 deletions typings.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"declaration": true,
"declarationDir": "./target/types",
"stripInternal": false,
"emitDeclarationOnly": true,
"declarationMap": true
},
"include": [
"./src/core/server/index.ts",
"./src/core/public/index.ts"
]
}

0 comments on commit a487c16

Please sign in to comment.