Skip to content

Conversation

joshuayoes
Copy link
Contributor

@joshuayoes joshuayoes commented Oct 7, 2025

Please verify the following:

  • yarn build-and-test:local passes
  • I have added tests for any new features, if relevant
  • README.md (or relevant documentation) has been updated with your changes

Describe your PR

Add npx CLI support to reactotron-core-server

This PR adds the ability to run reactotron-core-server as a standalone CLI tool via npx, making it easy for developers to start a Reactotron server without needing the full desktop app or writing custom server code.

Changes:

New Files:

  • lib/reactotron-core-server/src/cli.ts - CLI implementation with argument parsing, server lifecycle management, and event logging
  • lib/reactotron-core-server/bin/reactotron-core-server.js - Executable bin script

Modified Files:

  • lib/reactotron-core-server/package.json - Added bin mapping and included bin/ directory in published files
  • lib/reactotron-core-server/README.md - Added comprehensive CLI documentation with usage examples

Features:

  • Simple Usage: npx reactotron-core-server --port 9090
  • Port Configuration: -p or --port flag to specify custom port (default: 9090)
  • TLS/WSS Support: Optional flags for secure WebSocket connections:
    • PFX certificate: --wss-pfx with --wss-passphrase
    • Cert/Key files: --wss-cert, --wss-key, and optional --wss-passphrase
  • Help Documentation: --help flag displays usage information
  • Graceful Shutdown: Handles SIGINT/SIGTERM for clean server shutdown
  • Connection Logging: Logs server lifecycle events and client connections

Testing:

  • ✅ Build successful with yarn build
  • ✅ Help flag displays correct usage information
  • ✅ Server starts successfully on default and custom ports
  • ✅ Graceful shutdown works properly
  • ✅ No linting errors

Use Cases:

This enables developers to:

  1. Quickly spin up a Reactotron server for CI/CD pipelines
  2. Run headless Reactotron servers in Docker containers
  3. Use Reactotron in environments where the desktop app isn't available
  4. Test and debug without installing the full Reactotron app

…cture

- Introduced a new CLI for running the Reactotron server with options for port and TLS configuration.
- Updated `package.json` to include a `bin` entry for the CLI.
- Added a new `cli.ts` file for argument parsing and server initialization.
- Created a new executable script in `bin/reactotron-core-server.js`.
- Enhanced the README with usage instructions and examples for the CLI.
@joshuayoes joshuayoes self-assigned this Oct 7, 2025
@joshuayoes joshuayoes added the hold my beer 🍺 This may be crazy but... label Oct 7, 2025
…nd error handling

- Introduced a new test suite for the Reactotron CLI, covering help command, server startup on default and custom ports, graceful shutdown, and error handling for invalid arguments.
- Implemented tests to ensure correct behavior for various CLI options and error scenarios.
- Enhanced test coverage for TLS/WSS options and argument validation.
… "bin" for reactotron-core-server

- Adjusted the validation logic to dynamically check the "files" field in package.json based on the workspace name.
- Ensured that the expected files array includes "bin" for the reactotron-core-server package, improving validation accuracy.
@joshuayoes joshuayoes marked this pull request as ready for review October 7, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold my beer 🍺 This may be crazy but...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants