@foundrykit/cli 0.1.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/commands/init.ts","../src/commands/list.ts","../src/lib/registry.ts","../src/commands/add.ts","../src/commands/update.ts","../src/commands/doctor.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { initCommand } from './commands/init.js';\nimport { listCommand } from './commands/list.js';\nimport { addCommand } from './commands/add.js';\nimport { updateCommand } from './commands/update.js';\nimport { doctorCommand } from './commands/doctor.js';\n\nconst program = new Command();\n\nprogram\n .name('foundrykit')\n .description('FoundryKit CLI - Component library management tool')\n .version('0.1.0');\n\n// Add commands\nprogram.addCommand(initCommand());\nprogram.addCommand(listCommand());\nprogram.addCommand(addCommand());\nprogram.addCommand(updateCommand());\nprogram.addCommand(doctorCommand());\n\nprogram.parse();\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { execSync } from 'child_process';\nimport inquirer from 'inquirer';\n\ninterface InitOptions {\n force?: boolean;\n skipInstall?: boolean;\n}\n\nexport function initCommand() {\n return new Command('init')\n .description('Initialize FoundryKit in your Next.js project')\n .option('-f, --force', 'overwrite existing files')\n .option('--skip-install', 'skip installing dependencies')\n .action(async (options: InitOptions) => {\n try {\n console.log(chalk.blue('šŸš€ Initializing FoundryKit...'));\n\n // Check if it's a Next.js project\n await validateNextJsProject();\n\n // Check if already initialized\n if (!options.force && (await isFoundryKitInitialized())) {\n const { shouldContinue } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'shouldContinue',\n message: 'FoundryKit is already initialized. Continue anyway?',\n default: false,\n },\n ]);\n\n if (!shouldContinue) {\n console.log(chalk.yellow('āŒ Initialization cancelled.'));\n return;\n }\n }\n\n // Install dependencies\n if (!options.skipInstall) {\n await installDependencies();\n }\n\n // Setup CSS with Tailwind v4\n await setupTailwindV4();\n\n // Create components directory\n await createDirectories();\n\n // Create example files\n await createExampleFiles();\n\n // Update package.json scripts\n await updatePackageScripts();\n\n console.log(chalk.green('\\nāœ… FoundryKit initialized successfully!'));\n console.log(chalk.cyan('\\nšŸ“¦ Next steps:'));\n console.log(\n chalk.gray(\n ' 1. Add a component: npx @foundrykit/cli add hero-minimal'\n )\n );\n console.log(\n chalk.gray(' 2. List available components: npx @foundrykit/cli list')\n );\n console.log(\n chalk.gray(' 3. Check out the docs: https://foundrykit.dev')\n );\n } catch (error) {\n console.error(chalk.red('āŒ Failed to initialize FoundryKit:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\nasync function validateNextJsProject(): Promise<void> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(\n 'No package.json found. Please run this command in a Next.js project root.'\n );\n }\n\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n if (!dependencies.next) {\n throw new Error(\n 'Next.js not detected. This command should be run in a Next.js project.'\n );\n }\n\n console.log(chalk.green('āœ… Next.js project detected'));\n}\n\nasync function isFoundryKitInitialized(): Promise<boolean> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check if any FoundryKit packages are installed\n return Object.keys(dependencies).some(dep =>\n dep.startsWith('@foundrykit/')\n );\n }\n\n return false;\n}\n\nasync function installDependencies(): Promise<void> {\n console.log(chalk.blue('šŸ“¦ Installing FoundryKit dependencies...'));\n\n // Check if we're in a workspace (local development)\n const isWorkspace = await checkIfWorkspace();\n\n if (isWorkspace) {\n console.log(\n chalk.yellow('āš ļø Workspace detected - skipping dependency installation')\n );\n console.log(chalk.gray('Dependencies are already available via workspace'));\n return;\n }\n\n const dependencies = [\n '@foundrykit/primitives',\n '@foundrykit/components',\n '@foundrykit/blocks',\n '@foundrykit/hooks',\n '@foundrykit/animation',\n '@foundrykit/tailwind',\n ];\n\n try {\n // Detect package manager\n const packageManager = detectPackageManager();\n console.log(chalk.gray(`Using ${packageManager}...`));\n\n const installCmd =\n packageManager === 'npm'\n ? `npm install ${dependencies.join(' ')}`\n : packageManager === 'yarn'\n ? `yarn add ${dependencies.join(' ')}`\n : `pnpm add ${dependencies.join(' ')}`;\n\n execSync(installCmd, { stdio: 'inherit' });\n console.log(chalk.green('āœ… Dependencies installed'));\n } catch (error) {\n throw new Error(\n 'Failed to install dependencies. Please install them manually.'\n );\n }\n}\n\nasync function checkIfWorkspace(): Promise<boolean> {\n try {\n // Check for pnpm workspace\n const pnpmWorkspacePath = path.join(\n process.cwd(),\n '../../pnpm-workspace.yaml'\n );\n if (fs.existsSync(pnpmWorkspacePath)) {\n return true;\n }\n\n // Check package.json for workspace packages\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = await fs.readJson(packageJsonPath);\n const allDeps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check if any FoundryKit packages use workspace protocol\n const foundryKitPackages = Object.keys(allDeps).filter(key =>\n key.startsWith('@foundrykit/')\n );\n for (const pkg of foundryKitPackages) {\n if (allDeps[pkg]?.includes('workspace:')) {\n return true;\n }\n }\n }\n\n return false;\n } catch {\n return false;\n }\n}\n\nfunction detectPackageManager(): string {\n if (fs.existsSync('pnpm-lock.yaml')) return 'pnpm';\n if (fs.existsSync('yarn.lock')) return 'yarn';\n return 'npm';\n}\n\nasync function setupTailwindV4(): Promise<void> {\n console.log(chalk.blue('āš™ļø Setting up Tailwind CSS v4...'));\n\n // First check if layout already imports FoundryKit styles\n const layoutInfo = await findLayoutFile();\n if (layoutInfo) {\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing FoundryKit styles directly\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n const { importPreference } = await inquirer.prompt([\n {\n type: 'list',\n name: 'importPreference',\n message:\n 'FoundryKit styles are already imported directly. How would you like to proceed?',\n choices: [\n {\n name: 'Keep direct import from @foundrykit/tailwind/globals.css',\n value: 'direct',\n },\n {\n name: 'Switch to local globals.css file (recommended for customization)',\n value: 'local',\n },\n ],\n default: 'direct',\n },\n ]);\n\n if (importPreference === 'direct') {\n console.log(\n chalk.green(\n 'āœ… Keeping direct import from @foundrykit/tailwind/globals.css'\n )\n );\n return;\n }\n\n // User wants to switch to local globals.css\n await createLocalGlobalsAndUpdateLayout(layoutInfo.path, layoutContent);\n return;\n }\n\n // Check if importing a local globals.css\n const globalsCssImportMatch = layoutContent.match(\n /import\\s+['\"]([^'\"]*globals\\.css)['\"]/\n );\n if (globalsCssImportMatch && globalsCssImportMatch[1]) {\n // Local globals.css is imported, check if it needs updating\n const importPath = globalsCssImportMatch[1];\n const resolvedPath = importPath.startsWith('.')\n ? path.join(path.dirname(layoutInfo.path), importPath)\n : path.join(process.cwd(), importPath.replace(/^@\\//, 'app/'));\n\n if (fs.existsSync(resolvedPath)) {\n const globalsCssContent = await fs.readFile(resolvedPath, 'utf-8');\n if (globalsCssContent.includes('@foundrykit/tailwind/globals.css')) {\n console.log(chalk.green('āœ… FoundryKit styles already configured'));\n return;\n }\n\n // Update existing globals.css\n const updatedContent = `/* Import FoundryKit's Tailwind CSS v4 styles */\n@import \"@foundrykit/tailwind/globals.css\";\n\n/* Your custom styles below */\n${globalsCssContent}`;\n\n await fs.writeFile(resolvedPath, updatedContent);\n console.log(\n chalk.green('āœ… Updated existing globals.css with FoundryKit styles')\n );\n return;\n }\n }\n }\n\n // No existing setup found, ask user preference\n const { setupPreference } = await inquirer.prompt([\n {\n type: 'list',\n name: 'setupPreference',\n message: 'How would you like to import FoundryKit styles?',\n choices: [\n {\n name: 'Create a local globals.css file (recommended for customization)',\n value: 'local',\n },\n {\n name: 'Import directly from @foundrykit/tailwind/globals.css',\n value: 'direct',\n },\n ],\n default: 'local',\n },\n ]);\n\n if (setupPreference === 'direct') {\n // Add direct import to layout\n await addDirectImportToLayout();\n } else {\n // Create local globals.css and update layout\n await createLocalGlobalsAndUpdateLayout();\n }\n}\n\nasync function createLocalGlobalsAndUpdateLayout(\n existingLayoutPath?: string,\n existingLayoutContent?: string\n): Promise<void> {\n // Find or create globals.css\n const possiblePaths = [\n 'app/globals.css',\n 'src/app/globals.css',\n 'styles/globals.css',\n 'src/styles/globals.css',\n ];\n\n let globalCssPath: string | null = null;\n for (const p of possiblePaths) {\n const fullPath = path.join(process.cwd(), p);\n if (fs.existsSync(fullPath)) {\n globalCssPath = fullPath;\n break;\n }\n }\n\n if (!globalCssPath) {\n // Create in app directory by default\n globalCssPath = path.join(process.cwd(), 'app/globals.css');\n await fs.ensureDir(path.dirname(globalCssPath));\n }\n\n // Check if the file already imports FoundryKit styles\n const existingContent = fs.existsSync(globalCssPath)\n ? await fs.readFile(globalCssPath, 'utf-8')\n : '';\n\n if (!existingContent.includes('@foundrykit/tailwind/globals.css')) {\n // Add FoundryKit import to globals.css\n const cssContent = `/* Import FoundryKit's Tailwind CSS v4 styles */\n@import \"@foundrykit/tailwind/globals.css\";\n\n/* Your custom styles below */\n${existingContent}`;\n\n await fs.writeFile(globalCssPath, cssContent);\n console.log(\n chalk.green('āœ… Created/updated globals.css with FoundryKit styles')\n );\n }\n\n // Update layout file\n if (existingLayoutPath && existingLayoutContent) {\n // Replace direct import with local globals.css\n const layoutDir = path.dirname(existingLayoutPath);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n const updatedContent = existingLayoutContent.replace(\n /@foundrykit\\/tailwind\\/globals\\.css/g,\n importPath\n );\n\n await fs.writeFile(existingLayoutPath, updatedContent);\n console.log(chalk.green('āœ… Updated layout to use local globals.css'));\n } else {\n // Add import to layout\n await updateLayoutImport(globalCssPath);\n }\n}\n\nasync function addDirectImportToLayout(): Promise<void> {\n const layoutInfo = await findLayoutFile();\n\n if (!layoutInfo) {\n console.log(\n chalk.yellow(\n 'āš ļø No layout file found. Please add this import to your layout manually:'\n )\n );\n console.log(chalk.gray(` import '@foundrykit/tailwind/globals.css';`));\n return;\n }\n\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n console.log(\n chalk.gray('Layout already imports FoundryKit styles directly')\n );\n return;\n }\n\n // Add import statement after existing imports\n const importStatement = `import '@foundrykit/tailwind/globals.css';`;\n\n // Find a good place to insert the import (after other imports)\n const importRegex = /^import\\s+.*$/gm;\n const imports = layoutContent.match(importRegex);\n\n let updatedContent: string;\n if (imports && imports.length > 0) {\n const lastImport = imports[imports.length - 1];\n const lastImportIndex = layoutContent.lastIndexOf(lastImport!);\n const insertPosition = lastImportIndex + lastImport!.length;\n\n updatedContent =\n layoutContent.slice(0, insertPosition) +\n '\\n' +\n importStatement +\n layoutContent.slice(insertPosition);\n } else {\n // No imports found, add at the beginning\n updatedContent = importStatement + '\\n' + layoutContent;\n }\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(\n chalk.green('āœ… Added direct import of FoundryKit styles to layout')\n );\n}\n\nasync function findLayoutFile(): Promise<{ path: string } | null> {\n const layoutPaths = [\n 'app/layout.tsx',\n 'app/layout.jsx',\n 'app/layout.js',\n 'src/app/layout.tsx',\n 'src/app/layout.jsx',\n 'src/app/layout.js',\n ];\n\n for (const p of layoutPaths) {\n const fullPath = path.join(process.cwd(), p);\n if (fs.existsSync(fullPath)) {\n return { path: fullPath };\n }\n }\n\n return null;\n}\n\nasync function updateLayoutImport(globalCssPath: string): Promise<void> {\n const layoutInfo = await findLayoutFile();\n\n if (!layoutInfo) {\n console.log(\n chalk.yellow(\n 'āš ļø No layout file found. Please import globals.css manually in your layout.'\n )\n );\n return;\n }\n\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing any globals.css\n if (layoutContent.match(/import\\s+['\"][^'\"]*globals\\.css['\"]/)) {\n console.log(chalk.gray('Layout already has a globals.css import'));\n return;\n }\n\n // Check if already importing FoundryKit styles directly\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n // Replace direct FoundryKit import with local globals.css\n const layoutDir = path.dirname(layoutInfo.path);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n const updatedContent = layoutContent.replace(\n /@foundrykit\\/tailwind\\/globals\\.css/g,\n importPath\n );\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(\n chalk.green('āœ… Updated layout import to use local globals.css')\n );\n return;\n }\n\n // Calculate relative import path\n const layoutDir = path.dirname(layoutInfo.path);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n // Add import statement after existing imports\n const importStatement = `import '${importPath}';`;\n\n // Find a good place to insert the import (after other imports)\n const importRegex = /^import\\s+.*$/gm;\n const imports = layoutContent.match(importRegex);\n\n let updatedContent: string;\n if (imports && imports.length > 0) {\n const lastImport = imports[imports.length - 1];\n const lastImportIndex = layoutContent.lastIndexOf(lastImport!);\n const insertPosition = lastImportIndex + lastImport!.length;\n\n updatedContent =\n layoutContent.slice(0, insertPosition) +\n '\\n' +\n importStatement +\n layoutContent.slice(insertPosition);\n } else {\n // No imports found, add at the beginning\n updatedContent = importStatement + '\\n' + layoutContent;\n }\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(chalk.green('āœ… Layout file updated with globals.css import'));\n}\n\nasync function createDirectories(): Promise<void> {\n console.log(chalk.blue('šŸ“ Creating component directories...'));\n\n const dirs = ['components/ui', 'components/blocks', 'lib', 'hooks'];\n\n for (const dir of dirs) {\n await fs.ensureDir(path.join(process.cwd(), dir));\n }\n\n console.log(chalk.green('āœ… Directories created'));\n}\n\nasync function createExampleFiles(): Promise<void> {\n console.log(chalk.blue('šŸ“ Creating example files...'));\n\n // Create lib/utils.ts\n const utilsPath = path.join(process.cwd(), 'lib/utils.ts');\n const utilsContent = `import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n`;\n\n if (!fs.existsSync(utilsPath)) {\n await fs.writeFile(utilsPath, utilsContent);\n console.log(chalk.gray('Created lib/utils.ts'));\n }\n\n // Create providers.tsx if using theme support\n const providersPath = path.join(process.cwd(), 'components/providers.tsx');\n const providersContent = `'use client';\n\nimport { ThemeProvider } from 'next-themes';\n\nexport function Providers({ children }: { children: React.ReactNode }) {\n return (\n <ThemeProvider attribute=\"class\" defaultTheme=\"system\" enableSystem>\n {children}\n </ThemeProvider>\n );\n}\n`;\n\n if (!fs.existsSync(providersPath)) {\n await fs.writeFile(providersPath, providersContent);\n console.log(chalk.gray('Created components/providers.tsx'));\n }\n\n console.log(chalk.green('āœ… Example files created'));\n}\n\nasync function updatePackageScripts(): Promise<void> {\n console.log(chalk.blue('šŸ“‹ Updating package.json scripts...'));\n\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n const packageJson = await fs.readJson(packageJsonPath);\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n // Add FoundryKit CLI scripts if they don't exist\n if (!packageJson.scripts['foundrykit']) {\n packageJson.scripts['foundrykit'] = 'foundrykit';\n }\n\n if (!packageJson.scripts['fk']) {\n packageJson.scripts['fk'] = 'foundrykit';\n }\n\n await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });\n console.log(chalk.green('āœ… Package scripts updated'));\n}\n","/**\n * List command for FoundryKit CLI\n * Displays available components from the registry\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport type { ComponentMeta, ComponentCategory } from '@foundrykit/types';\nimport { getRegistry } from '../lib/registry.js';\n\ninterface ListOptions {\n category?: string;\n search?: string;\n}\n\nexport function listCommand() {\n return new Command('list')\n .description('List all available FoundryKit components and blocks')\n .option(\n '-c, --category <category>',\n 'filter by category (primitives, components, blocks, animations)'\n )\n .option('-s, --search <term>', 'search components by name or description')\n .action(async (options: ListOptions) => {\n try {\n console.log(chalk.blue('šŸ“¦ Available FoundryKit components:'));\n\n const registry = getRegistry();\n\n // Validate category if provided\n if (options.category) {\n const validCategories: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n if (\n !validCategories.includes(options.category as ComponentCategory)\n ) {\n console.error(chalk.red(`Invalid category: ${options.category}`));\n console.log(\n chalk.gray(`Valid categories: ${validCategories.join(', ')}`)\n );\n process.exit(1);\n }\n }\n\n // Fetch components from registry\n console.log(chalk.gray('Fetching from registry...'));\n const components = await registry.getComponents(\n options.category,\n options.search\n );\n\n if (components.length === 0) {\n console.log(\n chalk.yellow('\\nNo components found matching your criteria.')\n );\n if (options.search) {\n console.log(chalk.gray(`Search term: \"${options.search}\"`));\n }\n if (options.category) {\n console.log(chalk.gray(`Category: ${options.category}`));\n }\n return;\n }\n\n // Group and display components\n displayComponents(components);\n\n // Show usage hints\n console.log(chalk.cyan('\\nšŸ’” Usage:'));\n console.log(\n chalk.gray(' foundrykit add # Interactive mode')\n );\n console.log(\n chalk.gray(' foundrykit add <id> # Add specific component')\n );\n console.log(chalk.gray(' foundrykit add button # Example'));\n } catch (error) {\n console.error(chalk.red('āŒ Failed to fetch component registry:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\n/**\n * Display components grouped by category\n */\nfunction displayComponents(components: ComponentMeta[]): void {\n // Group components by category\n const grouped = components.reduce(\n (acc, component) => {\n if (!acc[component.category]) {\n acc[component.category] = [];\n }\n acc[component.category].push(component);\n return acc;\n },\n {} as Record<ComponentCategory, ComponentMeta[]>\n );\n\n // Display in category order\n const categoryOrder: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n\n for (const category of categoryOrder) {\n const items = grouped[category];\n if (!items || items.length === 0) continue;\n\n console.log(`\\n${chalk.cyan.bold(category.toUpperCase())}`);\n console.log(chalk.gray('─'.repeat(40)));\n\n for (const item of items) {\n // Component name and ID\n console.log(\n `${chalk.green('ā—')} ${chalk.bold(item.name)} ${chalk.gray(\n `(${item.id})`\n )}`\n );\n\n // Description\n console.log(` ${chalk.gray(item.description)}`);\n\n // Tags\n if (item.tags && item.tags.length > 0) {\n console.log(\n ` ${chalk.blue(item.tags.map(tag => `#${tag}`).join(' '))}`\n );\n }\n\n // Dependencies\n if (item.registryDependencies && item.registryDependencies.length > 0) {\n console.log(\n ` ${chalk.yellow('Requires:')} ${item.registryDependencies.join(\n ', '\n )}`\n );\n }\n\n // Package dependencies\n if (item.packageDependencies && item.packageDependencies.length > 0) {\n console.log(\n ` ${chalk.magenta('NPM packages:')} ${item.packageDependencies.join(\n ', '\n )}`\n );\n }\n\n console.log();\n }\n }\n\n // Show summary\n const total = components.length;\n const byCategory = Object.entries(grouped)\n .map(([cat, items]) => `${items.length} ${cat}`)\n .join(', ');\n\n console.log(chalk.gray('─'.repeat(40)));\n console.log(chalk.gray(`Total: ${total} components (${byCategory})`));\n}\n","/**\n * Registry service for fetching and caching component data\n * Handles communication with the FoundryKit registry\n */\n\nimport fs from 'fs-extra';\nimport path from 'path';\nimport os from 'os';\nimport chalk from 'chalk';\nimport type {\n ComponentMeta,\n ComponentData,\n RegistryIndex,\n RegistryComponent,\n RegistryError,\n LocalCache,\n CLIConfig,\n} from '@foundrykit/types';\n\n/**\n * Default configuration\n */\nconst DEFAULT_CONFIG: CLIConfig = {\n registryUrl:\n process.env.FOUNDRYKIT_REGISTRY_URL || 'https://foundry.umiflow.com',\n cacheDir: path.join(os.homedir(), '.foundrykit', 'cache'),\n cacheMaxAge: 1000 * 60 * 60 * 24, // 24 hours\n};\n\n/**\n * Registry service class\n */\nexport class RegistryService {\n private config: CLIConfig;\n private cacheFile: string;\n\n constructor(config?: Partial<CLIConfig>) {\n this.config = { ...DEFAULT_CONFIG, ...config };\n this.cacheFile = path.join(this.config.cacheDir, 'registry.json');\n }\n\n /**\n * Fetch all components from the registry\n */\n async getComponents(\n category?: string,\n search?: string\n ): Promise<RegistryIndex> {\n try {\n // Build query params\n const params = new URLSearchParams();\n if (category) params.append('category', category);\n if (search) params.append('search', search);\n\n const url = `${this.config.registryUrl}/registry${\n params.toString() ? '?' + params.toString() : ''\n }`;\n\n console.log(chalk.gray(`Fetching from: ${url}`));\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Registry returned ${response.status}: ${response.statusText}`\n );\n }\n\n const components = (await response.json()) as RegistryIndex;\n\n // Update cache\n await this.updateCache(components);\n\n return components;\n } catch (error) {\n // Try to load from cache\n const cache = await this.loadCache();\n if (cache && this.isCacheValid(cache)) {\n console.log(chalk.yellow('Using cached registry data'));\n return this.filterComponents(cache.components, category, search);\n }\n\n // No valid cache, throw error\n throw new Error(\n `Failed to connect to registry: ${error instanceof Error ? error.message : 'Unknown error'}\\n` +\n `Registry URL: ${this.config.registryUrl}\\n` +\n `Try again later or check your internet connection.`\n );\n }\n }\n\n /**\n * Fetch a specific component by ID\n */\n async getComponent(id: string): Promise<ComponentData> {\n try {\n const url = `${this.config.registryUrl}/registry/${id}`;\n console.log(chalk.gray(`Fetching component: ${url}`));\n\n const response = await fetch(url);\n\n if (!response.ok) {\n if (response.status === 404) {\n throw new Error(`Component \"${id}\" not found in registry`);\n }\n throw new Error(\n `Registry returned ${response.status}: ${response.statusText}`\n );\n }\n\n const component = (await response.json()) as RegistryComponent;\n\n // Cache the component data\n await this.cacheComponent(component);\n\n return component;\n } catch (error) {\n // Try to load from cache\n const cache = await this.loadCache();\n if (cache?.componentData?.[id]) {\n console.log(chalk.yellow(`Using cached data for component: ${id}`));\n return cache.componentData[id];\n }\n\n // No cached data, throw error\n throw new Error(\n `Failed to fetch component \"${id}\": ${error instanceof Error ? error.message : 'Unknown error'}\\n` +\n `Registry URL: ${this.config.registryUrl}\\n` +\n `Try again later or check your internet connection.`\n );\n }\n }\n\n /**\n * Update the local cache with new component list\n */\n private async updateCache(components: RegistryIndex): Promise<void> {\n try {\n const cache = await this.loadCache();\n const newCache: LocalCache = {\n version: '1.0.0',\n lastUpdated: new Date().toISOString(),\n components,\n componentData: cache?.componentData || {},\n };\n\n await fs.ensureDir(this.config.cacheDir);\n await fs.writeJson(this.cacheFile, newCache, { spaces: 2 });\n } catch (error) {\n // Cache update failed, but don't throw - this is not critical\n console.log(chalk.gray('Failed to update cache'));\n }\n }\n\n /**\n * Cache a specific component\n */\n private async cacheComponent(component: ComponentData): Promise<void> {\n try {\n const cache = await this.loadCache();\n if (!cache) return;\n\n cache.componentData[component.id] = component;\n cache.lastUpdated = new Date().toISOString();\n\n await fs.writeJson(this.cacheFile, cache, { spaces: 2 });\n } catch (error) {\n // Cache update failed, but don't throw\n console.log(chalk.gray('Failed to cache component'));\n }\n }\n\n /**\n * Load the local cache\n */\n private async loadCache(): Promise<LocalCache | null> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n return await fs.readJson(this.cacheFile);\n }\n } catch (error) {\n console.log(chalk.gray('Failed to load cache'));\n }\n return null;\n }\n\n /**\n * Check if cache is still valid\n */\n private isCacheValid(cache: LocalCache): boolean {\n const lastUpdated = new Date(cache.lastUpdated).getTime();\n const now = Date.now();\n return now - lastUpdated < this.config.cacheMaxAge;\n }\n\n /**\n * Filter components by category and search\n */\n private filterComponents(\n components: ComponentMeta[],\n category?: string,\n search?: string\n ): ComponentMeta[] {\n let filtered = components;\n\n if (category) {\n filtered = filtered.filter(c => c.category === category);\n }\n\n if (search) {\n const searchLower = search.toLowerCase();\n filtered = filtered.filter(\n c =>\n c.name.toLowerCase().includes(searchLower) ||\n c.description.toLowerCase().includes(searchLower) ||\n c.id.toLowerCase().includes(searchLower) ||\n c.tags?.some(tag => tag.toLowerCase().includes(searchLower))\n );\n }\n\n return filtered;\n }\n\n /**\n * Clear the local cache\n */\n async clearCache(): Promise<void> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n await fs.remove(this.cacheFile);\n console.log(chalk.green('Cache cleared successfully'));\n }\n } catch (error) {\n throw new Error(\n `Failed to clear cache: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n\n /**\n * Get cache statistics\n */\n async getCacheStats(): Promise<{\n exists: boolean;\n size: number;\n lastUpdated: string | null;\n componentCount: number;\n }> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n const cache = await this.loadCache();\n const stats = await fs.stat(this.cacheFile);\n\n return {\n exists: true,\n size: stats.size,\n lastUpdated: cache?.lastUpdated || null,\n componentCount: cache?.components.length || 0,\n };\n }\n } catch (error) {\n // Ignore errors\n }\n\n return {\n exists: false,\n size: 0,\n lastUpdated: null,\n componentCount: 0,\n };\n }\n}\n\n/**\n * Singleton instance\n */\nlet registryInstance: RegistryService | null = null;\n\n/**\n * Get the registry service instance\n */\nexport function getRegistry(config?: Partial<CLIConfig>): RegistryService {\n if (!registryInstance) {\n registryInstance = new RegistryService(config);\n }\n return registryInstance;\n}\n\n/**\n * Reset the registry instance (mainly for testing)\n */\nexport function resetRegistry(): void {\n registryInstance = null;\n}\n","/**\n * Add command for FoundryKit CLI\n * Handles adding components to projects\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport inquirer from 'inquirer';\nimport type {\n ComponentMeta,\n ComponentData,\n ComponentCategory,\n} from '@foundrykit/types';\nimport { getRegistry } from '../lib/registry.js';\n\ninterface AddOptions {\n withAnimation?: boolean;\n path?: string;\n overwrite?: boolean;\n}\n\nexport function addCommand() {\n return new Command('add')\n .description('Add a component or block to your project')\n .argument('[id]', 'Component or block ID (optional for interactive mode)')\n .option('--with-animation', 'Include animation variants')\n .option('-p, --path <path>', 'Custom installation path')\n .option('-o, --overwrite', 'Overwrite existing files')\n .action(async (id: string | undefined, options: AddOptions) => {\n try {\n // If no ID provided, show interactive selector\n if (!id) {\n const selectedIds = await selectComponentsInteractively();\n if (selectedIds.length === 0) {\n console.log(chalk.yellow('No components selected.'));\n return;\n }\n\n // Add each selected component\n for (const componentId of selectedIds) {\n await addSingleComponent(componentId, options);\n }\n } else {\n // Add single component\n await addSingleComponent(id, options);\n }\n } catch (error) {\n console.error(chalk.red('āŒ Failed to add component:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\n/**\n * Interactive component selection\n */\nasync function selectComponentsInteractively(): Promise<string[]> {\n console.log(chalk.blue('šŸ“¦ Select components to add:'));\n console.log(\n chalk.gray(' Use arrow keys to navigate, space to select, a to toggle all')\n );\n console.log(chalk.gray(' Press enter when done\\n'));\n\n const registry = getRegistry();\n\n try {\n // Fetch all available components from registry\n console.log(chalk.gray('Fetching components from registry...'));\n const allComponents = await registry.getComponents();\n\n if (allComponents.length === 0) {\n console.log(chalk.yellow('No components available in the registry.'));\n return [];\n }\n\n // Group components by category\n const groupedChoices = createGroupedChoices(allComponents);\n\n const { selectedComponents } = await inquirer.prompt([\n {\n type: 'checkbox',\n name: 'selectedComponents',\n message: 'Which components would you like to add?',\n choices: groupedChoices,\n pageSize: 20,\n loop: false,\n },\n ]);\n\n return selectedComponents;\n } catch (error) {\n console.error(chalk.red('Failed to fetch components from registry:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n throw error;\n }\n}\n\n/**\n * Create grouped choices for the interactive selector\n */\nfunction createGroupedChoices(components: ComponentMeta[]) {\n const categories: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n\n const choices: any[] = [];\n\n for (const category of categories) {\n const categoryComponents = components.filter(c => c.category === category);\n\n if (categoryComponents.length === 0) continue;\n\n // Add category separator\n choices.push({\n name: chalk.bold.cyan(`─── ${category.toUpperCase()} ───`),\n disabled: true,\n value: `separator-${category}`,\n });\n\n // Add components in this category\n for (const component of categoryComponents) {\n choices.push({\n name: `${component.name} - ${chalk.gray(component.description)}`,\n value: component.id,\n short: component.name,\n });\n }\n }\n\n return choices;\n}\n\n/**\n * Add a single component to the project\n */\nasync function addSingleComponent(\n id: string,\n options: AddOptions\n): Promise<void> {\n console.log(chalk.blue(`\\nšŸ“¦ Adding ${id} to your project...`));\n\n // Validate project is initialized\n await validateProject();\n\n const registry = getRegistry();\n\n try {\n // Fetch component data from registry\n const componentData = await registry.getComponent(id);\n\n // Check for existing files\n if (\n !options.overwrite &&\n (await hasConflictingFiles(componentData, options))\n ) {\n const { shouldContinue } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'shouldContinue',\n message: `Some files for ${componentData.name} already exist. Overwrite?`,\n default: false,\n },\n ]);\n\n if (!shouldContinue) {\n console.log(chalk.yellow(`ā­ļø Skipping ${componentData.name}.`));\n return;\n }\n }\n\n // Install registry dependencies first\n if (componentData.registryDependencies?.length) {\n console.log(chalk.blue('šŸ“¦ Installing required dependencies...'));\n for (const dep of componentData.registryDependencies) {\n // Check if dependency is already installed\n const depData = await registry.getComponent(dep);\n if (!(await hasConflictingFiles(depData, options))) {\n await installComponentFiles(depData, options);\n console.log(chalk.green(` āœ“ Installed ${dep}`));\n }\n }\n }\n\n // Install the component files\n await installComponentFiles(componentData, options);\n\n console.log(chalk.green(`āœ… ${componentData.name} added successfully!`));\n\n // Show usage example\n showUsageExample(componentData);\n\n // Show package dependencies if any\n if (componentData.packageDependencies?.length) {\n console.log(chalk.yellow('\\nšŸ“¦ Required npm packages:'));\n console.log(\n chalk.gray(` ${componentData.packageDependencies.join(', ')}`)\n );\n console.log(chalk.gray(' Install them with:'));\n console.log(\n chalk.cyan(` pnpm add ${componentData.packageDependencies.join(' ')}`)\n );\n }\n } catch (error) {\n console.error(chalk.red(`Failed to add ${id}:`));\n throw error;\n }\n}\n\n/**\n * Validate that the project is properly initialized\n */\nasync function validateProject(): Promise<void> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(\n 'No package.json found. Please run this command in a project root.'\n );\n }\n\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check for Next.js or FoundryKit packages\n const hasFoundryKit = Object.keys(dependencies).some(dep =>\n dep.startsWith('@foundrykit/')\n );\n\n if (!hasFoundryKit && !dependencies.next) {\n throw new Error('FoundryKit not initialized. Run \"foundrykit init\" first.');\n }\n}\n\n/**\n * Check if component files already exist\n */\nasync function hasConflictingFiles(\n componentData: ComponentData,\n options: AddOptions\n): Promise<boolean> {\n const basePath = options.path || process.cwd();\n\n for (const file of componentData.files) {\n const filePath = path.join(basePath, file.path);\n if (fs.existsSync(filePath)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Install component files to the project\n */\nasync function installComponentFiles(\n componentData: ComponentData,\n options: AddOptions\n): Promise<void> {\n const basePath = options.path || process.cwd();\n\n console.log(chalk.blue('šŸ“ Installing component files...'));\n\n for (const file of componentData.files) {\n const filePath = path.join(basePath, file.path);\n\n // Ensure directory exists\n await fs.ensureDir(path.dirname(filePath));\n\n // Write file\n await fs.writeFile(filePath, file.content);\n\n console.log(chalk.green(` āœ“ ${file.path}`));\n }\n}\n\n/**\n * Show usage example for the installed component\n */\nfunction showUsageExample(componentData: ComponentData): void {\n console.log(chalk.cyan('\\nšŸ’” Usage:'));\n\n const componentName = componentData.name.replace(/\\s+/g, '');\n\n if (\n componentData.category === 'primitives' ||\n componentData.category === 'components'\n ) {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/ui/${componentData.id}\"`\n )\n );\n } else if (componentData.category === 'blocks') {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/blocks/${componentData.id}\"`\n )\n );\n } else if (componentData.category === 'animations') {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/animations/${componentData.id}\"`\n )\n );\n }\n\n // Show basic usage examples based on component type\n if (componentData.id === 'button') {\n console.log(chalk.gray('\\n<Button>Click me</Button>'));\n console.log(chalk.gray('<Button variant=\"outline\">Outline</Button>'));\n } else if (componentData.id === 'input') {\n console.log(chalk.gray('\\n<Input placeholder=\"Enter text...\" />'));\n } else if (componentData.id.includes('hero')) {\n console.log(chalk.gray(`\\n<${componentName} />`));\n } else if (componentData.id === 'card') {\n console.log(chalk.gray('\\n<Card>'));\n console.log(chalk.gray(' <CardHeader>'));\n console.log(chalk.gray(' <CardTitle>Title</CardTitle>'));\n console.log(\n chalk.gray(' <CardDescription>Description</CardDescription>')\n );\n console.log(chalk.gray(' </CardHeader>'));\n console.log(chalk.gray(' <CardContent>Content</CardContent>'));\n console.log(chalk.gray('</Card>'));\n }\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\n\nexport function updateCommand() {\n return new Command('update')\n .description('Update an existing component or block')\n .argument('<id>', 'Component or block ID')\n .action(async id => {\n console.log(chalk.blue(`šŸ”„ Updating ${id}...`));\n console.log(chalk.green(`āœ… ${id} updated successfully!`));\n });\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\n\nexport function doctorCommand() {\n return new Command('doctor')\n .description('Check project health and configuration')\n .action(async () => {\n console.log(chalk.blue('šŸ” Checking project health...'));\n console.log(chalk.green('āœ… All checks passed!'));\n });\n}\n"],"mappings":";;;AAEA,SAAS,WAAAA,gBAAe;;;ACFxB,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,gBAAgB;AACzB,OAAO,cAAc;AAOd,SAAS,cAAc;AAC5B,SAAO,IAAI,QAAQ,MAAM,EACtB,YAAY,+CAA+C,EAC3D,OAAO,eAAe,0BAA0B,EAChD,OAAO,kBAAkB,8BAA8B,EACvD,OAAO,OAAO,YAA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IAAID,SAAQ,QAAQ,EACxB,YAAY,uCAAuC,EACnD,SAAS,QAAQ,uBAAuB,EACxC,OAAO,OAAM,OAAM;AAClB,YAAQ,IAAIC,OAAM,KAAK,sBAAe,EAAE,KAAK,CAAC;AAC9C,YAAQ,IAAIA,OAAM,MAAM,UAAK,EAAE,wBAAwB,CAAC;AAAA,EAC1D,CAAC;AACL;;;ACXA,SAAS,WAAAC,gBAAe;AACxB,OAAOC,YAAW;AAEX,SAAS,gBAAgB;AAC9B,SAAO,IAAID,SAAQ,QAAQ,EACxB,YAAY,wCAAwC,EACpD,OAAO,YAAY;AAClB,YAAQ,IAAIC,OAAM,KAAK,sCAA+B,CAAC;AACvD,YAAQ,IAAIA,OAAM,MAAM,2BAAsB,CAAC;AAAA,EACjD,CAAC;AACL;;;ANDA,IAAM,UAAU,IAAIC,SAAQ;AAE5B,QACG,KAAK,YAAY,EACjB,YAAY,oDAAoD,EAChE,QAAQ,OAAO;AAGlB,QAAQ,WAAW,YAAY,CAAC;AAChC,QAAQ,WAAW,YAAY,CAAC;AAChC,QAAQ,WAAW,WAAW,CAAC;AAC/B,QAAQ,WAAW,cAAc,CAAC;AAClC,QAAQ,WAAW,cAAc,CAAC;AAElC,QAAQ,MAAM;","names":["Command","layoutDir","cssRelativePath","importPath","updatedContent","Command","chalk","fs","path","chalk","Command","chalk","Command","chalk","fs","path","inquirer","Command","chalk","inquirer","path","fs","Command","chalk","Command","chalk","Command"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/commands/init.ts","../src/commands/list.ts","../src/lib/registry.ts","../src/commands/add.ts","../src/commands/update.ts","../src/commands/doctor.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { readFileSync } from 'fs';\nimport { fileURLToPath } from 'url';\nimport { dirname, join } from 'path';\nimport { initCommand } from './commands/init.js';\nimport { listCommand } from './commands/list.js';\nimport { addCommand } from './commands/add.js';\nimport { updateCommand } from './commands/update.js';\nimport { doctorCommand } from './commands/doctor.js';\n\n// Get package.json version\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst packageJson = JSON.parse(\n readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')\n);\n\nconst program = new Command();\n\nprogram\n .name('foundrykit')\n .description('FoundryKit CLI - Component library management tool')\n .version(packageJson.version);\n\n// Add commands\nprogram.addCommand(initCommand());\nprogram.addCommand(listCommand());\nprogram.addCommand(addCommand());\nprogram.addCommand(updateCommand());\nprogram.addCommand(doctorCommand());\n\nprogram.parse();\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { execSync } from 'child_process';\nimport inquirer from 'inquirer';\n\ninterface InitOptions {\n force?: boolean;\n skipInstall?: boolean;\n}\n\nexport function initCommand() {\n return new Command('init')\n .description('Initialize FoundryKit in your Next.js project')\n .option('-f, --force', 'overwrite existing files')\n .option('--skip-install', 'skip installing dependencies')\n .action(async (options: InitOptions) => {\n try {\n console.log(chalk.blue('šŸš€ Initializing FoundryKit...'));\n\n // Check if it's a Next.js project\n await validateNextJsProject();\n\n // Check if already initialized\n if (!options.force && (await isFoundryKitInitialized())) {\n const { shouldContinue } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'shouldContinue',\n message: 'FoundryKit is already initialized. Continue anyway?',\n default: false,\n },\n ]);\n\n if (!shouldContinue) {\n console.log(chalk.yellow('āŒ Initialization cancelled.'));\n return;\n }\n }\n\n // Install dependencies\n if (!options.skipInstall) {\n await installDependencies();\n }\n\n // Setup CSS with Tailwind v4\n await setupTailwindV4();\n\n // Create components directory\n await createDirectories();\n\n // Create example files\n await createExampleFiles();\n\n // Update package.json scripts\n await updatePackageScripts();\n\n console.log(chalk.green('\\nāœ… FoundryKit initialized successfully!'));\n console.log(chalk.cyan('\\nšŸ“¦ Next steps:'));\n console.log(\n chalk.gray(\n ' 1. Add a component: npx @foundrykit/cli add hero-minimal'\n )\n );\n console.log(\n chalk.gray(' 2. List available components: npx @foundrykit/cli list')\n );\n console.log(\n chalk.gray(' 3. Check out the docs: https://foundrykit.dev')\n );\n } catch (error) {\n console.error(chalk.red('āŒ Failed to initialize FoundryKit:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\nasync function validateNextJsProject(): Promise<void> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(\n 'No package.json found. Please run this command in a Next.js project root.'\n );\n }\n\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n if (!dependencies.next) {\n throw new Error(\n 'Next.js not detected. This command should be run in a Next.js project.'\n );\n }\n\n console.log(chalk.green('āœ… Next.js project detected'));\n}\n\nasync function isFoundryKitInitialized(): Promise<boolean> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check if any FoundryKit packages are installed\n return Object.keys(dependencies).some(dep =>\n dep.startsWith('@foundrykit/')\n );\n }\n\n return false;\n}\n\nasync function installDependencies(): Promise<void> {\n console.log(chalk.blue('šŸ“¦ Installing FoundryKit dependencies...'));\n\n // Check if we're in a workspace (local development)\n const isWorkspace = await checkIfWorkspace();\n\n if (isWorkspace) {\n console.log(\n chalk.yellow('āš ļø Workspace detected - skipping dependency installation')\n );\n console.log(chalk.gray('Dependencies are already available via workspace'));\n return;\n }\n\n const dependencies = [\n '@foundrykit/primitives',\n '@foundrykit/components',\n '@foundrykit/blocks',\n '@foundrykit/hooks',\n '@foundrykit/animation',\n '@foundrykit/tailwind',\n ];\n\n try {\n // Detect package manager\n const packageManager = detectPackageManager();\n console.log(chalk.gray(`Using ${packageManager}...`));\n\n const installCmd =\n packageManager === 'npm'\n ? `npm install ${dependencies.join(' ')}`\n : packageManager === 'yarn'\n ? `yarn add ${dependencies.join(' ')}`\n : `pnpm add ${dependencies.join(' ')}`;\n\n execSync(installCmd, { stdio: 'inherit' });\n console.log(chalk.green('āœ… Dependencies installed'));\n } catch (error) {\n throw new Error(\n 'Failed to install dependencies. Please install them manually.'\n );\n }\n}\n\nasync function checkIfWorkspace(): Promise<boolean> {\n try {\n // Check for pnpm workspace\n const pnpmWorkspacePath = path.join(\n process.cwd(),\n '../../pnpm-workspace.yaml'\n );\n if (fs.existsSync(pnpmWorkspacePath)) {\n return true;\n }\n\n // Check package.json for workspace packages\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = await fs.readJson(packageJsonPath);\n const allDeps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check if any FoundryKit packages use workspace protocol\n const foundryKitPackages = Object.keys(allDeps).filter(key =>\n key.startsWith('@foundrykit/')\n );\n for (const pkg of foundryKitPackages) {\n if (allDeps[pkg]?.includes('workspace:')) {\n return true;\n }\n }\n }\n\n return false;\n } catch {\n return false;\n }\n}\n\nfunction detectPackageManager(): string {\n if (fs.existsSync('pnpm-lock.yaml')) return 'pnpm';\n if (fs.existsSync('yarn.lock')) return 'yarn';\n return 'npm';\n}\n\nasync function setupTailwindV4(): Promise<void> {\n console.log(chalk.blue('āš™ļø Setting up Tailwind CSS v4...'));\n\n // First check if layout already imports FoundryKit styles\n const layoutInfo = await findLayoutFile();\n if (layoutInfo) {\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing FoundryKit styles directly\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n const { importPreference } = await inquirer.prompt([\n {\n type: 'list',\n name: 'importPreference',\n message:\n 'FoundryKit styles are already imported directly. How would you like to proceed?',\n choices: [\n {\n name: 'Keep direct import from @foundrykit/tailwind/globals.css',\n value: 'direct',\n },\n {\n name: 'Switch to local globals.css file (recommended for customization)',\n value: 'local',\n },\n ],\n default: 'direct',\n },\n ]);\n\n if (importPreference === 'direct') {\n console.log(\n chalk.green(\n 'āœ… Keeping direct import from @foundrykit/tailwind/globals.css'\n )\n );\n return;\n }\n\n // User wants to switch to local globals.css\n await createLocalGlobalsAndUpdateLayout(layoutInfo.path, layoutContent);\n return;\n }\n\n // Check if importing a local globals.css\n const globalsCssImportMatch = layoutContent.match(\n /import\\s+['\"]([^'\"]*globals\\.css)['\"]/\n );\n if (globalsCssImportMatch && globalsCssImportMatch[1]) {\n // Local globals.css is imported, check if it needs updating\n const importPath = globalsCssImportMatch[1];\n const resolvedPath = importPath.startsWith('.')\n ? path.join(path.dirname(layoutInfo.path), importPath)\n : path.join(process.cwd(), importPath.replace(/^@\\//, 'app/'));\n\n if (fs.existsSync(resolvedPath)) {\n const globalsCssContent = await fs.readFile(resolvedPath, 'utf-8');\n if (globalsCssContent.includes('@foundrykit/tailwind/globals.css')) {\n console.log(chalk.green('āœ… FoundryKit styles already configured'));\n return;\n }\n\n // Update existing globals.css\n const updatedContent = `/* Import FoundryKit's Tailwind CSS v4 styles */\n@import \"@foundrykit/tailwind/globals.css\";\n\n/* Your custom styles below */\n${globalsCssContent}`;\n\n await fs.writeFile(resolvedPath, updatedContent);\n console.log(\n chalk.green('āœ… Updated existing globals.css with FoundryKit styles')\n );\n return;\n }\n }\n }\n\n // No existing setup found, ask user preference\n const { setupPreference } = await inquirer.prompt([\n {\n type: 'list',\n name: 'setupPreference',\n message: 'How would you like to import FoundryKit styles?',\n choices: [\n {\n name: 'Create a local globals.css file (recommended for customization)',\n value: 'local',\n },\n {\n name: 'Import directly from @foundrykit/tailwind/globals.css',\n value: 'direct',\n },\n ],\n default: 'local',\n },\n ]);\n\n if (setupPreference === 'direct') {\n // Add direct import to layout\n await addDirectImportToLayout();\n } else {\n // Create local globals.css and update layout\n await createLocalGlobalsAndUpdateLayout();\n }\n}\n\nasync function createLocalGlobalsAndUpdateLayout(\n existingLayoutPath?: string,\n existingLayoutContent?: string\n): Promise<void> {\n // Find or create globals.css\n const possiblePaths = [\n 'app/globals.css',\n 'src/app/globals.css',\n 'styles/globals.css',\n 'src/styles/globals.css',\n ];\n\n let globalCssPath: string | null = null;\n for (const p of possiblePaths) {\n const fullPath = path.join(process.cwd(), p);\n if (fs.existsSync(fullPath)) {\n globalCssPath = fullPath;\n break;\n }\n }\n\n if (!globalCssPath) {\n // Create in app directory by default\n globalCssPath = path.join(process.cwd(), 'app/globals.css');\n await fs.ensureDir(path.dirname(globalCssPath));\n }\n\n // Check if the file already imports FoundryKit styles\n const existingContent = fs.existsSync(globalCssPath)\n ? await fs.readFile(globalCssPath, 'utf-8')\n : '';\n\n if (!existingContent.includes('@foundrykit/tailwind/globals.css')) {\n // Add FoundryKit import to globals.css\n const cssContent = `/* Import FoundryKit's Tailwind CSS v4 styles */\n@import \"@foundrykit/tailwind/globals.css\";\n\n/* Your custom styles below */\n${existingContent}`;\n\n await fs.writeFile(globalCssPath, cssContent);\n console.log(\n chalk.green('āœ… Created/updated globals.css with FoundryKit styles')\n );\n }\n\n // Update layout file\n if (existingLayoutPath && existingLayoutContent) {\n // Replace direct import with local globals.css\n const layoutDir = path.dirname(existingLayoutPath);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n const updatedContent = existingLayoutContent.replace(\n /@foundrykit\\/tailwind\\/globals\\.css/g,\n importPath\n );\n\n await fs.writeFile(existingLayoutPath, updatedContent);\n console.log(chalk.green('āœ… Updated layout to use local globals.css'));\n } else {\n // Add import to layout\n await updateLayoutImport(globalCssPath);\n }\n}\n\nasync function addDirectImportToLayout(): Promise<void> {\n const layoutInfo = await findLayoutFile();\n\n if (!layoutInfo) {\n console.log(\n chalk.yellow(\n 'āš ļø No layout file found. Please add this import to your layout manually:'\n )\n );\n console.log(chalk.gray(` import '@foundrykit/tailwind/globals.css';`));\n return;\n }\n\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n console.log(\n chalk.gray('Layout already imports FoundryKit styles directly')\n );\n return;\n }\n\n // Add import statement after existing imports\n const importStatement = `import '@foundrykit/tailwind/globals.css';`;\n\n // Find a good place to insert the import (after other imports)\n const importRegex = /^import\\s+.*$/gm;\n const imports = layoutContent.match(importRegex);\n\n let updatedContent: string;\n if (imports && imports.length > 0) {\n const lastImport = imports[imports.length - 1];\n const lastImportIndex = layoutContent.lastIndexOf(lastImport!);\n const insertPosition = lastImportIndex + lastImport!.length;\n\n updatedContent =\n layoutContent.slice(0, insertPosition) +\n '\\n' +\n importStatement +\n layoutContent.slice(insertPosition);\n } else {\n // No imports found, add at the beginning\n updatedContent = importStatement + '\\n' + layoutContent;\n }\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(\n chalk.green('āœ… Added direct import of FoundryKit styles to layout')\n );\n}\n\nasync function findLayoutFile(): Promise<{ path: string } | null> {\n const layoutPaths = [\n 'app/layout.tsx',\n 'app/layout.jsx',\n 'app/layout.js',\n 'src/app/layout.tsx',\n 'src/app/layout.jsx',\n 'src/app/layout.js',\n ];\n\n for (const p of layoutPaths) {\n const fullPath = path.join(process.cwd(), p);\n if (fs.existsSync(fullPath)) {\n return { path: fullPath };\n }\n }\n\n return null;\n}\n\nasync function updateLayoutImport(globalCssPath: string): Promise<void> {\n const layoutInfo = await findLayoutFile();\n\n if (!layoutInfo) {\n console.log(\n chalk.yellow(\n 'āš ļø No layout file found. Please import globals.css manually in your layout.'\n )\n );\n return;\n }\n\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing any globals.css\n if (layoutContent.match(/import\\s+['\"][^'\"]*globals\\.css['\"]/)) {\n console.log(chalk.gray('Layout already has a globals.css import'));\n return;\n }\n\n // Check if already importing FoundryKit styles directly\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n // Replace direct FoundryKit import with local globals.css\n const layoutDir = path.dirname(layoutInfo.path);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n const updatedContent = layoutContent.replace(\n /@foundrykit\\/tailwind\\/globals\\.css/g,\n importPath\n );\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(\n chalk.green('āœ… Updated layout import to use local globals.css')\n );\n return;\n }\n\n // Calculate relative import path\n const layoutDir = path.dirname(layoutInfo.path);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n // Add import statement after existing imports\n const importStatement = `import '${importPath}';`;\n\n // Find a good place to insert the import (after other imports)\n const importRegex = /^import\\s+.*$/gm;\n const imports = layoutContent.match(importRegex);\n\n let updatedContent: string;\n if (imports && imports.length > 0) {\n const lastImport = imports[imports.length - 1];\n const lastImportIndex = layoutContent.lastIndexOf(lastImport!);\n const insertPosition = lastImportIndex + lastImport!.length;\n\n updatedContent =\n layoutContent.slice(0, insertPosition) +\n '\\n' +\n importStatement +\n layoutContent.slice(insertPosition);\n } else {\n // No imports found, add at the beginning\n updatedContent = importStatement + '\\n' + layoutContent;\n }\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(chalk.green('āœ… Layout file updated with globals.css import'));\n}\n\nasync function createDirectories(): Promise<void> {\n console.log(chalk.blue('šŸ“ Creating component directories...'));\n\n const dirs = ['components/ui', 'components/blocks', 'lib', 'hooks'];\n\n for (const dir of dirs) {\n await fs.ensureDir(path.join(process.cwd(), dir));\n }\n\n console.log(chalk.green('āœ… Directories created'));\n}\n\nasync function createExampleFiles(): Promise<void> {\n console.log(chalk.blue('šŸ“ Creating example files...'));\n\n // Create lib/utils.ts\n const utilsPath = path.join(process.cwd(), 'lib/utils.ts');\n const utilsContent = `import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n`;\n\n if (!fs.existsSync(utilsPath)) {\n await fs.writeFile(utilsPath, utilsContent);\n console.log(chalk.gray('Created lib/utils.ts'));\n }\n\n // Create providers.tsx if using theme support\n const providersPath = path.join(process.cwd(), 'components/providers.tsx');\n const providersContent = `'use client';\n\nimport { ThemeProvider } from 'next-themes';\n\nexport function Providers({ children }: { children: React.ReactNode }) {\n return (\n <ThemeProvider attribute=\"class\" defaultTheme=\"system\" enableSystem>\n {children}\n </ThemeProvider>\n );\n}\n`;\n\n if (!fs.existsSync(providersPath)) {\n await fs.writeFile(providersPath, providersContent);\n console.log(chalk.gray('Created components/providers.tsx'));\n }\n\n console.log(chalk.green('āœ… Example files created'));\n}\n\nasync function updatePackageScripts(): Promise<void> {\n console.log(chalk.blue('šŸ“‹ Updating package.json scripts...'));\n\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n const packageJson = await fs.readJson(packageJsonPath);\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n // Add FoundryKit CLI scripts if they don't exist\n if (!packageJson.scripts['foundrykit']) {\n packageJson.scripts['foundrykit'] = 'foundrykit';\n }\n\n if (!packageJson.scripts['fk']) {\n packageJson.scripts['fk'] = 'foundrykit';\n }\n\n await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });\n console.log(chalk.green('āœ… Package scripts updated'));\n}\n","/**\n * List command for FoundryKit CLI\n * Displays available components from the registry\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport type { ComponentMeta, ComponentCategory } from '@foundrykit/types';\nimport { getRegistry } from '../lib/registry.js';\n\ninterface ListOptions {\n category?: string;\n search?: string;\n}\n\nexport function listCommand() {\n return new Command('list')\n .description('List all available FoundryKit components and blocks')\n .option(\n '-c, --category <category>',\n 'filter by category (primitives, components, blocks, animations)'\n )\n .option('-s, --search <term>', 'search components by name or description')\n .action(async (options: ListOptions) => {\n try {\n console.log(chalk.blue('šŸ“¦ Available FoundryKit components:'));\n\n const registry = getRegistry();\n\n // Validate category if provided\n if (options.category) {\n const validCategories: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n if (\n !validCategories.includes(options.category as ComponentCategory)\n ) {\n console.error(chalk.red(`Invalid category: ${options.category}`));\n console.log(\n chalk.gray(`Valid categories: ${validCategories.join(', ')}`)\n );\n process.exit(1);\n }\n }\n\n // Fetch components from registry\n console.log(chalk.gray('Fetching from registry...'));\n const components = await registry.getComponents(\n options.category,\n options.search\n );\n\n if (components.length === 0) {\n console.log(\n chalk.yellow('\\nNo components found matching your criteria.')\n );\n if (options.search) {\n console.log(chalk.gray(`Search term: \"${options.search}\"`));\n }\n if (options.category) {\n console.log(chalk.gray(`Category: ${options.category}`));\n }\n return;\n }\n\n // Group and display components\n displayComponents(components);\n\n // Show usage hints\n console.log(chalk.cyan('\\nšŸ’” Usage:'));\n console.log(\n chalk.gray(' foundrykit add # Interactive mode')\n );\n console.log(\n chalk.gray(' foundrykit add <id> # Add specific component')\n );\n console.log(chalk.gray(' foundrykit add button # Example'));\n } catch (error) {\n console.error(chalk.red('āŒ Failed to fetch component registry:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\n/**\n * Display components grouped by category\n */\nfunction displayComponents(components: ComponentMeta[]): void {\n // Group components by category\n const grouped = components.reduce(\n (acc, component) => {\n if (!acc[component.category]) {\n acc[component.category] = [];\n }\n acc[component.category].push(component);\n return acc;\n },\n {} as Record<ComponentCategory, ComponentMeta[]>\n );\n\n // Display in category order\n const categoryOrder: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n\n for (const category of categoryOrder) {\n const items = grouped[category];\n if (!items || items.length === 0) continue;\n\n console.log(`\\n${chalk.cyan.bold(category.toUpperCase())}`);\n console.log(chalk.gray('─'.repeat(40)));\n\n for (const item of items) {\n // Component name and ID\n console.log(\n `${chalk.green('ā—')} ${chalk.bold(item.name)} ${chalk.gray(\n `(${item.id})`\n )}`\n );\n\n // Description\n console.log(` ${chalk.gray(item.description)}`);\n\n // Tags\n if (item.tags && item.tags.length > 0) {\n console.log(\n ` ${chalk.blue(item.tags.map(tag => `#${tag}`).join(' '))}`\n );\n }\n\n // Dependencies\n if (item.registryDependencies && item.registryDependencies.length > 0) {\n console.log(\n ` ${chalk.yellow('Requires:')} ${item.registryDependencies.join(\n ', '\n )}`\n );\n }\n\n // Package dependencies\n if (item.packageDependencies && item.packageDependencies.length > 0) {\n console.log(\n ` ${chalk.magenta('NPM packages:')} ${item.packageDependencies.join(\n ', '\n )}`\n );\n }\n\n console.log();\n }\n }\n\n // Show summary\n const total = components.length;\n const byCategory = Object.entries(grouped)\n .map(([cat, items]) => `${items.length} ${cat}`)\n .join(', ');\n\n console.log(chalk.gray('─'.repeat(40)));\n console.log(chalk.gray(`Total: ${total} components (${byCategory})`));\n}\n","/**\n * Registry service for fetching and caching component data\n * Handles communication with the FoundryKit registry\n */\n\nimport fs from 'fs-extra';\nimport path from 'path';\nimport os from 'os';\nimport chalk from 'chalk';\nimport type {\n ComponentMeta,\n ComponentData,\n RegistryIndex,\n RegistryComponent,\n RegistryError,\n LocalCache,\n CLIConfig,\n} from '@foundrykit/types';\n\n/**\n * Default configuration\n */\nconst DEFAULT_CONFIG: CLIConfig = {\n registryUrl:\n process.env.FOUNDRYKIT_REGISTRY_URL || 'https://foundry.umiflow.com',\n cacheDir: path.join(os.homedir(), '.foundrykit', 'cache'),\n cacheMaxAge: 1000 * 60 * 60 * 24, // 24 hours\n};\n\n/**\n * Registry service class\n */\nexport class RegistryService {\n private config: CLIConfig;\n private cacheFile: string;\n\n constructor(config?: Partial<CLIConfig>) {\n this.config = { ...DEFAULT_CONFIG, ...config };\n this.cacheFile = path.join(this.config.cacheDir, 'registry.json');\n }\n\n /**\n * Fetch all components from the registry\n */\n async getComponents(\n category?: string,\n search?: string\n ): Promise<RegistryIndex> {\n try {\n // Build query params\n const params = new URLSearchParams();\n if (category) params.append('category', category);\n if (search) params.append('search', search);\n\n const url = `${this.config.registryUrl}/registry${\n params.toString() ? '?' + params.toString() : ''\n }`;\n\n console.log(chalk.gray(`Fetching from: ${url}`));\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Registry returned ${response.status}: ${response.statusText}`\n );\n }\n\n const components = (await response.json()) as RegistryIndex;\n\n // Update cache\n await this.updateCache(components);\n\n return components;\n } catch (error) {\n // Try to load from cache\n const cache = await this.loadCache();\n if (cache && this.isCacheValid(cache)) {\n console.log(chalk.yellow('Using cached registry data'));\n return this.filterComponents(cache.components, category, search);\n }\n\n // No valid cache, throw error\n throw new Error(\n `Failed to connect to registry: ${error instanceof Error ? error.message : 'Unknown error'}\\n` +\n `Registry URL: ${this.config.registryUrl}\\n` +\n `Try again later or check your internet connection.`\n );\n }\n }\n\n /**\n * Fetch a specific component by ID\n */\n async getComponent(id: string): Promise<ComponentData> {\n try {\n // Special handling for common utility dependencies\n if (id === 'utils') {\n console.log(chalk.gray(`Creating utils dependency...`));\n return this.createUtilsComponent();\n }\n\n const url = `${this.config.registryUrl}/registry/${id}`;\n console.log(chalk.gray(`Fetching component: ${url}`));\n\n const response = await fetch(url);\n\n if (!response.ok) {\n if (response.status === 404) {\n // Check if it's a known special dependency\n if (this.isSpecialDependency(id)) {\n console.log(\n chalk.yellow(\n `Special dependency \"${id}\" will be handled separately`\n )\n );\n return this.createSpecialDependency(id);\n }\n throw new Error(`Component \"${id}\" not found in registry`);\n }\n throw new Error(\n `Registry returned ${response.status}: ${response.statusText}`\n );\n }\n\n const component = (await response.json()) as RegistryComponent;\n\n // Cache the component data\n await this.cacheComponent(component);\n\n return component;\n } catch (error) {\n // Try to load from cache\n const cache = await this.loadCache();\n if (cache?.componentData?.[id]) {\n console.log(chalk.yellow(`Using cached data for component: ${id}`));\n return cache.componentData[id];\n }\n\n // Check if it's a special dependency that we can handle locally\n if (this.isSpecialDependency(id)) {\n console.log(chalk.yellow(`Creating local version of \"${id}\"`));\n return this.createSpecialDependency(id);\n }\n\n // No cached data, throw error\n throw new Error(\n `Failed to fetch component \"${id}\": ${error instanceof Error ? error.message : 'Unknown error'}\\n` +\n `Registry URL: ${this.config.registryUrl}\\n` +\n `Try again later or check your internet connection.`\n );\n }\n }\n\n /**\n * Check if a dependency is a special/utility dependency\n */\n private isSpecialDependency(id: string): boolean {\n const specialDeps = ['utils', 'lib', 'helpers', 'cn'];\n return specialDeps.includes(id);\n }\n\n /**\n * Create a special dependency component\n */\n private createSpecialDependency(id: string): ComponentData {\n switch (id) {\n case 'utils':\n case 'lib':\n case 'helpers':\n case 'cn':\n return this.createUtilsComponent();\n default:\n throw new Error(`Unknown special dependency: ${id}`);\n }\n }\n\n /**\n * Create a utils component with the cn function\n */\n private createUtilsComponent(): ComponentData {\n return {\n id: 'utils',\n name: 'Utils',\n category: 'primitives',\n description: 'Utility functions for className merging',\n tags: ['utility', 'helper'],\n packageDependencies: ['clsx', 'tailwind-merge'],\n files: [\n {\n path: 'lib/utils.ts',\n type: 'util',\n content: `import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n`,\n },\n ],\n };\n }\n\n /**\n * Update the local cache with new component list\n */\n private async updateCache(components: RegistryIndex): Promise<void> {\n try {\n const cache = await this.loadCache();\n const newCache: LocalCache = {\n version: '1.0.0',\n lastUpdated: new Date().toISOString(),\n components,\n componentData: cache?.componentData || {},\n };\n\n await fs.ensureDir(this.config.cacheDir);\n await fs.writeJson(this.cacheFile, newCache, { spaces: 2 });\n } catch (error) {\n // Cache update failed, but don't throw - this is not critical\n console.log(chalk.gray('Failed to update cache'));\n }\n }\n\n /**\n * Cache a specific component\n */\n private async cacheComponent(component: ComponentData): Promise<void> {\n try {\n const cache = await this.loadCache();\n if (!cache) return;\n\n cache.componentData[component.id] = component;\n cache.lastUpdated = new Date().toISOString();\n\n await fs.writeJson(this.cacheFile, cache, { spaces: 2 });\n } catch (error) {\n // Cache update failed, but don't throw\n console.log(chalk.gray('Failed to cache component'));\n }\n }\n\n /**\n * Load the local cache\n */\n private async loadCache(): Promise<LocalCache | null> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n return await fs.readJson(this.cacheFile);\n }\n } catch (error) {\n console.log(chalk.gray('Failed to load cache'));\n }\n return null;\n }\n\n /**\n * Check if cache is still valid\n */\n private isCacheValid(cache: LocalCache): boolean {\n const lastUpdated = new Date(cache.lastUpdated).getTime();\n const now = Date.now();\n return now - lastUpdated < this.config.cacheMaxAge;\n }\n\n /**\n * Filter components by category and search\n */\n private filterComponents(\n components: ComponentMeta[],\n category?: string,\n search?: string\n ): ComponentMeta[] {\n let filtered = components;\n\n if (category) {\n filtered = filtered.filter(c => c.category === category);\n }\n\n if (search) {\n const searchLower = search.toLowerCase();\n filtered = filtered.filter(\n c =>\n c.name.toLowerCase().includes(searchLower) ||\n c.description.toLowerCase().includes(searchLower) ||\n c.id.toLowerCase().includes(searchLower) ||\n c.tags?.some(tag => tag.toLowerCase().includes(searchLower))\n );\n }\n\n return filtered;\n }\n\n /**\n * Clear the local cache\n */\n async clearCache(): Promise<void> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n await fs.remove(this.cacheFile);\n console.log(chalk.green('Cache cleared successfully'));\n }\n } catch (error) {\n throw new Error(\n `Failed to clear cache: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n\n /**\n * Get cache statistics\n */\n async getCacheStats(): Promise<{\n exists: boolean;\n size: number;\n lastUpdated: string | null;\n componentCount: number;\n }> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n const cache = await this.loadCache();\n const stats = await fs.stat(this.cacheFile);\n\n return {\n exists: true,\n size: stats.size,\n lastUpdated: cache?.lastUpdated || null,\n componentCount: cache?.components.length || 0,\n };\n }\n } catch (error) {\n // Ignore errors\n }\n\n return {\n exists: false,\n size: 0,\n lastUpdated: null,\n componentCount: 0,\n };\n }\n}\n\n/**\n * Singleton instance\n */\nlet registryInstance: RegistryService | null = null;\n\n/**\n * Get the registry service instance\n */\nexport function getRegistry(config?: Partial<CLIConfig>): RegistryService {\n if (!registryInstance) {\n registryInstance = new RegistryService(config);\n }\n return registryInstance;\n}\n\n/**\n * Reset the registry instance (mainly for testing)\n */\nexport function resetRegistry(): void {\n registryInstance = null;\n}\n","/**\n * Add command for FoundryKit CLI\n * Handles adding components to projects\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport inquirer from 'inquirer';\nimport type {\n ComponentMeta,\n ComponentData,\n ComponentCategory,\n} from '@foundrykit/types';\nimport { getRegistry } from '../lib/registry.js';\n\ninterface AddOptions {\n withAnimation?: boolean;\n path?: string;\n overwrite?: boolean;\n}\n\nexport function addCommand() {\n return new Command('add')\n .description('Add a component or block to your project')\n .argument('[id]', 'Component or block ID (optional for interactive mode)')\n .option('--with-animation', 'Include animation variants')\n .option('-p, --path <path>', 'Custom installation path')\n .option('-o, --overwrite', 'Overwrite existing files')\n .action(async (id: string | undefined, options: AddOptions) => {\n try {\n // If no ID provided, show interactive selector\n if (!id) {\n const selectedIds = await selectComponentsInteractively();\n if (selectedIds.length === 0) {\n console.log(chalk.yellow('No components selected.'));\n return;\n }\n\n // Add each selected component\n for (const componentId of selectedIds) {\n await addSingleComponent(componentId, options);\n }\n } else {\n // Add single component\n await addSingleComponent(id, options);\n }\n } catch (error) {\n console.error(chalk.red('āŒ Failed to add component:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\n/**\n * Interactive component selection\n */\nasync function selectComponentsInteractively(): Promise<string[]> {\n console.log(chalk.blue('šŸ“¦ Select components to add:'));\n console.log(\n chalk.gray(' Use arrow keys to navigate, space to select, a to toggle all')\n );\n console.log(chalk.gray(' Press enter when done\\n'));\n\n const registry = getRegistry();\n\n try {\n // Fetch all available components from registry\n console.log(chalk.gray('Fetching components from registry...'));\n const allComponents = await registry.getComponents();\n\n if (allComponents.length === 0) {\n console.log(chalk.yellow('No components available in the registry.'));\n return [];\n }\n\n // Group components by category\n const groupedChoices = createGroupedChoices(allComponents);\n\n const { selectedComponents } = await inquirer.prompt([\n {\n type: 'checkbox',\n name: 'selectedComponents',\n message: 'Which components would you like to add?',\n choices: groupedChoices,\n pageSize: 20,\n loop: false,\n },\n ]);\n\n return selectedComponents;\n } catch (error) {\n console.error(chalk.red('Failed to fetch components from registry:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n throw error;\n }\n}\n\n/**\n * Create grouped choices for the interactive selector\n */\nfunction createGroupedChoices(components: ComponentMeta[]) {\n const categories: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n\n const choices: any[] = [];\n\n for (const category of categories) {\n const categoryComponents = components.filter(c => c.category === category);\n\n if (categoryComponents.length === 0) continue;\n\n // Add category separator\n choices.push({\n name: chalk.bold.cyan(`─── ${category.toUpperCase()} ───`),\n disabled: true,\n value: `separator-${category}`,\n });\n\n // Add components in this category\n for (const component of categoryComponents) {\n choices.push({\n name: `${component.name} - ${chalk.gray(component.description)}`,\n value: component.id,\n short: component.name,\n });\n }\n }\n\n return choices;\n}\n\n/**\n * Add a single component to the project\n */\nasync function addSingleComponent(\n id: string,\n options: AddOptions\n): Promise<void> {\n console.log(chalk.blue(`\\nšŸ“¦ Adding ${id} to your project...`));\n\n // Validate project is initialized\n await validateProject();\n\n const registry = getRegistry();\n\n try {\n // Fetch component data from registry\n const componentData = await registry.getComponent(id);\n\n // Check for existing files\n if (\n !options.overwrite &&\n (await hasConflictingFiles(componentData, options))\n ) {\n const { shouldContinue } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'shouldContinue',\n message: `Some files for ${componentData.name} already exist. Overwrite?`,\n default: false,\n },\n ]);\n\n if (!shouldContinue) {\n console.log(chalk.yellow(`ā­ļø Skipping ${componentData.name}.`));\n return;\n }\n }\n\n // Install registry dependencies first\n if (componentData.registryDependencies?.length) {\n console.log(chalk.blue('šŸ“¦ Installing required dependencies...'));\n for (const dep of componentData.registryDependencies) {\n try {\n // Special handling for utility dependencies\n if (dep === 'utils') {\n // Check if utils already exists\n const utilsPath = path.join(\n options.path || process.cwd(),\n 'lib/utils.ts'\n );\n if (!fs.existsSync(utilsPath)) {\n // Create a basic utils file if it doesn't exist\n await fs.ensureDir(path.dirname(utilsPath));\n await fs.writeFile(\n utilsPath,\n `import { type ClassValue, clsx } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n`\n );\n console.log(chalk.green(` āœ“ Created ${dep} file`));\n } else {\n console.log(chalk.gray(` ā­ ${dep} already exists`));\n }\n } else {\n // Try to fetch as a regular component\n const depData = await registry.getComponent(dep);\n if (!(await hasConflictingFiles(depData, options))) {\n await installComponentFiles(depData, options);\n console.log(chalk.green(` āœ“ Installed ${dep}`));\n } else {\n console.log(chalk.gray(` ā­ ${dep} already exists`));\n }\n }\n } catch (error) {\n // If dependency fetch fails, log warning but continue\n console.log(\n chalk.yellow(\n ` ⚠ Could not install dependency \"${dep}\": ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n )\n );\n\n // For utils specifically, create it if missing\n if (\n dep === 'utils' &&\n error instanceof Error &&\n error.message.includes('not found')\n ) {\n const utilsPath = path.join(\n options.path || process.cwd(),\n 'lib/utils.ts'\n );\n if (!fs.existsSync(utilsPath)) {\n await fs.ensureDir(path.dirname(utilsPath));\n await fs.writeFile(\n utilsPath,\n `import { type ClassValue, clsx } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n`\n );\n console.log(chalk.green(` āœ“ Created ${dep} file`));\n }\n }\n }\n }\n }\n\n // Install the component files\n await installComponentFiles(componentData, options);\n\n console.log(chalk.green(`āœ… ${componentData.name} added successfully!`));\n\n // Show usage example\n showUsageExample(componentData);\n\n // Show package dependencies if any\n if (componentData.packageDependencies?.length) {\n console.log(chalk.yellow('\\nšŸ“¦ Required npm packages:'));\n console.log(\n chalk.gray(` ${componentData.packageDependencies.join(', ')}`)\n );\n console.log(chalk.gray(' Install them with:'));\n console.log(\n chalk.cyan(` pnpm add ${componentData.packageDependencies.join(' ')}`)\n );\n }\n\n // Additional dependencies for utils\n if (componentData.registryDependencies?.includes('utils')) {\n const utilsDeps = ['clsx', 'tailwind-merge'];\n console.log(chalk.yellow('\\nšŸ“¦ Required packages for utils:'));\n console.log(chalk.gray(` ${utilsDeps.join(', ')}`));\n console.log(chalk.gray(' Install them with:'));\n console.log(chalk.cyan(` pnpm add ${utilsDeps.join(' ')}`));\n }\n } catch (error) {\n console.error(chalk.red(`Failed to add ${id}:`));\n throw error;\n }\n}\n\n/**\n * Validate that the project is properly initialized\n */\nasync function validateProject(): Promise<void> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(\n 'No package.json found. Please run this command in a project root.'\n );\n }\n\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check for Next.js or FoundryKit packages\n const hasFoundryKit = Object.keys(dependencies).some(dep =>\n dep.startsWith('@foundrykit/')\n );\n\n if (!hasFoundryKit && !dependencies.next) {\n throw new Error('FoundryKit not initialized. Run \"foundrykit init\" first.');\n }\n}\n\n/**\n * Check if component files already exist\n */\nasync function hasConflictingFiles(\n componentData: ComponentData,\n options: AddOptions\n): Promise<boolean> {\n const basePath = options.path || process.cwd();\n\n for (const file of componentData.files) {\n const filePath = path.join(basePath, file.path);\n if (fs.existsSync(filePath)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Install component files to the project\n */\nasync function installComponentFiles(\n componentData: ComponentData,\n options: AddOptions\n): Promise<void> {\n const basePath = options.path || process.cwd();\n\n console.log(chalk.blue('šŸ“ Installing component files...'));\n\n for (const file of componentData.files) {\n const filePath = path.join(basePath, file.path);\n\n // Ensure directory exists\n await fs.ensureDir(path.dirname(filePath));\n\n // Write file\n await fs.writeFile(filePath, file.content);\n\n console.log(chalk.green(` āœ“ ${file.path}`));\n }\n}\n\n/**\n * Show usage example for the installed component\n */\nfunction showUsageExample(componentData: ComponentData): void {\n console.log(chalk.cyan('\\nšŸ’” Usage:'));\n\n const componentName = componentData.name.replace(/\\s+/g, '');\n\n if (\n componentData.category === 'primitives' ||\n componentData.category === 'components'\n ) {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/ui/${componentData.id}\"`\n )\n );\n } else if (componentData.category === 'blocks') {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/blocks/${componentData.id}\"`\n )\n );\n } else if (componentData.category === 'animations') {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/animations/${componentData.id}\"`\n )\n );\n }\n\n // Show basic usage examples based on component type\n if (componentData.id === 'button') {\n console.log(chalk.gray('\\n<Button>Click me</Button>'));\n console.log(chalk.gray('<Button variant=\"outline\">Outline</Button>'));\n } else if (componentData.id === 'input') {\n console.log(chalk.gray('\\n<Input placeholder=\"Enter text...\" />'));\n } else if (componentData.id.includes('hero')) {\n console.log(chalk.gray(`\\n<${componentName} />`));\n } else if (componentData.id === 'card') {\n console.log(chalk.gray('\\n<Card>'));\n console.log(chalk.gray(' <CardHeader>'));\n console.log(chalk.gray(' <CardTitle>Title</CardTitle>'));\n console.log(\n chalk.gray(' <CardDescription>Description</CardDescription>')\n );\n console.log(chalk.gray(' </CardHeader>'));\n console.log(chalk.gray(' <CardContent>Content</CardContent>'));\n console.log(chalk.gray('</Card>'));\n }\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\n\nexport function updateCommand() {\n return new Command('update')\n .description('Update an existing component or block')\n .argument('<id>', 'Component or block ID')\n .action(async id => {\n console.log(chalk.blue(`šŸ”„ Updating ${id}...`));\n console.log(chalk.green(`āœ… ${id} updated successfully!`));\n });\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\n\nexport function doctorCommand() {\n return new Command('doctor')\n .description('Check project health and configuration')\n .action(async () => {\n console.log(chalk.blue('šŸ” Checking project health...'));\n console.log(chalk.green('āœ… All checks passed!'));\n });\n}\n"],"mappings":";;;AAEA,SAAS,WAAAA,gBAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;;;ACL9B,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,gBAAgB;AACzB,OAAO,cAAc;AAOd,SAAS,cAAc;AAC5B,SAAO,IAAI,QAAQ,MAAM,EACtB,YAAY,+CAA+C,EAC3D,OAAO,eAAe,0BAA0B,EAChD,OAAO,kBAAkB,8BAA8B,EACvD,OAAO,OAAO,YAAyB;AACtC,QAAI;AACF,cAAQ,IAAI,MAAM,KAAK,sCAA+B,CAAC;AAGvD,YAAM,sBAAsB;AAG5B,UAAI,CAAC,QAAQ,SAAU,MAAM,wBAAwB,GAAI;AACvD,cAAM,EAAE,eAAe,IAAI,MAAM,SAAS,OAAO;AAAA,UAC/C;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA,YACT,SAAS;AAAA,UACX;AAAA,QACF,CAAC;AAED,YAAI,CAAC,gBAAgB;AACnB,kBAAQ,IAAI,MAAM,OAAO,kCAA6B,CAAC;AACvD;AAAA,QACF;AAAA,MACF;AAGA,UAAI,CAAC,QAAQ,aAAa;AACxB,cAAM,oBAAoB;AAAA,MAC5B;AAGA,YAAM,gBAAgB;AAGtB,YAAM,kBAAkB;AAGxB,YAAM,mBAAmB;AAGzB,YAAM,qBAAqB;AAE3B,cAAQ,IAAI,MAAM,MAAM,+CAA0C,CAAC;AACnE,cAAQ,IAAI,MAAM,KAAK,yBAA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IC,OAAM,KAAK,sCAA+B,CAAC;AACvD,YAAQ,IAAIA,OAAM,MAAM,2BAAsB,CAAC;AAAA,EACjD,CAAC;AACL;;;ANGA,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,QAAQ,UAAU;AACpC,IAAM,cAAc,KAAK;AAAA,EACvB,aAAa,KAAK,WAAW,MAAM,cAAc,GAAG,OAAO;AAC7D;AAEA,IAAM,UAAU,IAAIC,SAAQ;AAE5B,QACG,KAAK,YAAY,EACjB,YAAY,oDAAoD,EAChE,QAAQ,YAAY,OAAO;AAG9B,QAAQ,WAAW,YAAY,CAAC;AAChC,QAAQ,WAAW,YAAY,CAAC;AAChC,QAAQ,WAAW,WAAW,CAAC;AAC/B,QAAQ,WAAW,cAAc,CAAC;AAClC,QAAQ,WAAW,cAAc,CAAC;AAElC,QAAQ,MAAM;","names":["Command","packageJson","layoutDir","cssRelativePath","importPath","updatedContent","Command","chalk","fs","path","chalk","Command","chalk","Command","chalk","fs","path","inquirer","Command","chalk","inquirer","path","fs","packageJson","Command","chalk","Command","chalk","Command"]}
package/dist/index.js CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  // src/index.ts
4
4
  import { Command as Command6 } from "commander";
5
+ import { readFileSync } from "fs";
6
+ import { fileURLToPath } from "url";
7
+ import { dirname, join } from "path";
5
8
 
6
9
  // src/commands/init.ts
7
10
  import { Command } from "commander";
@@ -65,10 +68,10 @@ async function validateNextJsProject() {
65
68
  "No package.json found. Please run this command in a Next.js project root."
66
69
  );
67
70
  }
68
- const packageJson = await fs.readJson(packageJsonPath);
71
+ const packageJson2 = await fs.readJson(packageJsonPath);
69
72
  const dependencies = {
70
- ...packageJson.dependencies,
71
- ...packageJson.devDependencies
73
+ ...packageJson2.dependencies,
74
+ ...packageJson2.devDependencies
72
75
  };
73
76
  if (!dependencies.next) {
74
77
  throw new Error(
@@ -80,10 +83,10 @@ async function validateNextJsProject() {
80
83
  async function isFoundryKitInitialized() {
81
84
  const packageJsonPath = path.join(process.cwd(), "package.json");
82
85
  if (fs.existsSync(packageJsonPath)) {
83
- const packageJson = await fs.readJson(packageJsonPath);
86
+ const packageJson2 = await fs.readJson(packageJsonPath);
84
87
  const dependencies = {
85
- ...packageJson.dependencies,
86
- ...packageJson.devDependencies
88
+ ...packageJson2.dependencies,
89
+ ...packageJson2.devDependencies
87
90
  };
88
91
  return Object.keys(dependencies).some(
89
92
  (dep) => dep.startsWith("@foundrykit/")
@@ -132,10 +135,10 @@ async function checkIfWorkspace() {
132
135
  }
133
136
  const packageJsonPath = path.join(process.cwd(), "package.json");
134
137
  if (fs.existsSync(packageJsonPath)) {
135
- const packageJson = await fs.readJson(packageJsonPath);
138
+ const packageJson2 = await fs.readJson(packageJsonPath);
136
139
  const allDeps = {
137
- ...packageJson.dependencies,
138
- ...packageJson.devDependencies
140
+ ...packageJson2.dependencies,
141
+ ...packageJson2.devDependencies
139
142
  };
140
143
  const foundryKitPackages = Object.keys(allDeps).filter(
141
144
  (key) => key.startsWith("@foundrykit/")
@@ -428,17 +431,17 @@ export function Providers({ children }: { children: React.ReactNode }) {
428
431
  async function updatePackageScripts() {
429
432
  console.log(chalk.blue("\u{1F4CB} Updating package.json scripts..."));
430
433
  const packageJsonPath = path.join(process.cwd(), "package.json");
431
- const packageJson = await fs.readJson(packageJsonPath);
432
- if (!packageJson.scripts) {
433
- packageJson.scripts = {};
434
+ const packageJson2 = await fs.readJson(packageJsonPath);
435
+ if (!packageJson2.scripts) {
436
+ packageJson2.scripts = {};
434
437
  }
435
- if (!packageJson.scripts["foundrykit"]) {
436
- packageJson.scripts["foundrykit"] = "foundrykit";
438
+ if (!packageJson2.scripts["foundrykit"]) {
439
+ packageJson2.scripts["foundrykit"] = "foundrykit";
437
440
  }
438
- if (!packageJson.scripts["fk"]) {
439
- packageJson.scripts["fk"] = "foundrykit";
441
+ if (!packageJson2.scripts["fk"]) {
442
+ packageJson2.scripts["fk"] = "foundrykit";
440
443
  }
441
- await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
444
+ await fs.writeJson(packageJsonPath, packageJson2, { spaces: 2 });
442
445
  console.log(chalk.green("\u2705 Package scripts updated"));
443
446
  }
444
447
 
@@ -501,11 +504,23 @@ Try again later or check your internet connection.`
501
504
  */
502
505
  async getComponent(id) {
503
506
  try {
507
+ if (id === "utils") {
508
+ console.log(chalk2.gray(`Creating utils dependency...`));
509
+ return this.createUtilsComponent();
510
+ }
504
511
  const url = `${this.config.registryUrl}/registry/${id}`;
505
512
  console.log(chalk2.gray(`Fetching component: ${url}`));
506
513
  const response = await fetch(url);
507
514
  if (!response.ok) {
508
515
  if (response.status === 404) {
516
+ if (this.isSpecialDependency(id)) {
517
+ console.log(
518
+ chalk2.yellow(
519
+ `Special dependency "${id}" will be handled separately`
520
+ )
521
+ );
522
+ return this.createSpecialDependency(id);
523
+ }
509
524
  throw new Error(`Component "${id}" not found in registry`);
510
525
  }
511
526
  throw new Error(
@@ -521,6 +536,10 @@ Try again later or check your internet connection.`
521
536
  console.log(chalk2.yellow(`Using cached data for component: ${id}`));
522
537
  return cache.componentData[id];
523
538
  }
539
+ if (this.isSpecialDependency(id)) {
540
+ console.log(chalk2.yellow(`Creating local version of "${id}"`));
541
+ return this.createSpecialDependency(id);
542
+ }
524
543
  throw new Error(
525
544
  `Failed to fetch component "${id}": ${error instanceof Error ? error.message : "Unknown error"}
526
545
  Registry URL: ${this.config.registryUrl}
@@ -528,6 +547,53 @@ Try again later or check your internet connection.`
528
547
  );
529
548
  }
530
549
  }
550
+ /**
551
+ * Check if a dependency is a special/utility dependency
552
+ */
553
+ isSpecialDependency(id) {
554
+ const specialDeps = ["utils", "lib", "helpers", "cn"];
555
+ return specialDeps.includes(id);
556
+ }
557
+ /**
558
+ * Create a special dependency component
559
+ */
560
+ createSpecialDependency(id) {
561
+ switch (id) {
562
+ case "utils":
563
+ case "lib":
564
+ case "helpers":
565
+ case "cn":
566
+ return this.createUtilsComponent();
567
+ default:
568
+ throw new Error(`Unknown special dependency: ${id}`);
569
+ }
570
+ }
571
+ /**
572
+ * Create a utils component with the cn function
573
+ */
574
+ createUtilsComponent() {
575
+ return {
576
+ id: "utils",
577
+ name: "Utils",
578
+ category: "primitives",
579
+ description: "Utility functions for className merging",
580
+ tags: ["utility", "helper"],
581
+ packageDependencies: ["clsx", "tailwind-merge"],
582
+ files: [
583
+ {
584
+ path: "lib/utils.ts",
585
+ type: "util",
586
+ content: `import { type ClassValue, clsx } from 'clsx';
587
+ import { twMerge } from 'tailwind-merge';
588
+
589
+ export function cn(...inputs: ClassValue[]) {
590
+ return twMerge(clsx(inputs));
591
+ }
592
+ `
593
+ }
594
+ ]
595
+ };
596
+ }
531
597
  /**
532
598
  * Update the local cache with new component list
533
599
  */
@@ -876,10 +942,63 @@ async function addSingleComponent(id, options) {
876
942
  if (componentData.registryDependencies?.length) {
877
943
  console.log(chalk4.blue("\u{1F4E6} Installing required dependencies..."));
878
944
  for (const dep of componentData.registryDependencies) {
879
- const depData = await registry.getComponent(dep);
880
- if (!await hasConflictingFiles(depData, options)) {
881
- await installComponentFiles(depData, options);
882
- console.log(chalk4.green(` \u2713 Installed ${dep}`));
945
+ try {
946
+ if (dep === "utils") {
947
+ const utilsPath = path3.join(
948
+ options.path || process.cwd(),
949
+ "lib/utils.ts"
950
+ );
951
+ if (!fs3.existsSync(utilsPath)) {
952
+ await fs3.ensureDir(path3.dirname(utilsPath));
953
+ await fs3.writeFile(
954
+ utilsPath,
955
+ `import { type ClassValue, clsx } from "clsx"
956
+ import { twMerge } from "tailwind-merge"
957
+
958
+ export function cn(...inputs: ClassValue[]) {
959
+ return twMerge(clsx(inputs))
960
+ }
961
+ `
962
+ );
963
+ console.log(chalk4.green(` \u2713 Created ${dep} file`));
964
+ } else {
965
+ console.log(chalk4.gray(` \u23ED ${dep} already exists`));
966
+ }
967
+ } else {
968
+ const depData = await registry.getComponent(dep);
969
+ if (!await hasConflictingFiles(depData, options)) {
970
+ await installComponentFiles(depData, options);
971
+ console.log(chalk4.green(` \u2713 Installed ${dep}`));
972
+ } else {
973
+ console.log(chalk4.gray(` \u23ED ${dep} already exists`));
974
+ }
975
+ }
976
+ } catch (error) {
977
+ console.log(
978
+ chalk4.yellow(
979
+ ` \u26A0 Could not install dependency "${dep}": ${error instanceof Error ? error.message : "Unknown error"}`
980
+ )
981
+ );
982
+ if (dep === "utils" && error instanceof Error && error.message.includes("not found")) {
983
+ const utilsPath = path3.join(
984
+ options.path || process.cwd(),
985
+ "lib/utils.ts"
986
+ );
987
+ if (!fs3.existsSync(utilsPath)) {
988
+ await fs3.ensureDir(path3.dirname(utilsPath));
989
+ await fs3.writeFile(
990
+ utilsPath,
991
+ `import { type ClassValue, clsx } from "clsx"
992
+ import { twMerge } from "tailwind-merge"
993
+
994
+ export function cn(...inputs: ClassValue[]) {
995
+ return twMerge(clsx(inputs))
996
+ }
997
+ `
998
+ );
999
+ console.log(chalk4.green(` \u2713 Created ${dep} file`));
1000
+ }
1001
+ }
883
1002
  }
884
1003
  }
885
1004
  }
@@ -896,6 +1015,13 @@ async function addSingleComponent(id, options) {
896
1015
  chalk4.cyan(` pnpm add ${componentData.packageDependencies.join(" ")}`)
897
1016
  );
898
1017
  }
1018
+ if (componentData.registryDependencies?.includes("utils")) {
1019
+ const utilsDeps = ["clsx", "tailwind-merge"];
1020
+ console.log(chalk4.yellow("\n\u{1F4E6} Required packages for utils:"));
1021
+ console.log(chalk4.gray(` ${utilsDeps.join(", ")}`));
1022
+ console.log(chalk4.gray(" Install them with:"));
1023
+ console.log(chalk4.cyan(` pnpm add ${utilsDeps.join(" ")}`));
1024
+ }
899
1025
  } catch (error) {
900
1026
  console.error(chalk4.red(`Failed to add ${id}:`));
901
1027
  throw error;
@@ -908,10 +1034,10 @@ async function validateProject() {
908
1034
  "No package.json found. Please run this command in a project root."
909
1035
  );
910
1036
  }
911
- const packageJson = await fs3.readJson(packageJsonPath);
1037
+ const packageJson2 = await fs3.readJson(packageJsonPath);
912
1038
  const dependencies = {
913
- ...packageJson.dependencies,
914
- ...packageJson.devDependencies
1039
+ ...packageJson2.dependencies,
1040
+ ...packageJson2.devDependencies
915
1041
  };
916
1042
  const hasFoundryKit = Object.keys(dependencies).some(
917
1043
  (dep) => dep.startsWith("@foundrykit/")
@@ -1004,8 +1130,13 @@ function doctorCommand() {
1004
1130
  }
1005
1131
 
1006
1132
  // src/index.ts
1133
+ var __filename = fileURLToPath(import.meta.url);
1134
+ var __dirname = dirname(__filename);
1135
+ var packageJson = JSON.parse(
1136
+ readFileSync(join(__dirname, "..", "package.json"), "utf-8")
1137
+ );
1007
1138
  var program = new Command6();
1008
- program.name("foundrykit").description("FoundryKit CLI - Component library management tool").version("0.1.0");
1139
+ program.name("foundrykit").description("FoundryKit CLI - Component library management tool").version(packageJson.version);
1009
1140
  program.addCommand(initCommand());
1010
1141
  program.addCommand(listCommand());
1011
1142
  program.addCommand(addCommand());