Skip to content

feat: nuxt doctor with hook-based architecture #1205

@onmax

Description

@onmax

Motivation

Related to #330. After some research, the original dependency-checking scope is mostly addressed by nuxt upgrade --dedupe. But there's an interesting opportunity here:

A hook-based nuxt doctor command where the CLI provides core checks and exposes a doctor:check hook for modules to contribute their own.

Example output

$ nuxt doctor

[✓] Config - validated against schema
[✓] Versions - Nuxt 3.15.0, Node 20.10.0
[!] Modules (via nuxt-care) - @old/module 45/100 ⚠
[✓] A11y (via @nuxt/a11y) - 0 violations

Core checks (built-in)

  • config validation against @nuxt/schema
  • Node/Nuxt version checks
  • module compatibility

Hook for modules

nuxt.hook('doctor:check', (ctx) => {
  ctx.addCheck({ name: 'My Check', status: 'success', message: '...' })
})

This would allow modules like @nuxt/a11y to contribute a11y violation checks, nuxt-care module to report module health scores.

Implementation

The pattern follows analyze.ts which calls the build:analyze:done hook.

Component Location
Hook type @nuxt/schema (PR to nuxt/nuxt)
Command packages/nuxi/src/commands/doctor.ts

Open questions

  • should hooks run in parallel or sequentially?
  • for module checks that need the dev server (like a11y), would a separate --full flag make sense?

I'd love feedback before starting implementation 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions