@foundrykit/cli 0.1.2 ā 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/cli.js +156 -25
- package/dist/cli.js.map +1 -1
- package/dist/index.js +156 -25
- package/dist/index.js.map +1 -1
- package/docs/DEPENDENCY_RESOLUTION.md +194 -0
- package/package.json +8 -5
- package/src/commands/add.ts +79 -5
- package/src/index.ts +11 -1
- package/src/lib/registry.ts +71 -0
- package/tests/dependency-resolution.test.ts +289 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/commands/init.ts","../src/commands/list.ts","../src/lib/registry.ts","../src/commands/add.ts","../src/commands/update.ts","../src/commands/doctor.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { initCommand } from './commands/init.js';\nimport { listCommand } from './commands/list.js';\nimport { addCommand } from './commands/add.js';\nimport { updateCommand } from './commands/update.js';\nimport { doctorCommand } from './commands/doctor.js';\n\nconst program = new Command();\n\nprogram\n .name('foundrykit')\n .description('FoundryKit CLI - Component library management tool')\n .version('0.1.0');\n\n// Add commands\nprogram.addCommand(initCommand());\nprogram.addCommand(listCommand());\nprogram.addCommand(addCommand());\nprogram.addCommand(updateCommand());\nprogram.addCommand(doctorCommand());\n\nprogram.parse();\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { execSync } from 'child_process';\nimport inquirer from 'inquirer';\n\ninterface InitOptions {\n force?: boolean;\n skipInstall?: boolean;\n}\n\nexport function initCommand() {\n return new Command('init')\n .description('Initialize FoundryKit in your Next.js project')\n .option('-f, --force', 'overwrite existing files')\n .option('--skip-install', 'skip installing dependencies')\n .action(async (options: InitOptions) => {\n try {\n console.log(chalk.blue('š Initializing FoundryKit...'));\n\n // Check if it's a Next.js project\n await validateNextJsProject();\n\n // Check if already initialized\n if (!options.force && (await isFoundryKitInitialized())) {\n const { shouldContinue } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'shouldContinue',\n message: 'FoundryKit is already initialized. Continue anyway?',\n default: false,\n },\n ]);\n\n if (!shouldContinue) {\n console.log(chalk.yellow('ā Initialization cancelled.'));\n return;\n }\n }\n\n // Install dependencies\n if (!options.skipInstall) {\n await installDependencies();\n }\n\n // Setup CSS with Tailwind v4\n await setupTailwindV4();\n\n // Create components directory\n await createDirectories();\n\n // Create example files\n await createExampleFiles();\n\n // Update package.json scripts\n await updatePackageScripts();\n\n console.log(chalk.green('\\nā
FoundryKit initialized successfully!'));\n console.log(chalk.cyan('\\nš¦ Next steps:'));\n console.log(\n chalk.gray(\n ' 1. Add a component: npx @foundrykit/cli add hero-minimal'\n )\n );\n console.log(\n chalk.gray(' 2. List available components: npx @foundrykit/cli list')\n );\n console.log(\n chalk.gray(' 3. Check out the docs: https://foundrykit.dev')\n );\n } catch (error) {\n console.error(chalk.red('ā Failed to initialize FoundryKit:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\nasync function validateNextJsProject(): Promise<void> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(\n 'No package.json found. Please run this command in a Next.js project root.'\n );\n }\n\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n if (!dependencies.next) {\n throw new Error(\n 'Next.js not detected. This command should be run in a Next.js project.'\n );\n }\n\n console.log(chalk.green('ā
Next.js project detected'));\n}\n\nasync function isFoundryKitInitialized(): Promise<boolean> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check if any FoundryKit packages are installed\n return Object.keys(dependencies).some(dep =>\n dep.startsWith('@foundrykit/')\n );\n }\n\n return false;\n}\n\nasync function installDependencies(): Promise<void> {\n console.log(chalk.blue('š¦ Installing FoundryKit dependencies...'));\n\n // Check if we're in a workspace (local development)\n const isWorkspace = await checkIfWorkspace();\n\n if (isWorkspace) {\n console.log(\n chalk.yellow('ā ļø Workspace detected - skipping dependency installation')\n );\n console.log(chalk.gray('Dependencies are already available via workspace'));\n return;\n }\n\n const dependencies = [\n '@foundrykit/primitives',\n '@foundrykit/components',\n '@foundrykit/blocks',\n '@foundrykit/hooks',\n '@foundrykit/animation',\n '@foundrykit/tailwind',\n ];\n\n try {\n // Detect package manager\n const packageManager = detectPackageManager();\n console.log(chalk.gray(`Using ${packageManager}...`));\n\n const installCmd =\n packageManager === 'npm'\n ? `npm install ${dependencies.join(' ')}`\n : packageManager === 'yarn'\n ? `yarn add ${dependencies.join(' ')}`\n : `pnpm add ${dependencies.join(' ')}`;\n\n execSync(installCmd, { stdio: 'inherit' });\n console.log(chalk.green('ā
Dependencies installed'));\n } catch (error) {\n throw new Error(\n 'Failed to install dependencies. Please install them manually.'\n );\n }\n}\n\nasync function checkIfWorkspace(): Promise<boolean> {\n try {\n // Check for pnpm workspace\n const pnpmWorkspacePath = path.join(\n process.cwd(),\n '../../pnpm-workspace.yaml'\n );\n if (fs.existsSync(pnpmWorkspacePath)) {\n return true;\n }\n\n // Check package.json for workspace packages\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = await fs.readJson(packageJsonPath);\n const allDeps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check if any FoundryKit packages use workspace protocol\n const foundryKitPackages = Object.keys(allDeps).filter(key =>\n key.startsWith('@foundrykit/')\n );\n for (const pkg of foundryKitPackages) {\n if (allDeps[pkg]?.includes('workspace:')) {\n return true;\n }\n }\n }\n\n return false;\n } catch {\n return false;\n }\n}\n\nfunction detectPackageManager(): string {\n if (fs.existsSync('pnpm-lock.yaml')) return 'pnpm';\n if (fs.existsSync('yarn.lock')) return 'yarn';\n return 'npm';\n}\n\nasync function setupTailwindV4(): Promise<void> {\n console.log(chalk.blue('āļø Setting up Tailwind CSS v4...'));\n\n // First check if layout already imports FoundryKit styles\n const layoutInfo = await findLayoutFile();\n if (layoutInfo) {\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing FoundryKit styles directly\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n const { importPreference } = await inquirer.prompt([\n {\n type: 'list',\n name: 'importPreference',\n message:\n 'FoundryKit styles are already imported directly. How would you like to proceed?',\n choices: [\n {\n name: 'Keep direct import from @foundrykit/tailwind/globals.css',\n value: 'direct',\n },\n {\n name: 'Switch to local globals.css file (recommended for customization)',\n value: 'local',\n },\n ],\n default: 'direct',\n },\n ]);\n\n if (importPreference === 'direct') {\n console.log(\n chalk.green(\n 'ā
Keeping direct import from @foundrykit/tailwind/globals.css'\n )\n );\n return;\n }\n\n // User wants to switch to local globals.css\n await createLocalGlobalsAndUpdateLayout(layoutInfo.path, layoutContent);\n return;\n }\n\n // Check if importing a local globals.css\n const globalsCssImportMatch = layoutContent.match(\n /import\\s+['\"]([^'\"]*globals\\.css)['\"]/\n );\n if (globalsCssImportMatch && globalsCssImportMatch[1]) {\n // Local globals.css is imported, check if it needs updating\n const importPath = globalsCssImportMatch[1];\n const resolvedPath = importPath.startsWith('.')\n ? path.join(path.dirname(layoutInfo.path), importPath)\n : path.join(process.cwd(), importPath.replace(/^@\\//, 'app/'));\n\n if (fs.existsSync(resolvedPath)) {\n const globalsCssContent = await fs.readFile(resolvedPath, 'utf-8');\n if (globalsCssContent.includes('@foundrykit/tailwind/globals.css')) {\n console.log(chalk.green('ā
FoundryKit styles already configured'));\n return;\n }\n\n // Update existing globals.css\n const updatedContent = `/* Import FoundryKit's Tailwind CSS v4 styles */\n@import \"@foundrykit/tailwind/globals.css\";\n\n/* Your custom styles below */\n${globalsCssContent}`;\n\n await fs.writeFile(resolvedPath, updatedContent);\n console.log(\n chalk.green('ā
Updated existing globals.css with FoundryKit styles')\n );\n return;\n }\n }\n }\n\n // No existing setup found, ask user preference\n const { setupPreference } = await inquirer.prompt([\n {\n type: 'list',\n name: 'setupPreference',\n message: 'How would you like to import FoundryKit styles?',\n choices: [\n {\n name: 'Create a local globals.css file (recommended for customization)',\n value: 'local',\n },\n {\n name: 'Import directly from @foundrykit/tailwind/globals.css',\n value: 'direct',\n },\n ],\n default: 'local',\n },\n ]);\n\n if (setupPreference === 'direct') {\n // Add direct import to layout\n await addDirectImportToLayout();\n } else {\n // Create local globals.css and update layout\n await createLocalGlobalsAndUpdateLayout();\n }\n}\n\nasync function createLocalGlobalsAndUpdateLayout(\n existingLayoutPath?: string,\n existingLayoutContent?: string\n): Promise<void> {\n // Find or create globals.css\n const possiblePaths = [\n 'app/globals.css',\n 'src/app/globals.css',\n 'styles/globals.css',\n 'src/styles/globals.css',\n ];\n\n let globalCssPath: string | null = null;\n for (const p of possiblePaths) {\n const fullPath = path.join(process.cwd(), p);\n if (fs.existsSync(fullPath)) {\n globalCssPath = fullPath;\n break;\n }\n }\n\n if (!globalCssPath) {\n // Create in app directory by default\n globalCssPath = path.join(process.cwd(), 'app/globals.css');\n await fs.ensureDir(path.dirname(globalCssPath));\n }\n\n // Check if the file already imports FoundryKit styles\n const existingContent = fs.existsSync(globalCssPath)\n ? await fs.readFile(globalCssPath, 'utf-8')\n : '';\n\n if (!existingContent.includes('@foundrykit/tailwind/globals.css')) {\n // Add FoundryKit import to globals.css\n const cssContent = `/* Import FoundryKit's Tailwind CSS v4 styles */\n@import \"@foundrykit/tailwind/globals.css\";\n\n/* Your custom styles below */\n${existingContent}`;\n\n await fs.writeFile(globalCssPath, cssContent);\n console.log(\n chalk.green('ā
Created/updated globals.css with FoundryKit styles')\n );\n }\n\n // Update layout file\n if (existingLayoutPath && existingLayoutContent) {\n // Replace direct import with local globals.css\n const layoutDir = path.dirname(existingLayoutPath);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n const updatedContent = existingLayoutContent.replace(\n /@foundrykit\\/tailwind\\/globals\\.css/g,\n importPath\n );\n\n await fs.writeFile(existingLayoutPath, updatedContent);\n console.log(chalk.green('ā
Updated layout to use local globals.css'));\n } else {\n // Add import to layout\n await updateLayoutImport(globalCssPath);\n }\n}\n\nasync function addDirectImportToLayout(): Promise<void> {\n const layoutInfo = await findLayoutFile();\n\n if (!layoutInfo) {\n console.log(\n chalk.yellow(\n 'ā ļø No layout file found. Please add this import to your layout manually:'\n )\n );\n console.log(chalk.gray(` import '@foundrykit/tailwind/globals.css';`));\n return;\n }\n\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n console.log(\n chalk.gray('Layout already imports FoundryKit styles directly')\n );\n return;\n }\n\n // Add import statement after existing imports\n const importStatement = `import '@foundrykit/tailwind/globals.css';`;\n\n // Find a good place to insert the import (after other imports)\n const importRegex = /^import\\s+.*$/gm;\n const imports = layoutContent.match(importRegex);\n\n let updatedContent: string;\n if (imports && imports.length > 0) {\n const lastImport = imports[imports.length - 1];\n const lastImportIndex = layoutContent.lastIndexOf(lastImport!);\n const insertPosition = lastImportIndex + lastImport!.length;\n\n updatedContent =\n layoutContent.slice(0, insertPosition) +\n '\\n' +\n importStatement +\n layoutContent.slice(insertPosition);\n } else {\n // No imports found, add at the beginning\n updatedContent = importStatement + '\\n' + layoutContent;\n }\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(\n chalk.green('ā
Added direct import of FoundryKit styles to layout')\n );\n}\n\nasync function findLayoutFile(): Promise<{ path: string } | null> {\n const layoutPaths = [\n 'app/layout.tsx',\n 'app/layout.jsx',\n 'app/layout.js',\n 'src/app/layout.tsx',\n 'src/app/layout.jsx',\n 'src/app/layout.js',\n ];\n\n for (const p of layoutPaths) {\n const fullPath = path.join(process.cwd(), p);\n if (fs.existsSync(fullPath)) {\n return { path: fullPath };\n }\n }\n\n return null;\n}\n\nasync function updateLayoutImport(globalCssPath: string): Promise<void> {\n const layoutInfo = await findLayoutFile();\n\n if (!layoutInfo) {\n console.log(\n chalk.yellow(\n 'ā ļø No layout file found. Please import globals.css manually in your layout.'\n )\n );\n return;\n }\n\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing any globals.css\n if (layoutContent.match(/import\\s+['\"][^'\"]*globals\\.css['\"]/)) {\n console.log(chalk.gray('Layout already has a globals.css import'));\n return;\n }\n\n // Check if already importing FoundryKit styles directly\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n // Replace direct FoundryKit import with local globals.css\n const layoutDir = path.dirname(layoutInfo.path);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n const updatedContent = layoutContent.replace(\n /@foundrykit\\/tailwind\\/globals\\.css/g,\n importPath\n );\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(\n chalk.green('ā
Updated layout import to use local globals.css')\n );\n return;\n }\n\n // Calculate relative import path\n const layoutDir = path.dirname(layoutInfo.path);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n // Add import statement after existing imports\n const importStatement = `import '${importPath}';`;\n\n // Find a good place to insert the import (after other imports)\n const importRegex = /^import\\s+.*$/gm;\n const imports = layoutContent.match(importRegex);\n\n let updatedContent: string;\n if (imports && imports.length > 0) {\n const lastImport = imports[imports.length - 1];\n const lastImportIndex = layoutContent.lastIndexOf(lastImport!);\n const insertPosition = lastImportIndex + lastImport!.length;\n\n updatedContent =\n layoutContent.slice(0, insertPosition) +\n '\\n' +\n importStatement +\n layoutContent.slice(insertPosition);\n } else {\n // No imports found, add at the beginning\n updatedContent = importStatement + '\\n' + layoutContent;\n }\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(chalk.green('ā
Layout file updated with globals.css import'));\n}\n\nasync function createDirectories(): Promise<void> {\n console.log(chalk.blue('š Creating component directories...'));\n\n const dirs = ['components/ui', 'components/blocks', 'lib', 'hooks'];\n\n for (const dir of dirs) {\n await fs.ensureDir(path.join(process.cwd(), dir));\n }\n\n console.log(chalk.green('ā
Directories created'));\n}\n\nasync function createExampleFiles(): Promise<void> {\n console.log(chalk.blue('š Creating example files...'));\n\n // Create lib/utils.ts\n const utilsPath = path.join(process.cwd(), 'lib/utils.ts');\n const utilsContent = `import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n`;\n\n if (!fs.existsSync(utilsPath)) {\n await fs.writeFile(utilsPath, utilsContent);\n console.log(chalk.gray('Created lib/utils.ts'));\n }\n\n // Create providers.tsx if using theme support\n const providersPath = path.join(process.cwd(), 'components/providers.tsx');\n const providersContent = `'use client';\n\nimport { ThemeProvider } from 'next-themes';\n\nexport function Providers({ children }: { children: React.ReactNode }) {\n return (\n <ThemeProvider attribute=\"class\" defaultTheme=\"system\" enableSystem>\n {children}\n </ThemeProvider>\n );\n}\n`;\n\n if (!fs.existsSync(providersPath)) {\n await fs.writeFile(providersPath, providersContent);\n console.log(chalk.gray('Created components/providers.tsx'));\n }\n\n console.log(chalk.green('ā
Example files created'));\n}\n\nasync function updatePackageScripts(): Promise<void> {\n console.log(chalk.blue('š Updating package.json scripts...'));\n\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n const packageJson = await fs.readJson(packageJsonPath);\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n // Add FoundryKit CLI scripts if they don't exist\n if (!packageJson.scripts['foundrykit']) {\n packageJson.scripts['foundrykit'] = 'foundrykit';\n }\n\n if (!packageJson.scripts['fk']) {\n packageJson.scripts['fk'] = 'foundrykit';\n }\n\n await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });\n console.log(chalk.green('ā
Package scripts updated'));\n}\n","/**\n * List command for FoundryKit CLI\n * Displays available components from the registry\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport type { ComponentMeta, ComponentCategory } from '@foundrykit/types';\nimport { getRegistry } from '../lib/registry.js';\n\ninterface ListOptions {\n category?: string;\n search?: string;\n}\n\nexport function listCommand() {\n return new Command('list')\n .description('List all available FoundryKit components and blocks')\n .option(\n '-c, --category <category>',\n 'filter by category (primitives, components, blocks, animations)'\n )\n .option('-s, --search <term>', 'search components by name or description')\n .action(async (options: ListOptions) => {\n try {\n console.log(chalk.blue('š¦ Available FoundryKit components:'));\n\n const registry = getRegistry();\n\n // Validate category if provided\n if (options.category) {\n const validCategories: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n if (\n !validCategories.includes(options.category as ComponentCategory)\n ) {\n console.error(chalk.red(`Invalid category: ${options.category}`));\n console.log(\n chalk.gray(`Valid categories: ${validCategories.join(', ')}`)\n );\n process.exit(1);\n }\n }\n\n // Fetch components from registry\n console.log(chalk.gray('Fetching from registry...'));\n const components = await registry.getComponents(\n options.category,\n options.search\n );\n\n if (components.length === 0) {\n console.log(\n chalk.yellow('\\nNo components found matching your criteria.')\n );\n if (options.search) {\n console.log(chalk.gray(`Search term: \"${options.search}\"`));\n }\n if (options.category) {\n console.log(chalk.gray(`Category: ${options.category}`));\n }\n return;\n }\n\n // Group and display components\n displayComponents(components);\n\n // Show usage hints\n console.log(chalk.cyan('\\nš” Usage:'));\n console.log(\n chalk.gray(' foundrykit add # Interactive mode')\n );\n console.log(\n chalk.gray(' foundrykit add <id> # Add specific component')\n );\n console.log(chalk.gray(' foundrykit add button # Example'));\n } catch (error) {\n console.error(chalk.red('ā Failed to fetch component registry:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\n/**\n * Display components grouped by category\n */\nfunction displayComponents(components: ComponentMeta[]): void {\n // Group components by category\n const grouped = components.reduce(\n (acc, component) => {\n if (!acc[component.category]) {\n acc[component.category] = [];\n }\n acc[component.category].push(component);\n return acc;\n },\n {} as Record<ComponentCategory, ComponentMeta[]>\n );\n\n // Display in category order\n const categoryOrder: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n\n for (const category of categoryOrder) {\n const items = grouped[category];\n if (!items || items.length === 0) continue;\n\n console.log(`\\n${chalk.cyan.bold(category.toUpperCase())}`);\n console.log(chalk.gray('ā'.repeat(40)));\n\n for (const item of items) {\n // Component name and ID\n console.log(\n `${chalk.green('ā')} ${chalk.bold(item.name)} ${chalk.gray(\n `(${item.id})`\n )}`\n );\n\n // Description\n console.log(` ${chalk.gray(item.description)}`);\n\n // Tags\n if (item.tags && item.tags.length > 0) {\n console.log(\n ` ${chalk.blue(item.tags.map(tag => `#${tag}`).join(' '))}`\n );\n }\n\n // Dependencies\n if (item.registryDependencies && item.registryDependencies.length > 0) {\n console.log(\n ` ${chalk.yellow('Requires:')} ${item.registryDependencies.join(\n ', '\n )}`\n );\n }\n\n // Package dependencies\n if (item.packageDependencies && item.packageDependencies.length > 0) {\n console.log(\n ` ${chalk.magenta('NPM packages:')} ${item.packageDependencies.join(\n ', '\n )}`\n );\n }\n\n console.log();\n }\n }\n\n // Show summary\n const total = components.length;\n const byCategory = Object.entries(grouped)\n .map(([cat, items]) => `${items.length} ${cat}`)\n .join(', ');\n\n console.log(chalk.gray('ā'.repeat(40)));\n console.log(chalk.gray(`Total: ${total} components (${byCategory})`));\n}\n","/**\n * Registry service for fetching and caching component data\n * Handles communication with the FoundryKit registry\n */\n\nimport fs from 'fs-extra';\nimport path from 'path';\nimport os from 'os';\nimport chalk from 'chalk';\nimport type {\n ComponentMeta,\n ComponentData,\n RegistryIndex,\n RegistryComponent,\n RegistryError,\n LocalCache,\n CLIConfig,\n} from '@foundrykit/types';\n\n/**\n * Default configuration\n */\nconst DEFAULT_CONFIG: CLIConfig = {\n registryUrl:\n process.env.FOUNDRYKIT_REGISTRY_URL || 'https://foundry.umiflow.com',\n cacheDir: path.join(os.homedir(), '.foundrykit', 'cache'),\n cacheMaxAge: 1000 * 60 * 60 * 24, // 24 hours\n};\n\n/**\n * Registry service class\n */\nexport class RegistryService {\n private config: CLIConfig;\n private cacheFile: string;\n\n constructor(config?: Partial<CLIConfig>) {\n this.config = { ...DEFAULT_CONFIG, ...config };\n this.cacheFile = path.join(this.config.cacheDir, 'registry.json');\n }\n\n /**\n * Fetch all components from the registry\n */\n async getComponents(\n category?: string,\n search?: string\n ): Promise<RegistryIndex> {\n try {\n // Build query params\n const params = new URLSearchParams();\n if (category) params.append('category', category);\n if (search) params.append('search', search);\n\n const url = `${this.config.registryUrl}/registry${\n params.toString() ? '?' + params.toString() : ''\n }`;\n\n console.log(chalk.gray(`Fetching from: ${url}`));\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Registry returned ${response.status}: ${response.statusText}`\n );\n }\n\n const components = (await response.json()) as RegistryIndex;\n\n // Update cache\n await this.updateCache(components);\n\n return components;\n } catch (error) {\n // Try to load from cache\n const cache = await this.loadCache();\n if (cache && this.isCacheValid(cache)) {\n console.log(chalk.yellow('Using cached registry data'));\n return this.filterComponents(cache.components, category, search);\n }\n\n // No valid cache, throw error\n throw new Error(\n `Failed to connect to registry: ${error instanceof Error ? error.message : 'Unknown error'}\\n` +\n `Registry URL: ${this.config.registryUrl}\\n` +\n `Try again later or check your internet connection.`\n );\n }\n }\n\n /**\n * Fetch a specific component by ID\n */\n async getComponent(id: string): Promise<ComponentData> {\n try {\n const url = `${this.config.registryUrl}/registry/${id}`;\n console.log(chalk.gray(`Fetching component: ${url}`));\n\n const response = await fetch(url);\n\n if (!response.ok) {\n if (response.status === 404) {\n throw new Error(`Component \"${id}\" not found in registry`);\n }\n throw new Error(\n `Registry returned ${response.status}: ${response.statusText}`\n );\n }\n\n const component = (await response.json()) as RegistryComponent;\n\n // Cache the component data\n await this.cacheComponent(component);\n\n return component;\n } catch (error) {\n // Try to load from cache\n const cache = await this.loadCache();\n if (cache?.componentData?.[id]) {\n console.log(chalk.yellow(`Using cached data for component: ${id}`));\n return cache.componentData[id];\n }\n\n // No cached data, throw error\n throw new Error(\n `Failed to fetch component \"${id}\": ${error instanceof Error ? error.message : 'Unknown error'}\\n` +\n `Registry URL: ${this.config.registryUrl}\\n` +\n `Try again later or check your internet connection.`\n );\n }\n }\n\n /**\n * Update the local cache with new component list\n */\n private async updateCache(components: RegistryIndex): Promise<void> {\n try {\n const cache = await this.loadCache();\n const newCache: LocalCache = {\n version: '1.0.0',\n lastUpdated: new Date().toISOString(),\n components,\n componentData: cache?.componentData || {},\n };\n\n await fs.ensureDir(this.config.cacheDir);\n await fs.writeJson(this.cacheFile, newCache, { spaces: 2 });\n } catch (error) {\n // Cache update failed, but don't throw - this is not critical\n console.log(chalk.gray('Failed to update cache'));\n }\n }\n\n /**\n * Cache a specific component\n */\n private async cacheComponent(component: ComponentData): Promise<void> {\n try {\n const cache = await this.loadCache();\n if (!cache) return;\n\n cache.componentData[component.id] = component;\n cache.lastUpdated = new Date().toISOString();\n\n await fs.writeJson(this.cacheFile, cache, { spaces: 2 });\n } catch (error) {\n // Cache update failed, but don't throw\n console.log(chalk.gray('Failed to cache component'));\n }\n }\n\n /**\n * Load the local cache\n */\n private async loadCache(): Promise<LocalCache | null> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n return await fs.readJson(this.cacheFile);\n }\n } catch (error) {\n console.log(chalk.gray('Failed to load cache'));\n }\n return null;\n }\n\n /**\n * Check if cache is still valid\n */\n private isCacheValid(cache: LocalCache): boolean {\n const lastUpdated = new Date(cache.lastUpdated).getTime();\n const now = Date.now();\n return now - lastUpdated < this.config.cacheMaxAge;\n }\n\n /**\n * Filter components by category and search\n */\n private filterComponents(\n components: ComponentMeta[],\n category?: string,\n search?: string\n ): ComponentMeta[] {\n let filtered = components;\n\n if (category) {\n filtered = filtered.filter(c => c.category === category);\n }\n\n if (search) {\n const searchLower = search.toLowerCase();\n filtered = filtered.filter(\n c =>\n c.name.toLowerCase().includes(searchLower) ||\n c.description.toLowerCase().includes(searchLower) ||\n c.id.toLowerCase().includes(searchLower) ||\n c.tags?.some(tag => tag.toLowerCase().includes(searchLower))\n );\n }\n\n return filtered;\n }\n\n /**\n * Clear the local cache\n */\n async clearCache(): Promise<void> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n await fs.remove(this.cacheFile);\n console.log(chalk.green('Cache cleared successfully'));\n }\n } catch (error) {\n throw new Error(\n `Failed to clear cache: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n\n /**\n * Get cache statistics\n */\n async getCacheStats(): Promise<{\n exists: boolean;\n size: number;\n lastUpdated: string | null;\n componentCount: number;\n }> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n const cache = await this.loadCache();\n const stats = await fs.stat(this.cacheFile);\n\n return {\n exists: true,\n size: stats.size,\n lastUpdated: cache?.lastUpdated || null,\n componentCount: cache?.components.length || 0,\n };\n }\n } catch (error) {\n // Ignore errors\n }\n\n return {\n exists: false,\n size: 0,\n lastUpdated: null,\n componentCount: 0,\n };\n }\n}\n\n/**\n * Singleton instance\n */\nlet registryInstance: RegistryService | null = null;\n\n/**\n * Get the registry service instance\n */\nexport function getRegistry(config?: Partial<CLIConfig>): RegistryService {\n if (!registryInstance) {\n registryInstance = new RegistryService(config);\n }\n return registryInstance;\n}\n\n/**\n * Reset the registry instance (mainly for testing)\n */\nexport function resetRegistry(): void {\n registryInstance = null;\n}\n","/**\n * Add command for FoundryKit CLI\n * Handles adding components to projects\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport inquirer from 'inquirer';\nimport type {\n ComponentMeta,\n ComponentData,\n ComponentCategory,\n} from '@foundrykit/types';\nimport { getRegistry } from '../lib/registry.js';\n\ninterface AddOptions {\n withAnimation?: boolean;\n path?: string;\n overwrite?: boolean;\n}\n\nexport function addCommand() {\n return new Command('add')\n .description('Add a component or block to your project')\n .argument('[id]', 'Component or block ID (optional for interactive mode)')\n .option('--with-animation', 'Include animation variants')\n .option('-p, --path <path>', 'Custom installation path')\n .option('-o, --overwrite', 'Overwrite existing files')\n .action(async (id: string | undefined, options: AddOptions) => {\n try {\n // If no ID provided, show interactive selector\n if (!id) {\n const selectedIds = await selectComponentsInteractively();\n if (selectedIds.length === 0) {\n console.log(chalk.yellow('No components selected.'));\n return;\n }\n\n // Add each selected component\n for (const componentId of selectedIds) {\n await addSingleComponent(componentId, options);\n }\n } else {\n // Add single component\n await addSingleComponent(id, options);\n }\n } catch (error) {\n console.error(chalk.red('ā Failed to add component:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\n/**\n * Interactive component selection\n */\nasync function selectComponentsInteractively(): Promise<string[]> {\n console.log(chalk.blue('š¦ Select components to add:'));\n console.log(\n chalk.gray(' Use arrow keys to navigate, space to select, a to toggle all')\n );\n console.log(chalk.gray(' Press enter when done\\n'));\n\n const registry = getRegistry();\n\n try {\n // Fetch all available components from registry\n console.log(chalk.gray('Fetching components from registry...'));\n const allComponents = await registry.getComponents();\n\n if (allComponents.length === 0) {\n console.log(chalk.yellow('No components available in the registry.'));\n return [];\n }\n\n // Group components by category\n const groupedChoices = createGroupedChoices(allComponents);\n\n const { selectedComponents } = await inquirer.prompt([\n {\n type: 'checkbox',\n name: 'selectedComponents',\n message: 'Which components would you like to add?',\n choices: groupedChoices,\n pageSize: 20,\n loop: false,\n },\n ]);\n\n return selectedComponents;\n } catch (error) {\n console.error(chalk.red('Failed to fetch components from registry:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n throw error;\n }\n}\n\n/**\n * Create grouped choices for the interactive selector\n */\nfunction createGroupedChoices(components: ComponentMeta[]) {\n const categories: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n\n const choices: any[] = [];\n\n for (const category of categories) {\n const categoryComponents = components.filter(c => c.category === category);\n\n if (categoryComponents.length === 0) continue;\n\n // Add category separator\n choices.push({\n name: chalk.bold.cyan(`āāā ${category.toUpperCase()} āāā`),\n disabled: true,\n value: `separator-${category}`,\n });\n\n // Add components in this category\n for (const component of categoryComponents) {\n choices.push({\n name: `${component.name} - ${chalk.gray(component.description)}`,\n value: component.id,\n short: component.name,\n });\n }\n }\n\n return choices;\n}\n\n/**\n * Add a single component to the project\n */\nasync function addSingleComponent(\n id: string,\n options: AddOptions\n): Promise<void> {\n console.log(chalk.blue(`\\nš¦ Adding ${id} to your project...`));\n\n // Validate project is initialized\n await validateProject();\n\n const registry = getRegistry();\n\n try {\n // Fetch component data from registry\n const componentData = await registry.getComponent(id);\n\n // Check for existing files\n if (\n !options.overwrite &&\n (await hasConflictingFiles(componentData, options))\n ) {\n const { shouldContinue } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'shouldContinue',\n message: `Some files for ${componentData.name} already exist. Overwrite?`,\n default: false,\n },\n ]);\n\n if (!shouldContinue) {\n console.log(chalk.yellow(`āļø Skipping ${componentData.name}.`));\n return;\n }\n }\n\n // Install registry dependencies first\n if (componentData.registryDependencies?.length) {\n console.log(chalk.blue('š¦ Installing required dependencies...'));\n for (const dep of componentData.registryDependencies) {\n // Check if dependency is already installed\n const depData = await registry.getComponent(dep);\n if (!(await hasConflictingFiles(depData, options))) {\n await installComponentFiles(depData, options);\n console.log(chalk.green(` ā Installed ${dep}`));\n }\n }\n }\n\n // Install the component files\n await installComponentFiles(componentData, options);\n\n console.log(chalk.green(`ā
${componentData.name} added successfully!`));\n\n // Show usage example\n showUsageExample(componentData);\n\n // Show package dependencies if any\n if (componentData.packageDependencies?.length) {\n console.log(chalk.yellow('\\nš¦ Required npm packages:'));\n console.log(\n chalk.gray(` ${componentData.packageDependencies.join(', ')}`)\n );\n console.log(chalk.gray(' Install them with:'));\n console.log(\n chalk.cyan(` pnpm add ${componentData.packageDependencies.join(' ')}`)\n );\n }\n } catch (error) {\n console.error(chalk.red(`Failed to add ${id}:`));\n throw error;\n }\n}\n\n/**\n * Validate that the project is properly initialized\n */\nasync function validateProject(): Promise<void> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(\n 'No package.json found. Please run this command in a project root.'\n );\n }\n\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check for Next.js or FoundryKit packages\n const hasFoundryKit = Object.keys(dependencies).some(dep =>\n dep.startsWith('@foundrykit/')\n );\n\n if (!hasFoundryKit && !dependencies.next) {\n throw new Error('FoundryKit not initialized. Run \"foundrykit init\" first.');\n }\n}\n\n/**\n * Check if component files already exist\n */\nasync function hasConflictingFiles(\n componentData: ComponentData,\n options: AddOptions\n): Promise<boolean> {\n const basePath = options.path || process.cwd();\n\n for (const file of componentData.files) {\n const filePath = path.join(basePath, file.path);\n if (fs.existsSync(filePath)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Install component files to the project\n */\nasync function installComponentFiles(\n componentData: ComponentData,\n options: AddOptions\n): Promise<void> {\n const basePath = options.path || process.cwd();\n\n console.log(chalk.blue('š Installing component files...'));\n\n for (const file of componentData.files) {\n const filePath = path.join(basePath, file.path);\n\n // Ensure directory exists\n await fs.ensureDir(path.dirname(filePath));\n\n // Write file\n await fs.writeFile(filePath, file.content);\n\n console.log(chalk.green(` ā ${file.path}`));\n }\n}\n\n/**\n * Show usage example for the installed component\n */\nfunction showUsageExample(componentData: ComponentData): void {\n console.log(chalk.cyan('\\nš” Usage:'));\n\n const componentName = componentData.name.replace(/\\s+/g, '');\n\n if (\n componentData.category === 'primitives' ||\n componentData.category === 'components'\n ) {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/ui/${componentData.id}\"`\n )\n );\n } else if (componentData.category === 'blocks') {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/blocks/${componentData.id}\"`\n )\n );\n } else if (componentData.category === 'animations') {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/animations/${componentData.id}\"`\n )\n );\n }\n\n // Show basic usage examples based on component type\n if (componentData.id === 'button') {\n console.log(chalk.gray('\\n<Button>Click me</Button>'));\n console.log(chalk.gray('<Button variant=\"outline\">Outline</Button>'));\n } else if (componentData.id === 'input') {\n console.log(chalk.gray('\\n<Input placeholder=\"Enter text...\" />'));\n } else if (componentData.id.includes('hero')) {\n console.log(chalk.gray(`\\n<${componentName} />`));\n } else if (componentData.id === 'card') {\n console.log(chalk.gray('\\n<Card>'));\n console.log(chalk.gray(' <CardHeader>'));\n console.log(chalk.gray(' <CardTitle>Title</CardTitle>'));\n console.log(\n chalk.gray(' <CardDescription>Description</CardDescription>')\n );\n console.log(chalk.gray(' </CardHeader>'));\n console.log(chalk.gray(' <CardContent>Content</CardContent>'));\n console.log(chalk.gray('</Card>'));\n }\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\n\nexport function updateCommand() {\n return new Command('update')\n .description('Update an existing component or block')\n .argument('<id>', 'Component or block ID')\n .action(async id => {\n console.log(chalk.blue(`š Updating ${id}...`));\n console.log(chalk.green(`ā
${id} updated successfully!`));\n });\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\n\nexport function doctorCommand() {\n return new Command('doctor')\n .description('Check project health and configuration')\n .action(async () => {\n console.log(chalk.blue('š Checking project health...'));\n console.log(chalk.green('ā
All checks passed!'));\n });\n}\n"],"mappings":";;;AAEA,SAAS,WAAAA,gBAAe;;;ACFxB,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,gBAAgB;AACzB,OAAO,cAAc;AAOd,SAAS,cAAc;AAC5B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,OAAM,KAAK,SAAS,CAAC;AAAA,EACnC;AACF;;;ACnVA,SAAS,WAAAI,gBAAe;AACxB,OAAOC,YAAW;AAEX,SAAS,gBAAgB;AAC9B,SAAO,IAAID,SAAQ,QAAQ,EACxB,YAAY,uCAAuC,EACnD,SAAS,QAAQ,uBAAuB,EACxC,OAAO,OAAM,OAAM;AAClB,YAAQ,IAAIC,OAAM,KAAK,sBAAe,EAAE,KAAK,CAAC;AAC9C,YAAQ,IAAIA,OAAM,MAAM,UAAK,EAAE,wBAAwB,CAAC;AAAA,EAC1D,CAAC;AACL;;;ACXA,SAAS,WAAAC,gBAAe;AACxB,OAAOC,YAAW;AAEX,SAAS,gBAAgB;AAC9B,SAAO,IAAID,SAAQ,QAAQ,EACxB,YAAY,wCAAwC,EACpD,OAAO,YAAY;AAClB,YAAQ,IAAIC,OAAM,KAAK,sCAA+B,CAAC;AACvD,YAAQ,IAAIA,OAAM,MAAM,2BAAsB,CAAC;AAAA,EACjD,CAAC;AACL;;;ANDA,IAAM,UAAU,IAAIC,SAAQ;AAE5B,QACG,KAAK,YAAY,EACjB,YAAY,oDAAoD,EAChE,QAAQ,OAAO;AAGlB,QAAQ,WAAW,YAAY,CAAC;AAChC,QAAQ,WAAW,YAAY,CAAC;AAChC,QAAQ,WAAW,WAAW,CAAC;AAC/B,QAAQ,WAAW,cAAc,CAAC;AAClC,QAAQ,WAAW,cAAc,CAAC;AAElC,QAAQ,MAAM;","names":["Command","layoutDir","cssRelativePath","importPath","updatedContent","Command","chalk","fs","path","chalk","Command","chalk","Command","chalk","fs","path","inquirer","Command","chalk","inquirer","path","fs","Command","chalk","Command","chalk","Command"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/commands/init.ts","../src/commands/list.ts","../src/lib/registry.ts","../src/commands/add.ts","../src/commands/update.ts","../src/commands/doctor.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { readFileSync } from 'fs';\nimport { fileURLToPath } from 'url';\nimport { dirname, join } from 'path';\nimport { initCommand } from './commands/init.js';\nimport { listCommand } from './commands/list.js';\nimport { addCommand } from './commands/add.js';\nimport { updateCommand } from './commands/update.js';\nimport { doctorCommand } from './commands/doctor.js';\n\n// Get package.json version\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst packageJson = JSON.parse(\n readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')\n);\n\nconst program = new Command();\n\nprogram\n .name('foundrykit')\n .description('FoundryKit CLI - Component library management tool')\n .version(packageJson.version);\n\n// Add commands\nprogram.addCommand(initCommand());\nprogram.addCommand(listCommand());\nprogram.addCommand(addCommand());\nprogram.addCommand(updateCommand());\nprogram.addCommand(doctorCommand());\n\nprogram.parse();\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { execSync } from 'child_process';\nimport inquirer from 'inquirer';\n\ninterface InitOptions {\n force?: boolean;\n skipInstall?: boolean;\n}\n\nexport function initCommand() {\n return new Command('init')\n .description('Initialize FoundryKit in your Next.js project')\n .option('-f, --force', 'overwrite existing files')\n .option('--skip-install', 'skip installing dependencies')\n .action(async (options: InitOptions) => {\n try {\n console.log(chalk.blue('š Initializing FoundryKit...'));\n\n // Check if it's a Next.js project\n await validateNextJsProject();\n\n // Check if already initialized\n if (!options.force && (await isFoundryKitInitialized())) {\n const { shouldContinue } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'shouldContinue',\n message: 'FoundryKit is already initialized. Continue anyway?',\n default: false,\n },\n ]);\n\n if (!shouldContinue) {\n console.log(chalk.yellow('ā Initialization cancelled.'));\n return;\n }\n }\n\n // Install dependencies\n if (!options.skipInstall) {\n await installDependencies();\n }\n\n // Setup CSS with Tailwind v4\n await setupTailwindV4();\n\n // Create components directory\n await createDirectories();\n\n // Create example files\n await createExampleFiles();\n\n // Update package.json scripts\n await updatePackageScripts();\n\n console.log(chalk.green('\\nā
FoundryKit initialized successfully!'));\n console.log(chalk.cyan('\\nš¦ Next steps:'));\n console.log(\n chalk.gray(\n ' 1. Add a component: npx @foundrykit/cli add hero-minimal'\n )\n );\n console.log(\n chalk.gray(' 2. List available components: npx @foundrykit/cli list')\n );\n console.log(\n chalk.gray(' 3. Check out the docs: https://foundrykit.dev')\n );\n } catch (error) {\n console.error(chalk.red('ā Failed to initialize FoundryKit:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\nasync function validateNextJsProject(): Promise<void> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(\n 'No package.json found. Please run this command in a Next.js project root.'\n );\n }\n\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n if (!dependencies.next) {\n throw new Error(\n 'Next.js not detected. This command should be run in a Next.js project.'\n );\n }\n\n console.log(chalk.green('ā
Next.js project detected'));\n}\n\nasync function isFoundryKitInitialized(): Promise<boolean> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check if any FoundryKit packages are installed\n return Object.keys(dependencies).some(dep =>\n dep.startsWith('@foundrykit/')\n );\n }\n\n return false;\n}\n\nasync function installDependencies(): Promise<void> {\n console.log(chalk.blue('š¦ Installing FoundryKit dependencies...'));\n\n // Check if we're in a workspace (local development)\n const isWorkspace = await checkIfWorkspace();\n\n if (isWorkspace) {\n console.log(\n chalk.yellow('ā ļø Workspace detected - skipping dependency installation')\n );\n console.log(chalk.gray('Dependencies are already available via workspace'));\n return;\n }\n\n const dependencies = [\n '@foundrykit/primitives',\n '@foundrykit/components',\n '@foundrykit/blocks',\n '@foundrykit/hooks',\n '@foundrykit/animation',\n '@foundrykit/tailwind',\n ];\n\n try {\n // Detect package manager\n const packageManager = detectPackageManager();\n console.log(chalk.gray(`Using ${packageManager}...`));\n\n const installCmd =\n packageManager === 'npm'\n ? `npm install ${dependencies.join(' ')}`\n : packageManager === 'yarn'\n ? `yarn add ${dependencies.join(' ')}`\n : `pnpm add ${dependencies.join(' ')}`;\n\n execSync(installCmd, { stdio: 'inherit' });\n console.log(chalk.green('ā
Dependencies installed'));\n } catch (error) {\n throw new Error(\n 'Failed to install dependencies. Please install them manually.'\n );\n }\n}\n\nasync function checkIfWorkspace(): Promise<boolean> {\n try {\n // Check for pnpm workspace\n const pnpmWorkspacePath = path.join(\n process.cwd(),\n '../../pnpm-workspace.yaml'\n );\n if (fs.existsSync(pnpmWorkspacePath)) {\n return true;\n }\n\n // Check package.json for workspace packages\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = await fs.readJson(packageJsonPath);\n const allDeps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check if any FoundryKit packages use workspace protocol\n const foundryKitPackages = Object.keys(allDeps).filter(key =>\n key.startsWith('@foundrykit/')\n );\n for (const pkg of foundryKitPackages) {\n if (allDeps[pkg]?.includes('workspace:')) {\n return true;\n }\n }\n }\n\n return false;\n } catch {\n return false;\n }\n}\n\nfunction detectPackageManager(): string {\n if (fs.existsSync('pnpm-lock.yaml')) return 'pnpm';\n if (fs.existsSync('yarn.lock')) return 'yarn';\n return 'npm';\n}\n\nasync function setupTailwindV4(): Promise<void> {\n console.log(chalk.blue('āļø Setting up Tailwind CSS v4...'));\n\n // First check if layout already imports FoundryKit styles\n const layoutInfo = await findLayoutFile();\n if (layoutInfo) {\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing FoundryKit styles directly\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n const { importPreference } = await inquirer.prompt([\n {\n type: 'list',\n name: 'importPreference',\n message:\n 'FoundryKit styles are already imported directly. How would you like to proceed?',\n choices: [\n {\n name: 'Keep direct import from @foundrykit/tailwind/globals.css',\n value: 'direct',\n },\n {\n name: 'Switch to local globals.css file (recommended for customization)',\n value: 'local',\n },\n ],\n default: 'direct',\n },\n ]);\n\n if (importPreference === 'direct') {\n console.log(\n chalk.green(\n 'ā
Keeping direct import from @foundrykit/tailwind/globals.css'\n )\n );\n return;\n }\n\n // User wants to switch to local globals.css\n await createLocalGlobalsAndUpdateLayout(layoutInfo.path, layoutContent);\n return;\n }\n\n // Check if importing a local globals.css\n const globalsCssImportMatch = layoutContent.match(\n /import\\s+['\"]([^'\"]*globals\\.css)['\"]/\n );\n if (globalsCssImportMatch && globalsCssImportMatch[1]) {\n // Local globals.css is imported, check if it needs updating\n const importPath = globalsCssImportMatch[1];\n const resolvedPath = importPath.startsWith('.')\n ? path.join(path.dirname(layoutInfo.path), importPath)\n : path.join(process.cwd(), importPath.replace(/^@\\//, 'app/'));\n\n if (fs.existsSync(resolvedPath)) {\n const globalsCssContent = await fs.readFile(resolvedPath, 'utf-8');\n if (globalsCssContent.includes('@foundrykit/tailwind/globals.css')) {\n console.log(chalk.green('ā
FoundryKit styles already configured'));\n return;\n }\n\n // Update existing globals.css\n const updatedContent = `/* Import FoundryKit's Tailwind CSS v4 styles */\n@import \"@foundrykit/tailwind/globals.css\";\n\n/* Your custom styles below */\n${globalsCssContent}`;\n\n await fs.writeFile(resolvedPath, updatedContent);\n console.log(\n chalk.green('ā
Updated existing globals.css with FoundryKit styles')\n );\n return;\n }\n }\n }\n\n // No existing setup found, ask user preference\n const { setupPreference } = await inquirer.prompt([\n {\n type: 'list',\n name: 'setupPreference',\n message: 'How would you like to import FoundryKit styles?',\n choices: [\n {\n name: 'Create a local globals.css file (recommended for customization)',\n value: 'local',\n },\n {\n name: 'Import directly from @foundrykit/tailwind/globals.css',\n value: 'direct',\n },\n ],\n default: 'local',\n },\n ]);\n\n if (setupPreference === 'direct') {\n // Add direct import to layout\n await addDirectImportToLayout();\n } else {\n // Create local globals.css and update layout\n await createLocalGlobalsAndUpdateLayout();\n }\n}\n\nasync function createLocalGlobalsAndUpdateLayout(\n existingLayoutPath?: string,\n existingLayoutContent?: string\n): Promise<void> {\n // Find or create globals.css\n const possiblePaths = [\n 'app/globals.css',\n 'src/app/globals.css',\n 'styles/globals.css',\n 'src/styles/globals.css',\n ];\n\n let globalCssPath: string | null = null;\n for (const p of possiblePaths) {\n const fullPath = path.join(process.cwd(), p);\n if (fs.existsSync(fullPath)) {\n globalCssPath = fullPath;\n break;\n }\n }\n\n if (!globalCssPath) {\n // Create in app directory by default\n globalCssPath = path.join(process.cwd(), 'app/globals.css');\n await fs.ensureDir(path.dirname(globalCssPath));\n }\n\n // Check if the file already imports FoundryKit styles\n const existingContent = fs.existsSync(globalCssPath)\n ? await fs.readFile(globalCssPath, 'utf-8')\n : '';\n\n if (!existingContent.includes('@foundrykit/tailwind/globals.css')) {\n // Add FoundryKit import to globals.css\n const cssContent = `/* Import FoundryKit's Tailwind CSS v4 styles */\n@import \"@foundrykit/tailwind/globals.css\";\n\n/* Your custom styles below */\n${existingContent}`;\n\n await fs.writeFile(globalCssPath, cssContent);\n console.log(\n chalk.green('ā
Created/updated globals.css with FoundryKit styles')\n );\n }\n\n // Update layout file\n if (existingLayoutPath && existingLayoutContent) {\n // Replace direct import with local globals.css\n const layoutDir = path.dirname(existingLayoutPath);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n const updatedContent = existingLayoutContent.replace(\n /@foundrykit\\/tailwind\\/globals\\.css/g,\n importPath\n );\n\n await fs.writeFile(existingLayoutPath, updatedContent);\n console.log(chalk.green('ā
Updated layout to use local globals.css'));\n } else {\n // Add import to layout\n await updateLayoutImport(globalCssPath);\n }\n}\n\nasync function addDirectImportToLayout(): Promise<void> {\n const layoutInfo = await findLayoutFile();\n\n if (!layoutInfo) {\n console.log(\n chalk.yellow(\n 'ā ļø No layout file found. Please add this import to your layout manually:'\n )\n );\n console.log(chalk.gray(` import '@foundrykit/tailwind/globals.css';`));\n return;\n }\n\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n console.log(\n chalk.gray('Layout already imports FoundryKit styles directly')\n );\n return;\n }\n\n // Add import statement after existing imports\n const importStatement = `import '@foundrykit/tailwind/globals.css';`;\n\n // Find a good place to insert the import (after other imports)\n const importRegex = /^import\\s+.*$/gm;\n const imports = layoutContent.match(importRegex);\n\n let updatedContent: string;\n if (imports && imports.length > 0) {\n const lastImport = imports[imports.length - 1];\n const lastImportIndex = layoutContent.lastIndexOf(lastImport!);\n const insertPosition = lastImportIndex + lastImport!.length;\n\n updatedContent =\n layoutContent.slice(0, insertPosition) +\n '\\n' +\n importStatement +\n layoutContent.slice(insertPosition);\n } else {\n // No imports found, add at the beginning\n updatedContent = importStatement + '\\n' + layoutContent;\n }\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(\n chalk.green('ā
Added direct import of FoundryKit styles to layout')\n );\n}\n\nasync function findLayoutFile(): Promise<{ path: string } | null> {\n const layoutPaths = [\n 'app/layout.tsx',\n 'app/layout.jsx',\n 'app/layout.js',\n 'src/app/layout.tsx',\n 'src/app/layout.jsx',\n 'src/app/layout.js',\n ];\n\n for (const p of layoutPaths) {\n const fullPath = path.join(process.cwd(), p);\n if (fs.existsSync(fullPath)) {\n return { path: fullPath };\n }\n }\n\n return null;\n}\n\nasync function updateLayoutImport(globalCssPath: string): Promise<void> {\n const layoutInfo = await findLayoutFile();\n\n if (!layoutInfo) {\n console.log(\n chalk.yellow(\n 'ā ļø No layout file found. Please import globals.css manually in your layout.'\n )\n );\n return;\n }\n\n const layoutContent = await fs.readFile(layoutInfo.path, 'utf-8');\n\n // Check if already importing any globals.css\n if (layoutContent.match(/import\\s+['\"][^'\"]*globals\\.css['\"]/)) {\n console.log(chalk.gray('Layout already has a globals.css import'));\n return;\n }\n\n // Check if already importing FoundryKit styles directly\n if (layoutContent.includes('@foundrykit/tailwind/globals.css')) {\n // Replace direct FoundryKit import with local globals.css\n const layoutDir = path.dirname(layoutInfo.path);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n const updatedContent = layoutContent.replace(\n /@foundrykit\\/tailwind\\/globals\\.css/g,\n importPath\n );\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(\n chalk.green('ā
Updated layout import to use local globals.css')\n );\n return;\n }\n\n // Calculate relative import path\n const layoutDir = path.dirname(layoutInfo.path);\n const cssRelativePath = path\n .relative(layoutDir, globalCssPath)\n .replace(/\\\\/g, '/');\n const importPath = cssRelativePath.startsWith('.')\n ? cssRelativePath\n : `./${cssRelativePath}`;\n\n // Add import statement after existing imports\n const importStatement = `import '${importPath}';`;\n\n // Find a good place to insert the import (after other imports)\n const importRegex = /^import\\s+.*$/gm;\n const imports = layoutContent.match(importRegex);\n\n let updatedContent: string;\n if (imports && imports.length > 0) {\n const lastImport = imports[imports.length - 1];\n const lastImportIndex = layoutContent.lastIndexOf(lastImport!);\n const insertPosition = lastImportIndex + lastImport!.length;\n\n updatedContent =\n layoutContent.slice(0, insertPosition) +\n '\\n' +\n importStatement +\n layoutContent.slice(insertPosition);\n } else {\n // No imports found, add at the beginning\n updatedContent = importStatement + '\\n' + layoutContent;\n }\n\n await fs.writeFile(layoutInfo.path, updatedContent);\n console.log(chalk.green('ā
Layout file updated with globals.css import'));\n}\n\nasync function createDirectories(): Promise<void> {\n console.log(chalk.blue('š Creating component directories...'));\n\n const dirs = ['components/ui', 'components/blocks', 'lib', 'hooks'];\n\n for (const dir of dirs) {\n await fs.ensureDir(path.join(process.cwd(), dir));\n }\n\n console.log(chalk.green('ā
Directories created'));\n}\n\nasync function createExampleFiles(): Promise<void> {\n console.log(chalk.blue('š Creating example files...'));\n\n // Create lib/utils.ts\n const utilsPath = path.join(process.cwd(), 'lib/utils.ts');\n const utilsContent = `import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n`;\n\n if (!fs.existsSync(utilsPath)) {\n await fs.writeFile(utilsPath, utilsContent);\n console.log(chalk.gray('Created lib/utils.ts'));\n }\n\n // Create providers.tsx if using theme support\n const providersPath = path.join(process.cwd(), 'components/providers.tsx');\n const providersContent = `'use client';\n\nimport { ThemeProvider } from 'next-themes';\n\nexport function Providers({ children }: { children: React.ReactNode }) {\n return (\n <ThemeProvider attribute=\"class\" defaultTheme=\"system\" enableSystem>\n {children}\n </ThemeProvider>\n );\n}\n`;\n\n if (!fs.existsSync(providersPath)) {\n await fs.writeFile(providersPath, providersContent);\n console.log(chalk.gray('Created components/providers.tsx'));\n }\n\n console.log(chalk.green('ā
Example files created'));\n}\n\nasync function updatePackageScripts(): Promise<void> {\n console.log(chalk.blue('š Updating package.json scripts...'));\n\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n const packageJson = await fs.readJson(packageJsonPath);\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n // Add FoundryKit CLI scripts if they don't exist\n if (!packageJson.scripts['foundrykit']) {\n packageJson.scripts['foundrykit'] = 'foundrykit';\n }\n\n if (!packageJson.scripts['fk']) {\n packageJson.scripts['fk'] = 'foundrykit';\n }\n\n await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });\n console.log(chalk.green('ā
Package scripts updated'));\n}\n","/**\n * List command for FoundryKit CLI\n * Displays available components from the registry\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport type { ComponentMeta, ComponentCategory } from '@foundrykit/types';\nimport { getRegistry } from '../lib/registry.js';\n\ninterface ListOptions {\n category?: string;\n search?: string;\n}\n\nexport function listCommand() {\n return new Command('list')\n .description('List all available FoundryKit components and blocks')\n .option(\n '-c, --category <category>',\n 'filter by category (primitives, components, blocks, animations)'\n )\n .option('-s, --search <term>', 'search components by name or description')\n .action(async (options: ListOptions) => {\n try {\n console.log(chalk.blue('š¦ Available FoundryKit components:'));\n\n const registry = getRegistry();\n\n // Validate category if provided\n if (options.category) {\n const validCategories: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n if (\n !validCategories.includes(options.category as ComponentCategory)\n ) {\n console.error(chalk.red(`Invalid category: ${options.category}`));\n console.log(\n chalk.gray(`Valid categories: ${validCategories.join(', ')}`)\n );\n process.exit(1);\n }\n }\n\n // Fetch components from registry\n console.log(chalk.gray('Fetching from registry...'));\n const components = await registry.getComponents(\n options.category,\n options.search\n );\n\n if (components.length === 0) {\n console.log(\n chalk.yellow('\\nNo components found matching your criteria.')\n );\n if (options.search) {\n console.log(chalk.gray(`Search term: \"${options.search}\"`));\n }\n if (options.category) {\n console.log(chalk.gray(`Category: ${options.category}`));\n }\n return;\n }\n\n // Group and display components\n displayComponents(components);\n\n // Show usage hints\n console.log(chalk.cyan('\\nš” Usage:'));\n console.log(\n chalk.gray(' foundrykit add # Interactive mode')\n );\n console.log(\n chalk.gray(' foundrykit add <id> # Add specific component')\n );\n console.log(chalk.gray(' foundrykit add button # Example'));\n } catch (error) {\n console.error(chalk.red('ā Failed to fetch component registry:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\n/**\n * Display components grouped by category\n */\nfunction displayComponents(components: ComponentMeta[]): void {\n // Group components by category\n const grouped = components.reduce(\n (acc, component) => {\n if (!acc[component.category]) {\n acc[component.category] = [];\n }\n acc[component.category].push(component);\n return acc;\n },\n {} as Record<ComponentCategory, ComponentMeta[]>\n );\n\n // Display in category order\n const categoryOrder: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n\n for (const category of categoryOrder) {\n const items = grouped[category];\n if (!items || items.length === 0) continue;\n\n console.log(`\\n${chalk.cyan.bold(category.toUpperCase())}`);\n console.log(chalk.gray('ā'.repeat(40)));\n\n for (const item of items) {\n // Component name and ID\n console.log(\n `${chalk.green('ā')} ${chalk.bold(item.name)} ${chalk.gray(\n `(${item.id})`\n )}`\n );\n\n // Description\n console.log(` ${chalk.gray(item.description)}`);\n\n // Tags\n if (item.tags && item.tags.length > 0) {\n console.log(\n ` ${chalk.blue(item.tags.map(tag => `#${tag}`).join(' '))}`\n );\n }\n\n // Dependencies\n if (item.registryDependencies && item.registryDependencies.length > 0) {\n console.log(\n ` ${chalk.yellow('Requires:')} ${item.registryDependencies.join(\n ', '\n )}`\n );\n }\n\n // Package dependencies\n if (item.packageDependencies && item.packageDependencies.length > 0) {\n console.log(\n ` ${chalk.magenta('NPM packages:')} ${item.packageDependencies.join(\n ', '\n )}`\n );\n }\n\n console.log();\n }\n }\n\n // Show summary\n const total = components.length;\n const byCategory = Object.entries(grouped)\n .map(([cat, items]) => `${items.length} ${cat}`)\n .join(', ');\n\n console.log(chalk.gray('ā'.repeat(40)));\n console.log(chalk.gray(`Total: ${total} components (${byCategory})`));\n}\n","/**\n * Registry service for fetching and caching component data\n * Handles communication with the FoundryKit registry\n */\n\nimport fs from 'fs-extra';\nimport path from 'path';\nimport os from 'os';\nimport chalk from 'chalk';\nimport type {\n ComponentMeta,\n ComponentData,\n RegistryIndex,\n RegistryComponent,\n RegistryError,\n LocalCache,\n CLIConfig,\n} from '@foundrykit/types';\n\n/**\n * Default configuration\n */\nconst DEFAULT_CONFIG: CLIConfig = {\n registryUrl:\n process.env.FOUNDRYKIT_REGISTRY_URL || 'https://foundry.umiflow.com',\n cacheDir: path.join(os.homedir(), '.foundrykit', 'cache'),\n cacheMaxAge: 1000 * 60 * 60 * 24, // 24 hours\n};\n\n/**\n * Registry service class\n */\nexport class RegistryService {\n private config: CLIConfig;\n private cacheFile: string;\n\n constructor(config?: Partial<CLIConfig>) {\n this.config = { ...DEFAULT_CONFIG, ...config };\n this.cacheFile = path.join(this.config.cacheDir, 'registry.json');\n }\n\n /**\n * Fetch all components from the registry\n */\n async getComponents(\n category?: string,\n search?: string\n ): Promise<RegistryIndex> {\n try {\n // Build query params\n const params = new URLSearchParams();\n if (category) params.append('category', category);\n if (search) params.append('search', search);\n\n const url = `${this.config.registryUrl}/registry${\n params.toString() ? '?' + params.toString() : ''\n }`;\n\n console.log(chalk.gray(`Fetching from: ${url}`));\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Registry returned ${response.status}: ${response.statusText}`\n );\n }\n\n const components = (await response.json()) as RegistryIndex;\n\n // Update cache\n await this.updateCache(components);\n\n return components;\n } catch (error) {\n // Try to load from cache\n const cache = await this.loadCache();\n if (cache && this.isCacheValid(cache)) {\n console.log(chalk.yellow('Using cached registry data'));\n return this.filterComponents(cache.components, category, search);\n }\n\n // No valid cache, throw error\n throw new Error(\n `Failed to connect to registry: ${error instanceof Error ? error.message : 'Unknown error'}\\n` +\n `Registry URL: ${this.config.registryUrl}\\n` +\n `Try again later or check your internet connection.`\n );\n }\n }\n\n /**\n * Fetch a specific component by ID\n */\n async getComponent(id: string): Promise<ComponentData> {\n try {\n // Special handling for common utility dependencies\n if (id === 'utils') {\n console.log(chalk.gray(`Creating utils dependency...`));\n return this.createUtilsComponent();\n }\n\n const url = `${this.config.registryUrl}/registry/${id}`;\n console.log(chalk.gray(`Fetching component: ${url}`));\n\n const response = await fetch(url);\n\n if (!response.ok) {\n if (response.status === 404) {\n // Check if it's a known special dependency\n if (this.isSpecialDependency(id)) {\n console.log(\n chalk.yellow(\n `Special dependency \"${id}\" will be handled separately`\n )\n );\n return this.createSpecialDependency(id);\n }\n throw new Error(`Component \"${id}\" not found in registry`);\n }\n throw new Error(\n `Registry returned ${response.status}: ${response.statusText}`\n );\n }\n\n const component = (await response.json()) as RegistryComponent;\n\n // Cache the component data\n await this.cacheComponent(component);\n\n return component;\n } catch (error) {\n // Try to load from cache\n const cache = await this.loadCache();\n if (cache?.componentData?.[id]) {\n console.log(chalk.yellow(`Using cached data for component: ${id}`));\n return cache.componentData[id];\n }\n\n // Check if it's a special dependency that we can handle locally\n if (this.isSpecialDependency(id)) {\n console.log(chalk.yellow(`Creating local version of \"${id}\"`));\n return this.createSpecialDependency(id);\n }\n\n // No cached data, throw error\n throw new Error(\n `Failed to fetch component \"${id}\": ${error instanceof Error ? error.message : 'Unknown error'}\\n` +\n `Registry URL: ${this.config.registryUrl}\\n` +\n `Try again later or check your internet connection.`\n );\n }\n }\n\n /**\n * Check if a dependency is a special/utility dependency\n */\n private isSpecialDependency(id: string): boolean {\n const specialDeps = ['utils', 'lib', 'helpers', 'cn'];\n return specialDeps.includes(id);\n }\n\n /**\n * Create a special dependency component\n */\n private createSpecialDependency(id: string): ComponentData {\n switch (id) {\n case 'utils':\n case 'lib':\n case 'helpers':\n case 'cn':\n return this.createUtilsComponent();\n default:\n throw new Error(`Unknown special dependency: ${id}`);\n }\n }\n\n /**\n * Create a utils component with the cn function\n */\n private createUtilsComponent(): ComponentData {\n return {\n id: 'utils',\n name: 'Utils',\n category: 'primitives',\n description: 'Utility functions for className merging',\n tags: ['utility', 'helper'],\n packageDependencies: ['clsx', 'tailwind-merge'],\n files: [\n {\n path: 'lib/utils.ts',\n type: 'util',\n content: `import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n`,\n },\n ],\n };\n }\n\n /**\n * Update the local cache with new component list\n */\n private async updateCache(components: RegistryIndex): Promise<void> {\n try {\n const cache = await this.loadCache();\n const newCache: LocalCache = {\n version: '1.0.0',\n lastUpdated: new Date().toISOString(),\n components,\n componentData: cache?.componentData || {},\n };\n\n await fs.ensureDir(this.config.cacheDir);\n await fs.writeJson(this.cacheFile, newCache, { spaces: 2 });\n } catch (error) {\n // Cache update failed, but don't throw - this is not critical\n console.log(chalk.gray('Failed to update cache'));\n }\n }\n\n /**\n * Cache a specific component\n */\n private async cacheComponent(component: ComponentData): Promise<void> {\n try {\n const cache = await this.loadCache();\n if (!cache) return;\n\n cache.componentData[component.id] = component;\n cache.lastUpdated = new Date().toISOString();\n\n await fs.writeJson(this.cacheFile, cache, { spaces: 2 });\n } catch (error) {\n // Cache update failed, but don't throw\n console.log(chalk.gray('Failed to cache component'));\n }\n }\n\n /**\n * Load the local cache\n */\n private async loadCache(): Promise<LocalCache | null> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n return await fs.readJson(this.cacheFile);\n }\n } catch (error) {\n console.log(chalk.gray('Failed to load cache'));\n }\n return null;\n }\n\n /**\n * Check if cache is still valid\n */\n private isCacheValid(cache: LocalCache): boolean {\n const lastUpdated = new Date(cache.lastUpdated).getTime();\n const now = Date.now();\n return now - lastUpdated < this.config.cacheMaxAge;\n }\n\n /**\n * Filter components by category and search\n */\n private filterComponents(\n components: ComponentMeta[],\n category?: string,\n search?: string\n ): ComponentMeta[] {\n let filtered = components;\n\n if (category) {\n filtered = filtered.filter(c => c.category === category);\n }\n\n if (search) {\n const searchLower = search.toLowerCase();\n filtered = filtered.filter(\n c =>\n c.name.toLowerCase().includes(searchLower) ||\n c.description.toLowerCase().includes(searchLower) ||\n c.id.toLowerCase().includes(searchLower) ||\n c.tags?.some(tag => tag.toLowerCase().includes(searchLower))\n );\n }\n\n return filtered;\n }\n\n /**\n * Clear the local cache\n */\n async clearCache(): Promise<void> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n await fs.remove(this.cacheFile);\n console.log(chalk.green('Cache cleared successfully'));\n }\n } catch (error) {\n throw new Error(\n `Failed to clear cache: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n\n /**\n * Get cache statistics\n */\n async getCacheStats(): Promise<{\n exists: boolean;\n size: number;\n lastUpdated: string | null;\n componentCount: number;\n }> {\n try {\n if (await fs.pathExists(this.cacheFile)) {\n const cache = await this.loadCache();\n const stats = await fs.stat(this.cacheFile);\n\n return {\n exists: true,\n size: stats.size,\n lastUpdated: cache?.lastUpdated || null,\n componentCount: cache?.components.length || 0,\n };\n }\n } catch (error) {\n // Ignore errors\n }\n\n return {\n exists: false,\n size: 0,\n lastUpdated: null,\n componentCount: 0,\n };\n }\n}\n\n/**\n * Singleton instance\n */\nlet registryInstance: RegistryService | null = null;\n\n/**\n * Get the registry service instance\n */\nexport function getRegistry(config?: Partial<CLIConfig>): RegistryService {\n if (!registryInstance) {\n registryInstance = new RegistryService(config);\n }\n return registryInstance;\n}\n\n/**\n * Reset the registry instance (mainly for testing)\n */\nexport function resetRegistry(): void {\n registryInstance = null;\n}\n","/**\n * Add command for FoundryKit CLI\n * Handles adding components to projects\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport inquirer from 'inquirer';\nimport type {\n ComponentMeta,\n ComponentData,\n ComponentCategory,\n} from '@foundrykit/types';\nimport { getRegistry } from '../lib/registry.js';\n\ninterface AddOptions {\n withAnimation?: boolean;\n path?: string;\n overwrite?: boolean;\n}\n\nexport function addCommand() {\n return new Command('add')\n .description('Add a component or block to your project')\n .argument('[id]', 'Component or block ID (optional for interactive mode)')\n .option('--with-animation', 'Include animation variants')\n .option('-p, --path <path>', 'Custom installation path')\n .option('-o, --overwrite', 'Overwrite existing files')\n .action(async (id: string | undefined, options: AddOptions) => {\n try {\n // If no ID provided, show interactive selector\n if (!id) {\n const selectedIds = await selectComponentsInteractively();\n if (selectedIds.length === 0) {\n console.log(chalk.yellow('No components selected.'));\n return;\n }\n\n // Add each selected component\n for (const componentId of selectedIds) {\n await addSingleComponent(componentId, options);\n }\n } else {\n // Add single component\n await addSingleComponent(id, options);\n }\n } catch (error) {\n console.error(chalk.red('ā Failed to add component:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n process.exit(1);\n }\n });\n}\n\n/**\n * Interactive component selection\n */\nasync function selectComponentsInteractively(): Promise<string[]> {\n console.log(chalk.blue('š¦ Select components to add:'));\n console.log(\n chalk.gray(' Use arrow keys to navigate, space to select, a to toggle all')\n );\n console.log(chalk.gray(' Press enter when done\\n'));\n\n const registry = getRegistry();\n\n try {\n // Fetch all available components from registry\n console.log(chalk.gray('Fetching components from registry...'));\n const allComponents = await registry.getComponents();\n\n if (allComponents.length === 0) {\n console.log(chalk.yellow('No components available in the registry.'));\n return [];\n }\n\n // Group components by category\n const groupedChoices = createGroupedChoices(allComponents);\n\n const { selectedComponents } = await inquirer.prompt([\n {\n type: 'checkbox',\n name: 'selectedComponents',\n message: 'Which components would you like to add?',\n choices: groupedChoices,\n pageSize: 20,\n loop: false,\n },\n ]);\n\n return selectedComponents;\n } catch (error) {\n console.error(chalk.red('Failed to fetch components from registry:'));\n console.error(\n chalk.red(error instanceof Error ? error.message : String(error))\n );\n throw error;\n }\n}\n\n/**\n * Create grouped choices for the interactive selector\n */\nfunction createGroupedChoices(components: ComponentMeta[]) {\n const categories: ComponentCategory[] = [\n 'primitives',\n 'components',\n 'blocks',\n 'animations',\n ];\n\n const choices: any[] = [];\n\n for (const category of categories) {\n const categoryComponents = components.filter(c => c.category === category);\n\n if (categoryComponents.length === 0) continue;\n\n // Add category separator\n choices.push({\n name: chalk.bold.cyan(`āāā ${category.toUpperCase()} āāā`),\n disabled: true,\n value: `separator-${category}`,\n });\n\n // Add components in this category\n for (const component of categoryComponents) {\n choices.push({\n name: `${component.name} - ${chalk.gray(component.description)}`,\n value: component.id,\n short: component.name,\n });\n }\n }\n\n return choices;\n}\n\n/**\n * Add a single component to the project\n */\nasync function addSingleComponent(\n id: string,\n options: AddOptions\n): Promise<void> {\n console.log(chalk.blue(`\\nš¦ Adding ${id} to your project...`));\n\n // Validate project is initialized\n await validateProject();\n\n const registry = getRegistry();\n\n try {\n // Fetch component data from registry\n const componentData = await registry.getComponent(id);\n\n // Check for existing files\n if (\n !options.overwrite &&\n (await hasConflictingFiles(componentData, options))\n ) {\n const { shouldContinue } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'shouldContinue',\n message: `Some files for ${componentData.name} already exist. Overwrite?`,\n default: false,\n },\n ]);\n\n if (!shouldContinue) {\n console.log(chalk.yellow(`āļø Skipping ${componentData.name}.`));\n return;\n }\n }\n\n // Install registry dependencies first\n if (componentData.registryDependencies?.length) {\n console.log(chalk.blue('š¦ Installing required dependencies...'));\n for (const dep of componentData.registryDependencies) {\n try {\n // Special handling for utility dependencies\n if (dep === 'utils') {\n // Check if utils already exists\n const utilsPath = path.join(\n options.path || process.cwd(),\n 'lib/utils.ts'\n );\n if (!fs.existsSync(utilsPath)) {\n // Create a basic utils file if it doesn't exist\n await fs.ensureDir(path.dirname(utilsPath));\n await fs.writeFile(\n utilsPath,\n `import { type ClassValue, clsx } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n`\n );\n console.log(chalk.green(` ā Created ${dep} file`));\n } else {\n console.log(chalk.gray(` ā ${dep} already exists`));\n }\n } else {\n // Try to fetch as a regular component\n const depData = await registry.getComponent(dep);\n if (!(await hasConflictingFiles(depData, options))) {\n await installComponentFiles(depData, options);\n console.log(chalk.green(` ā Installed ${dep}`));\n } else {\n console.log(chalk.gray(` ā ${dep} already exists`));\n }\n }\n } catch (error) {\n // If dependency fetch fails, log warning but continue\n console.log(\n chalk.yellow(\n ` ā Could not install dependency \"${dep}\": ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n )\n );\n\n // For utils specifically, create it if missing\n if (\n dep === 'utils' &&\n error instanceof Error &&\n error.message.includes('not found')\n ) {\n const utilsPath = path.join(\n options.path || process.cwd(),\n 'lib/utils.ts'\n );\n if (!fs.existsSync(utilsPath)) {\n await fs.ensureDir(path.dirname(utilsPath));\n await fs.writeFile(\n utilsPath,\n `import { type ClassValue, clsx } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n`\n );\n console.log(chalk.green(` ā Created ${dep} file`));\n }\n }\n }\n }\n }\n\n // Install the component files\n await installComponentFiles(componentData, options);\n\n console.log(chalk.green(`ā
${componentData.name} added successfully!`));\n\n // Show usage example\n showUsageExample(componentData);\n\n // Show package dependencies if any\n if (componentData.packageDependencies?.length) {\n console.log(chalk.yellow('\\nš¦ Required npm packages:'));\n console.log(\n chalk.gray(` ${componentData.packageDependencies.join(', ')}`)\n );\n console.log(chalk.gray(' Install them with:'));\n console.log(\n chalk.cyan(` pnpm add ${componentData.packageDependencies.join(' ')}`)\n );\n }\n\n // Additional dependencies for utils\n if (componentData.registryDependencies?.includes('utils')) {\n const utilsDeps = ['clsx', 'tailwind-merge'];\n console.log(chalk.yellow('\\nš¦ Required packages for utils:'));\n console.log(chalk.gray(` ${utilsDeps.join(', ')}`));\n console.log(chalk.gray(' Install them with:'));\n console.log(chalk.cyan(` pnpm add ${utilsDeps.join(' ')}`));\n }\n } catch (error) {\n console.error(chalk.red(`Failed to add ${id}:`));\n throw error;\n }\n}\n\n/**\n * Validate that the project is properly initialized\n */\nasync function validateProject(): Promise<void> {\n const packageJsonPath = path.join(process.cwd(), 'package.json');\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(\n 'No package.json found. Please run this command in a project root.'\n );\n }\n\n const packageJson = await fs.readJson(packageJsonPath);\n const dependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n // Check for Next.js or FoundryKit packages\n const hasFoundryKit = Object.keys(dependencies).some(dep =>\n dep.startsWith('@foundrykit/')\n );\n\n if (!hasFoundryKit && !dependencies.next) {\n throw new Error('FoundryKit not initialized. Run \"foundrykit init\" first.');\n }\n}\n\n/**\n * Check if component files already exist\n */\nasync function hasConflictingFiles(\n componentData: ComponentData,\n options: AddOptions\n): Promise<boolean> {\n const basePath = options.path || process.cwd();\n\n for (const file of componentData.files) {\n const filePath = path.join(basePath, file.path);\n if (fs.existsSync(filePath)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Install component files to the project\n */\nasync function installComponentFiles(\n componentData: ComponentData,\n options: AddOptions\n): Promise<void> {\n const basePath = options.path || process.cwd();\n\n console.log(chalk.blue('š Installing component files...'));\n\n for (const file of componentData.files) {\n const filePath = path.join(basePath, file.path);\n\n // Ensure directory exists\n await fs.ensureDir(path.dirname(filePath));\n\n // Write file\n await fs.writeFile(filePath, file.content);\n\n console.log(chalk.green(` ā ${file.path}`));\n }\n}\n\n/**\n * Show usage example for the installed component\n */\nfunction showUsageExample(componentData: ComponentData): void {\n console.log(chalk.cyan('\\nš” Usage:'));\n\n const componentName = componentData.name.replace(/\\s+/g, '');\n\n if (\n componentData.category === 'primitives' ||\n componentData.category === 'components'\n ) {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/ui/${componentData.id}\"`\n )\n );\n } else if (componentData.category === 'blocks') {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/blocks/${componentData.id}\"`\n )\n );\n } else if (componentData.category === 'animations') {\n console.log(\n chalk.gray(\n `import { ${componentName} } from \"@/components/animations/${componentData.id}\"`\n )\n );\n }\n\n // Show basic usage examples based on component type\n if (componentData.id === 'button') {\n console.log(chalk.gray('\\n<Button>Click me</Button>'));\n console.log(chalk.gray('<Button variant=\"outline\">Outline</Button>'));\n } else if (componentData.id === 'input') {\n console.log(chalk.gray('\\n<Input placeholder=\"Enter text...\" />'));\n } else if (componentData.id.includes('hero')) {\n console.log(chalk.gray(`\\n<${componentName} />`));\n } else if (componentData.id === 'card') {\n console.log(chalk.gray('\\n<Card>'));\n console.log(chalk.gray(' <CardHeader>'));\n console.log(chalk.gray(' <CardTitle>Title</CardTitle>'));\n console.log(\n chalk.gray(' <CardDescription>Description</CardDescription>')\n );\n console.log(chalk.gray(' </CardHeader>'));\n console.log(chalk.gray(' <CardContent>Content</CardContent>'));\n console.log(chalk.gray('</Card>'));\n }\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\n\nexport function updateCommand() {\n return new Command('update')\n .description('Update an existing component or block')\n .argument('<id>', 'Component or block ID')\n .action(async id => {\n console.log(chalk.blue(`š Updating ${id}...`));\n console.log(chalk.green(`ā
${id} updated successfully!`));\n });\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\n\nexport function doctorCommand() {\n return new Command('doctor')\n .description('Check project health and configuration')\n .action(async () => {\n console.log(chalk.blue('š Checking project health...'));\n console.log(chalk.green('ā
All checks passed!'));\n });\n}\n"],"mappings":";;;AAEA,SAAS,WAAAA,gBAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;;;ACL9B,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,gBAAgB;AACzB,OAAO,cAAc;AAOd,SAAS,cAAc;AAC5B,SAAO,IAAI,QAAQ,MAAM,EACtB,YAAY,+CAA+C,EAC3D,OAAO,eAAe,0BAA0B,EAChD,OAAO,kBAAkB,8BAA8B,EACvD,OAAO,OAAO,YAAyB;AACtC,QAAI;AACF,cAAQ,IAAI,MAAM,KAAK,sCAA+B,CAAC;AAGvD,YAAM,sBAAsB;AAG5B,UAAI,CAAC,QAAQ,SAAU,MAAM,wBAAwB,GAAI;AACvD,cAAM,EAAE,eAAe,IAAI,MAAM,SAAS,OAAO;AAAA,UAC/C;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS;AAAA,YACT,SAAS;AAAA,UACX;AAAA,QACF,CAAC;AAED,YAAI,CAAC,gBAAgB;AACnB,kBAAQ,IAAI,MAAM,OAAO,kCAA6B,CAAC;AACvD;AAAA,QACF;AAAA,MACF;AAGA,UAAI,CAAC,QAAQ,aAAa;AACxB,cAAM,oBAAoB;AAAA,MAC5B;AAGA,YAAM,gBAAgB;AAGtB,YAAM,kBAAkB;AAGxB,YAAM,mBAAmB;AAGzB,YAAM,qBAAqB;AAE3B,cAAQ,IAAI,MAAM,MAAM,+CAA0C,CAAC;AACnE,cAAQ,IAAI,MAAM,KAAK,yBAAkB,CAAC;AAC1C,cAA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+B,CAAC;AACvD,YAAQ,IAAIA,OAAM,MAAM,2BAAsB,CAAC;AAAA,EACjD,CAAC;AACL;;;ANGA,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,QAAQ,UAAU;AACpC,IAAM,cAAc,KAAK;AAAA,EACvB,aAAa,KAAK,WAAW,MAAM,cAAc,GAAG,OAAO;AAC7D;AAEA,IAAM,UAAU,IAAIC,SAAQ;AAE5B,QACG,KAAK,YAAY,EACjB,YAAY,oDAAoD,EAChE,QAAQ,YAAY,OAAO;AAG9B,QAAQ,WAAW,YAAY,CAAC;AAChC,QAAQ,WAAW,YAAY,CAAC;AAChC,QAAQ,WAAW,WAAW,CAAC;AAC/B,QAAQ,WAAW,cAAc,CAAC;AAClC,QAAQ,WAAW,cAAc,CAAC;AAElC,QAAQ,MAAM;","names":["Command","packageJson","layoutDir","cssRelativePath","importPath","updatedContent","Command","chalk","fs","path","chalk","Command","chalk","Command","chalk","fs","path","inquirer","Command","chalk","inquirer","path","fs","packageJson","Command","chalk","Command","chalk","Command"]}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Dependency Resolution in FoundryKit CLI
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The FoundryKit CLI handles two types of dependencies when adding components:
|
|
6
|
+
|
|
7
|
+
1. **Registry Dependencies** - Other components or utilities from the registry that a component depends on
|
|
8
|
+
2. **Package Dependencies** - NPM packages that need to be installed
|
|
9
|
+
|
|
10
|
+
## How It Works
|
|
11
|
+
|
|
12
|
+
### Registry Dependencies
|
|
13
|
+
|
|
14
|
+
When a component lists registry dependencies (e.g., `registryDependencies: ['utils']`), the CLI:
|
|
15
|
+
|
|
16
|
+
1. **Checks if the dependency already exists** in the project
|
|
17
|
+
2. **Handles special dependencies** (like `utils`) with custom logic
|
|
18
|
+
3. **Fetches regular dependencies** from the registry as components
|
|
19
|
+
4. **Gracefully handles failures** - warns but continues installation
|
|
20
|
+
|
|
21
|
+
### Special Dependencies
|
|
22
|
+
|
|
23
|
+
The following dependencies are handled specially:
|
|
24
|
+
|
|
25
|
+
- `utils` - Creates a `lib/utils.ts` file with the `cn()` function for className merging
|
|
26
|
+
- `lib` - Alias for `utils`
|
|
27
|
+
- `helpers` - Alias for `utils`
|
|
28
|
+
- `cn` - Alias for `utils`
|
|
29
|
+
|
|
30
|
+
#### Utils Dependency
|
|
31
|
+
|
|
32
|
+
When a component requires `utils`, the CLI:
|
|
33
|
+
|
|
34
|
+
1. Checks if `lib/utils.ts` already exists
|
|
35
|
+
2. If not, creates it with the standard `cn()` function:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { type ClassValue, clsx } from 'clsx';
|
|
39
|
+
import { twMerge } from 'tailwind-merge';
|
|
40
|
+
|
|
41
|
+
export function cn(...inputs: ClassValue[]) {
|
|
42
|
+
return twMerge(clsx(inputs));
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
3. If it exists, preserves the existing file
|
|
47
|
+
4. Notifies about required NPM packages (`clsx`, `tailwind-merge`)
|
|
48
|
+
|
|
49
|
+
### Error Handling
|
|
50
|
+
|
|
51
|
+
The dependency resolution system is designed to be resilient:
|
|
52
|
+
|
|
53
|
+
- **Missing dependencies**: Logs a warning but continues installation
|
|
54
|
+
- **Network failures**: Falls back to local generation for special dependencies
|
|
55
|
+
- **Existing files**: Prompts user or skips based on `--overwrite` flag
|
|
56
|
+
|
|
57
|
+
## Examples
|
|
58
|
+
|
|
59
|
+
### Component with Utils Dependency
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"id": "button",
|
|
64
|
+
"name": "Button",
|
|
65
|
+
"registryDependencies": ["utils"],
|
|
66
|
+
"packageDependencies": ["clsx", "tailwind-merge"],
|
|
67
|
+
"files": [...]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
When installing this component:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
foundrykit add button
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The CLI will:
|
|
78
|
+
1. Check/create `lib/utils.ts`
|
|
79
|
+
2. Install the button component files
|
|
80
|
+
3. Notify about required NPM packages
|
|
81
|
+
|
|
82
|
+
### Component with Multiple Dependencies
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"id": "data-table",
|
|
87
|
+
"name": "DataTable",
|
|
88
|
+
"registryDependencies": ["utils", "table", "pagination"],
|
|
89
|
+
"packageDependencies": ["@tanstack/react-table"],
|
|
90
|
+
"files": [...]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The CLI will:
|
|
95
|
+
1. Process each registry dependency in order
|
|
96
|
+
2. Skip already installed dependencies
|
|
97
|
+
3. Create special dependencies as needed
|
|
98
|
+
4. Fetch regular components from the registry
|
|
99
|
+
|
|
100
|
+
## Implementation Details
|
|
101
|
+
|
|
102
|
+
### Registry Service
|
|
103
|
+
|
|
104
|
+
The `RegistryService` class handles dependency resolution:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
// Check if it's a special dependency
|
|
108
|
+
if (this.isSpecialDependency(id)) {
|
|
109
|
+
return this.createSpecialDependency(id);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Otherwise, fetch from registry
|
|
113
|
+
const component = await registry.getComponent(id);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Add Command
|
|
117
|
+
|
|
118
|
+
The `add` command processes dependencies before installing the main component:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// Install registry dependencies first
|
|
122
|
+
if (componentData.registryDependencies?.length) {
|
|
123
|
+
for (const dep of componentData.registryDependencies) {
|
|
124
|
+
try {
|
|
125
|
+
// Special handling for utils
|
|
126
|
+
if (dep === 'utils') {
|
|
127
|
+
// Create utils file if needed
|
|
128
|
+
} else {
|
|
129
|
+
// Fetch and install as component
|
|
130
|
+
}
|
|
131
|
+
} catch (error) {
|
|
132
|
+
// Log warning but continue
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Testing
|
|
139
|
+
|
|
140
|
+
Run the test script to verify dependency resolution:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
cd packages/cli
|
|
144
|
+
node test-add-command.js
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
This tests:
|
|
148
|
+
1. Utils file creation
|
|
149
|
+
2. Existing file preservation
|
|
150
|
+
3. Missing dependency handling
|
|
151
|
+
4. Error recovery
|
|
152
|
+
|
|
153
|
+
## Best Practices
|
|
154
|
+
|
|
155
|
+
### For Component Authors
|
|
156
|
+
|
|
157
|
+
1. **List all dependencies** in `registryDependencies`
|
|
158
|
+
2. **Use `utils` for className merging** instead of bundling your own
|
|
159
|
+
3. **Specify package dependencies** for NPM packages
|
|
160
|
+
|
|
161
|
+
### For CLI Users
|
|
162
|
+
|
|
163
|
+
1. **Install package dependencies** after adding components
|
|
164
|
+
2. **Use `--overwrite` carefully** to avoid losing customizations
|
|
165
|
+
3. **Check the output** for any warnings about failed dependencies
|
|
166
|
+
|
|
167
|
+
## Troubleshooting
|
|
168
|
+
|
|
169
|
+
### Component fails to install
|
|
170
|
+
|
|
171
|
+
1. Check network connection
|
|
172
|
+
2. Clear cache: `foundrykit cache clear`
|
|
173
|
+
3. Try with `--overwrite` flag if files exist
|
|
174
|
+
|
|
175
|
+
### Utils not found error
|
|
176
|
+
|
|
177
|
+
1. Ensure `lib/utils.ts` exists
|
|
178
|
+
2. Install required packages: `pnpm add clsx tailwind-merge`
|
|
179
|
+
3. Check import path matches: `@/lib/utils`
|
|
180
|
+
|
|
181
|
+
### Dependency not found in registry
|
|
182
|
+
|
|
183
|
+
This is usually fine - special dependencies are created locally. The CLI will:
|
|
184
|
+
1. Log a warning
|
|
185
|
+
2. Create the dependency if it's special (like `utils`)
|
|
186
|
+
3. Continue with the installation
|
|
187
|
+
|
|
188
|
+
## Future Improvements
|
|
189
|
+
|
|
190
|
+
- [ ] Dependency version management
|
|
191
|
+
- [ ] Circular dependency detection
|
|
192
|
+
- [ ] Batch dependency installation
|
|
193
|
+
- [ ] Dependency tree visualization
|
|
194
|
+
- [ ] Custom dependency handlers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foundrykit/cli",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"glob": "^10.3.10",
|
|
26
26
|
"inquirer": "^9.2.15",
|
|
27
27
|
"node-fetch": "^3.3.0",
|
|
28
|
-
"@foundrykit/types": "0.1
|
|
28
|
+
"@foundrykit/types": "1.0.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.19.9",
|
|
@@ -34,13 +34,16 @@
|
|
|
34
34
|
"eslint": "^9.0.0",
|
|
35
35
|
"tsup": "^8.0.0",
|
|
36
36
|
"typescript": "^5.9.2",
|
|
37
|
-
"
|
|
38
|
-
"@foundrykit/
|
|
37
|
+
"vitest": "^1.2.0",
|
|
38
|
+
"@foundrykit/eslint-config": "1.0.0",
|
|
39
|
+
"@foundrykit/typescript-config": "1.0.0"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"build": "tsup",
|
|
42
43
|
"dev": "tsup --watch",
|
|
43
44
|
"lint": "eslint . --max-warnings 0",
|
|
44
|
-
"type-check": "tsc --noEmit"
|
|
45
|
+
"type-check": "tsc --noEmit",
|
|
46
|
+
"test": "vitest",
|
|
47
|
+
"test:watch": "vitest --watch"
|
|
45
48
|
}
|
|
46
49
|
}
|