Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9f3921f
refactor: reorganize into monorepo structure
justin808 Sep 29, 2025
b031070
feat: update to v16 and add enhanced demo scaffolding
justin808 Sep 29, 2025
fd8520c
feat: add pre-flight checks and dry-run mode to demo scripts
justin808 Sep 30, 2025
507be19
fix: remove bin/dev symlink from demo scripts
justin808 Sep 30, 2025
8265d7d
feat: add configurable gem versions with fallback defaults
justin808 Sep 30, 2025
9873588
docs: add comprehensive version management workflow
justin808 Sep 30, 2025
ae081c6
feat: convert demo scripts from Bash to Ruby with comprehensive tests
justin808 Sep 30, 2025
e7a74e1
fix: correct GitHub Actions workflow for PR base refs and shell quoting
justin808 Sep 30, 2025
2fed447
feat: add Lefthook pre-commit hooks for code quality
justin808 Sep 30, 2025
379dc76
chore: update RuboCop to latest and lint all files
justin808 Sep 30, 2025
1c501df
fix: address PR review comments - module rename, security fixes, and …
justin808 Sep 30, 2025
0a4eb78
chore: increase RuboCop ParameterLists max to 13 for DemoScaffolder
justin808 Oct 1, 2025
a019604
feat: add Prettier for code formatting at monorepo root
justin808 Oct 1, 2025
e008aaf
docs: enhance help messages and documentation for demo management com…
justin808 Oct 1, 2025
73b801a
refactor: rename .demo-versions to .new-demo-versions
justin808 Oct 1, 2025
4bf8d43
refactor: rename gem from demo_common to shakacode-demo-common
justin808 Oct 1, 2025
ffba293
refactor: rename gem from demo_common to shakacode_demo_common
justin808 Oct 1, 2025
a997e94
fix: correct variable expansion for CURRENT_DATE in scaffold-demo.sh
justin808 Oct 1, 2025
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
32 changes: 32 additions & 0 deletions .demo-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Default versions for React on Rails demo creation
# These are used when creating new demos unless overridden with command-line flags
#
# IMPORTANT: After creation, each demo's Gemfile controls its actual versions.
# Changing these values does NOT update existing demos.
#
# To update existing demos, see docs/VERSION_MANAGEMENT.md

# Shakapacker version (use ~> for compatibility range, or specific version)
SHAKAPACKER_VERSION="~> 8.0"

# React on Rails version (use ~> for compatibility range, or specific version)
REACT_ON_RAILS_VERSION="~> 16.0"

# ═══════════════════════════════════════════════════════════════════════
# Version Management Workflows
# ═══════════════════════════════════════════════════════════════════════
#
# Creating demos with stable versions:
# ./scripts/new-demo.sh my-demo
# (Uses versions above)
#
# Creating demos with custom versions:
# ./scripts/new-demo.sh my-demo --react-on-rails-version '~> 16.1'
#
# Creating demos with beta/RC versions:
# ./scripts/new-demo.sh beta-demo --react-on-rails-version '16.1.0.beta.1'
#
# Updating existing demos to new versions:
# ./scripts/update-all-demos.sh --react-on-rails-version '~> 16.1'
#
# For detailed workflows, see: docs/VERSION_MANAGEMENT.md
119 changes: 119 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: CI

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
lint-demo-common:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/demo_common
steps:
Comment on lines +14 to +15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | πŸ”΄ Critical

Fix paths to renamed package directory (breaking).

Jobs still use packages/demo_common. The repo renamed to packages/shakacode_demo_common, so steps will run in a non-existent path and fail.

Apply this diff:

-        working-directory: packages/demo_common
+        working-directory: packages/shakacode_demo_common
@@
-          working-directory: packages/demo_common
+          working-directory: packages/shakacode_demo_common
@@
-        working-directory: packages/demo_common
+        working-directory: packages/shakacode_demo_common
@@
-          working-directory: packages/demo_common
+          working-directory: packages/shakacode_demo_common
@@
-          cache-dependency-path: packages/demo_common/package-lock.json
+          cache-dependency-path: packages/shakacode_demo_common/package-lock.json
@@
-        working-directory: packages/demo_common
+        working-directory: packages/shakacode_demo_common
@@
-          cache-dependency-path: packages/demo_common/package-lock.json
+          cache-dependency-path: packages/shakacode_demo_common/package-lock.json

Also applies to: 22-22, 30-31, 38-38, 44-45, 54-55, 62-62

πŸ€– Prompt for AI Agents
.github/workflows/ci.yml around lines 14-15 (and also at 22, 30-31, 38, 44-45,
54-55, 62): CI steps reference the old package path packages/demo_common which
no longer exists; update every occurrence of packages/demo_common in this
workflow to the new directory name packages/shakacode_demo_common so all
working-directory and path entries point to the renamed package; ensure no
remaining references to the old name remain in the listed line ranges.

- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
working-directory: packages/demo_common
- name: Run RuboCop
run: bundle exec rubocop

test-demo-common:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/demo_common
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
working-directory: packages/demo_common
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: packages/demo_common/package-lock.json
- name: Install npm dependencies
run: npm ci
- name: Run tests
run: bundle exec rake spec

lint-javascript-demo-common:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/demo_common
steps:
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: packages/demo_common/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npm run lint
continue-on-error: true # Allow to continue if lint script doesn't exist
- name: Check Prettier formatting
run: npm run format:check
continue-on-error: true # Allow to continue if format script doesn't exist
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | πŸ”΄ Critical

🧩 Analysis chain

Verify that npm scripts exist before using continue-on-error.

Both npm run lint and npm run format:check use continue-on-error: true, which silently ignores failures if the scripts don't exist. This can mask configuration issues.

Run this script to verify the npm scripts are defined in package.json:


🏁 Script executed:

#!/bin/bash
# Description: Check if lint and format:check scripts exist in package.json

if [ -f "packages/demo_common/package.json" ]; then
  echo "Checking for npm scripts in packages/demo_common/package.json:"
  jq -r '.scripts | keys[]' packages/demo_common/package.json | grep -E '^(lint|format:check)$' || echo "Missing lint or format:check scripts"
else
  echo "package.json not found at packages/demo_common/package.json"
fi

Length of output: 176


Lint and formatting CI steps silently ignored
In .github/workflows/ci.yml (lines 66–70), the npm run lint and npm run format:check steps use continue-on-error: true despite the corresponding scripts missing in packages/demo_common/package.json. This masks failures.

  • Add lint and format:check scripts to packages/demo_common/package.json.
  • Remove continue-on-error: true so CI fails on errors.
  • Or switch to npm run lint --if-present and npm run format:check --if-present.
πŸ€– Prompt for AI Agents
.github/workflows/ci.yml lines 66-70: the workflow currently runs `npm run lint`
and `npm run format:check` with `continue-on-error: true`, which masks failures
because the scripts are missing; fix by either (A) adding `lint` and
`format:check` scripts to packages/demo_common/package.json so the commands
exist and then remove the `continue-on-error: true` lines so CI fails on errors,
or (B) update the workflow commands to `npm run lint --if-present` and `npm run
format:check --if-present` and remove `continue-on-error: true` so the steps are
no-ops when scripts are absent but still fail for real script errorsβ€”make the
change consistently for both steps and remove the `continue-on-error` keys.


# Matrix build for demos when they are added
test-demos:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
strategy:
matrix:
demo: [] # Will be populated as demos are added
fail-fast: false
steps:
Comment on lines 76 to 80
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Remove empty matrix; run loop without strategy.

Empty matrix triggers actionlint and adds no value since you already loop over demos.

Apply this diff:

-    strategy:
-      matrix:
-        demo: []  # Will be populated as demos are added
-      fail-fast: false
🧰 Tools
πŸͺ› actionlint (1.7.7)

78-78: "matrix values" section should not be empty

(syntax-check)

πŸ€– Prompt for AI Agents
.github/workflows/ci.yml around lines 76 to 80 contains an empty strategy.matrix
block which is unnecessary and triggers actionlint; remove the entire strategy
block (both matrix: and fail-fast: entries) so the job runs without a strategy,
leaving the steps section directly under the job definition and ensuring
indentation remains correct.

- uses: actions/checkout@v4
- name: Detect changed demos
id: changed-demos
run: |
if [ -d "demos" ] && [ "$(ls -A demos)" ]; then
CHANGED=$(git diff --name-only origin/main...HEAD | grep '^demos/' | cut -d/ -f2 | sort -u | head -5)
if [ -n "$CHANGED" ]; then
echo "demos=$CHANGED" >> $GITHUB_OUTPUT
fi
fi
- name: Set up Ruby
if: steps.changed-demos.outputs.demos
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: Set up Node
if: steps.changed-demos.outputs.demos
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Run demo tests
if: steps.changed-demos.outputs.demos
run: |
for demo in ${{ steps.changed-demos.outputs.demos }}; do
if [ -d "demos/$demo" ]; then
echo "Testing $demo..."
cd "demos/$demo"
if [ -f "Gemfile" ]; then
bundle install
fi
if [ -f "package.json" ]; then
npm ci
fi
if [ -f "bin/rails" ] && [ -f "spec" ]; then
bundle exec rspec
fi
cd ../..
fi
done
78 changes: 52 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,54 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
*.bundle
*.so
*.o
*.a
mkmf.log
# Dependencies
node_modules/
npm-debug.log*
yarn-error.log*
.DS_Store
*.log
.pnpm-debug.log*

# Build outputs
dist/
build/
tmp/
coverage/

# IDE
.idea/
.vscode/
.vscode/
*.swp
*.swo
*~
.DS_Store

# Environment
.env
.env.local
.env.*.local

# Ruby
*.gem
.bundle/
vendor/bundle/
.ruby-version
.ruby-gemset

# Rails
/demos/*/log/*
/demos/*/tmp/*
!/demos/*/log/.keep
!/demos/*/tmp/.keep
/demos/*/storage/*
!/demos/*/storage/.keep
/demos/*/public/assets
/demos/*/public/packs
/demos/*/public/packs-test
/demos/*/yarn-error.log

# Testing
/demos/*/coverage/
/demos/*/test/reports/

# Database
/demos/*/db/*.sqlite3
/demos/*/db/*.sqlite3-*

# Ignore master key for decrypting credentials and more
/demos/*/config/master.key
/demos/*/config/credentials.yml.enc
150 changes: 150 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Contributing to React on Rails Demos

Thank you for your interest in contributing to the React on Rails demo applications! This document provides guidelines and instructions for contributing.

## Code of Conduct

Please note that this project adheres to a code of conduct. By participating, you are expected to uphold this standard.

## Getting Started

1. Fork the repository
2. Clone your fork
3. Create a new branch for your feature or fix
4. Make your changes
5. Run tests and linting
6. Submit a pull request

## Development Setup

### Prerequisites

- Ruby 3.3+
- Node.js 20+
- PostgreSQL
- pnpm (recommended) or npm/yarn

### Initial Setup

```bash
# Clone the repository
git clone https://github.com/shakacode/react_on_rails-demos.git
cd react_on_rails-demos

# Bootstrap all demos
./scripts/bootstrap-all.sh
```

## Working with Demos

### Running a Specific Demo

```bash
cd demos/react_on_rails-demo-v16-[feature-name]
bin/dev
```

### Creating a New Demo

```bash
./scripts/new-demo.sh react_on_rails-demo-v16-your-feature

# Or use the scaffold script with options:
./scripts/scaffold-demo.sh react_on_rails-demo-v16-your-feature --typescript --tailwind
```

### Testing

Run tests for all demos:
```bash
./scripts/test-all.sh
```

Run tests for a specific demo:
```bash
cd demos/react_on_rails-demo-v16-[feature-name]
bundle exec rspec
```

## Code Style

All demos share common linting configurations:

### Ruby Code
```bash
bundle exec rubocop
```

### JavaScript/TypeScript Code
```bash
pnpm run lint
```

## Commit Guidelines

- Use clear, descriptive commit messages
- Follow conventional commit format when possible
- Reference issues in commit messages where applicable

Example:
```
feat: add TypeScript support to v16 demo

- Configure TypeScript with React on Rails
- Add type definitions for server rendering
- Update webpack configuration

Fixes #123
```

## Pull Request Process

1. **Update Documentation**: Ensure README files are updated with details of changes
2. **Run Tests**: Verify all tests pass locally
3. **Lint Code**: Ensure code passes all linting checks
4. **Update Changelog**: Add notes about your changes if significant
5. **Request Review**: Tag maintainers for review

### PR Title Format

Use descriptive titles that explain what the PR does:
- `feat: add React Server Components demo`
- `fix: correct webpack configuration in SSR demo`
- `docs: update setup instructions for demos`

## Demo Standards

Each demo should:

1. **Have a Clear Purpose**: Focus on demonstrating specific React on Rails features
2. **Include Documentation**: Provide a comprehensive README explaining:
- What features are demonstrated
- How to run the demo
- Key files to examine
- Any special configuration
3. **Follow Best Practices**: Use current React on Rails best practices
4. **Be Self-Contained**: Each demo should run independently
5. **Include Tests**: Add appropriate test coverage

## Shared Configuration

When modifying shared configuration in `packages/demo_common/`:

1. Test changes across multiple demos
2. Update documentation if configuration options change
3. Consider backward compatibility
4. Update the gem/npm package versions appropriately

## Questions and Support

- Open an issue for bugs or feature requests
- Join the [ShakaCode Slack](https://www.shakacode.com/slack-invite) for discussion
- Tag `@shakacode/react-on-rails` for React on Rails specific questions

## License

By contributing, you agree that your contributions will be licensed under the same license as the project.

## Acknowledgments

Thank you for helping make React on Rails better through clear, working examples!
Loading
Loading