-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathapiExtractor.ts
55 lines (49 loc) · 1.56 KB
/
apiExtractor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import * as path from "path";
import {
Extractor,
ExtractorConfig,
ExtractorResult,
} from "@microsoft/api-extractor";
// @ts-ignore
import { map } from "./entryPoints.js";
// Load and parse the api-extractor.json file
const configObjectFullPath = path.resolve(__dirname, "../api-extractor.json");
const baseConfig = ExtractorConfig.loadFile(configObjectFullPath);
const packageJsonFullPath = path.resolve(__dirname, "../package.json");
process.exitCode = 0;
map((entryPoint: { dirs: string[] }) => {
const path = entryPoint.dirs.join("/");
const mainEntryPointFilePath =
`<projectFolder>/dist/${path}/index.d.ts`.replace("//", "/");
console.log(
"\n\nCreating API extractor report for " + mainEntryPointFilePath
);
const extractorConfig: ExtractorConfig = ExtractorConfig.prepare({
configObject: {
...baseConfig,
mainEntryPointFilePath,
apiReport: {
enabled: true,
...baseConfig.apiReport,
reportFileName: `api-report${
path ? "-" + path.replace("/", "_") : ""
}.md`,
},
},
packageJsonFullPath,
configObjectFullPath,
});
const extractorResult: ExtractorResult = Extractor.invoke(extractorConfig, {
localBuild: process.env.CI === undefined,
showVerboseMessages: true,
});
if (extractorResult.succeeded) {
console.log(`✅ API Extractor completed successfully`);
} else {
console.error(
`❗ API Extractor completed with ${extractorResult.errorCount} errors` +
` and ${extractorResult.warningCount} warnings`
);
process.exitCode = 1;
}
});