GraftThis
A command-line tool for installing utility tools that work with the RWSDK (Redwood SDK).
Installation
npm install -g graftthis
# or for local development
npm link
Usage
Run the command-line tool to install utilities:
# Install all available tools
npx graftthis
# Install specific tools
npx graftthis routes
npx graftthis component
npx graftthis tailwind
# Show help
npx graftthis help
How It Works
This package provides a simple command-line interface to install utility tools for RWSDK projects. When you run a command, it:
- Copies the necessary files to your project
- Adds appropriate scripts to your package.json
- Sets up everything so you can use the tools immediately
Available Tools
generateRoutes
The generateRoutes
tool helps generate routes for your RWSDK project.
npx graftthis routes
This command:
- Copies the
generateRoutes.ts
script to your project'ssrc/scripts
directory - Adds a
routes
script to your project's package.json file that runs:npx tsx src/scripts/generateRoutes.ts
After installation, you can generate routes by running:
npm run routes
componentGenerator
The component
tool helps generate and restructure React components for your RWSDK project using Plop.
npx graftthis component
This command:
- Copies the
plopfile.mjs
file to your project's root directory - Copies component templates to a
plop-templates
directory - Adds the following scripts to your project's package.json:
plop
: Run the plop CLIcomponent
: Generate a new componentrestructure
: Restructure an existing componentrestructure-all
: Restructure all components in a directory
- Automatically installs plop as a dev dependency if it's not already installed
After installation, you can use the component generator by running:
# Generate a new component
npm run component
# Restructure an existing component
npm run restructure
# Restructure all components
npm run restructure-all
tailwindSetup
The tailwind
tool sets up Tailwind CSS for your RWSDK project.
npx graftthis tailwind
This command:
- Creates a
src/app/styles.css
file with the Tailwind import - Updates the
vite.config.mts
file to:- Import the Tailwind plugin
- Add the environments config if needed
- Add Tailwind to the plugins array
- Updates the
src/app/Document.tsx
file to:- Import the styles
- Add a link tag to the head
- Prompts you to install the required dependencies
The command will automatically install the required dependencies for you:
pnpm install tailwindcss @tailwindcss/vite
shadcnSetup
The shadcn
tool sets up shadcn UI components for your RWSDK project.
npx graftthis shadcn
This command:
- Copies a pre-configured
components.json
file to your project's root directory - Installs all necessary dependencies for shadcn UI:
- class-variance-authority
- clsx
- tailwind-merge
- lucide-react
- @radix-ui/react-slot
- tw-animate-css
- Sets up the required configuration:
- Updates
tsconfig.json
with the baseUrl setting - Adds path aliases to
vite.config.ts
for the "@" import
- Updates
- Creates the necessary files:
- Adds a
src/app/lib/utils.ts
file with thecn
utility function - Sets up
src/app/styles.css
with shadcn theme variables
- Adds a
- Updates the
src/app/Document.tsx
file to:- Import the styles
- Add a link tag to the head
After installation, you can add shadcn components to your project by installing the specific Radix UI components you need and copying the component code from the shadcn website.
Requirements
- Node.js 14+
- RWSDK