A powerful CLI to add Pittaya UI components to your React/Next.js project with intelligent dependency management and AST-based detection.
No installation required! Use directly with npx:
npx pittaya@latest initCurrent Version: 0.0.9 (View Changelog)
- π― Smart Installation - Automatically detects and skips already installed components
- π Dependency Management - Intelligently installs component dependencies
- π‘οΈ Preserves Customizations - Won't overwrite your modified components
- π¦ Internal Dependencies - Components can declare dependencies on other Pittaya components
- π€ AST-Based Detection - 100% precision in detecting component dependencies using TypeScript Compiler API
- ποΈ Easy Removal - Remove components and clean up empty directories with a single command
- β‘ Fast & Efficient - Only installs what's needed
- π Update Management - Check for updates and update components easily
- π Component Discovery - List all available and installed components with detailed information
- π¨ Import Transformation - Automatically adjusts imports to your project structure
- π GitHub Registry - Components served via free CDN
- π Idempotent - Safe to run multiple times
- π¨ Multiple Styles - Choose from
default,new-york, orpittayadesign styles - π Auto-Detection - Automatically detects
src/directory structure - π Debug Tools - Built-in diagnostics for troubleshooting
π See ROADMAP.md for upcoming features and completed milestones
npx pittaya@latest initThis command will:
- Create a
components.jsonfile with your preferences - Install required base dependencies
- Configure import aliases
- Apply style-specific CSS variables to your globals.css
-y, --yes- Use default settings without prompts
npx pittaya@latest init -ynpx pittaya@latest add buttonnpx pittaya@latest add button badge skeletonnpx pittaya@latest add --allIf you don't specify components, it will enter interactive mode:
npx pittaya@latest add-y, --yes- Overwrite existing files without prompting-o, --overwrite- Overwrite existing files-a, --all- Add all components--add-missing-deps- Automatically install missing dependencies
Flag Comparison:
| Flag | Overwrites Files | Auto-Installs Dependencies |
|---|---|---|
--yes |
β Yes | β No |
--add-missing-deps |
β No | β Yes |
--yes --add-missing-deps |
β Yes | β Yes |
The CLI automatically detects if a component is already installed and skips reinstallation to preserve your customizations:
# Install orbit-images (which depends on button and utils)
npx pittaya@latest add orbit-imagesFirst run:
π¦ orbit-images requires: button, utils
β button installed successfully!
β utils installed successfully!
β orbit-images installed successfully!
Second run (components already installed):
βοΈ orbit-images already installed, skipping...
Benefits:
- π‘οΈ Preserves Customizations - Your modified components won't be overwritten
- β‘ Faster Installation - Doesn't reinstall dependencies unnecessarily
- π Idempotent - Running the same command multiple times is safe
Force Reinstallation:
npx pittaya@latest add button --overwriteπ Learn more: See SKIP_INSTALLED.md for detailed documentation.
When adding a component, the CLI automatically checks for required dependencies. If any are missing, you'll see:
npx pittaya@latest add buttonOutput:
β οΈ button requires the following dependencies:
β’ @radix-ui/react-slot
? Do you want to install the dependencies now? βΊ (Y/n)
Skip the prompt with --add-missing-deps:
npx pittaya@latest add button --add-missing-depsThis will automatically install all missing dependencies without asking.
Check if your installed components have updates available in the registry:
npx pittaya@latest diffThis will show you an interactive list of installed components to check.
npx pittaya@latest diff button orbit-imagesnpx pittaya@latest diff --allOutput:
π Components with updates available (2):
β’ button
ββ button.tsx (modified)
β’ orbit-images
ββ orbit-images.tsx (modified)
Run npx pittaya update <component> to update.
β
Components up to date (1):
β’ utils
Update your installed components to the latest version from the registry:
npx pittaya@latest updateThis will show you an interactive list of installed components to update.
npx pittaya@latest update buttonnpx pittaya@latest update --all-y, --yes- Skip confirmation prompts-f, --force- Force update even if no changes detected-a, --all- Update all installed components
Examples:
# Update all components without prompts
npx pittaya@latest update --all --yes
# Force update button (even if up to date)
npx pittaya@latest update button --forceOutput:
β
Updated 2 component(s):
β’ button
β’ orbit-images
βοΈ Skipped 1 component(s):
β’ utils (already up to date)
View all available and installed components:
npx pittaya@latest listThis will show all components from the registry, organized by category, with installation status.
--installed- Show only installed components--available- Show only available components--json- Output in JSON format
Remove installed components from your project:
npx pittaya@latest remove buttonIf you don't specify components, it will show a list of installed components to select for removal:
npx pittaya@latest remove-y, --yes- Skip confirmation prompt
Diagnose why a component is not being detected as installed:
npx pittaya@latest debug --component installation-sectionThis will show:
- Project structure (src/ vs root)
- Resolved alias paths
- Expected file locations
- Actual file existence
- Similar files found (helps identify naming issues)
Common issues it helps solve:
- File name mismatches (e.g.,
InstallationSection.tsxvsinstallation-section.tsx) - Wrong directory structure
- Incorrect
components.jsonconfiguration
Show the creators and contributors of Pittaya UI:
npx pittaya@latest credits- announcement-badge - Displays an announcement badge with customizable styles
- button - Displays a button or a component that looks like a button
- copy-button - A button that copies content to clipboard
- checkbox - A checkbox form control
- input - Text input field
- label - Form label component
- multi-select - Multi-selection dropdown component
- radio-group - Radio button group
- textarea - Multiline text input
- badge - Displays a badge with customizable styles
- card - Card container component
- carousel - Image carousel component
- command - Command palette component
- orbit-images - Displays images in an orbiting motion
- popover - Popover overlay component
- tabs - Tab navigation component
- installation-section - Displays installation instructions with code snippets
- utils - Utility functions for className management
π‘ Note: Components are available in three styles:
default,new-york, andpittaya. Each style has its own visual design and can include different implementations.
# 1. Install a component
npx pittaya add button
# 2. Customize it in your project
# Edit: src/components/ui/button.tsx
# Add your own styles, logic, etc.
# 3. Install other components that depend on button
npx pittaya add modal card dialog orbit-images
# β
Result: Your customized button is preserved!
# Only modal, card, dialog, and orbit-images are installed# Install a component with multiple dependencies
npx pittaya add orbit-images
# Output:
# π¦ orbit-images requires: button, utils
# β button installed successfully!
# β utils installed successfully!
# β orbit-images installed successfully!
# Run again - nothing is reinstalled
npx pittaya add orbit-images
# Output:
# βοΈ orbit-images already installed, skipping...# Want to reset a component to its original state?
npx pittaya add button --overwrite
# This will:
# β
Overwrite the existing button.tsx
# β
Keep your other customized components intactThe components.json file stores your preferences:
{
"$schema": "https://raw.githubusercontent.com/pittaya-ui/ui/main/registry/schema.json",
"style": "pittaya",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"iconLibrary": "lucide"
}default- Clean and minimal designnew-york- Modern and sophisticated look (inspired by shadcn/ui)pittaya- Rounded and vibrant design with primary colors
Each style provides different visual implementations of the same components.
Components can declare dependencies on other Pittaya components using internalDependencies in the components-index.ts file:
// ui/src/lib/docs/components-index.ts
{
slug: "orbit-images",
name: "Orbit Images",
description: "Displays a set of images in an orbiting motion.",
category: "Components",
dependencies: ["framer-motion"], // NPM dependencies
internalDependencies: ["button"], // Pittaya components
}When the registry is built, internalDependencies are automatically added to registryDependencies:
{
"name": "orbit-images",
"registryDependencies": [
"button", // β¬
οΈ From internalDependencies
"utils" // β¬
οΈ Auto-detected from code via AST
]
}When a user installs the component, all dependencies are automatically installed:
npx pittaya add orbit-imagesThis will automatically install: orbit-images β button β utils
π Learn more: See INTERNAL_DEPENDENCIES.md for detailed documentation.
The registry can be built from two sources. Configure via .env file:
- Copy the template:
cp .env.example .env- Edit
.env:
# GitHub mode (default) - Fetches from repository
USE_LOCAL_UI=false
# Local mode - Uses ../ui directory
# USE_LOCAL_UI=trueFetches components directly from pittaya-ui/ui:
npm run build:registryAdvantages:
- β No need to clone UI repository
- β
Always uses latest from
mainbranch - β Works in CI/CD environments
- β Completely decoupled repos
Uses local UI repo (../ui relative to CLI):
# Set in .env:
USE_LOCAL_UI=true
# Then run:
npm run build:registryWhen to use:
- Testing unreleased components
- Working on UI and CLI simultaneously
- No internet connection
cd packages/cli
npm run build# Test the built CLI
npm link
pittaya --versionnpm run pub:releaseβ Expected output:
# In a completely new project
npx create-next-app@latest test-published --typescript --tailwind --app
cd test-published
# Test with npx
npx pittaya@latest init -y
npx pittaya@latest add button
# Verify
cat src/components/ui/button.tsx
npm run devFollow Semantic Versioning:
cd packages/cli
# Patch version (0.0.x) - Bug fixes
npm version patch
# Minor version (0.x.0) - New features
npm version minor
# Major version (x.0.0) - Breaking changes
npm version major
# Then publish
npm run pub:release# 1. Make changes to CLI code
# 2. Update version
cd packages/cli
npm version patch # or minor/major
# 3. Build and publish
npm run pub:release
# 4. Commit version bump
cd ../..
git add packages/cli/package.json
git commit -m "chore: bump cli to 0.0.10"
git pushBefore publishing or committing registry changes, validate that all components have correct NPM dependencies declared:
# From root directory
npm run validate:depsThis will check all components and report any missing dependencies:
π Validating dependencies in registry components...
β
button - 2 dependencies OK
β installation-section
Declared: [react-syntax-highlighter]
Detected: [lucide-react, react-syntax-highlighter, sonner]
Missing: [lucide-react, sonner]
π Summary:
Total components: 19
With errors: 1
Valid: 18Fix missing dependencies:
- Open the component JSON file (e.g.,
registry/styles/pittaya/components/installation-section.json) - Add missing dependencies to the
dependenciesarray - Run
npm run validate:depsagain to confirm
See: DEPENDENCY_VALIDATION.md for detailed documentation.
Error: "Package name already taken"
# Update name in packages/cli/package.json
{
"name": "@pittaya-ui/cli" // or another name
}Error: "Permission denied"
npm whoami # Check if logged in
npm logout
npm loginError: "Must provide one-time password"
# 2FA is enabled, use OTP from authenticator app
npm publish --otp=123456- Style-Specific Registry - Components are organized by style (
default,new-york,pittaya) - GitHub Registry - Components are hosted via GitHub Raw (free CDN)
- Smart Detection - CLI checks if components are already installed before adding them
- AST-Based Analysis - Uses TypeScript Compiler API to detect dependencies with 100% accuracy
- Internal Dependencies - Components can declare dependencies on other Pittaya components
- Automatic Installation - NPM dependencies and related components are installed automatically
- Skip Installed - Already installed components are skipped to preserve customizations
- Import Transformation - Imports are adjusted according to your aliases
- Auto-Detection - Automatically detects
src/directory structure - No Vendor Lock-in - Components are copied to your project, you have full control
User runs: npx pittaya add orbit-images
1. Check if orbit-images is installed β
ββ Not installed, proceed
2. Fetch orbit-images from registry β
ββ Found: registryDependencies: [button, utils]
3. Install dependencies:
ββ Check if button is installed
β ββ Not installed, install button
β ββ Check NPM deps: @radix-ui/react-slot
β ββ Install to: src/components/ui/button.tsx
β
ββ Check if utils is installed
ββ Not installed, install utils
ββ Check NPM deps: clsx, tailwind-merge
ββ Install to: src/lib/utils.ts
4. Install orbit-images β
ββ Install to: src/components/ui/orbit-images.tsx
β
Done! All components and dependencies installed.
On second run:
User runs: npx pittaya add orbit-images
1. Check if orbit-images is installed β
ββ Already installed, skip!
βοΈ orbit-images already installed, skipping...
- Main Documentation
- Roadmap - πΊοΈ Future plans and completed features
- Changelog - Version history and changes
- Architecture Decision Records (ADRs) - Architectural decisions and rationale
- Internal Dependencies Guide
- Skip Installed Components Guide
- GitHub - CLI & UI Monorepo
- Component Registry - Default Style
- Component Registry - New York Style
- Component Registry - Pittaya Style
Contributions are welcome! See our:
- Contributing Guide - How to contribute
- Roadmap - Features we're working on
- ADRs - Architectural decisions
Proprietary Use License - You may use this CLI in any project, but you may not modify or redistribute the source code.
See LICENSE for full terms.
Β© 2025 Pittaya UI - All rights reserved