Skip to content

Commit 137908f

Browse files
committed
Allow auth to use a separate d.ts file for docgen
1 parent 736cc88 commit 137908f

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

packages/auth/api-extractor.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "../../config/api-extractor.json",
3-
// Point it to your entry point d.ts file.
4-
"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.doc.d.ts",
3+
// If this path ever changes, make sure to change scripts/exp/docgen.ts
4+
// accordingly.
5+
"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.d.ts",
56
"dtsRollup": {
67
"enabled": true,
78
"untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",

scripts/exp/docgen.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ async function generateDocs(forDevsite: boolean = false) {
3838
const outputFolder = forDevsite ? 'docs-devsite' : 'docs-exp';
3939
const command = forDevsite ? 'api-documenter-devsite' : 'api-documenter';
4040

41+
// Use a special d.ts file for auth for doc gen only.
42+
const authApiConfigOriginal = fs.readFileSync(
43+
`${projectRoot}/packages/auth/api-extractor.json`,
44+
'utf8'
45+
);
46+
const authApiConfigModified = authApiConfigOriginal.replace(
47+
`"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.d.ts"`,
48+
`"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.doc.d.ts"`
49+
);
50+
fs.writeFileSync(
51+
`${projectRoot}/packages/auth/api-extractor.json`,
52+
authApiConfigModified
53+
);
54+
4155
await spawn('yarn', ['build'], {
4256
stdio: 'inherit'
4357
});
@@ -46,15 +60,19 @@ async function generateDocs(forDevsite: boolean = false) {
4660
stdio: 'inherit'
4761
});
4862

63+
// Restore original auth api-extractor.json contents.
64+
fs.writeFileSync(
65+
`${projectRoot}/packages/auth/api-extractor.json`,
66+
authApiConfigOriginal
67+
);
68+
4969
if (!fs.existsSync(tmpDir)) {
5070
fs.mkdirSync(tmpDir);
5171
}
5272

5373
// TODO: Throw error if path doesn't exist once all packages add markdown support.
5474
const apiJsonDirectories = (
55-
await mapWorkspaceToPackages([
56-
`${projectRoot}/packages/*`
57-
])
75+
await mapWorkspaceToPackages([`${projectRoot}/packages/*`])
5876
)
5977
.map(path => `${path}/temp`)
6078
.filter(path => fs.existsSync(path));

0 commit comments

Comments
 (0)