Skip to content

Migrate @commitlint/cz-commitlint to @inquirer/prompts to remove inquirer v12 peer cap #4877

Description

@taterhead247

Summary

@commitlint/cz-commitlint currently constrains inquirer to ^9 || ^10 || ^11 || ^12, which blocks downstream repos from upgrading their workspace inquirer reference to v13+ while using this adapter.

This issue documents:

  • what was verified,
  • why downstream installs are blocked,
  • and the planned migration path from legacy inquirer APIs to @inquirer/prompts for @commitlint/cz-commitlint.

Verified Findings

1) Current peer dependency cap in @commitlint/cz-commitlint

In @commitlint/cz-commitlint/package.json, peer deps currently include:

  • inquirer": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0"

This is the direct compatibility cap for consumers using newer inquirer majors.

2) inquirerIns in prompter() is not truly “unused” today

Code comment says:

@param inquirerIns instance passed by commitizen, unused

But code currently passes it through and calls .prompt(...):

  • src/index.ts passes inquirerIns to process(...)
  • src/Process.ts does await inquirer.prompt(questions)

So this comment is stale/misleading. More accurate wording: only the prompt function shape is used, not the full inquirer API surface.

Why migrate to @inquirer/prompts

The legacy monolithic inquirer package is still maintained but is not the actively developed API surface. @inquirer/prompts is the modern prompt API and supports progressive adoption patterns.

Migrating @commitlint/cz-commitlint to @inquirer/prompts would remove the tight coupling to old inquirer question typings (DistinctQuestion, Answers, etc.) and avoid the peer cap mismatch for consumers.

Proposed Migration Plan (PR scope)

Goal

Migrate only @commitlint/cz-commitlint prompt execution path from inquirer.prompt(questions[]) to @inquirer/prompts while preserving current UX and output behavior.

Key implementation strategy

  1. Introduce a package-local prompt model
  • Replace direct inquirer runtime/type coupling in src/Question.ts, src/Process.ts, section builders, and tests.
  • Keep existing validation/filter/transformation semantics.
  1. Replace prompt engine
  • Map old prompt types to modern prompts:
    • input -> input
    • list -> select
    • checkbox -> checkbox
    • confirm -> confirm
  • Preserve conditional when behavior and sequential flow currently provided by array-based .prompt(...).
  1. Preserve separator/choice UX
  • Current code uses new inquirer.Separator() in enum flows.
  • @inquirer/prompts supports Separator in select / checkbox; adopt equivalent usage.
  1. Keep Commitizen adapter contract stable
  • Exported prompter(...) API should remain compatible for users invoking through commitizen.
  • Internally, parameter can be ignored or kept for signature compatibility during transition.
  1. Update dependencies/docs
  • Remove old inquirer peer constraint from @commitlint/cz-commitlint once no longer needed.
  • Add/update deps for @inquirer/prompts.
  • Update adapter README install guidance that currently recommends legacy inquirer explicitly.

File areas expected to change

  • @commitlint/cz-commitlint/package.json
  • @commitlint/cz-commitlint/src/index.ts
  • @commitlint/cz-commitlint/src/Process.ts
  • @commitlint/cz-commitlint/src/Question.ts
  • @commitlint/cz-commitlint/src/SectionHeader.ts
  • @commitlint/cz-commitlint/src/SectionBody.ts
  • @commitlint/cz-commitlint/src/SectionFooter.ts
  • @commitlint/cz-commitlint/src/*.test.ts
  • @commitlint/cz-commitlint/README.md

Testing Plan

  1. Unit parity
  • Ensure existing tests around:
    • required/optional fields,
    • max/min validations,
    • case/full-stop filters,
    • conditional footer/body prompts,
    • combined commit message output
      continue to pass or are updated with equivalent expectations.
  1. Integration smoke
  • run commitizen flow against adapter in this repo and validate resulting commit messages remain unchanged for canonical cases.
  1. Downstream verification (optional but useful)
  • locally test a consumer workspace with inquirer v13+ and @commitlint/cz-commitlint from branch/release candidate.

Risk Areas

  • Small UX differences between old and new prompt renderers (especially transformer rendering and list behavior).
  • Test harness changes required because current tests mock inquirer question object execution.
  • Potential need to keep backward-compatible adapter entry signature while decoupling runtime from inquirer.

Non-goals

  • Full migration of other commitlint packages (@commitlint/prompt, @commitlint/prompt-cli, etc.) in the same change.
  • Broad prompt feature redesign.

Expected Outcome

After this migration, downstream repositories should no longer be blocked by @commitlint/cz-commitlint’s legacy peer range when upgrading their inquirer-related toolchain.


If maintainers are open to this direction, I can follow up with a PR scoped exactly to @commitlint/cz-commitlint and keep the change narrowly focused on parity + compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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