Skip to content

fix(prompts): start every command on csdx 2.x, whose inquirer 12 broke registerSearchList - #278

Closed
SakshiKoli-CS wants to merge 1 commit into
v2-devfrom
CL-8328
Closed

SakshiKoli-CS wants to merge 1 commit into
v2-devfrom
CL-8328

Conversation

@SakshiKoli-CS

Copy link
Copy Markdown
Contributor

What

On csdx 2.x (@contentstack/cli 2.0.2, npm latest), every launch:* command failed at startup with error: inquirer.registerPrompt is not a function. The new Launch-cli-v2-dev11-integration-sanity GoCD pipeline hit it on its first run.

Why it broke

  • csdx 2.x's bin/run.js makes every plugin resolve @contentstack/cli-utilities to csdx's own 2.x copy, which ships inquirer 12. Launch CLI's own ^1.18.5 pin is bypassed.
  • registerSearchList(), which every command runs at init, assumed inquirer 8 in two ways:
    • it called a top-level registerPrompt, which inquirer 12 only has on its default export;
    • it loaded inquirer/lib/prompts/{list,checkbox}, which inquirer 12's package exports hide (ERR_PACKAGE_PATH_NOT_EXPORTED).

Fix (src/core/search-list.ts)

  • Register on whichever of the module or its default export has registerPrompt.
  • When lib/prompts/{list,checkbox} is absent (MODULE_NOT_FOUND) or not exported (ERR_PACKAGE_PATH_NOT_EXPORTED), keep inquirer's own list and checkbox. Any other load error still throws.
  • The custom search-list is still registered on both csdx versions.

What changes for users: nothing on csdx 1.x. On csdx 2.x, commands start, and list/checkbox page with inquirer 12's built-in paging instead of launch-cli's custom scroller.

Tests

  • New unit tests in search-list.test.ts:
    • inquirer-12-shaped module (registerPrompt only on default);
    • lib/prompts hidden by package exports or missing, so only search-list is registered and nothing throws;
    • any other load error still throws.
  • Checked against the real modules:
    • csdx 2.0.1's cli-utilities (inquirer 12): the old build throws inquirer.registerPrompt is not a function; the fixed build registers the launch search-list.
    • launch-cli's own cli-utilities 1.19.2 (inquirer 8): list and checkbox are still launch's paginated prompts.
  • npm test: 193 suites, 3821 tests passed. npm run lint clean.
  • End to end: the next Launch-cli-v2-dev11-integration-sanity run (csdx 2.0.2) should get past projects:create.

Jira: https://contentstack.atlassian.net/browse/CL-8328 (found by CL-7176's sanity pipeline)

#claude_code#
🤖 Generated with Claude Code

…e registerSearchList

csdx 2.x's bin/run.js makes every plugin resolve @contentstack/cli-utilities
to csdx's own 2.x copy, which ships inquirer 12. registerSearchList(), run by
every command at init, assumed inquirer 8: it called a top-level
registerPrompt, which inquirer 12 only has on its default export, and loaded
inquirer/lib/prompts/{list,checkbox}, which inquirer 12's package exports
hide. So every launch:* command failed on csdx 2.x with "inquirer.registerPrompt
is not a function".

registerSearchList now registers on whichever of the module or its default
export has registerPrompt, and keeps inquirer's own list and checkbox when
their lib/prompts files are absent or not exported. Any other load error
still throws. On csdx 1.x nothing changes.

Refs CL-8328

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@SakshiKoli-CS
SakshiKoli-CS requested review from a team as code owners November 3, 2026 06:42
@snyk-io

snyk-io Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 6 9 25 ✅ Passed
🟡 Medium Severity 5 7 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 9
  • Medium without fixes: 7
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@SakshiKoli-CS

Copy link
Copy Markdown
Contributor Author

Closing in favour of upgrading Launch CLI V2 to @contentstack/cli-utilities 2.x (inquirer 12) under CL-8328, rather than keeping a compatibility shim for inquirer 8. A new PR will follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant