How rio-cloud/create-frontend works
Project type and purpose
• This is an open‐source CLI tool (a Node.js application) whose purpose is to scaffold opinionated React/Vite frontend projects.
• It provides a template directory containing a ready-to-go frontend stack (React, Redux Toolkit, RTK Query, React Router, MSW, etc.), and a set of CLI modules to customize and write out that template based on user-provided parameters (OAuth IDs, Sentry DSN, etc.).
File structure
• Top‐level:
• index.js – CLI entrypoint
• src/cli.js, src/tasks.js, src/util.js, src/rioLogo.js – core modules for parsing arguments, orchestrating tasks, utilities, and console art
• template/ – a complete React/Vite frontend project scaffold that will be copied and parameterized
• .github/, LICENSE, README.md, package.json, biome.json – CI, licensing, dependencies, formatting
• Patterns:
• A “template engine” pattern: copy-and-transform
• Task orchestration: CLI → tasks → utility functions → filesystem & child_process
• No web server or database inside this project—it’s purely a code generator.
README for additional insights
• Confirms it’s invoked via npm create rio-cloud/frontend <project-name>
• Lists the frontend stack (Vite, React, Redux Toolkit, RTK Query, MSW, React Hook Form, react-intl, Sentry, Renovate, Biome) – these are only in the template.
• Mentions external dependencies (OAuth, Sentry) that the generated project will integrate with but not used by the CLI itself except for parameter injection.
Main components and interactions
A. User & Environment
• The developer runs the CLI (npm create …) in a shell.
• CLI prompts (or reads flags) for OAuth/Sentry params.
B. CLI Core (Node.js process)
1. index.js
– Bootstraps the CLI, shows rio logo, forwards args to cli.js
2. src/cli.js
– Parses user input (project name, OAuth IDs, DSN)
– Calls tasks.js with parsed options
3. src/tasks.js
– High-level orchestration:
• Create project directory
• Copy template folder contents using fs.* functions
• Perform variable substitution in .env, package.json, config files
• Install dependencies (invoke npm install via child_process)
• Initialize git (if enabled)
• Output “Next steps” instructions
4. src/util.js
– Helpers for string templating, path resolution, logging, error handling
5. src/rioLogo.js
– ASCII art/logo displayed at startup
C. Template Directory
• A self-contained React/Vite project that includes:
– src/ (components, pages, routes, configuration, mocks, tests)
– package.json, tsconfig, Vite config, .env files, CI configs, mocks setup, Playwright config, Renovate, Biome, etc.
D. External Systems
• npm registry – to fetch packages when installing dependencies in the new project
• git – optional git init in the new project directory
• OAuth provider & Sentry – parameters injected into the scaffolded project for later runtime usage (no live calls at CLI time)
Architectural patterns and design principles
• Single‐responsibility modules: cli, tasks, util, logo
• Template engine: treat the template folder as a source of truth; isolate transformation logic
• Sequential task orchestration: each step produces the inputs for the next
• Minimal external side‐effects (only FS and child_process calls)