Skip to content

Commit 5aaee75

Browse files
committed
test: Expand test scenarios
1 parent 6b385c9 commit 5aaee75

27 files changed

+516
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This project's outputs are tracked to surface changes to API Extractor rollups during PRs
2+
!dist
3+
dist/*
4+
!dist/*.d.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fsx = require('fs-extra');
2+
const child_process = require('child_process');
3+
const path = require('path');
4+
const process = require('process');
5+
6+
function executeCommand(command) {
7+
console.log('---> ' + command);
8+
child_process.execSync(command, { stdio: 'inherit' });
9+
}
10+
11+
// Clean the old build outputs
12+
console.log(`==> Starting build.js for ${path.basename(process.cwd())}`);
13+
fsx.emptyDirSync('dist');
14+
fsx.emptyDirSync('lib');
15+
fsx.emptyDirSync('temp');
16+
17+
// Run the TypeScript compiler
18+
executeCommand('node node_modules/typescript/lib/tsc');
19+
20+
// Run the API Extractor command-line
21+
if (process.argv.indexOf('--production') >= 0) {
22+
executeCommand('node node_modules/@microsoft/api-extractor/lib/start run');
23+
} else {
24+
executeCommand('node node_modules/@microsoft/api-extractor/lib/start run --local');
25+
}
26+
27+
console.log(`==> Finished build.js for ${path.basename(process.cwd())}`);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3+
4+
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
5+
6+
"apiReport": {
7+
"enabled": true
8+
},
9+
10+
"docModel": {
11+
"enabled": true
12+
},
13+
14+
"dtsRollup": {
15+
"enabled": true
16+
},
17+
18+
"testMode": true
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-project.schema.json",
3+
4+
"operationSettings": [
5+
{
6+
"operationName": "_phase:build",
7+
"outputFolderNames": ["lib"]
8+
}
9+
]
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* api-extractor-lib4-test
3+
*
4+
* @remarks
5+
* This library is consumed by api-extractor-scenarios.
6+
*
7+
* @packageDocumentation
8+
*/
9+
10+
/** @public */
11+
export declare enum Lib4Enum {
12+
Foo = "Foo",
13+
Bar = "Bar",
14+
Baz = "Baz"
15+
}
16+
17+
export { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## API Report File for "api-extractor-lib4-test"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
7+
// @public (undocumented)
8+
export enum Lib4Enum {
9+
// (undocumented)
10+
Bar = "Bar",
11+
// (undocumented)
12+
Baz = "Baz",
13+
// (undocumented)
14+
Foo = "Foo"
15+
}
16+
17+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "api-extractor-lib4-test",
3+
"description": "Building this project is a regression test for api-extractor",
4+
"version": "1.0.0",
5+
"private": true,
6+
"main": "lib/index.js",
7+
"typings": "dist/api-extractor-lib3-test.d.ts",
8+
"scripts": {
9+
"build": "node build.js",
10+
"_phase:build": "node build.js"
11+
},
12+
"devDependencies": {
13+
"@microsoft/api-extractor": "workspace:*",
14+
"@types/jest": "29.2.5",
15+
"@types/node": "18.17.15",
16+
"fs-extra": "~7.0.1",
17+
"typescript": "~5.3.3"
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
/**
5+
* api-extractor-lib4-test
6+
*
7+
* @remarks
8+
* This library is consumed by api-extractor-scenarios.
9+
*
10+
* @packageDocumentation
11+
*/
12+
13+
/** @public */
14+
export enum Lib4Enum {
15+
Foo = 'Foo',
16+
Bar = 'Bar',
17+
Baz = 'Baz'
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es6",
4+
"forceConsistentCasingInFileNames": true,
5+
"module": "commonjs",
6+
"declaration": true,
7+
"sourceMap": true,
8+
"declarationMap": true,
9+
"experimentalDecorators": true,
10+
"strictNullChecks": true,
11+
"types": ["node", "jest"],
12+
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
13+
"outDir": "lib"
14+
},
15+
"include": ["src/**/*.ts", "typings/tsd.d.ts"]
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This project's outputs are tracked to surface changes to API Extractor rollups during PRs
2+
!dist
3+
dist/*
4+
!dist/*.d.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fsx = require('fs-extra');
2+
const child_process = require('child_process');
3+
const path = require('path');
4+
const process = require('process');
5+
6+
function executeCommand(command) {
7+
console.log('---> ' + command);
8+
child_process.execSync(command, { stdio: 'inherit' });
9+
}
10+
11+
// Clean the old build outputs
12+
console.log(`==> Starting build.js for ${path.basename(process.cwd())}`);
13+
fsx.emptyDirSync('dist');
14+
fsx.emptyDirSync('lib');
15+
fsx.emptyDirSync('temp');
16+
17+
// Run the TypeScript compiler
18+
executeCommand('node node_modules/typescript/lib/tsc');
19+
20+
// Run the API Extractor command-line
21+
if (process.argv.indexOf('--production') >= 0) {
22+
executeCommand('node node_modules/@microsoft/api-extractor/lib/start run');
23+
} else {
24+
executeCommand('node node_modules/@microsoft/api-extractor/lib/start run --local');
25+
}
26+
27+
console.log(`==> Finished build.js for ${path.basename(process.cwd())}`);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3+
4+
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
5+
6+
"apiReport": {
7+
"enabled": true
8+
},
9+
10+
"docModel": {
11+
"enabled": true
12+
},
13+
14+
"dtsRollup": {
15+
"enabled": true
16+
},
17+
18+
"testMode": true
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-project.schema.json",
3+
4+
"operationSettings": [
5+
{
6+
"operationName": "_phase:build",
7+
"outputFolderNames": ["lib"]
8+
}
9+
]
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* api-extractor-lib5-test
3+
*
4+
* @remarks
5+
* This library is consumed by api-extractor-scenarios.
6+
*
7+
* @packageDocumentation
8+
*/
9+
10+
/** @public */
11+
export declare function lib5Function(): number;
12+
13+
export { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## API Report File for "api-extractor-lib5-test"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
7+
// @public (undocumented)
8+
export function lib5Function(): number;
9+
10+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "api-extractor-lib5-test",
3+
"description": "Building this project is a regression test for api-extractor",
4+
"version": "1.0.0",
5+
"private": true,
6+
"main": "lib/index.js",
7+
"typings": "dist/api-extractor-lib3-test.d.ts",
8+
"scripts": {
9+
"build": "node build.js",
10+
"_phase:build": "node build.js"
11+
},
12+
"devDependencies": {
13+
"@microsoft/api-extractor": "workspace:*",
14+
"@types/jest": "29.2.5",
15+
"@types/node": "18.17.15",
16+
"fs-extra": "~7.0.1",
17+
"typescript": "~5.3.3"
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2+
// See LICENSE in the project root for license information.
3+
4+
/**
5+
* api-extractor-lib5-test
6+
*
7+
* @remarks
8+
* This library is consumed by api-extractor-scenarios.
9+
*
10+
* @packageDocumentation
11+
*/
12+
13+
/** @public */
14+
export function lib5Function(): number {
15+
return 42;
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es6",
4+
"forceConsistentCasingInFileNames": true,
5+
"module": "commonjs",
6+
"declaration": true,
7+
"sourceMap": true,
8+
"declarationMap": true,
9+
"experimentalDecorators": true,
10+
"strictNullChecks": true,
11+
"types": ["node", "jest"],
12+
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
13+
"outDir": "lib"
14+
},
15+
"include": ["src/**/*.ts", "typings/tsd.d.ts"]
16+
}

0 commit comments

Comments
 (0)