conventional-changelog / conventional-changelog/commitlint
Migrate @commitlint/cz-commitlint to @inquirer/prompts to remove inquirer v12 peer cap
- Dominant language
- TypeScript
- Stars
- 18.7k
- Forks
- 970
- Avg merge
- 7h 33m
- Merged PRs (30d)
- 49
Description
## 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.
2. 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(...)`.
3. Preserve separator/choice UX
- Current code uses `new inquirer.Separator()` in enum flows.
- `@inquirer/prompts` supports `Separator` in `select` / `checkbox`; adopt equivalent usage.
4. 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.
5. 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.
2. Integration smoke
- run commitizen flow against adapter in this repo and validate resulting commit messages remain unchanged for canonical cases.
3. 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.
Contributor guide
Research direction
Start with @commitlint/cz-commitlint/src/Process.ts, src/Question.ts, src/index.ts, and the section builders to trace the current prompt flow, then run the existing *.test.ts tests. Update the package, README, implementation, and tests for @inquirer/prompts while preserving validation, conditional prompts, separators, and commit-message output. Done means the adapter works with inquirer v13+ without the old peer cap and its tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100