docfy init
One-shot onboarding: wires DocfyModule, decorates controllers, registers the webpack plugin if needed, adds package.json scripts, and generates docs files.
Usage
bash
npx nestjs-docfy init [options]Fastest path to a working setup — bundles what generate --link-controller --register-plugin already do, plus the one new step: wiring DocfyModule.forRoot() into your root module.
What it does
- Locates each app's bootstrap file and the class passed to
NestFactory.create(...), then wiresDocfyModule.forRoot()into that root module's@Module({ imports: [...] }). Static analysis only — never executes your code. If it can't locate the bootstrap file or the module with certainty, it warns and skips that app instead of guessing. - Runs the same steps as
generate --link-controller --register-plugin: decorates every controller with@WithDocs(), registers the webpack CLI plugin if needed, and generates the companion*.controller.docs.tsfiles. - Adds
docs:generate/docs:previewscripts to the rootpackage.json, without overwriting any script already defined under those names.
Every step is independently idempotent, so running init again is always safe — useful after adding a new controller or a second app to the project. See CLI: generate for what each bundled step does on its own.
Options
| Option | Default | Description |
|---|---|---|
--root <path> | . | Project root directory |
--tsconfig <path> | auto-detected | Path to tsconfig.json |
--pattern <glob> | **/*.controller.ts | Glob pattern to find controllers |
--format | ts | Output format: ts or js |
--dry-run | false | Print what would change without writing any files |
--quiet | false | Suppress all output except errors |