CLI
comark-content ships a small CLI binary, comark-content, installed alongside the package. It currently has one subcommand.
npx comark-content --helpcomark-content prepare
Locates your comarkContent() instance and generates source types (comark-content.d.ts by default). This is the same writeSourceTypes() the Vite plugin runs automatically — reach for the CLI when you're not using Vite, or want to (re)generate types as a standalone script or CI step.
npx comark-content prepareConfig discovery:
Without --config, it searches for content.{ts,mts,js,mjs} in, relative to --cwd:
../server./lib./server/utils./server/lib
The first match is loaded (via jiti) and its exported Content instance resolved by checking, in order: the default export, a content export, then any other exported value that looks like a ComarkContent. Export it explicitly if discovery doesn't find it:
export const content = comarkContent({ /* ... */ })Flags:
| Flag | Type | Default | Description |
|---|---|---|---|
--cwd <dir> | string | process.cwd() | Project directory to search and resolve paths from. |
--config <path/to/content.ts> | string | — | Path to the Content instance file, bypassing directory search. |
--output <file>, -o | string | comark-content.d.ts | Where to write the generated types. |
--module-name <name> | string | comark-content | Module specifier the declare module augmentation targets. |
--paths / --no-paths | boolean | true | Emit the per-document ContentPaths map. Pass --no-paths to skip it on very large sites. |
Errors:
- No
content.{ts,mts,js,mjs}found in any searched directory: exits1and prints the directories searched. Pass--configto point at it explicitly. - The resolved config path doesn't exist, or doesn't export a Content instance: exits
1with a message telling you toexport const content = comarkContent({ ... }).
Usage:
# Default: search for content.ts, write ./comark-content.d.ts
comark-content prepare
# Explicit config and output path
comark-content prepare --config server/content.ts --output types/comark-content.d.ts
# Skip the ContentPaths map on a large site
comark-content prepare --no-pathsWhen writing to the default comark-content.d.ts, the command reminds you to add it to .gitignore and to your tsconfig.json include — see Type Safety.