rwsdk-tools
v0.5.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 rwsdk-tools
# or for local development
npm linkUsage
Run the command-line tool to install utilities:
# Install all available tools
npx rwsdk-tools
# Install specific tools
npx rwsdk-tools routes
npx rwsdk-tools component
npx rwsdk-tools tailwind
npx rwsdk-tools seedtosql
npx rwsdk-tools merge
npx rwsdk-tools email
npx rwsdk-tools windsurf
npx rwsdk-tools addon generate
npx rwsdk-tools addon install
# Show help
npx rwsdk-tools 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 rwsdk-tools 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 rwsdk-tools 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 rwsdk-tools 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 rwsdk-tools 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.
seedToSql
The seedToSql tool converts Redwood.js seed files to raw SQL statements that can be executed directly against your database.
npx rwsdk-tools seedtosqlThis command:
- Copies the
seedToSql.mjsscript to your project'ssrc/scriptsdirectory - Makes the script executable
- Adds a
seedtosqlscript to your project's package.json file that runs:node src/scripts/seedToSql.mjs
After installation, you can convert seed files to SQL by running:
# Convert the default seed file (or specify a custom one)
pnpm run seedtosql
# Convert a specific seed file
pnpm run seedtosql -- --input <path-to-seed-file> [--output <path-to-output-sql>]Features:
- Converts Prisma
createoperations toINSERTstatements - Converts Prisma
createManyoperations to multipleINSERTstatements - Preserves raw SQL commands from
$executeRawUnsafe - Handles nested relations and connections
- Supports TypeScript and JavaScript seed files
- No external dependencies required
mergePrisma
The merge tool combines multiple Prisma schema files into a single schema.prisma file.
npx rwsdk-tools mergeThis command:
- Copies the
mergePrismaSchema.mjsscript to your project'ssrc/scriptsdirectory - Adds a
mergescript to your project's package.json file that runs:node src/scripts/mergePrismaSchema.mjs
After installation, you can merge your Prisma schemas by running:
pnpm mergeaddonGenerate
The addon generate tool helps generate configuration files for RedwoodSDK addons.
npx rwsdk-tools addon generateThis command:
- Copies the
generateAddonConfig.mjsscript to your project'ssrc/scriptsdirectory - Adds an
addon:generatescript to your project's package.json file that runs:node src/scripts/generateAddonConfig.mjs
After installation, you can generate addon configuration by running:
pnpm addon:generate <addonName>The script analyzes an add-on's content and dynamically generates the addon.jsonc file by scanning imports, environment variables, CSS files, and other components.
addonInstall
The addon install tool helps install RedwoodSDK addons into your project.
npx rwsdk-tools addon installThis command:
- Copies the
installAddon.mjsscript to your project'ssrc/scriptsdirectory - Adds an
addon:installscript to your project's package.json file that runs:node src/scripts/installAddon.mjs
After installation, you can install addons by running:
pnpm addon:install install <addonName> [options]Options:
--repo <url>: Install from a GitHub repository--source <path>: Full path to the addon directory--dest <path>: Destination directory (defaults to src/app/addons)
The script handles all aspects of installing an addon, including copying files, installing dependencies, setting up environment variables, injecting CSS styles, adding routes, and setting up Prisma schema.
Features:
- Automatically finds and merges all .prisma files from specified directories
- Backs up existing schema.prisma file to schema.prisma.bak before overwriting it
- Includes the backup file content in the merge process to preserve existing schema
- Uses .bak extension to avoid Prisma validation errors with duplicate models
- Intelligently merges models with the same name, preserving unique fields
- Handles generators, datasources, models, and enums
- Supports commented model additions with special syntax
- Sorts models alphabetically for better readability
The email tool sets up email functionality for your RWSDK project using Resend.
npx rwsdk-tools emailThis command:
- Installs the
resendpackage using pnpm - Adds a
RESEND_APIvariable to your project's.envfile - Creates an
email.tsfile in thesrc/app/libdirectory - Asks if you want to install React Email for creating email templates
After installation, you can use the Resend client in your application:
import { resend } from 'src/app/lib/email';
// Send an email
await resend.emails.send({
from: '[email protected]',
to: '[email protected]',
subject: 'Hello World',
html: '<p>Hello world!</p>',
});Features:
- Seamless integration with Resend's email API
- Environment variable setup for secure API key storage
- Optional React Email integration for beautiful, responsive email templates
- Works with Cloudflare Workers environment variables
- Simple, clean API for sending emails from your application
windsurf
The windsurf tool sets up configuration for code quality checks and workflows in your RWSDK project.
npx rwsdk-tools windsurfThis command:
- Creates a
.windsurfdirectory in your project root (if it doesn't already exist) - Copies default rules to the
.windsurf/rulesdirectory - Copies workflow templates to the
.windsurf/workflowsdirectory
After installation, you can customize the Windsurf configuration by editing the files in the .windsurf directory.
Features:
- Pre-configured code quality rules
- Workflow templates for pre-commit and PR checks
- Non-destructive installation that preserves existing configurations
- Custom rule definitions for project-specific requirements
- Integrated workflow templates that work with common package managers
Requirements
- Node.js 14+
- RWSDK
