cloudflare / cloudflare/workers-sdk

[wrangler] Consolidate interactive prompts to use @cloudflare/cli

Open
#12,296 0 comments 0 reactions 2 assignees Claimed by @MattieTK View on GitHub
package:c3 package:wrangler tech-debt
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
186

Description

## Summary

Wrangler has two different systems for interactive prompts that should be consolidated:

1. **Legacy `dialogs.ts`** (`packages/wrangler/src/dialogs.ts`) - Uses the `prompts` npm package
2. **`@cloudflare/cli`** (`packages/cli/interactive.ts`) - Uses `@clack/core` with custom rendering

The `@cloudflare/cli` package was originally built for C3 (Create Cloudflare) but has been partially adopted in Wrangler for newer features. We should complete this migration to have a single, consistent approach to interactive prompts across our tools.

## Current State

### Wrangler's `dialogs.ts` (legacy)
- Location: `packages/wrangler/src/dialogs.ts`
- Library: `prompts` npm package
- Functions: `confirm()`, `prompt()`, `select()`, `multiselect()`
- Simple implementation (~30 lines per function)
- Limited customization

### @cloudflare/cli (modern)
- Location: `packages/cli/interactive.ts`
- Library: `@clack/core` with custom rendering layer
- Function: `inputPrompt()` supporting confirm, text, select, multiselect, and refreshable list types
- Features:
- Cloudflare-branded styling with custom colors
- State-based renderers (initial, active, error, submit, cancel)
- Spinner support
- `log-update` for TTY cursor control
- ~600 lines with full rendering system

### Current Adoption
Wrangler already uses `@cloudflare/cli` in several places:
- Cloudchamber commands
- Containers commands
- Versions/deployments
- D1 commands
- `isInteractive()` already delegates to `@cloudflare/cli`

## Proposed Work

1. **Audit usage** - Identify all call sites of `confirm()`, `prompt()`, `select()`, `multiselect()` from `dialogs.ts`

2. **Migrate call sites** - Update each call site to use `inputPrompt()` from `@cloudflare/cli` instead

3. **Deprecate `dialogs.ts`** - Once all call sites are migrated, remove or deprecate the legacy functions

4. **Ensure feature parity** - Verify `@cloudflare/cli` supports all use cases currently handled by `dialogs.ts`, adding functionality if needed

## Constraints

- **No user-facing breaking changes** - The prompts should behave the same from a user's perspective
- **Non-interactive/CI behavior must be preserved** - Fallback values and CI detection must work identically

## Benefits

- Single source of truth for interactive prompts
- Consistent UI/UX across Wrangler and C3
- Cloudflare-branded styling everywhere
- Easier maintenance - one system to update
- Access to modern features (spinners, refreshable lists) throughout Wrangler

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.