cli.ts

CLI for svelte-docinfo.

Static analysis for TypeScript and Svelte source code.

@example

# Analyze current project svelte-docinfo # Analyze specific directory svelte-docinfo ./packages/my-lib # Write to file svelte-docinfo --output docs/library.json

Declarations
#

2 declarations

view source

CliOptions
#

cli.ts view source

CliOptions

CLI options parsed from command line arguments.

include

File patterns to include (undefined = use exports discovery or defaults).

type Array<string>

exclude

File patterns to exclude (undefined = use defaults — test and spec files).

When provided, fully replaces the defaults — no array merge. Passing a custom --exclude pattern drops the default test/spec filters unless the caller re-includes them explicitly.

type Array<string>

output

Output file path (undefined = stdout).

type string

resolveDependencies

Whether to resolve dependencies. Mapped from the --no-resolve-dependencies flag (commander populates true by default; false when the flag is passed). Optional here so external callers can omit it; treated as true when undefined.

type boolean

discovery

Discovery strategy (undefined = 'auto').

Mapped from --discovery <auto|exports|glob>.

distDir

Dist directory name for exports-based discovery (undefined = 'dist').

type string

sourceDir

Source directories relative to project root (undefined = ['src/lib']).

Repeatable. Drives the implicit include glob in the glob-discovery fallback (via deriveIncludePatterns inside discoverSourceFiles) so custom source directories survive without needing an explicit --include.

type Array<string>

sourceRoot

Source root for module path extraction, relative to project root (undefined = single sourceDir or longest common prefix).

Module paths in output are stripped of <projectRoot>/<sourceRoot>/. Pass . (or "") to keep module paths project-relative — useful when sourceDir entries share no common prefix. The . form is normalized to "" inside normalizeSourceOptions.

type string

onDuplicates

Behavior when duplicate declaration names are found across modules (undefined = emit duplicate_declaration diagnostic, no dispatch).

Duplicate detection always runs regardless of this option — the diagnostic is the data, this option is the dispatch action.

type OnDuplicatesFlag

only

Glob patterns to filter the emitted modules array against ModuleJson.path (undefined = emit all analyzed modules).

Repeatable. Output-only filter: full-project analysis still runs so re-exports, dependents, and alsoExportedFrom stay correct against the complete owned set. Diagnostics aren't filtered — they may reference modules dropped from output.

type Array<string>

quiet

Whether to suppress info messages to stderr. Treated as false when undefined.

type boolean

pretty

Whether to pretty-print JSON output. Treated as false when undefined.

type boolean

runCli
#

cli.ts view source

(argv?: string[]): Promise<number>

Run the CLI with the given arguments.

argv

command line arguments (defaults to process.argv)

type string[]
default process.argv

returns

Promise<number>

exit code: 0 for success, 1 if errors in diagnostics, 2 for CLI errors

Depends on
#

Imported by
#