docfy init

ワンコマンドでオンボーディング: DocfyModule を接続し、コントローラーにデコレータを追加し、必要に応じて webpack プラグインを登録し、package.json にスクリプトを追加し、ドキュメントファイルを生成します。

使い方

bash
npx nestjs-docfy init [options]

最速でセットアップを完了する方法 — generate --link-controller --register-plugin がすでに行っていることに加え、唯一新しいステップである DocfyModule.forRoot() のルートモジュールへの接続をまとめて行います。

動作内容

  1. Locates each app's bootstrap file and the class passed to NestFactory.create(...), then wires DocfyModule.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.
  2. 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.ts files.
  3. Adds docs:generate/docs:preview scripts to the root package.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.

オプション

OptionDefaultDescription
--root <path>.Project root directory
--tsconfig <path>auto-detectedPath to tsconfig.json
--pattern <glob>**/*.controller.tsGlob pattern to find controllers
--formattsOutput format: ts or js
--dry-runfalsePrint what would change without writing any files
--quietfalseSuppress all output except errors