This directory (gui/smalruby3-editor) is the monorepo root for the Smalruby 3 Editor, utilizing npm workspaces to manage the core packages of the visual programming environment.
Smalruby 3 is a fork of Scratch 3.0 that introduces Ruby programming capabilities. This monorepo aggregates the following key packages:
packages/scratch-gui: The React-based user interface. It includes the Ruby code editor (Ace Editor), the Opal transpiler configuration, and Smalruby-specific UI extensions.packages/scratch-vm: The execution engine. It has been modified to support the execution of Ruby code transpiled to JavaScript via Opal.packages/scratch-render: WebGL-based rendering engine.packages/scratch-svg-renderer: SVG handling and rendering.
CRITICAL: Docker Usage
As per the project's global mandates, ALL npm commands and development tasks must be performed within the Docker container (service name: app). Do not run npm install or build commands directly on the host machine to ensure environment consistency.
This project uses npm workspaces. The root package.json orchestrates commands across all packages.
- GUI:
packages/scratch-gui- Contains
opal/directory for Opal Ruby transpiler integration. scripts/make-setup-opal.js: Critical script for setting up Opal.
- Contains
- VM:
packages/scratch-vm- Handles the runtime logic for blocks and Ruby execution.
IMPORTANT: All npm commands MUST be run inside the Docker container using docker compose run --rm app.
Install dependencies for all workspaces:
docker compose run --rm app npm installBuild all packages:
docker compose run --rm app npm run buildBuild in development mode (faster, source maps):
docker compose run --rm app npm run build:devRun all tests (Unit + Integration) across all workspaces:
docker compose run --rm app npm testRun only unit tests:
docker compose run --rm app npm run test:unitRun only integration tests:
docker compose run --rm app npm run test:integrationRun ESLint across all workspaces:
docker compose run --rm app npm run lint# Run VM tests
docker compose run --rm app bash -c "cd packages/scratch-vm && npm test"
# Run specific tap tests
docker compose run --rm app bash -c "cd packages/scratch-vm && npm run tap:unit"
# Run a specific test
docker compose run --rm app bash -c "cd packages/scratch-vm && npx tap path/to/test"# Run GUI unit tests (runs ALL unit tests in the package)
docker compose run --rm app bash -c "cd packages/scratch-gui && npm run test:unit"
# Run a specific unit test
docker compose run --rm app bash -c "cd packages/scratch-gui && npx jest test/unit/components/action-menu.test.jsx"
# Run GUI integration tests (requires build:dev first; runs ALL integration tests)
docker compose run --rm app bash -c "cd packages/scratch-gui && npm run build:dev && npm run test:integration"
# Run a specific integration test (requires build:dev first)
docker compose run --rm app bash -c "cd packages/scratch-gui && npx jest test/integration/your-test.test.js"- Framework: React, Redux.
- Tests: Uses Jest for both unit and integration tests.
- Special Build Step:
npm run setup:opal(runs automatically before build) prepares the Opal transpiler environment. - Ruby Integration: Logic for the "Ruby" tab and code editor resides here.
- Tests: Uses Tap for unit and integration tests.
- Linting: Uses
eslintandformat-message. - Extension Support: Smalruby-specific extensions (like hardware support) are integrated here.
Before considering a task complete and preparing a Pull Request, follow these steps inside the Docker container:
- Verify Functionality: Ensure the changes work as expected and add new tests if applicable.
- Run Lint Checks:
docker compose run --rm app npm run lint
- Run Unit Tests:
# all tests docker compose run --rm app npm run test:unit # run specific test (scratch-vm or scratch-gui) docker compose run --rm app bash -c "cd /app/packages/scratch-vm && npm exec tap test/path/to/your-test.js" docker compose run --rm app bash -c "cd /app/packages/scratch-gui && npm exec jest test/path/to/your-test.js"
- Build the application:
docker compose run --rm app bash -c "cd /app/packages/scratch-gui && npm run build:dev" - Run Integration Tests (if applicable):
# all tests docker compose run --rm app npm run test:integration # run specific test (scratch-vm or scratch-gui) docker compose run --rm app bash -c "cd /app/packages/scratch-vm && npm exec tap test/path/to/your-test.js" docker compose run --rm app bash -c "cd /app/packages/scratch-gui && npm exec jest test/path/to/your-test.js"
- Debug with browser logs:
import SeleniumHelper from '../helpers/selenium-helper'; const { getLogs } = new SeleniumHelper(); test('Your test', async () => { // ... test code ... // Get all logs (INFO, WARNING, SEVERE) const logs = await getLogs({ includeAllLevels: true }); console.log('Browser logs:', logs); });
- Build Check: Ensure the project builds successfully.
docker compose run --rm app npm run build
- Git Status: Check for untracked files and ensure all changes are staged.
- Commit: Use Conventional Commits and ensure you are NOT on the
developbranch.
- Branching Strategy:
- The default branch is
develop. - NEVER commit directly to
develop. - Create feature branches from
develop(e.g.,fix/issue-description,feature/new-functionality). - All Pull Requests should target the
developbranch.
- The default branch is
- Commit Messages: This project enforces Conventional Commits (e.g.,
feat:,fix:,chore:,refactor:,docs:,test:). - GitHub Operations:
- Use the
ghcommand for GitHub access (issues, PRs). - Always target the Smalruby organization repositories, not upstream Scratch Foundation.
- For complex messages, use
gh ... -F <file>to avoid shell escaping issues.
- Use the
- Linting: Ensure
npm run lintpasses before committing. - Lockfile:
package-lock.jsonis maintained at the root level.