forked from vltpkg/vltpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypedoc.workspace.mjs
More file actions
50 lines (43 loc) · 1.11 KB
/
typedoc.workspace.mjs
File metadata and controls
50 lines (43 loc) · 1.11 KB
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
// @ts-check
import { join } from 'node:path'
import { readFileSync } from 'node:fs'
/**
* @param {string} cwd
* @returns {Record<string, unknown>}
*/
const readPkg = cwd => {
try {
return JSON.parse(readFileSync(join(cwd, 'package.json'), 'utf8'))
} catch {
return {}
}
}
/**
* @param {string} cwd
* @returns {undefined | Partial<import('typedoc').TypeDocOptions>}
*/
export default cwd => {
const pkg = readPkg(cwd)
// Private workspaces are not included in the docs site.
if (pkg.private) {
return
}
const exports =
'exports' in pkg && typeof pkg.exports === 'object' ?
pkg.exports
: null
// get actual code entry points from package.json exports
const entryPoints = Object.values(exports ?? {})
.map(p => (typeof p === 'string' ? p : p.import.default))
.filter(p => !p.endsWith('package.json'))
.map(p => join(cwd, p))
// If there are no entry points (like the gui) then it means to skip this workspace.
if (entryPoints.length === 0) {
return
}
return {
// get readme local to workspace
readme: join(cwd, './README.md'),
entryPoints,
}
}