@foundrykit/cli 1.0.3 ā 1.0.5
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/CHANGELOG.md +16 -0
- package/dist/cli.js +102 -75
- package/dist/cli.js.map +1 -1
- package/dist/index.js +102 -75
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/commands/add.ts +125 -88
- package/src/commands/init.ts +12 -5
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 { 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 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 // Validate project\n await validateProject();\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 // Create configuration file\n await createConfigFile(options);\n\n // Install utils\n await installUtils();\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: pnpm dlx @foundrykit/cli add hero-minimal'\n )\n );\n console.log(\n chalk.gray(\n ' 2. List available components: pnpm dlx @foundrykit/cli list'\n )\n );\n console.log(\n chalk.gray(\n ' 3. Check out the docs: https://foundry-docs.umiflow.com'\n )\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 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 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 // Check for foundrykit.config.json\n const configPath = path.join(process.cwd(), 'foundrykit.config.json');\n return fs.existsSync(configPath);\n}\n\nasync function installDependencies(): Promise<void> {\n console.log(chalk.blue('š¦ Installing base dependencies...'));\n\n const dependencies = ['clsx', 'tailwind-merge'];\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 : packageManager === 'bun'\n ? `bun 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 console.log(\n chalk.yellow('ā ļø Could not install dependencies automatically')\n );\n console.log(chalk.gray('Please install them manually:'));\n console.log(\n chalk.cyan(` ${detectPackageManager()} add ${dependencies.join(' ')}`)\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 if (fs.existsSync('bun.lockb')) return 'bun';\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\nasync function createConfigFile(options: InitOptions): Promise<void> {\n console.log(chalk.blue('š Creating configuration file...'));\n\n const configPath = path.join(process.cwd(), 'foundrykit.config.json');\n\n if (fs.existsSync(configPath) && !options.force) {\n console.log(chalk.yellow('ā ļø Configuration file already exists'));\n return;\n }\n\n // Detect framework\n const framework = await detectFramework();\n\n // Detect TypeScript\n const isTypeScript = fs.existsSync(path.join(process.cwd(), 'tsconfig.json'));\n\n // Create configuration\n const config = {\n version: '1.0.0',\n registry: 'https://foundry.umiflow.com',\n paths: {\n utils: './src/lib/utils.ts',\n primitives: './src/components/ui',\n components: './src/components',\n blocks: './src/components/blocks',\n hooks: './src/hooks',\n animations: './src/components/animations',\n },\n packageManager: detectPackageManager(),\n typescript: isTypeScript,\n framework,\n tailwind: {\n config: './tailwind.config.js',\n css: './src/styles/globals.css',\n },\n aliases: {\n '@': './src',\n '@/components': './src/components',\n '@/lib': './src/lib',\n '@/hooks': './src/hooks',\n },\n };\n\n // Adjust paths based on framework\n if (framework === 'next') {\n const hasAppDir = fs.existsSync(path.join(process.cwd(), 'app'));\n if (hasAppDir && !fs.existsSync(path.join(process.cwd(), 'src/app'))) {\n // Using app directory without src\n config.paths = {\n utils: './lib/utils.ts',\n primitives: './components/ui',\n components: './components',\n blocks: './components/blocks',\n hooks: './hooks',\n animations: './components/animations',\n };\n config.tailwind.css = './app/globals.css';\n config.aliases = {\n '@': './',\n '@/components': './components',\n '@/lib': './lib',\n '@/hooks': './hooks',\n };\n }\n }\n\n await fs.writeJson(configPath, config, { spaces: 2 });\n console.log(chalk.green('ā
Created foundrykit.config.json'));\n}\n\nasync function installUtils(): Promise<void> {\n console.log(chalk.blue('š¦ Installing utils...'));\n\n // Read config to get utils path\n const configPath = path.join(process.cwd(), 'foundrykit.config.json');\n if (!fs.existsSync(configPath)) {\n console.log(chalk.yellow('ā ļø Configuration file not found'));\n return;\n }\n\n const config = await fs.readJson(configPath);\n const utilsPath = path.join(process.cwd(), config.paths.utils);\n\n // Check if utils already exists\n if (fs.existsSync(utilsPath)) {\n console.log(chalk.yellow('ā ļø Utils file already exists'));\n return;\n }\n\n // Create utils file\n await fs.ensureDir(path.dirname(utilsPath));\n\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 await fs.writeFile(utilsPath, utilsContent);\n console.log(chalk.green('ā
Created utils file'));\n}\n\nasync function detectFramework(): Promise<string> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = await fs.readJson(packageJsonPath);\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n if (deps.next) return 'next';\n if (deps.remix) return 'remix';\n if (deps.vite) return 'vite';\n if (deps.react) return 'react';\n }\n\n return 'react';\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 { exec } from 'child_process';\nimport { promisify } from 'util';\nimport type {\n ComponentMeta,\n ComponentData,\n ComponentCategory,\n} from '@foundrykit/types';\nimport { getRegistry } from '../lib/registry.js';\n\nconst execAsync = promisify(exec);\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 // Skip 'primitives' as it's not a single component but a category\n if (dep === 'primitives') {\n console.log(\n chalk.gray(\n ` ā Skipping \"${dep}\" - primitive dependencies will be handled separately`\n )\n );\n continue;\n }\n\n // Fetch dependency from registry\n const depData = await registry.getComponent(dep);\n\n // Check if dependency files already exist\n const hasExisting = await hasConflictingFiles(depData, options);\n\n if (!hasExisting) {\n await installComponentFiles(depData, options);\n console.log(chalk.green(` ā Installed ${dep}`));\n } else {\n console.log(chalk.gray(` ā ${dep} already exists`));\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 }\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 // Handle package dependencies\n await handlePackageDependencies(componentData);\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 * Handle package dependencies - check and auto-install if needed\n */\nasync function handlePackageDependencies(\n componentData: ComponentData\n): Promise<void> {\n const allDependencies = new Set<string>();\n\n // Add component's package dependencies\n if (componentData.packageDependencies?.length) {\n componentData.packageDependencies.forEach(dep => allDependencies.add(dep));\n }\n\n // Add utils dependencies if utils is a dependency\n if (componentData.registryDependencies?.includes('utils')) {\n allDependencies.add('clsx');\n allDependencies.add('tailwind-merge');\n }\n\n // Add primitives dependencies if primitives is a dependency\n if (componentData.registryDependencies?.includes('primitives')) {\n // Common primitives dependencies\n allDependencies.add('@radix-ui/react-slot');\n allDependencies.add('class-variance-authority');\n allDependencies.add('clsx');\n allDependencies.add('tailwind-merge');\n }\n\n // Add class-variance-authority for button\n if (componentData.id === 'button') {\n allDependencies.add('class-variance-authority');\n }\n\n // Add lucide-react for components that use icons\n if (componentData.id === 'search-bar') {\n allDependencies.add('lucide-react');\n }\n\n if (allDependencies.size === 0) {\n return;\n }\n\n // Check which packages are already installed\n const missingPackages = await getMissingPackages(Array.from(allDependencies));\n\n if (missingPackages.length === 0) {\n console.log(chalk.green('ā
All required packages are already installed'));\n return;\n }\n\n console.log(chalk.yellow('\\nš¦ Installing required packages...'));\n console.log(chalk.gray(` ${missingPackages.join(', ')}`));\n\n // Try to detect package manager\n const packageManager = await detectPackageManager();\n\n try {\n const installCommand = `${packageManager} add ${missingPackages.join(' ')}`;\n console.log(chalk.blue(` Running: ${installCommand}`));\n\n const { stdout, stderr } = await execAsync(installCommand);\n\n if (stderr && !stderr.includes('warning')) {\n console.error(chalk.yellow(` Warning: ${stderr}`));\n }\n\n console.log(chalk.green('ā
Packages installed successfully'));\n } catch (error) {\n console.log(chalk.yellow('\\nā ļø Could not install packages automatically'));\n console.log(chalk.gray(' Please install them manually:'));\n console.log(\n chalk.cyan(` ${packageManager} add ${missingPackages.join(' ')}`)\n );\n }\n}\n\n/**\n * Check which packages are missing from the project\n */\nasync function getMissingPackages(packages: string[]): Promise<string[]> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n try {\n const packageJson = await fs.readJson(packageJsonPath);\n const installedPackages = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n return packages.filter(pkg => !installedPackages[pkg]);\n } catch (error) {\n // If we can't read package.json, assume all packages are missing\n return packages;\n }\n}\n\n/**\n * Detect which package manager is being used\n */\nasync function detectPackageManager(): Promise<string> {\n // Check for lock files\n if (await fs.pathExists(path.join(process.cwd(), 'pnpm-lock.yaml'))) {\n return 'pnpm';\n }\n if (await fs.pathExists(path.join(process.cwd(), 'yarn.lock'))) {\n return 'yarn';\n }\n if (await fs.pathExists(path.join(process.cwd(), 'package-lock.json'))) {\n return 'npm';\n }\n if (await fs.pathExists(path.join(process.cwd(), 'bun.lockb'))) {\n return 'bun';\n }\n\n // Default to pnpm as it's what FoundryKit uses\n return 'pnpm';\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,gBA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Ac,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","packageJson","Command","chalk","fs","path","chalk","Command","chalk","Command","chalk","fs","path","inquirer","Command","chalk","inquirer","validateProject","path","fs","packageJson","detectPackageManager","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 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 // Validate project\n await validateProject();\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 // Create configuration file\n await createConfigFile(options);\n\n // Install utils\n await installUtils();\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: pnpm dlx @foundrykit/cli add hero-minimal'\n )\n );\n console.log(\n chalk.gray(\n ' 2. List available components: pnpm dlx @foundrykit/cli list'\n )\n );\n console.log(\n chalk.gray(\n ' 3. Check out the docs: https://foundry-docs.umiflow.com'\n )\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 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 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 // Check for foundrykit.config.json\n const configPath = path.join(process.cwd(), 'foundrykit.config.json');\n return fs.existsSync(configPath);\n}\n\nasync function installDependencies(): Promise<void> {\n console.log(chalk.blue('š¦ Installing base dependencies...'));\n\n const dependencies = ['clsx', 'tailwind-merge'];\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 : packageManager === 'bun'\n ? `bun 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 console.log(\n chalk.yellow('ā ļø Could not install dependencies automatically')\n );\n console.log(chalk.gray('Please install them manually:'));\n console.log(\n chalk.cyan(` ${detectPackageManager()} add ${dependencies.join(' ')}`)\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 if (fs.existsSync('bun.lockb')) return 'bun';\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 = [\n 'components/primitives',\n 'components/components',\n 'components/blocks',\n 'components/animations',\n 'lib',\n 'hooks',\n ];\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\nasync function createConfigFile(options: InitOptions): Promise<void> {\n console.log(chalk.blue('š Creating configuration file...'));\n\n const configPath = path.join(process.cwd(), 'foundrykit.config.json');\n\n if (fs.existsSync(configPath) && !options.force) {\n console.log(chalk.yellow('ā ļø Configuration file already exists'));\n return;\n }\n\n // Detect framework\n const framework = await detectFramework();\n\n // Detect TypeScript\n const isTypeScript = fs.existsSync(path.join(process.cwd(), 'tsconfig.json'));\n\n // Create configuration\n const config = {\n version: '1.0.0',\n registry: 'https://foundry.umiflow.com',\n paths: {\n utils: './src/lib/utils.ts',\n primitives: './src/components/primitives',\n components: './src/components/components',\n blocks: './src/components/blocks',\n hooks: './src/hooks',\n animations: './src/components/animations',\n },\n packageManager: detectPackageManager(),\n typescript: isTypeScript,\n framework,\n tailwind: {\n config: './tailwind.config.js',\n css: './src/styles/globals.css',\n },\n aliases: {\n '@': './src',\n '@/components': './src/components',\n '@/lib': './src/lib',\n '@/hooks': './src/hooks',\n },\n };\n\n // Adjust paths based on framework\n if (framework === 'next') {\n const hasAppDir = fs.existsSync(path.join(process.cwd(), 'app'));\n if (hasAppDir && !fs.existsSync(path.join(process.cwd(), 'src/app'))) {\n // Using app directory without src\n config.paths = {\n utils: './lib/utils.ts',\n primitives: './components/primitives',\n components: './components/components',\n blocks: './components/blocks',\n hooks: './hooks',\n animations: './components/animations',\n };\n config.tailwind.css = './app/globals.css';\n config.aliases = {\n '@': './',\n '@/components': './components',\n '@/lib': './lib',\n '@/hooks': './hooks',\n };\n }\n }\n\n await fs.writeJson(configPath, config, { spaces: 2 });\n console.log(chalk.green('ā
Created foundrykit.config.json'));\n}\n\nasync function installUtils(): Promise<void> {\n console.log(chalk.blue('š¦ Installing utils...'));\n\n // Read config to get utils path\n const configPath = path.join(process.cwd(), 'foundrykit.config.json');\n if (!fs.existsSync(configPath)) {\n console.log(chalk.yellow('ā ļø Configuration file not found'));\n return;\n }\n\n const config = await fs.readJson(configPath);\n const utilsPath = path.join(process.cwd(), config.paths.utils);\n\n // Check if utils already exists\n if (fs.existsSync(utilsPath)) {\n console.log(chalk.yellow('ā ļø Utils file already exists'));\n return;\n }\n\n // Create utils file\n await fs.ensureDir(path.dirname(utilsPath));\n\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 await fs.writeFile(utilsPath, utilsContent);\n console.log(chalk.green('ā
Created utils file'));\n}\n\nasync function detectFramework(): Promise<string> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = await fs.readJson(packageJsonPath);\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n if (deps.next) return 'next';\n if (deps.remix) return 'remix';\n if (deps.vite) return 'vite';\n if (deps.react) return 'react';\n }\n\n return 'react';\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 { exec } from 'child_process';\nimport { promisify } from 'util';\nimport type {\n ComponentMeta,\n ComponentData,\n ComponentCategory,\n} from '@foundrykit/types';\nimport { getRegistry } from '../lib/registry.js';\n\nconst execAsync = promisify(exec);\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 // Fetch dependency from registry\n const depData = await registry.getComponent(dep);\n\n // Check if dependency files already exist\n const hasExisting = await hasConflictingFiles(depData, options);\n\n if (!hasExisting) {\n await installComponentFiles(depData, options);\n console.log(chalk.green(` ā Installed ${dep}`));\n } else {\n console.log(chalk.gray(` ā ${dep} already exists`));\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 }\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 // Handle package dependencies\n await handlePackageDependencies(componentData);\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 // Check for configuration file\n const configPath = path.join(process.cwd(), 'foundrykit.config.json');\n if (!fs.existsSync(configPath)) {\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 config = await loadConfig();\n const basePath = options.path || process.cwd();\n\n for (const file of componentData.files) {\n // Special handling for utils to ensure it always goes to the right place\n let resolvedPath: string;\n if (componentData.id === 'utils' || file.path === 'lib/utils.ts') {\n resolvedPath = config.paths.utils || 'lib/utils.ts';\n } else {\n resolvedPath = resolveComponentPath(\n file.path,\n componentData.category,\n config\n );\n }\n const filePath = path.join(basePath, resolvedPath);\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 config = await loadConfig();\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 // Special handling for utils to ensure it always goes to the right place\n let resolvedPath: string;\n if (componentData.id === 'utils' || file.path === 'lib/utils.ts') {\n resolvedPath = config.paths.utils || 'lib/utils.ts';\n } else {\n resolvedPath = resolveComponentPath(\n file.path,\n componentData.category,\n config\n );\n }\n\n const filePath = path.join(basePath, resolvedPath);\n\n // Ensure directory exists\n await fs.ensureDir(path.dirname(filePath));\n\n // Check if file has content before writing\n if (!file.content || file.content.trim() === '') {\n console.log(\n chalk.yellow(` ā Skipping ${resolvedPath} - no content available`)\n );\n continue;\n }\n\n // Write file\n await fs.writeFile(filePath, file.content);\n\n console.log(chalk.green(` ā ${resolvedPath}`));\n }\n}\n\n/**\n * Handle package dependencies - check and auto-install if needed\n */\nasync function handlePackageDependencies(\n componentData: ComponentData\n): Promise<void> {\n // Only use the package dependencies specified by the component\n const allDependencies = new Set<string>();\n\n if (componentData.packageDependencies?.length) {\n componentData.packageDependencies.forEach(dep => allDependencies.add(dep));\n }\n\n if (allDependencies.size === 0) {\n return;\n }\n\n // Check which packages are already installed\n const missingPackages = await getMissingPackages(Array.from(allDependencies));\n\n if (missingPackages.length === 0) {\n console.log(chalk.green('ā
All required packages are already installed'));\n return;\n }\n\n console.log(chalk.yellow('\\nš¦ Installing required packages...'));\n console.log(chalk.gray(` ${missingPackages.join(', ')}`));\n\n // Try to detect package manager\n const packageManager = await detectPackageManager();\n\n try {\n const installCommand = `${packageManager} add ${missingPackages.join(' ')}`;\n console.log(chalk.blue(` Running: ${installCommand}`));\n\n const { stdout, stderr } = await execAsync(installCommand);\n\n if (stderr && !stderr.includes('warning')) {\n console.error(chalk.yellow(` Warning: ${stderr}`));\n }\n\n console.log(chalk.green('ā
Packages installed successfully'));\n } catch (error) {\n console.log(chalk.yellow('\\nā ļø Could not install packages automatically'));\n console.log(chalk.gray(' Please install them manually:'));\n console.log(\n chalk.cyan(` ${packageManager} add ${missingPackages.join(' ')}`)\n );\n }\n}\n\n/**\n * Check which packages are missing from the project\n */\nasync function getMissingPackages(packages: string[]): Promise<string[]> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n try {\n const packageJson = await fs.readJson(packageJsonPath);\n const installedPackages = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n return packages.filter(pkg => !installedPackages[pkg]);\n } catch (error) {\n // If we can't read package.json, assume all packages are missing\n return packages;\n }\n}\n\n/**\n * Detect which package manager is being used\n */\nasync function detectPackageManager(): Promise<string> {\n // Check for lock files\n if (await fs.pathExists(path.join(process.cwd(), 'pnpm-lock.yaml'))) {\n return 'pnpm';\n }\n if (await fs.pathExists(path.join(process.cwd(), 'yarn.lock'))) {\n return 'yarn';\n }\n if (await fs.pathExists(path.join(process.cwd(), 'package-lock.json'))) {\n return 'npm';\n }\n if (await fs.pathExists(path.join(process.cwd(), 'bun.lockb'))) {\n return 'bun';\n }\n\n // Default to pnpm as it's what FoundryKit uses\n return 'pnpm';\n}\n\n/**\n * Show usage example for the installed component\n */\nasync function showUsageExample(componentData: ComponentData): Promise<void> {\n const config = await loadConfig();\n console.log(chalk.cyan('\\nš” Usage:'));\n\n const componentName = componentData.name.replace(/\\s+/g, '');\n const importPath = getImportPath(componentData, config);\n\n console.log(chalk.gray(`import { ${componentName} } from \"${importPath}\"`));\n\n // Show usage example if provided in component data\n if (componentData.usageExample) {\n console.log(chalk.gray(`\\n${componentData.usageExample}`));\n }\n}\n\n/**\n * Load FoundryKit configuration\n */\nasync function loadConfig(): Promise<any> {\n const configPath = path.join(process.cwd(), 'foundrykit.config.json');\n if (!fs.existsSync(configPath)) {\n throw new Error(\n 'Configuration file not found. Run \"foundrykit init\" first.'\n );\n }\n return fs.readJson(configPath);\n}\n\n/**\n * Resolve component path based on category and configuration\n */\nfunction resolveComponentPath(\n originalPath: string,\n category: ComponentCategory,\n config: any\n): string {\n // Special handling for utils files - they should go directly to lib/utils.ts\n if (originalPath === 'lib/utils.ts') {\n return config.paths.utils || 'lib/utils.ts';\n }\n\n // Get the base path for the category from config\n const categoryPath = config.paths[category] || config.paths.components;\n\n // Extract just the filename from the original path\n const fileName = path.basename(originalPath);\n const componentName = path.dirname(originalPath).split('/').pop() || '';\n\n // Build the resolved path based on category\n if (category === 'primitives') {\n return path.join(categoryPath, componentName, fileName);\n } else if (category === 'components') {\n return path.join(\n config.paths.components,\n 'components',\n componentName,\n fileName\n );\n } else if (category === 'blocks') {\n return path.join(\n config.paths.blocks || path.join(config.paths.components, 'blocks'),\n componentName,\n fileName\n );\n } else if (category === 'animations') {\n return path.join(\n config.paths.animations ||\n path.join(config.paths.components, 'animations'),\n componentName,\n fileName\n );\n }\n\n // Default to original path if category not recognized\n return originalPath;\n}\n\n/**\n * Get import path for a component\n */\nfunction getImportPath(componentData: ComponentData, config: any): string {\n const aliases = config.aliases || {};\n const componentName = path.basename(componentData.files[0].path, '.tsx');\n\n if (componentData.category === 'primitives') {\n return `@/components/ui/${componentName}`;\n } else if (componentData.category === 'components') {\n return `@/components/components/${componentName}`;\n } else if (componentData.category === 'blocks') {\n return `@/components/blocks/${componentName}`;\n } else if (componentData.category === 'animations') {\n return `@/components/animations/${componentName}`;\n }\n\n return `@/components/${componentName}`;\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,uCAAuC,EACnD,OAAO,eAAe,0BAA0B,EAChD,OAAO,kBAAkB,8BAA8B,EACvD,OAAO,OAAO,YAAyB;AACtC,QAAI;AACF,cAAQ,IAAI,MAAM,KAAK,sCAA+B,CAAC;AAGvD,YAAM,gBAAgB;AAGtB,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,iBAAiB,OAAO;AAG9B,YAAM,aAAa;AAGnB,YAAM,gBAAgB;A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AClC,QAAQ,WAAW,cAAc,CAAC;AAElC,QAAQ,MAAM;","names":["Command","packageJson","layoutDir","cssRelativePath","importPath","updatedContent","packageJson","Command","chalk","fs","path","chalk","Command","chalk","Command","chalk","fs","path","inquirer","Command","chalk","inquirer","validateProject","path","fs","detectPackageManager","packageJson","Command","chalk","Command","chalk","Command"]}
|