Add shim for removed `reflex component` CLI command

Merged
MA
1mo ago
+117-3

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Description

Replaces the removed reflex component command with a hidden shim that gracefully guides users to the new workflow instead of showing a "No such command" error.

Changes:

  1. reflex/reflex.py: Added a hidden component command that:

    • Accepts any subcommand and flags (e.g., reflex component init, build, share, install)
    • Exits with code 1 and logs an error message pointing users to:
    • Uses ignore_unknown_options=True to prevent Click from raising "No such command" errors
  2. tests/units/test_reflex.py: Updated and expanded tests:

    • Changed test_component_command_is_not_registered() to test_component_command_is_hidden() — verifies the command exists but is hidden from --help output
    • Added test_component_command_points_to_template() — ensures all old subcommands redirect with the helpful message
    • Added test_component_help_points_to_template() — verifies --help invocations show the pointer
    • Added test_component_command_dispatches_from_cli() — integration test confirming the shim works when invoked via subprocess
    • Updated CLI startup test to include component --help in the denied modules list
  3. news/+component-cli-shim.bugfix.md: Added changelog fragment documenting the user-facing improvement.

Test Plan

All new and modified tests pass:

  • Unit tests verify the command is hidden, accepts any arguments, and returns the helpful error message
  • Integration test confirms the shim works when invoked via the CLI entry point
  • Existing tests continue to pass

https://claude.ai/code/session_01CEngePWmkuAQ31xWPb1Q9L