graftthis
v0.2.0
Published
A collection of utility tools for working with the RWSDK (Redwood SDK)
Readme
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 linkUsage
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 helpHow 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 routesThis command:
- Copies the
generateRoutes.tsscript to your project'ssrc/scriptsdirectory - Adds a
routesscript 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 routescomponentGenerator
The component tool helps generate and restructure React components for your RWSDK project using Plop.
npx graftthis componentThis command:
- Copies the
plopfile.mjsfile to your project's root directory - Copies component templates to a
plop-templatesdirectory - 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-alltailwindSetup
The tailwind tool sets up Tailwind CSS for your RWSDK project.
npx graftthis tailwindThis command:
- Creates a
src/app/styles.cssfile with the Tailwind import - Updates the
vite.config.mtsfile to:- Import the Tailwind plugin
- Add the environments config if needed
- Add Tailwind to the plugins array
- Updates the
src/app/Document.tsxfile 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/viteshadcnSetup
The shadcn tool sets up shadcn UI components for your RWSDK project.
npx graftthis shadcnThis command:
- Copies a pre-configured
components.jsonfile 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.jsonwith the baseUrl setting - Adds path aliases to
vite.config.tsfor the "@" import
- Updates
- Creates the necessary files:
- Adds a
src/app/lib/utils.tsfile with thecnutility function - Sets up
src/app/styles.csswith shadcn theme variables
- Adds a
- Updates the
src/app/Document.tsxfile 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
