Skip to content

feat: implement cy2play init command #2

Description

@barispe

Summary

Add a cy2play init command that scaffolds a cy2play.config.json configuration file interactively.

Motivation

The README documents cy2play.config.json and the config loader already supports it, but there's no CLI command to generate one. Users currently have to create it manually. The .gitignore already references 'Generated config (from cy2play init)', indicating this was a planned feature.

Proposed Behavior

Interactive Flow

�ash $ npx cy2play init

The command should prompt the user for:

  1. Conversion mode - Select from: strict, hybrid, pure-ai (default: hybrid)
  2. Output directory - Where to write generated files (default: ./playwright-tests)
  3. LLM provider - Select from: none, openai, anthropic, local (default: none for strict, openai for hybrid/pure-ai)
  4. Model - If provider selected (default: gpt-4o for openai, claude-3-5-sonnet for anthropic, codellama for local)
  5. API key source - env:OPENAI_API_KEY format or direct entry
  6. Local LLM URL - If local provider (default: http://localhost:11434/v1)
  7. Custom command mappings - Ask if they have custom Cypress commands (can be skipped)

Output

Generates cy2play.config.json:
json { mode: hybrid, targetDir: ./playwright-tests, llm: { provider: openai, model: gpt-4o, apiKey: env:OPENAI_API_KEY, temperature: 0.2 }, customMappings: {} }

CLI flags for non-interactive use

�ash cy2play init --mode strict --output ./tests cy2play init --yes # Accept all defaults

Implementation Plan

  1. Add a dependency for interactive prompts (e.g., inquirer or lighter prompts)
  2. Create src/init.ts with the initialization logic
  3. Register the init command in src/cli.ts
  4. Add tests in ests/init.test.ts
  5. Update README Quick Start section

Acceptance Criteria

  • cy2play init creates a valid cy2play.config.json
  • Generated config is loadable by the existing
    esolveOptions function
  • Non-interactive mode with --yes flag works
  • Does not overwrite existing config without confirmation
  • Tests cover interactive and non-interactive flows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions