react-component-scaffolder
Version:
CLI tool for scaffolding accessible React components with built-in Storybook stories, Jest tests, and markdown documentation
146 lines (122 loc) โข 3.89 kB
Markdown
Welcome to the react-component-scaffolder CLI tool! This utility streamlines the creation of accessible React components with TypeScript or JavaScript, offering options for tests, Storybook stories, and Markdown documentation.
[](https://www.npmjs.com/package/react-component-scaffolder)
[](https://www.npmjs.com/package/react-component-scaffolder)
- **Language Flexibility** โ Choose between TypeScript (`ts`) or JavaScript (`js`) by using the `--lang` flag
- **Optional File Generation** โ Add:
- `--with-tests`: ๐งช Jest test file
- `--with-story`: ๐ Storybook story file
- `--with-docs`: ๐ Markdown documentation
- **WCAG-Compliant Components** โ Built with accessibility in mind
- **Fast, Frictionless CLI** โ Generate and organize files with a single command
- **Contributor Friendly** โ Designed for open source extension, team templates, and automation
- โ๏ธ VS Code task integration and CLI flags
## ๐ Installation
```bash
npm install -g react-component-scaffolder
```
Or use it instantly:
```bash
npx react-component-scaffolder AccessibleButton --with-tests --with-story --with-docs
```
## ๐ ๏ธ Usage
### Examples
```
react-component-scaffolder MyComponent --element=button
```
```
npx react-component-scaffolder AccessibleButton --with-tests --with-story --with-docs
```
```
npx react-component-scaffolder AccessibleInput --with-tests --with-story
```
```
npx react-component-scaffolder AccessibleForm --with-story
```
```
npx react-component-scaffolder AccessibleTextarea
```
```
npx react-component-scaffolder AccessibleLabel --with-tests --with-story --with-docs
```
```
npx react-component-scaffolder AccessibleLink
```
| Flag | Description |
|------|-------------|
| --lang=js \| ts | Creates .js/.jsx files. Defaults to ts/tsx when flag ommitted
| --with-tests | Adds Jest test file |
| --with-story | Adds Storybook story |
| --with-docs | Adds Markdown file with prop documentation |
| --element | Override tag detection (e.g., input, form) |
| --help | Shows help info |
## ๐ฆ VS Code Integration
Add this to .vscode/tasks.json to run from Command Palette:
```
{
"version": "2.0.0",
"tasks": [
{
"label": "React Dev Scaffolder",
"type": "shell",
"command": "npx",
"args": [
"ts-node",
"scripts/generateComponent.ts",
"${input:componentName}",
"--with-tests",
"--with-story",
"--with-docs",
"--lang=${input:language}"
],
"group": "build",
"problemMatcher": [],
"detail": "Scaffold React component with tests, Storybook, and optional JS/TS output"
}
],
"inputs": [
{
"id": "componentName",
"type": "promptString",
"description": "Component name (e.g., Modal, FormFieldGroup)"
},
{
"id": "language",
"type": "pickString",
"description": "Choose language output",
"options": ["ts", "js"],
"default": "ts"
},
{
"id": "addDocs",
"type": "pickString",
"description": "Generate markdown docs?",
"options": ["yes", "no"],
"default": "yes"
}
]
}
```
Built by martinmqz โ scalable UI, accessibility, and automation enthusiast.
Initial release
Added support for TypeScript and JavaScript
Optional file generation for tests, Storybook, and Markdown documentation
Update
Changed output path to ./src/components folder
Update: Support links (anchor tags)