Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions conductor-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/zsh
set -e

# Initialize ASDF if available (for proper Ruby/Node versions)
if [[ -f ~/.asdf/asdf.sh ]]; then
source ~/.asdf/asdf.sh
elif command -v asdf >/dev/null 2>&1; then
# For homebrew-installed asdf
if [[ -f /opt/homebrew/opt/asdf/libexec/asdf.sh ]]; then
source /opt/homebrew/opt/asdf/libexec/asdf.sh
fi
fi

echo "πŸš€ Setting up React on Rails workspace..."

# Check required tools
echo "πŸ“‹ Checking required tools..."
command -v bundle >/dev/null 2>&1 || { echo "❌ Error: bundler is not installed. Please install Ruby and bundler first."; exit 1; }
command -v yarn >/dev/null 2>&1 || { echo "❌ Error: yarn is not installed. Please install yarn first."; exit 1; }
command -v node >/dev/null 2>&1 || { echo "❌ Error: Node.js is not installed. Please install Node.js first."; exit 1; }

# Check Ruby version
RUBY_VERSION=$(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. React on Rails requires Ruby >= 3.0.0"
echo " Please upgrade Ruby using rbenv, rvm, or your system package manager."
exit 1
fi
echo "βœ… Ruby version: $RUBY_VERSION"

# Check Node version
NODE_VERSION=$(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. React on Rails requires Node.js >= 20.0.0"
echo " Please upgrade Node.js using nvm, asdf, or your system package manager."
exit 1
fi
echo "βœ… Node.js version: v$NODE_VERSION"

# Copy any environment files from root if they exist
if [ -f "$CONDUCTOR_ROOT_PATH/.env" ]; then
echo "πŸ“ Copying .env file..."
cp "$CONDUCTOR_ROOT_PATH/.env" .env
fi

if [ -f "$CONDUCTOR_ROOT_PATH/.env.local" ]; then
echo "πŸ“ Copying .env.local file..."
cp "$CONDUCTOR_ROOT_PATH/.env.local" .env.local
fi

# Install Ruby dependencies
echo "πŸ’Ž Installing Ruby dependencies..."
bundle install

# Install JavaScript dependencies
echo "πŸ“¦ Installing JavaScript dependencies..."
yarn install

# Build the TypeScript package
echo "πŸ”¨ Building TypeScript package..."
yarn run build

# Generate the node package
echo "πŸ“¦ Generating node package..."
rake node_package

# Install git hooks for linting
echo "πŸͺ Installing git hooks..."
bundle exec lefthook install || echo "⚠️ Could not install lefthook hooks"

# Run initial linting to ensure everything is set up correctly
echo "βœ… Running initial linting checks..."
bundle exec rubocop --version
yarn run type-check || echo "⚠️ Type checking had issues"

echo "✨ Workspace setup complete!"
echo ""
echo "πŸ“š Key commands:"
echo " β€’ rake - Run all tests and linting"
echo " β€’ rake run_rspec - Run Ruby tests"
echo " β€’ yarn run test - Run JavaScript tests"
echo " β€’ bundle exec rubocop - Run Ruby linting (required before commits)"
echo " β€’ rake autofix - Auto-fix formatting issues"
echo ""
echo "⚠️ Remember: Always run 'bundle exec rubocop' before committing!"
10 changes: 10 additions & 0 deletions conductor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"scripts": {
"setup": "./conductor-setup.sh",
"run": "cd spec/dummy && bin/dev",
"test": "rake run_rspec:dummy",
"lint": "bundle exec rubocop && yarn run lint",
"archive": ""
},
"runScriptMode": "nonconcurrent"
}
Loading