-
Notifications
You must be signed in to change notification settings - Fork 374
Port Conductor multi-version-manager support from react_on_rails#2302 #692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # React Webpack Rails Tutorial - Development Guide | ||
|
|
||
| ## Build and Test Commands | ||
|
|
||
| ```bash | ||
| # Run development server | ||
| bin/dev | ||
|
|
||
| # Run tests | ||
| bundle exec rspec | ||
|
|
||
| # Run linting | ||
| bundle exec rubocop | ||
|
|
||
| # Auto-fix linting issues | ||
| bundle exec rubocop -a | ||
| ``` | ||
|
|
||
| ## Conductor Compatibility (Version Managers) | ||
|
|
||
| ### Problem | ||
|
|
||
| Conductor runs commands in a non-interactive shell that doesn't source `.zshrc`. This means version manager shell hooks (like mise's PATH reordering based on `.tool-versions`) never run. Commands will use system Ruby/Node instead of project-specified versions. | ||
|
|
||
| **Symptoms:** | ||
| - `ruby --version` returns system Ruby (e.g., 2.6.10) instead of project Ruby (e.g., 3.4.3) | ||
| - Pre-commit hooks fail with wrong tool versions | ||
| - `bundle` commands fail due to incompatible Ruby versions | ||
| - Node/pnpm commands use wrong Node version | ||
|
|
||
| ### Solution | ||
|
|
||
| Use the `bin/conductor-exec` wrapper to ensure commands run with correct tool versions: | ||
|
|
||
| ```bash | ||
| # Instead of: | ||
| ruby --version | ||
| bundle exec rubocop | ||
| pnpm install | ||
| git commit -m "message" | ||
|
|
||
| # Use: | ||
| bin/conductor-exec ruby --version | ||
| bin/conductor-exec bundle exec rubocop | ||
| bin/conductor-exec pnpm install | ||
| bin/conductor-exec git commit -m "message" # Pre-commit hooks work correctly | ||
| ``` | ||
|
|
||
| The wrapper: | ||
| - Uses `mise exec` when mise is available | ||
| - Falls back to direct execution for non-mise users (asdf, rbenv, nvm, nodenv) | ||
|
|
||
| ### Reference | ||
|
|
||
| See [react_on_rails-demos#105](https://github.com/shakacode/react_on_rails-demos/issues/105) for detailed problem analysis and solution development. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #!/usr/bin/env zsh | ||
| # Wrapper script to run commands in Conductor with proper tool versions | ||
| # Usage: bin/conductor-exec <command> [args...] | ||
| # | ||
| # This is needed because Conductor (and other non-interactive shells) don't | ||
| # source .zshrc, so version manager PATH configuration isn't active by default. | ||
| # | ||
| # - If mise is available: uses `mise exec` for correct tool versions | ||
| # - Otherwise: falls back to direct execution (for asdf/rbenv/nvm users) | ||
| # | ||
| # Examples: | ||
| # bin/conductor-exec ruby --version # Uses correct Ruby version | ||
| # bin/conductor-exec bundle exec rubocop # Correct Ruby for linting | ||
| # bin/conductor-exec git commit -m "msg" # Pre-commit hooks work correctly | ||
| # bin/conductor-exec pnpm install # Uses correct Node version | ||
| # | ||
| # See: https://github.com/shakacode/react_on_rails-demos/issues/105 | ||
|
|
||
| if command -v mise &> /dev/null; then | ||
| exec mise exec -- "$@" | ||
| else | ||
| # Fall back to direct execution for non-mise users | ||
| exec "$@" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,107 @@ | ||
| #!/bin/bash | ||
| #!/bin/zsh | ||
| set -e | ||
|
|
||
| echo "🚀 Setting up React on Rails workspace..." | ||
|
|
||
| # Detect and initialize version manager | ||
| # Supports: mise, asdf, or direct PATH (rbenv/nvm/nodenv already in PATH) | ||
| VERSION_MANAGER="none" | ||
|
|
||
| echo "📋 Detecting version manager..." | ||
|
|
||
| if command -v mise &> /dev/null; then | ||
| VERSION_MANAGER="mise" | ||
| echo "✅ Found mise" | ||
| # Trust mise config for current directory only and install tools | ||
| mise trust 2>/dev/null || true | ||
| mise install | ||
| elif [[ -f ~/.asdf/asdf.sh ]]; then | ||
| VERSION_MANAGER="asdf" | ||
| source ~/.asdf/asdf.sh | ||
| echo "✅ Found asdf (from ~/.asdf/asdf.sh)" | ||
| elif command -v asdf &> /dev/null; then | ||
| VERSION_MANAGER="asdf" | ||
| # For homebrew-installed asdf | ||
| if [[ -f /opt/homebrew/opt/asdf/libexec/asdf.sh ]]; then | ||
| source /opt/homebrew/opt/asdf/libexec/asdf.sh | ||
| fi | ||
| echo "✅ Found asdf" | ||
| else | ||
| echo "ℹ️ No version manager detected, using system PATH" | ||
| echo " (Assuming rbenv/nvm/nodenv or system tools are already configured)" | ||
| fi | ||
|
|
||
| # Helper function to run commands with the detected version manager | ||
| run_cmd() { | ||
| if [[ "$VERSION_MANAGER" == "mise" ]] && [[ -x "bin/conductor-exec" ]]; then | ||
| bin/conductor-exec "$@" | ||
| else | ||
| "$@" | ||
| fi | ||
| } | ||
|
|
||
| # Note: This project requires Ruby 3.4.6. | ||
| # Please ensure you have the correct Ruby version active before running this script. | ||
|
|
||
| # Check required tools | ||
| echo "📋 Checking required tools..." | ||
| run_cmd ruby --version >/dev/null 2>&1 || { echo "❌ Error: Ruby is not installed or not in PATH."; exit 1; } | ||
| run_cmd node --version >/dev/null 2>&1 || { echo "❌ Error: Node.js is not installed or not in PATH."; exit 1; } | ||
|
|
||
| # Check Ruby version | ||
| RUBY_VERSION=$(run_cmd ruby -v | awk '{print $2}') | ||
| MIN_RUBY_VERSION="3.0.0" | ||
| if [[ $(echo -e "$MIN_RUBY_VERSION\n$RUBY_VERSION" | sort -V | head -n1) != "$MIN_RUBY_VERSION" ]]; then | ||
| echo "❌ Error: Ruby version $RUBY_VERSION is too old. This project requires Ruby >= 3.0.0" | ||
| echo " Please upgrade Ruby using your version manager or system package manager." | ||
| exit 1 | ||
| fi | ||
| echo "✅ Ruby version: $RUBY_VERSION" | ||
|
|
||
| # Check Node version | ||
| NODE_VERSION=$(run_cmd node -v | cut -d'v' -f2) | ||
| MIN_NODE_VERSION="20.0.0" | ||
| if [[ $(echo -e "$MIN_NODE_VERSION\n$NODE_VERSION" | sort -V | head -n1) != "$MIN_NODE_VERSION" ]]; then | ||
| echo "❌ Error: Node.js version v$NODE_VERSION is too old. This project requires Node.js >= 20.0.0" | ||
| echo " Please upgrade Node.js using your version manager or system package manager." | ||
| exit 1 | ||
| fi | ||
| echo "✅ Node.js version: v$NODE_VERSION" | ||
|
|
||
| # Copy environment files if they exist in the root | ||
| if [ -f "$CONDUCTOR_ROOT_PATH/.env" ]; then | ||
| if [[ -f "$CONDUCTOR_ROOT_PATH/.env" ]]; then | ||
| cp "$CONDUCTOR_ROOT_PATH/.env" .env | ||
| echo "✅ Copied .env file from root" | ||
| elif [ -f "$CONDUCTOR_ROOT_PATH/.env.example" ]; then | ||
| elif [[ -f "$CONDUCTOR_ROOT_PATH/.env.example" ]]; then | ||
| cp "$CONDUCTOR_ROOT_PATH/.env.example" .env | ||
| echo "✅ Copied .env.example to .env" | ||
| fi | ||
|
|
||
| if [ -f "$CONDUCTOR_ROOT_PATH/config/database.yml" ]; then | ||
| if [[ -f "$CONDUCTOR_ROOT_PATH/.env.local" ]]; then | ||
| cp "$CONDUCTOR_ROOT_PATH/.env.local" .env.local | ||
| echo "✅ Copied .env.local file from root" | ||
| fi | ||
|
|
||
| if [[ -f "$CONDUCTOR_ROOT_PATH/config/database.yml" ]]; then | ||
| cp "$CONDUCTOR_ROOT_PATH/config/database.yml" config/database.yml | ||
| echo "✅ Copied database.yml from root" | ||
| elif [ -f "config/database.yml.example" ]; then | ||
| elif [[ -f "config/database.yml.example" ]]; then | ||
| cp config/database.yml.example config/database.yml | ||
| echo "✅ Copied database.yml.example to database.yml" | ||
| fi | ||
|
|
||
| # Run the standard Rails setup script | ||
| echo "🔧 Running Rails setup script..." | ||
| bin/setup --skip-server | ||
| run_cmd bin/setup --skip-server | ||
|
|
||
| echo "✨ Setup complete! You can now run the development server." | ||
| echo "✨ Setup complete!" | ||
| echo "" | ||
| echo "📚 Key commands:" | ||
| echo " • bin/dev - Start development server" | ||
| echo " • bundle exec rspec - Run tests" | ||
| echo " • bundle exec rubocop - Run Ruby linting" | ||
| echo "" | ||
| if [[ "$VERSION_MANAGER" == "mise" ]]; then | ||
| echo "💡 Tip: Use 'bin/conductor-exec <command>' if tool versions aren't detected correctly." | ||
| fi | ||
| echo "⚠️ Remember: Always run 'bundle exec rubocop' before committing!" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Ruby version in comment is incorrect.
.ruby-versionfile specifies3.4.3, not3.4.6.Prompt To Fix With AI