@foundrykit/cli 0.1.0
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/.turbo/turbo-build.log +18 -0
- package/.turbo/turbo-lint.log +5 -0
- package/.turbo/turbo-type-check.log +5 -0
- package/README.md +328 -0
- package/components.json +20 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +761 -0
- package/dist/index.js.map +1 -0
- package/eslint.config.js +4 -0
- package/package.json +45 -0
- package/postcss.config.mjs +6 -0
- package/src/commands/add.ts +375 -0
- package/src/commands/doctor.ts +11 -0
- package/src/commands/init.ts +318 -0
- package/src/commands/list.ts +255 -0
- package/src/commands/update.ts +12 -0
- package/src/index.ts +24 -0
- package/tsconfig.json +11 -0
- package/tsconfig.lint.json +8 -0
- package/tsup.config.ts +11 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/commands/init.ts","../src/commands/list.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 Tailwind config\n await setupTailwindConfig();\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 tailwindConfigPath = path.join(process.cwd(), 'tailwind.config.js');\n const tailwindConfigTsPath = path.join(process.cwd(), 'tailwind.config.ts');\n\n if (fs.existsSync(tailwindConfigPath)) {\n const config = await fs.readFile(tailwindConfigPath, 'utf-8');\n return config.includes('@foundrykit/tailwind-config');\n }\n\n if (fs.existsSync(tailwindConfigTsPath)) {\n const config = await fs.readFile(tailwindConfigTsPath, 'utf-8');\n return config.includes('@foundrykit/tailwind-config');\n }\n\n return false;\n}\n\nasync function installDependencies(): Promise<void> {\n console.log(chalk.blue('š¦ Installing FoundryKit dependencies...'));\n\n const dependencies = [\n '@foundrykit/primitives',\n '@foundrykit/components',\n '@foundrykit/blocks',\n '@foundrykit/hooks',\n '@foundrykit/animation',\n '@foundrykit/tokens',\n '@foundrykit/tailwind-config',\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\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 setupTailwindConfig(): Promise<void> {\n console.log(chalk.blue('āļø Setting up Tailwind configuration...'));\n\n const configPath = path.join(process.cwd(), 'tailwind.config.ts');\n const configContent = `import type { Config } from 'tailwindcss';\nimport { withFoundryKit } from '@foundrykit/tailwind-config';\n\nconst config: Config = withFoundryKit({\n content: [\n './pages/**/*.{js,ts,jsx,tsx,mdx}',\n './components/**/*.{js,ts,jsx,tsx,mdx}',\n './app/**/*.{js,ts,jsx,tsx,mdx}',\n './src/**/*.{js,ts,jsx,tsx,mdx}',\n ],\n theme: {\n extend: {},\n },\n plugins: [],\n});\n\nexport default config;\n`;\n\n await fs.writeFile(configPath, configContent);\n console.log(chalk.green('ā
Tailwind config created'));\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 await fs.writeFile(utilsPath, utilsContent);\n\n // Create a basic globals.css if it doesn't exist\n const globalsCssPath = path.join(process.cwd(), 'app/globals.css');\n const srcGlobalsCssPath = path.join(process.cwd(), 'src/app/globals.css');\n\n const globalsCssContent = `@import \"tailwindcss\";\n\n@layer base {\n :root {\n --background: 0 0% 100%;\n --foreground: 222.2 84% 4.9%;\n --card: 0 0% 100%;\n --card-foreground: 222.2 84% 4.9%;\n --popover: 0 0% 100%;\n --popover-foreground: 222.2 84% 4.9%;\n --primary: 222.2 47.4% 11.2%;\n --primary-foreground: 210 40% 98%;\n --secondary: 210 40% 96%;\n --secondary-foreground: 222.2 84% 4.9%;\n --muted: 210 40% 96%;\n --muted-foreground: 215.4 16.3% 46.9%;\n --accent: 210 40% 96%;\n --accent-foreground: 222.2 84% 4.9%;\n --destructive: 0 84.2% 60.2%;\n --destructive-foreground: 210 40% 98%;\n --border: 214.3 31.8% 91.4%;\n --input: 214.3 31.8% 91.4%;\n --ring: 222.2 84% 4.9%;\n --radius: 0.5rem;\n }\n\n .dark {\n --background: 222.2 84% 4.9%;\n --foreground: 210 40% 98%;\n --card: 222.2 84% 4.9%;\n --card-foreground: 210 40% 98%;\n --popover: 222.2 84% 4.9%;\n --popover-foreground: 210 40% 98%;\n --primary: 210 40% 98%;\n --primary-foreground: 222.2 47.4% 11.2%;\n --secondary: 217.2 32.6% 17.5%;\n --secondary-foreground: 210 40% 98%;\n --muted: 217.2 32.6% 17.5%;\n --muted-foreground: 215 20.2% 65.1%;\n --accent: 217.2 32.6% 17.5%;\n --accent-foreground: 210 40% 98%;\n --destructive: 0 62.8% 30.6%;\n --destructive-foreground: 210 40% 98%;\n --border: 217.2 32.6% 17.5%;\n --input: 217.2 32.6% 17.5%;\n --ring: 212.7 26.8% 83.9%;\n }\n}\n\n@layer base {\n body {\n @apply bg-background text-foreground;\n }\n}\n`;\n\n // Try to update existing globals.css or create new one\n if (fs.existsSync(globalsCssPath)) {\n const existing = await fs.readFile(globalsCssPath, 'utf-8');\n if (!existing.includes('--background')) {\n await fs.writeFile(globalsCssPath, globalsCssContent);\n }\n } else if (fs.existsSync(srcGlobalsCssPath)) {\n const existing = await fs.readFile(srcGlobalsCssPath, 'utf-8');\n if (!existing.includes('--background')) {\n await fs.writeFile(srcGlobalsCssPath, globalsCssContent);\n }\n } else {\n // Create in app directory by default\n await fs.ensureDir(path.join(process.cwd(), 'app'));\n await fs.writeFile(globalsCssPath, globalsCssContent);\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","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport fetch from 'node-fetch';\n\ninterface Component {\n name: string;\n description: string;\n category: 'primitives' | 'components' | 'blocks';\n dependencies?: string[];\n tags?: string[];\n}\n\ninterface Registry {\n primitives: Component[];\n components: Component[];\n blocks: Component[];\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)'\n )\n .option('-s, --search <term>', 'search components by name or description')\n .action(async (options: { category?: string; search?: string }) => {\n try {\n console.log(chalk.blue('š¦ Available FoundryKit components:'));\n\n const registry = await getRegistry();\n\n // Filter by category if specified\n let categories: ('primitives' | 'components' | 'blocks')[] = [\n 'primitives',\n 'components',\n 'blocks',\n ];\n if (options.category) {\n if (\n !['primitives', 'components', 'blocks'].includes(options.category)\n ) {\n console.error(chalk.red(`Invalid category: ${options.category}`));\n console.log(\n chalk.gray('Available categories: primitives, components, blocks')\n );\n return;\n }\n categories = [\n options.category as 'primitives' | 'components' | 'blocks',\n ];\n }\n\n // Display components\n for (const category of categories) {\n const items = registry[category];\n const filteredItems = options.search\n ? items.filter(\n item =>\n item.name\n .toLowerCase()\n .includes(options.search!.toLowerCase()) ||\n item.description\n .toLowerCase()\n .includes(options.search!.toLowerCase())\n )\n : items;\n\n if (filteredItems.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 filteredItems) {\n console.log(`${chalk.green('ā')} ${chalk.bold(item.name)}`);\n console.log(` ${chalk.gray(item.description)}`);\n if (item.tags && item.tags.length > 0) {\n console.log(\n ` ${chalk.blue(item.tags.map(tag => `#${tag}`).join(' '))}`\n );\n }\n console.log();\n }\n }\n\n console.log(chalk.cyan('\\nš” Usage:'));\n console.log(chalk.gray(' foundrykit add <component-name>'));\n console.log(chalk.gray(' foundrykit add button --with-animation'));\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\n // Fallback to local registry\n console.log(chalk.yellow('\\nš Using local registry:'));\n displayLocalRegistry(options);\n }\n });\n}\n\nasync function getRegistry(): Promise<Registry> {\n try {\n // Try to fetch from registry API\n const response = await fetch('http://localhost:3001/api/components');\n if (response.ok) {\n const data = await response.json();\n return data as Registry;\n }\n } catch (error) {\n // Fall back to local registry\n }\n\n // Return local/fallback registry\n return getLocalRegistry();\n}\n\nfunction getLocalRegistry(): Registry {\n return {\n primitives: [\n {\n name: 'button',\n description:\n 'Displays a button or a component that looks like a button.',\n category: 'primitives',\n tags: ['form', 'interactive'],\n },\n {\n name: 'input',\n description:\n 'Displays a form input field or a component that looks like an input.',\n category: 'primitives',\n tags: ['form'],\n },\n {\n name: 'badge',\n description: 'Displays a badge or a component that looks like a badge.',\n category: 'primitives',\n tags: ['status', 'label'],\n },\n {\n name: 'card',\n description: 'Displays a card with header, content, and footer.',\n category: 'primitives',\n tags: ['layout', 'container'],\n },\n {\n name: 'avatar',\n description:\n 'An image element with a fallback for representing the user.',\n category: 'primitives',\n tags: ['user', 'profile'],\n },\n ],\n components: [\n {\n name: 'search-bar',\n description: 'A search input with suggestions and keyboard navigation.',\n category: 'components',\n dependencies: ['input', 'popover'],\n tags: ['search', 'form'],\n },\n {\n name: 'combobox',\n description:\n 'Combines a text input with a listbox, allowing users to filter a list.',\n category: 'components',\n dependencies: ['input', 'popover', 'command'],\n tags: ['form', 'selection'],\n },\n {\n name: 'date-picker',\n description: 'A date picker component with calendar popup.',\n category: 'components',\n dependencies: ['input', 'popover', 'calendar'],\n tags: ['form', 'date'],\n },\n ],\n blocks: [\n {\n name: 'hero-minimal',\n description:\n 'A minimal hero section with heading, description, and CTA button.',\n category: 'blocks',\n dependencies: ['button'],\n tags: ['landing', 'marketing'],\n },\n {\n name: 'hero-with-image',\n description:\n 'A hero section with background image and content overlay.',\n category: 'blocks',\n dependencies: ['button'],\n tags: ['landing', 'marketing', 'image'],\n },\n {\n name: 'pricing',\n description:\n 'A pricing section with multiple tiers and feature comparison.',\n category: 'blocks',\n dependencies: ['card', 'button', 'badge'],\n tags: ['pricing', 'marketing'],\n },\n {\n name: 'testimonials',\n description: 'A testimonials section with customer quotes and avatars.',\n category: 'blocks',\n dependencies: ['avatar', 'card'],\n tags: ['social-proof', 'marketing'],\n },\n ],\n };\n}\n\nfunction displayLocalRegistry(options: { category?: string; search?: string }) {\n const registry = getLocalRegistry();\n\n let categories: ('primitives' | 'components' | 'blocks')[] = [\n 'primitives',\n 'components',\n 'blocks',\n ];\n if (options.category) {\n categories = [options.category as 'primitives' | 'components' | 'blocks'];\n }\n\n for (const category of categories) {\n const items = registry[category];\n const filteredItems = options.search\n ? items.filter(\n item =>\n item.name.toLowerCase().includes(options.search!.toLowerCase()) ||\n item.description\n .toLowerCase()\n .includes(options.search!.toLowerCase())\n )\n : items;\n\n if (filteredItems.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 filteredItems) {\n console.log(`${chalk.green('ā')} ${chalk.bold(item.name)}`);\n console.log(` ${chalk.gray(item.description)}`);\n if (item.tags && item.tags.length > 0) {\n console.log(\n ` ${chalk.blue(item.tags.map(tag => `#${tag}`).join(' '))}`\n );\n }\n console.log();\n }\n }\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport fetch from 'node-fetch';\nimport inquirer from 'inquirer';\n\ninterface AddOptions {\n withAnimation?: boolean;\n path?: string;\n force?: boolean;\n}\n\ninterface ComponentFile {\n path: string;\n content: string;\n type: 'component' | 'hook' | 'util' | 'style';\n}\n\ninterface ComponentData {\n name: string;\n category: 'primitives' | 'components' | 'blocks';\n description: string;\n dependencies?: string[];\n files: ComponentFile[];\n registryDependencies?: string[];\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')\n .option('--with-animation', 'Include animation variants')\n .option('--path <path>', 'Custom installation path')\n .option('--force', 'Force overwrite existing files')\n .action(async (id: string, options: AddOptions) => {\n try {\n console.log(chalk.blue(`š¦ Adding ${id} to your project...`));\n\n // Validate FoundryKit is initialized\n await validateFoundryKitProject();\n\n // Get component data\n const componentData = await getComponentData(id);\n\n if (!componentData) {\n console.error(chalk.red(`ā Component \"${id}\" not found.`));\n console.log(\n chalk.gray('\\nUse \"foundrykit list\" to see available components.')\n );\n return;\n }\n\n // Check for existing files\n if (\n !options.force &&\n (await hasConflictingFiles(componentData, options))\n ) {\n const { shouldContinue } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'shouldContinue',\n message: 'Some files already exist. Continue and overwrite?',\n default: false,\n },\n ]);\n\n if (!shouldContinue) {\n console.log(chalk.yellow('ā Installation cancelled.'));\n return;\n }\n }\n\n // Install registry dependencies first\n if (\n componentData.registryDependencies &&\n componentData.registryDependencies.length > 0\n ) {\n console.log(chalk.blue('š¦ Installing required components...'));\n for (const dep of componentData.registryDependencies) {\n await addComponent(dep, { ...options, force: true });\n }\n }\n\n // Install the component files\n await installComponentFiles(componentData, options);\n\n // Update imports if needed\n await updateImports(componentData);\n\n console.log(\n chalk.green(`\\nā
${componentData.name} added successfully!`)\n );\n\n // Show usage example\n showUsageExample(componentData);\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\nasync function validateFoundryKitProject(): Promise<void> {\n const tailwindConfigPath = path.join(process.cwd(), 'tailwind.config.ts');\n const tailwindConfigJsPath = path.join(process.cwd(), 'tailwind.config.js');\n\n if (\n !fs.existsSync(tailwindConfigPath) &&\n !fs.existsSync(tailwindConfigJsPath)\n ) {\n throw new Error('FoundryKit not initialized. Run \"foundrykit init\" first.');\n }\n\n // Check if config includes FoundryKit\n const configPath = fs.existsSync(tailwindConfigPath)\n ? tailwindConfigPath\n : tailwindConfigJsPath;\n const config = await fs.readFile(configPath, 'utf-8');\n\n if (!config.includes('@foundrykit/tailwind-config')) {\n throw new Error(\n 'FoundryKit not properly configured. Run \"foundrykit init\" first.'\n );\n }\n}\n\nasync function getComponentData(id: string): Promise<ComponentData | null> {\n try {\n // Try to fetch from registry API\n const response = await fetch(`http://localhost:3001/api/components/${id}`);\n if (response.ok) {\n const data = await response.json();\n return data as ComponentData;\n }\n } catch (error) {\n // Fall back to local registry\n }\n\n // Return local component data\n return getLocalComponentData(id);\n}\n\nfunction getLocalComponentData(id: string): ComponentData | null {\n const components: Record<string, ComponentData> = {\n button: {\n name: 'Button',\n category: 'primitives',\n description: 'A button component with multiple variants.',\n files: [\n {\n path: 'components/ui/button.tsx',\n type: 'component',\n content: `import * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0\",\n {\n variants: {\n variant: {\n default:\n \"bg-primary text-primary-foreground shadow hover:bg-primary/90\",\n destructive:\n \"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90\",\n outline:\n \"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground\",\n secondary:\n \"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-9 px-4 py-2\",\n sm: \"h-8 rounded-md px-3 text-xs\",\n lg: \"h-10 rounded-md px-8\",\n icon: \"h-9 w-9\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ className, variant, size, asChild = false, ...props }, ref) => {\n const Comp = asChild ? Slot : \"button\"\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n {...props}\n />\n )\n }\n)\nButton.displayName = \"Button\"\n\nexport { Button, buttonVariants }\n`,\n },\n ],\n },\n input: {\n name: 'Input',\n category: 'primitives',\n description: 'A form input component.',\n files: [\n {\n path: 'components/ui/input.tsx',\n type: 'component',\n content: `import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport interface InputProps\n extends React.InputHTMLAttributes<HTMLInputElement> {}\n\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ className, type, ...props }, ref) => {\n return (\n <input\n type={type}\n className={cn(\n \"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\",\n className\n )}\n ref={ref}\n {...props}\n />\n )\n }\n)\nInput.displayName = \"Input\"\n\nexport { Input }\n`,\n },\n ],\n },\n 'hero-minimal': {\n name: 'Hero Minimal',\n category: 'blocks',\n description: 'A minimal hero section with heading, description, and CTA.',\n registryDependencies: ['button'],\n files: [\n {\n path: 'components/blocks/hero-minimal.tsx',\n type: 'component',\n content: `import { Button } from \"@/components/ui/button\"\n\nexport function HeroMinimal() {\n return (\n <section className=\"w-full py-12 md:py-24 lg:py-32\">\n <div className=\"container px-4 md:px-6\">\n <div className=\"flex flex-col items-center space-y-4 text-center\">\n <div className=\"space-y-2\">\n <h1 className=\"text-3xl font-bold tracking-tighter sm:text-4xl md:text-5xl lg:text-6xl/none\">\n Welcome to FoundryKit\n </h1>\n <p className=\"mx-auto max-w-[700px] text-gray-500 md:text-xl dark:text-gray-400\">\n Build beautiful, accessible React components with our comprehensive design system.\n Fast, flexible, and ready for production.\n </p>\n </div>\n <div className=\"space-x-4\">\n <Button>Get Started</Button>\n <Button variant=\"outline\">Learn More</Button>\n </div>\n </div>\n </div>\n </section>\n )\n}\n`,\n },\n ],\n },\n };\n\n return components[id] || null;\n}\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\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\nasync function updateImports(componentData: ComponentData): Promise<void> {\n // This would handle updating import maps, index files, etc.\n // For now, we'll skip this step\n}\n\nasync function addComponent(id: string, options: AddOptions): Promise<void> {\n const componentData = await getComponentData(id);\n if (!componentData) {\n throw new Error(`Dependency component \"${id}\" not found.`);\n }\n\n await installComponentFiles(componentData, options);\n}\n\nfunction showUsageExample(componentData: ComponentData): void {\n console.log(chalk.cyan('\\nš” Usage:'));\n\n if (componentData.category === 'primitives') {\n console.log(\n chalk.gray(\n `import { ${componentData.name} } from \"@/components/ui/${componentData.name.toLowerCase()}\"`\n )\n );\n } else if (componentData.category === 'blocks') {\n console.log(\n chalk.gray(\n `import { ${componentData.name.replace(/\\s+/g, '')} } from \"@/components/blocks/${componentData.name.toLowerCase().replace(/\\s+/g, '-')}\"`\n )\n );\n }\n\n // Show a basic usage example\n if (componentData.name === '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.name === 'Input') {\n console.log(chalk.gray('\\n<Input placeholder=\"Enter text...\" />'));\n } else if (componentData.name === 'Hero Minimal') {\n console.log(chalk.gray('\\n<HeroMinimal />'));\n }\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\n\nexport function updateCommand() {\n return new Command('update')\n .description('Update an existing component or block')\n .argument('<id>', 'Component or block ID')\n .action(async id => {\n console.log(chalk.blue(`š Updating ${id}...`));\n console.log(chalk.green(`ā
${id} updated successfully!`));\n });\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\n\nexport function doctorCommand() {\n return new Command('doctor')\n .description('Check project health and configuration')\n .action(async () => {\n console.log(chalk.blue('š Checking project health...'));\n console.log(chalk.green('ā
All checks passed!'));\n });\n}\n"],"mappings":";;;AAEA,SAAS,WAAAA,gBAAe;;;ACFxB,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,gBAAgB;AACzB,OAAO,cAAc;AAOd,SAAS,cAAc;AAC5B,SAAO,IAAI,QAAQ,MAAM,EACtB,YAAY,+CAA+C,EAC3D,OAAO,eAAe,0BAA0B,EAChD,OAAO,kBAAkB,8BAA8B,EACvD,OAAO,OAAO,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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C,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;;;ALDA,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","Command","chalk","Command","chalk","fs","path","fetch","inquirer","Command","chalk","Command","chalk","Command"]}
|
package/eslint.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@foundrykit/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"private": false,
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"foundrykit": "./dist/cli.js"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"commander": "^12.0.0",
|
|
23
|
+
"chalk": "^5.3.0",
|
|
24
|
+
"fs-extra": "^11.2.0",
|
|
25
|
+
"glob": "^10.3.10",
|
|
26
|
+
"inquirer": "^9.2.15",
|
|
27
|
+
"node-fetch": "^3.3.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.19.9",
|
|
31
|
+
"@types/fs-extra": "^11.0.4",
|
|
32
|
+
"@types/inquirer": "^9.0.7",
|
|
33
|
+
"eslint": "^9.0.0",
|
|
34
|
+
"tsup": "^8.0.0",
|
|
35
|
+
"typescript": "^5.9.2",
|
|
36
|
+
"@foundrykit/typescript-config": "0.1.0",
|
|
37
|
+
"@foundrykit/eslint-config": "0.1.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"dev": "tsup --watch",
|
|
42
|
+
"lint": "eslint . --max-warnings 0",
|
|
43
|
+
"type-check": "tsc --noEmit"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import fetch from 'node-fetch';
|
|
6
|
+
import inquirer from 'inquirer';
|
|
7
|
+
|
|
8
|
+
interface AddOptions {
|
|
9
|
+
withAnimation?: boolean;
|
|
10
|
+
path?: string;
|
|
11
|
+
force?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ComponentFile {
|
|
15
|
+
path: string;
|
|
16
|
+
content: string;
|
|
17
|
+
type: 'component' | 'hook' | 'util' | 'style';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface ComponentData {
|
|
21
|
+
name: string;
|
|
22
|
+
category: 'primitives' | 'components' | 'blocks';
|
|
23
|
+
description: string;
|
|
24
|
+
dependencies?: string[];
|
|
25
|
+
files: ComponentFile[];
|
|
26
|
+
registryDependencies?: string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function addCommand() {
|
|
30
|
+
return new Command('add')
|
|
31
|
+
.description('Add a component or block to your project')
|
|
32
|
+
.argument('<id>', 'Component or block ID')
|
|
33
|
+
.option('--with-animation', 'Include animation variants')
|
|
34
|
+
.option('--path <path>', 'Custom installation path')
|
|
35
|
+
.option('--force', 'Force overwrite existing files')
|
|
36
|
+
.action(async (id: string, options: AddOptions) => {
|
|
37
|
+
try {
|
|
38
|
+
console.log(chalk.blue(`š¦ Adding ${id} to your project...`));
|
|
39
|
+
|
|
40
|
+
// Validate FoundryKit is initialized
|
|
41
|
+
await validateFoundryKitProject();
|
|
42
|
+
|
|
43
|
+
// Get component data
|
|
44
|
+
const componentData = await getComponentData(id);
|
|
45
|
+
|
|
46
|
+
if (!componentData) {
|
|
47
|
+
console.error(chalk.red(`ā Component "${id}" not found.`));
|
|
48
|
+
console.log(
|
|
49
|
+
chalk.gray('\nUse "foundrykit list" to see available components.')
|
|
50
|
+
);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Check for existing files
|
|
55
|
+
if (
|
|
56
|
+
!options.force &&
|
|
57
|
+
(await hasConflictingFiles(componentData, options))
|
|
58
|
+
) {
|
|
59
|
+
const { shouldContinue } = await inquirer.prompt([
|
|
60
|
+
{
|
|
61
|
+
type: 'confirm',
|
|
62
|
+
name: 'shouldContinue',
|
|
63
|
+
message: 'Some files already exist. Continue and overwrite?',
|
|
64
|
+
default: false,
|
|
65
|
+
},
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
if (!shouldContinue) {
|
|
69
|
+
console.log(chalk.yellow('ā Installation cancelled.'));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Install registry dependencies first
|
|
75
|
+
if (
|
|
76
|
+
componentData.registryDependencies &&
|
|
77
|
+
componentData.registryDependencies.length > 0
|
|
78
|
+
) {
|
|
79
|
+
console.log(chalk.blue('š¦ Installing required components...'));
|
|
80
|
+
for (const dep of componentData.registryDependencies) {
|
|
81
|
+
await addComponent(dep, { ...options, force: true });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Install the component files
|
|
86
|
+
await installComponentFiles(componentData, options);
|
|
87
|
+
|
|
88
|
+
// Update imports if needed
|
|
89
|
+
await updateImports(componentData);
|
|
90
|
+
|
|
91
|
+
console.log(
|
|
92
|
+
chalk.green(`\nā
${componentData.name} added successfully!`)
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
// Show usage example
|
|
96
|
+
showUsageExample(componentData);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error(chalk.red('ā Failed to add component:'));
|
|
99
|
+
console.error(
|
|
100
|
+
chalk.red(error instanceof Error ? error.message : String(error))
|
|
101
|
+
);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function validateFoundryKitProject(): Promise<void> {
|
|
108
|
+
const tailwindConfigPath = path.join(process.cwd(), 'tailwind.config.ts');
|
|
109
|
+
const tailwindConfigJsPath = path.join(process.cwd(), 'tailwind.config.js');
|
|
110
|
+
|
|
111
|
+
if (
|
|
112
|
+
!fs.existsSync(tailwindConfigPath) &&
|
|
113
|
+
!fs.existsSync(tailwindConfigJsPath)
|
|
114
|
+
) {
|
|
115
|
+
throw new Error('FoundryKit not initialized. Run "foundrykit init" first.');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Check if config includes FoundryKit
|
|
119
|
+
const configPath = fs.existsSync(tailwindConfigPath)
|
|
120
|
+
? tailwindConfigPath
|
|
121
|
+
: tailwindConfigJsPath;
|
|
122
|
+
const config = await fs.readFile(configPath, 'utf-8');
|
|
123
|
+
|
|
124
|
+
if (!config.includes('@foundrykit/tailwind-config')) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
'FoundryKit not properly configured. Run "foundrykit init" first.'
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function getComponentData(id: string): Promise<ComponentData | null> {
|
|
132
|
+
try {
|
|
133
|
+
// Try to fetch from registry API
|
|
134
|
+
const response = await fetch(`http://localhost:3001/api/components/${id}`);
|
|
135
|
+
if (response.ok) {
|
|
136
|
+
const data = await response.json();
|
|
137
|
+
return data as ComponentData;
|
|
138
|
+
}
|
|
139
|
+
} catch (error) {
|
|
140
|
+
// Fall back to local registry
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Return local component data
|
|
144
|
+
return getLocalComponentData(id);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function getLocalComponentData(id: string): ComponentData | null {
|
|
148
|
+
const components: Record<string, ComponentData> = {
|
|
149
|
+
button: {
|
|
150
|
+
name: 'Button',
|
|
151
|
+
category: 'primitives',
|
|
152
|
+
description: 'A button component with multiple variants.',
|
|
153
|
+
files: [
|
|
154
|
+
{
|
|
155
|
+
path: 'components/ui/button.tsx',
|
|
156
|
+
type: 'component',
|
|
157
|
+
content: `import * as React from "react"
|
|
158
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
159
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
160
|
+
|
|
161
|
+
import { cn } from "@/lib/utils"
|
|
162
|
+
|
|
163
|
+
const buttonVariants = cva(
|
|
164
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
165
|
+
{
|
|
166
|
+
variants: {
|
|
167
|
+
variant: {
|
|
168
|
+
default:
|
|
169
|
+
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
170
|
+
destructive:
|
|
171
|
+
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
172
|
+
outline:
|
|
173
|
+
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
174
|
+
secondary:
|
|
175
|
+
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
176
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
177
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
178
|
+
},
|
|
179
|
+
size: {
|
|
180
|
+
default: "h-9 px-4 py-2",
|
|
181
|
+
sm: "h-8 rounded-md px-3 text-xs",
|
|
182
|
+
lg: "h-10 rounded-md px-8",
|
|
183
|
+
icon: "h-9 w-9",
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
defaultVariants: {
|
|
187
|
+
variant: "default",
|
|
188
|
+
size: "default",
|
|
189
|
+
},
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
export interface ButtonProps
|
|
194
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
195
|
+
VariantProps<typeof buttonVariants> {
|
|
196
|
+
asChild?: boolean
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
200
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
201
|
+
const Comp = asChild ? Slot : "button"
|
|
202
|
+
return (
|
|
203
|
+
<Comp
|
|
204
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
205
|
+
ref={ref}
|
|
206
|
+
{...props}
|
|
207
|
+
/>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
Button.displayName = "Button"
|
|
212
|
+
|
|
213
|
+
export { Button, buttonVariants }
|
|
214
|
+
`,
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
},
|
|
218
|
+
input: {
|
|
219
|
+
name: 'Input',
|
|
220
|
+
category: 'primitives',
|
|
221
|
+
description: 'A form input component.',
|
|
222
|
+
files: [
|
|
223
|
+
{
|
|
224
|
+
path: 'components/ui/input.tsx',
|
|
225
|
+
type: 'component',
|
|
226
|
+
content: `import * as React from "react"
|
|
227
|
+
|
|
228
|
+
import { cn } from "@/lib/utils"
|
|
229
|
+
|
|
230
|
+
export interface InputProps
|
|
231
|
+
extends React.InputHTMLAttributes<HTMLInputElement> {}
|
|
232
|
+
|
|
233
|
+
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
234
|
+
({ className, type, ...props }, ref) => {
|
|
235
|
+
return (
|
|
236
|
+
<input
|
|
237
|
+
type={type}
|
|
238
|
+
className={cn(
|
|
239
|
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
240
|
+
className
|
|
241
|
+
)}
|
|
242
|
+
ref={ref}
|
|
243
|
+
{...props}
|
|
244
|
+
/>
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
Input.displayName = "Input"
|
|
249
|
+
|
|
250
|
+
export { Input }
|
|
251
|
+
`,
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
'hero-minimal': {
|
|
256
|
+
name: 'Hero Minimal',
|
|
257
|
+
category: 'blocks',
|
|
258
|
+
description: 'A minimal hero section with heading, description, and CTA.',
|
|
259
|
+
registryDependencies: ['button'],
|
|
260
|
+
files: [
|
|
261
|
+
{
|
|
262
|
+
path: 'components/blocks/hero-minimal.tsx',
|
|
263
|
+
type: 'component',
|
|
264
|
+
content: `import { Button } from "@/components/ui/button"
|
|
265
|
+
|
|
266
|
+
export function HeroMinimal() {
|
|
267
|
+
return (
|
|
268
|
+
<section className="w-full py-12 md:py-24 lg:py-32">
|
|
269
|
+
<div className="container px-4 md:px-6">
|
|
270
|
+
<div className="flex flex-col items-center space-y-4 text-center">
|
|
271
|
+
<div className="space-y-2">
|
|
272
|
+
<h1 className="text-3xl font-bold tracking-tighter sm:text-4xl md:text-5xl lg:text-6xl/none">
|
|
273
|
+
Welcome to FoundryKit
|
|
274
|
+
</h1>
|
|
275
|
+
<p className="mx-auto max-w-[700px] text-gray-500 md:text-xl dark:text-gray-400">
|
|
276
|
+
Build beautiful, accessible React components with our comprehensive design system.
|
|
277
|
+
Fast, flexible, and ready for production.
|
|
278
|
+
</p>
|
|
279
|
+
</div>
|
|
280
|
+
<div className="space-x-4">
|
|
281
|
+
<Button>Get Started</Button>
|
|
282
|
+
<Button variant="outline">Learn More</Button>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
</div>
|
|
286
|
+
</section>
|
|
287
|
+
)
|
|
288
|
+
}
|
|
289
|
+
`,
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
return components[id] || null;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async function hasConflictingFiles(
|
|
299
|
+
componentData: ComponentData,
|
|
300
|
+
options: AddOptions
|
|
301
|
+
): Promise<boolean> {
|
|
302
|
+
const basePath = options.path || process.cwd();
|
|
303
|
+
|
|
304
|
+
for (const file of componentData.files) {
|
|
305
|
+
const filePath = path.join(basePath, file.path);
|
|
306
|
+
if (fs.existsSync(filePath)) {
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
async function installComponentFiles(
|
|
315
|
+
componentData: ComponentData,
|
|
316
|
+
options: AddOptions
|
|
317
|
+
): Promise<void> {
|
|
318
|
+
const basePath = options.path || process.cwd();
|
|
319
|
+
|
|
320
|
+
console.log(chalk.blue('š Installing component files...'));
|
|
321
|
+
|
|
322
|
+
for (const file of componentData.files) {
|
|
323
|
+
const filePath = path.join(basePath, file.path);
|
|
324
|
+
|
|
325
|
+
// Ensure directory exists
|
|
326
|
+
await fs.ensureDir(path.dirname(filePath));
|
|
327
|
+
|
|
328
|
+
// Write file
|
|
329
|
+
await fs.writeFile(filePath, file.content);
|
|
330
|
+
|
|
331
|
+
console.log(chalk.green(` ā ${file.path}`));
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
async function updateImports(componentData: ComponentData): Promise<void> {
|
|
336
|
+
// This would handle updating import maps, index files, etc.
|
|
337
|
+
// For now, we'll skip this step
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async function addComponent(id: string, options: AddOptions): Promise<void> {
|
|
341
|
+
const componentData = await getComponentData(id);
|
|
342
|
+
if (!componentData) {
|
|
343
|
+
throw new Error(`Dependency component "${id}" not found.`);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
await installComponentFiles(componentData, options);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function showUsageExample(componentData: ComponentData): void {
|
|
350
|
+
console.log(chalk.cyan('\nš” Usage:'));
|
|
351
|
+
|
|
352
|
+
if (componentData.category === 'primitives') {
|
|
353
|
+
console.log(
|
|
354
|
+
chalk.gray(
|
|
355
|
+
`import { ${componentData.name} } from "@/components/ui/${componentData.name.toLowerCase()}"`
|
|
356
|
+
)
|
|
357
|
+
);
|
|
358
|
+
} else if (componentData.category === 'blocks') {
|
|
359
|
+
console.log(
|
|
360
|
+
chalk.gray(
|
|
361
|
+
`import { ${componentData.name.replace(/\s+/g, '')} } from "@/components/blocks/${componentData.name.toLowerCase().replace(/\s+/g, '-')}"`
|
|
362
|
+
)
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Show a basic usage example
|
|
367
|
+
if (componentData.name === 'Button') {
|
|
368
|
+
console.log(chalk.gray('\n<Button>Click me</Button>'));
|
|
369
|
+
console.log(chalk.gray('<Button variant="outline">Outline</Button>'));
|
|
370
|
+
} else if (componentData.name === 'Input') {
|
|
371
|
+
console.log(chalk.gray('\n<Input placeholder="Enter text..." />'));
|
|
372
|
+
} else if (componentData.name === 'Hero Minimal') {
|
|
373
|
+
console.log(chalk.gray('\n<HeroMinimal />'));
|
|
374
|
+
}
|
|
375
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
|
|
4
|
+
export function doctorCommand() {
|
|
5
|
+
return new Command('doctor')
|
|
6
|
+
.description('Check project health and configuration')
|
|
7
|
+
.action(async () => {
|
|
8
|
+
console.log(chalk.blue('š Checking project health...'));
|
|
9
|
+
console.log(chalk.green('ā
All checks passed!'));
|
|
10
|
+
});
|
|
11
|
+
}
|