Skip to content

Commit 65939d6

Browse files
author
nickpape-msft
committed
Hook the ApiExtractor into both web-library-build & node-library-build, and run it on the test project.
1 parent a7df395 commit 65939d6

7 files changed

Lines changed: 54 additions & 9 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// (undocumented)
2+
export function add(num1: number, num2: number): number;
3+
4+
// (undocumented)
5+
export function log(message: string): void;
6+
7+
// (undocumented)
8+
export function logClass(): void;
9+

gulp-core-build-typescript/src/ApiExtractorTask.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export interface IApiExtractorTaskConfig {
6363
* find the aliased exports of the project. An api-extractor.ts file is generated for the project in the temp folder.
6464
*/
6565
export class ApiExtractorTask extends GulpTask<IApiExtractorTaskConfig> {
66-
public name: string = 'apiExtractor';
66+
public name: string = 'api-extractor';
6767

6868
public taskConfig: IApiExtractorTaskConfig = {
6969
enabled: false,
@@ -72,6 +72,10 @@ export class ApiExtractorTask extends GulpTask<IApiExtractorTaskConfig> {
7272
apiJsonFolder: undefined
7373
};
7474

75+
public loadSchema(): Object {
76+
return require('./api-extractor.schema.json');
77+
};
78+
7579
public executeTask(gulp: gulp.Gulp, completeCallback: (error?: string) => void): NodeJS.ReadWriteStream {
7680
if (!this.taskConfig.enabled || !this._validateConfiguration()) {
7781
completeCallback();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"title": "api-extractor Configuration",
3+
"description": "Generates a report of the Public API exports for a project, and detects changes that impact the SemVer contract",
4+
5+
"type": "object",
6+
"properties": {
7+
"enabled": {
8+
"description": "Indicates whether the task should be run",
9+
"type": "boolean"
10+
},
11+
"entry": {
12+
"description": "The file path of the exported entry point, relative to the project folder",
13+
"type": "string"
14+
},
15+
"apiReviewFolder": {
16+
"description": "The file path of the folder containing already approved API files, relative to the project folder",
17+
"type": "string"
18+
}
19+
}
20+
}

gulp-core-build/src/tasks/CopyTask.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export class CopyTask extends GulpTask<ICopyConfig> {
2424
shouldFlatten: true
2525
};
2626

27+
public loadSchema(): Object {
28+
return require('./copy.schema.json');
29+
};
30+
2731
public executeTask(
2832
gulp: gulp.Gulp,
2933
completeCallback: (result?: Object) => void

node-library-build/src/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { task, watch, serial, parallel, IExecutable } from '@microsoft/gulp-core-build';
2-
import { typescript, tslint } from '@microsoft/gulp-core-build-typescript';
2+
import { typescript, tslint, apiExtractor } from '@microsoft/gulp-core-build-typescript';
33
import { instrument, mocha } from '@microsoft/gulp-core-build-mocha';
44

55
export * from '@microsoft/gulp-core-build';
66
export * from '@microsoft/gulp-core-build-typescript';
77
export * from '@microsoft/gulp-core-build-mocha';
88

99
// Define default task groups.
10-
export const buildTasks: IExecutable = task('build', parallel(tslint, typescript));
11-
export const testTasks: IExecutable = task('test', serial(typescript, mocha));
12-
export const defaultTasks: IExecutable = task('default', serial(buildTasks, instrument, mocha));
10+
const buildSubtask: IExecutable = serial(parallel(tslint, typescript), apiExtractor);
11+
12+
export const buildTasks: IExecutable = task('build', buildSubtask);
13+
export const testTasks: IExecutable = task('test', serial(buildSubtask, mocha));
14+
export const defaultTasks: IExecutable = task('default', serial(buildSubtask, instrument, mocha));
1315

1416
task('watch', watch('src/**.ts', testTasks));
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"enabled": true,
3+
"apiReviewFolder": "../common/reviews/api",
4+
"apiJsonFolder": "./temp",
5+
"entry": "src/test.ts"
6+
}

web-library-build/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
task,
99
watch
1010
} from '@microsoft/gulp-core-build';
11-
import { typescript, tslint, text } from '@microsoft/gulp-core-build-typescript';
11+
import { apiExtractor, typescript, tslint, text } from '@microsoft/gulp-core-build-typescript';
1212
import { sass } from '@microsoft/gulp-core-build-sass';
1313
import { karma } from '@microsoft/gulp-core-build-karma';
1414
import { webpack } from '@microsoft/gulp-core-build-webpack';
@@ -35,7 +35,7 @@ const sourceMatch: string[] = [
3535
];
3636

3737
// Define default task groups.
38-
export const compileTsTasks: IExecutable = parallel(typescript, text);
38+
export const compileTsTasks: IExecutable = parallel(typescript, text, apiExtractor);
3939
export const buildTasks: IExecutable = task('build', serial(preCopy, sass, parallel(compileTsTasks, text), postCopy));
4040
export const bundleTasks: IExecutable = task('bundle', serial(buildTasks, webpack));
4141
export const testTasks: IExecutable = serial(sass, compileTsTasks, karma);
@@ -47,9 +47,9 @@ export const generateShrinkwrapTask: GenerateShrinkwrapTask = new GenerateShrink
4747
task('validate-shrinkwrap', validateShrinkwrapTask);
4848
task('generate', generateShrinkwrapTask);
4949

50-
task('test', serial(sass, testTasks));
50+
task('test', testTasks);
5151

52-
task('test-watch', watch(sourceMatch, serial(sass, compileTsTasks, karma)));
52+
task('test-watch', watch(sourceMatch, testTasks));
5353

5454
// For watch scenarios like serve, make sure to exclude generated files from src (like *.scss.ts.)
5555
task('serve',

0 commit comments

Comments
 (0)