chore(cz-commitlint): allow inquirer v14 compatibility#4879
chore(cz-commitlint): allow inquirer v14 compatibility#4879taterhead247 wants to merge 1 commit into
Conversation
PR Summary by Qodochore(cz-commitlint): widen peer dependency to support inquirer v14
AI Description
Diagram
High-Level Assessment
Files changed (12)
|
Confidence Score: 4/5The changed prompt path can break projects that use older inquirer versions still accepted by the peer range.
@commitlint/cz-commitlint/src/Question.ts and @commitlint/cz-commitlint/package.json Important Files Changed
Reviews (1): Last reviewed commit: "chore: update inquirer to allow v14 (#48..." | Re-trigger Greptile |
| if (enumList && Array.isArray(enumList)) { | ||
| this._question = { | ||
| type: multipleSelectDefaultDelimiter ? "checkbox" : "list", | ||
| type: multipleSelectDefaultDelimiter ? "checkbox" : "select", |
There was a problem hiding this comment.
Select Type Breaks Older Peers
When a project uses a still-supported inquirer 9-12 peer, enum-backed prompts now send type: "select" directly to inquirer.prompt(). Those versions use list for single-select prompts, so commitizen can fail to render the prompt or fall back to free text for type and scope selections.
| "devDependencies": { | ||
| "@types/inquirer": "^9.0.7", | ||
| "commitizen": "^4.2.4" | ||
| "commitizen": "^4.2.4", |
There was a problem hiding this comment.
Dependency Engine Exceeds Package Floor
inquirer@14.0.2 requires Node ^22.13.0, ^20.17.0, or >=23.5.0, while this package still advertises node >=22.12.0. A valid Node 22.12.0 install can satisfy @commitlint/cz-commitlint but fail when engine checks reach the new inquirer dependency or its transitive packages.
Code Review by Qodo
Context used 1. Still uses inquirer.prompt()
|
| rules: QualifiedRules, | ||
| prompts: UserPromptConfig, | ||
| inquirer: { | ||
| prompt(questions: DistinctQuestion[]): Promise<Answers>; | ||
| prompt(questions: PromptQuestion[]): Promise<PromptAnswers>; | ||
| }, | ||
| ): Promise<string> { | ||
| setRules(rules); |
There was a problem hiding this comment.
1. Still uses inquirer.prompt() 📎 Requirement gap ⚙ Maintainability
The runtime still depends on an injected inquirer/inquirerIns instance and executes questions via inquirer.prompt(questions), rather than migrating to @inquirer/prompts for sequential prompting. This keeps internals coupled to a legacy inquirer instance and blocks the required compliance migration away from legacy prompt execution.
Agent Prompt
## Issue description
The adapter and processing flow still rely on a passed `inquirerIns`/`inquirer` instance (via a required `.prompt(...)` method) and execute prompts through `inquirer.prompt(questions)`, instead of using `@inquirer/prompts` for sequential prompting; this violates compliance requirements to remove legacy inquirer prompt execution while also decoupling internals from the injected inquirer instance.
## Issue Context
Compliance requires (1) eliminating runtime calls to `inquirer.prompt(questions[])` in favor of `@inquirer/prompts` while preserving the sequential flow/UX/output, and (2) keeping the external prompter contract stable (as expected by commitizen) while ensuring internals do not require the passed inquirer instance to function (it should be ignored or used only for signature compatibility).
## Fix Focus Areas
- @commitlint/cz-commitlint/src/Process.ts[19-34]
- @commitlint/cz-commitlint/src/index.ts[13-21]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if (enumList && Array.isArray(enumList)) { | ||
| this._question = { | ||
| type: multipleSelectDefaultDelimiter ? "checkbox" : "list", | ||
| type: multipleSelectDefaultDelimiter ? "checkbox" : "select", | ||
| choices: skip | ||
| ? [ | ||
| ...enumList, |
There was a problem hiding this comment.
2. Uses inquirer.separator() 📎 Requirement gap ≡ Correctness
Choice separators are still implemented via new inquirer.Separator() rather than adopting the @inquirer/prompts Separator support required for select/checkbox prompts. This risks UX divergence once prompt execution is migrated.
Agent Prompt
## Issue description
Separators are still created with `inquirer.Separator()` instead of the equivalent Separator supported by `@inquirer/prompts`.
## Issue Context
Compliance requires preserving separator/choice UX while moving to `@inquirer/prompts`.
## Fix Focus Areas
- @commitlint/cz-commitlint/src/Question.ts[73-86]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| npm install --save-dev @commitlint/cz-commitlint commitizen inquirer@14 # inquirer is required as peer dependency | ||
| # or yarn | ||
| yarn add -D @commitlint/cz-commitlint commitizen inquirer@9 # inquirer is required as peer dependency | ||
| yarn add -D @commitlint/cz-commitlint commitizen inquirer@14 # inquirer is required as peer dependency | ||
| ``` |
There was a problem hiding this comment.
3. Docs still require inquirer 📎 Requirement gap ⚙ Maintainability
Documentation continues to instruct users to install inquirer as the required peer dependency rather than reflecting a @inquirer/prompts-based prompt engine. This conflicts with the requirement to update docs away from legacy inquirer guidance.
Agent Prompt
## Issue description
README installation/usage guidance still explicitly requires `inquirer` as a peer dependency, instead of reflecting `@inquirer/prompts` after migration.
## Issue Context
Compliance requires updating dependencies/docs to reflect the new prompt engine and removing explicit legacy inquirer recommendations.
## Fix Focus Areas
- @commitlint/cz-commitlint/README.md[15-19]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| "devDependencies": { | ||
| "@types/inquirer": "^9.0.7", | ||
| "commitizen": "^4.2.4" | ||
| "commitizen": "^4.2.4", | ||
| "inquirer": "^14.0.2" | ||
| }, | ||
| "peerDependencies": { | ||
| "commitizen": "^4.0.3", | ||
| "inquirer": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0" | ||
| "inquirer": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^14.0.0" | ||
| }, |
There was a problem hiding this comment.
4. No @inquirer/prompts dependency 📎 Requirement gap ⚙ Maintainability
The package still declares inquirer as a peer dependency and does not add a direct dependency on @inquirer/prompts as required by the migration plan. This keeps consumers coupled to inquirer rather than the intended prompt engine.
Agent Prompt
## Issue description
The package is still centered on `inquirer` (peer + dev dependency) and does not declare `@inquirer/prompts` as required.
## Issue Context
Compliance requires adding/updating `@inquirer/prompts` and removing the legacy peer dependency constraint once migration is complete.
## Fix Focus Areas
- @commitlint/cz-commitlint/package.json[45-52]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if (enumList && Array.isArray(enumList)) { | ||
| this._question = { | ||
| type: multipleSelectDefaultDelimiter ? "checkbox" : "list", | ||
| type: multipleSelectDefaultDelimiter ? "checkbox" : "select", |
There was a problem hiding this comment.
5. Select prompt peer mismatch 🐞 Bug ≡ Correctness
Question now emits type: "select" for single-choice enum questions, but the package still declares peer compatibility with inquirer ^9–^12. Without a fallback/mapping, installs using those still-allowed peer versions may fail at runtime due to an unsupported question type.
Agent Prompt
## Issue description
`@commitlint/cz-commitlint` now generates enum questions with `type: "select"`, but the peer dependency range still includes inquirer majors that may not support that question type. This creates a runtime compatibility gap relative to the declared peer contract.
## Issue Context
The adapter constructs question objects in `Question` (no access to the passed-in `inquirerIns`), so any compatibility logic must either:
- avoid version-specific question type strings, or
- narrow the supported peer range to match the implementation, or
- restructure question building to allow using the runtime inquirer instance to select an appropriate type.
## Fix Focus Areas
- @commitlint/cz-commitlint/src/Question.ts[73-86]
- @commitlint/cz-commitlint/package.json[49-52]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| "commitizen": "^4.2.4", | ||
| "inquirer": "^14.0.2" | ||
| }, |
There was a problem hiding this comment.
6. Node engine floor mismatch 🐞 Bug ☼ Reliability
The package engine allows Node >=22.12.0, but the newly added devDependency inquirer@14.0.2 requires Node ^22.13.0 (or newer) per the lockfile. Installs/tests run on Node 22.12.x (allowed by this package) can fail due to dependency engine constraints.
Agent Prompt
## Issue description
`@commitlint/cz-commitlint` adds `inquirer@^14.0.2` as a devDependency, but `inquirer@14.0.2` requires Node `^22.13.0` while the package advertises `>=22.12.0`. This can break `pnpm install`/CI in environments on 22.12.x.
## Issue Context
The repository/package engines currently permit Node 22.12.x; adding a devDependency with a stricter engine effectively tightens the real supported Node range for contributors/CI.
## Fix Focus Areas
- @commitlint/cz-commitlint/package.json[45-61]
- pnpm-lock.yaml[3680-3683]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Pull request overview
This PR updates @commitlint/cz-commitlint to work with modern Inquirer (v14), aiming to preserve the existing Commitizen prompt flow while loosening the previously capped peer dependency range.
Changes:
- Extend
inquirerpeer dependency range and addinquirer@14to devDependencies for local testing. - Update single-select prompt type from
listtoselectand decouple from strict Inquirer question typings via package-local prompt interfaces. - Update docs and tests to reflect the new prompt model and Inquirer version guidance.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Locks inquirer@14.0.2 and related @inquirer/* packages. |
| @commitlint/cz-commitlint/src/types.ts | Introduces package-local PromptQuestion / PromptAnswers types to avoid strict Inquirer typings. |
| @commitlint/cz-commitlint/src/SectionHeader.ts | Switches section question typing from Inquirer types to package-local prompt types. |
| @commitlint/cz-commitlint/src/SectionBody.ts | Switches section question typing from Inquirer types to package-local prompt types. |
| @commitlint/cz-commitlint/src/SectionFooter.ts | Switches section question typing from Inquirer types to package-local prompt types. |
| @commitlint/cz-commitlint/src/Question.ts | Changes single-select question type from list to select and updates typing imports. |
| @commitlint/cz-commitlint/src/Question.test.ts | Updates tests to expect select and removes reliance on Inquirer TS types. |
| @commitlint/cz-commitlint/src/Process.ts | Updates prompt/answers typing to the package-local model. |
| @commitlint/cz-commitlint/src/Process.test.ts | Updates mocked prompt typing to the package-local model. |
| @commitlint/cz-commitlint/src/index.ts | Updates prompt/answers typing for the Commitizen adapter entrypoint. |
| @commitlint/cz-commitlint/README.md | Updates installation instructions to recommend inquirer@14. |
| @commitlint/cz-commitlint/package.json | Adds inquirer@^14.0.2 devDependency and expands the inquirer peer range. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (1)
@commitlint/cz-commitlint/src/Question.ts:80
Questionnow emits{ type: "select" }for single-choice enum prompts, butinquirerversions <=12 (still allowed by this package's peer range) don't support theselectprompt type (they uselist). This will cause runtime failures for consumers on inquirer 9–12. Either add a version/feature-detection fallback (listfor legacy inquirer,selectfor modern), or narrow the supported peer range to inquirer >=13 so the runtime behavior matches the contract.
if (enumList && Array.isArray(enumList)) {
this._question = {
type: multipleSelectDefaultDelimiter ? "checkbox" : "select",
choices: skip
? [
...enumList,
new inquirer.Separator(),
{
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "peerDependencies": { | ||
| "commitizen": "^4.0.3", | ||
| "inquirer": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0" | ||
| "inquirer": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^14.0.0" | ||
| }, |
| "devDependencies": { | ||
| "@types/inquirer": "^9.0.7", | ||
| "commitizen": "^4.2.4" | ||
| "commitizen": "^4.2.4", | ||
| "inquirer": "^14.0.2" | ||
| }, |
| export function prompter( | ||
| inquirerIns: { | ||
| prompt(questions: DistinctQuestion[]): Promise<Answers>; | ||
| prompt(questions: PromptQuestion[]): Promise<PromptAnswers>; | ||
| }, |
|
Thanks! |
Description
Update
@commitlint/cz-commitlintfor inquirer 14 compatibility while preserving existing prompt behavior.Motivation and Context
@commitlint/cz-commitlinthad a peer range capped at inquirer 12, which caused downstream dependency-management friction for projects using newer inquirer versions.This change addresses that by:
listtoselect(required by modern inquirer)Fixes #4877.
Usage examples
How Has This Been Tested?
pnpm buildpnpm testpnpm --filter @commitlint/cz-commitlint exec git-czTypes of changes
Checklist: