@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/dist/index.js ADDED
@@ -0,0 +1,761 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { Command as Command6 } from "commander";
5
+
6
+ // src/commands/init.ts
7
+ import { Command } from "commander";
8
+ import chalk from "chalk";
9
+ import fs from "fs-extra";
10
+ import path from "path";
11
+ import { execSync } from "child_process";
12
+ import inquirer from "inquirer";
13
+ function initCommand() {
14
+ return new Command("init").description("Initialize FoundryKit in your Next.js project").option("-f, --force", "overwrite existing files").option("--skip-install", "skip installing dependencies").action(async (options) => {
15
+ try {
16
+ console.log(chalk.blue("\u{1F680} Initializing FoundryKit..."));
17
+ await validateNextJsProject();
18
+ if (!options.force && await isFoundryKitInitialized()) {
19
+ const { shouldContinue } = await inquirer.prompt([
20
+ {
21
+ type: "confirm",
22
+ name: "shouldContinue",
23
+ message: "FoundryKit is already initialized. Continue anyway?",
24
+ default: false
25
+ }
26
+ ]);
27
+ if (!shouldContinue) {
28
+ console.log(chalk.yellow("\u274C Initialization cancelled."));
29
+ return;
30
+ }
31
+ }
32
+ if (!options.skipInstall) {
33
+ await installDependencies();
34
+ }
35
+ await setupTailwindConfig();
36
+ await createDirectories();
37
+ await createExampleFiles();
38
+ await updatePackageScripts();
39
+ console.log(chalk.green("\n\u2705 FoundryKit initialized successfully!"));
40
+ console.log(chalk.cyan("\n\u{1F4E6} Next steps:"));
41
+ console.log(
42
+ chalk.gray(
43
+ " 1. Add a component: npx @foundrykit/cli add hero-minimal"
44
+ )
45
+ );
46
+ console.log(
47
+ chalk.gray(" 2. List available components: npx @foundrykit/cli list")
48
+ );
49
+ console.log(
50
+ chalk.gray(" 3. Check out the docs: https://foundrykit.dev")
51
+ );
52
+ } catch (error) {
53
+ console.error(chalk.red("\u274C Failed to initialize FoundryKit:"));
54
+ console.error(
55
+ chalk.red(error instanceof Error ? error.message : String(error))
56
+ );
57
+ process.exit(1);
58
+ }
59
+ });
60
+ }
61
+ async function validateNextJsProject() {
62
+ const packageJsonPath = path.join(process.cwd(), "package.json");
63
+ if (!fs.existsSync(packageJsonPath)) {
64
+ throw new Error(
65
+ "No package.json found. Please run this command in a Next.js project root."
66
+ );
67
+ }
68
+ const packageJson = await fs.readJson(packageJsonPath);
69
+ const dependencies = {
70
+ ...packageJson.dependencies,
71
+ ...packageJson.devDependencies
72
+ };
73
+ if (!dependencies.next) {
74
+ throw new Error(
75
+ "Next.js not detected. This command should be run in a Next.js project."
76
+ );
77
+ }
78
+ console.log(chalk.green("\u2705 Next.js project detected"));
79
+ }
80
+ async function isFoundryKitInitialized() {
81
+ const tailwindConfigPath = path.join(process.cwd(), "tailwind.config.js");
82
+ const tailwindConfigTsPath = path.join(process.cwd(), "tailwind.config.ts");
83
+ if (fs.existsSync(tailwindConfigPath)) {
84
+ const config = await fs.readFile(tailwindConfigPath, "utf-8");
85
+ return config.includes("@foundrykit/tailwind-config");
86
+ }
87
+ if (fs.existsSync(tailwindConfigTsPath)) {
88
+ const config = await fs.readFile(tailwindConfigTsPath, "utf-8");
89
+ return config.includes("@foundrykit/tailwind-config");
90
+ }
91
+ return false;
92
+ }
93
+ async function installDependencies() {
94
+ console.log(chalk.blue("\u{1F4E6} Installing FoundryKit dependencies..."));
95
+ const dependencies = [
96
+ "@foundrykit/primitives",
97
+ "@foundrykit/components",
98
+ "@foundrykit/blocks",
99
+ "@foundrykit/hooks",
100
+ "@foundrykit/animation",
101
+ "@foundrykit/tokens",
102
+ "@foundrykit/tailwind-config"
103
+ ];
104
+ try {
105
+ const packageManager = detectPackageManager();
106
+ console.log(chalk.gray(`Using ${packageManager}...`));
107
+ const installCmd = packageManager === "npm" ? `npm install ${dependencies.join(" ")}` : packageManager === "yarn" ? `yarn add ${dependencies.join(" ")}` : `pnpm add ${dependencies.join(" ")}`;
108
+ execSync(installCmd, { stdio: "inherit" });
109
+ console.log(chalk.green("\u2705 Dependencies installed"));
110
+ } catch (error) {
111
+ throw new Error(
112
+ "Failed to install dependencies. Please install them manually."
113
+ );
114
+ }
115
+ }
116
+ function detectPackageManager() {
117
+ if (fs.existsSync("pnpm-lock.yaml")) return "pnpm";
118
+ if (fs.existsSync("yarn.lock")) return "yarn";
119
+ return "npm";
120
+ }
121
+ async function setupTailwindConfig() {
122
+ console.log(chalk.blue("\u2699\uFE0F Setting up Tailwind configuration..."));
123
+ const configPath = path.join(process.cwd(), "tailwind.config.ts");
124
+ const configContent = `import type { Config } from 'tailwindcss';
125
+ import { withFoundryKit } from '@foundrykit/tailwind-config';
126
+
127
+ const config: Config = withFoundryKit({
128
+ content: [
129
+ './pages/**/*.{js,ts,jsx,tsx,mdx}',
130
+ './components/**/*.{js,ts,jsx,tsx,mdx}',
131
+ './app/**/*.{js,ts,jsx,tsx,mdx}',
132
+ './src/**/*.{js,ts,jsx,tsx,mdx}',
133
+ ],
134
+ theme: {
135
+ extend: {},
136
+ },
137
+ plugins: [],
138
+ });
139
+
140
+ export default config;
141
+ `;
142
+ await fs.writeFile(configPath, configContent);
143
+ console.log(chalk.green("\u2705 Tailwind config created"));
144
+ }
145
+ async function createDirectories() {
146
+ console.log(chalk.blue("\u{1F4C1} Creating component directories..."));
147
+ const dirs = ["components/ui", "components/blocks", "lib", "hooks"];
148
+ for (const dir of dirs) {
149
+ await fs.ensureDir(path.join(process.cwd(), dir));
150
+ }
151
+ console.log(chalk.green("\u2705 Directories created"));
152
+ }
153
+ async function createExampleFiles() {
154
+ console.log(chalk.blue("\u{1F4DD} Creating example files..."));
155
+ const utilsPath = path.join(process.cwd(), "lib/utils.ts");
156
+ const utilsContent = `import { type ClassValue, clsx } from 'clsx';
157
+ import { twMerge } from 'tailwind-merge';
158
+
159
+ export function cn(...inputs: ClassValue[]) {
160
+ return twMerge(clsx(inputs));
161
+ }
162
+ `;
163
+ await fs.writeFile(utilsPath, utilsContent);
164
+ const globalsCssPath = path.join(process.cwd(), "app/globals.css");
165
+ const srcGlobalsCssPath = path.join(process.cwd(), "src/app/globals.css");
166
+ const globalsCssContent = `@import "tailwindcss";
167
+
168
+ @layer base {
169
+ :root {
170
+ --background: 0 0% 100%;
171
+ --foreground: 222.2 84% 4.9%;
172
+ --card: 0 0% 100%;
173
+ --card-foreground: 222.2 84% 4.9%;
174
+ --popover: 0 0% 100%;
175
+ --popover-foreground: 222.2 84% 4.9%;
176
+ --primary: 222.2 47.4% 11.2%;
177
+ --primary-foreground: 210 40% 98%;
178
+ --secondary: 210 40% 96%;
179
+ --secondary-foreground: 222.2 84% 4.9%;
180
+ --muted: 210 40% 96%;
181
+ --muted-foreground: 215.4 16.3% 46.9%;
182
+ --accent: 210 40% 96%;
183
+ --accent-foreground: 222.2 84% 4.9%;
184
+ --destructive: 0 84.2% 60.2%;
185
+ --destructive-foreground: 210 40% 98%;
186
+ --border: 214.3 31.8% 91.4%;
187
+ --input: 214.3 31.8% 91.4%;
188
+ --ring: 222.2 84% 4.9%;
189
+ --radius: 0.5rem;
190
+ }
191
+
192
+ .dark {
193
+ --background: 222.2 84% 4.9%;
194
+ --foreground: 210 40% 98%;
195
+ --card: 222.2 84% 4.9%;
196
+ --card-foreground: 210 40% 98%;
197
+ --popover: 222.2 84% 4.9%;
198
+ --popover-foreground: 210 40% 98%;
199
+ --primary: 210 40% 98%;
200
+ --primary-foreground: 222.2 47.4% 11.2%;
201
+ --secondary: 217.2 32.6% 17.5%;
202
+ --secondary-foreground: 210 40% 98%;
203
+ --muted: 217.2 32.6% 17.5%;
204
+ --muted-foreground: 215 20.2% 65.1%;
205
+ --accent: 217.2 32.6% 17.5%;
206
+ --accent-foreground: 210 40% 98%;
207
+ --destructive: 0 62.8% 30.6%;
208
+ --destructive-foreground: 210 40% 98%;
209
+ --border: 217.2 32.6% 17.5%;
210
+ --input: 217.2 32.6% 17.5%;
211
+ --ring: 212.7 26.8% 83.9%;
212
+ }
213
+ }
214
+
215
+ @layer base {
216
+ body {
217
+ @apply bg-background text-foreground;
218
+ }
219
+ }
220
+ `;
221
+ if (fs.existsSync(globalsCssPath)) {
222
+ const existing = await fs.readFile(globalsCssPath, "utf-8");
223
+ if (!existing.includes("--background")) {
224
+ await fs.writeFile(globalsCssPath, globalsCssContent);
225
+ }
226
+ } else if (fs.existsSync(srcGlobalsCssPath)) {
227
+ const existing = await fs.readFile(srcGlobalsCssPath, "utf-8");
228
+ if (!existing.includes("--background")) {
229
+ await fs.writeFile(srcGlobalsCssPath, globalsCssContent);
230
+ }
231
+ } else {
232
+ await fs.ensureDir(path.join(process.cwd(), "app"));
233
+ await fs.writeFile(globalsCssPath, globalsCssContent);
234
+ }
235
+ console.log(chalk.green("\u2705 Example files created"));
236
+ }
237
+ async function updatePackageScripts() {
238
+ console.log(chalk.blue("\u{1F4CB} Updating package.json scripts..."));
239
+ const packageJsonPath = path.join(process.cwd(), "package.json");
240
+ const packageJson = await fs.readJson(packageJsonPath);
241
+ if (!packageJson.scripts) {
242
+ packageJson.scripts = {};
243
+ }
244
+ if (!packageJson.scripts["foundrykit"]) {
245
+ packageJson.scripts["foundrykit"] = "foundrykit";
246
+ }
247
+ if (!packageJson.scripts["fk"]) {
248
+ packageJson.scripts["fk"] = "foundrykit";
249
+ }
250
+ await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
251
+ console.log(chalk.green("\u2705 Package scripts updated"));
252
+ }
253
+
254
+ // src/commands/list.ts
255
+ import { Command as Command2 } from "commander";
256
+ import chalk2 from "chalk";
257
+ import fetch from "node-fetch";
258
+ function listCommand() {
259
+ return new Command2("list").description("List all available FoundryKit components and blocks").option(
260
+ "-c, --category <category>",
261
+ "filter by category (primitives, components, blocks)"
262
+ ).option("-s, --search <term>", "search components by name or description").action(async (options) => {
263
+ try {
264
+ console.log(chalk2.blue("\u{1F4E6} Available FoundryKit components:"));
265
+ const registry = await getRegistry();
266
+ let categories = [
267
+ "primitives",
268
+ "components",
269
+ "blocks"
270
+ ];
271
+ if (options.category) {
272
+ if (!["primitives", "components", "blocks"].includes(options.category)) {
273
+ console.error(chalk2.red(`Invalid category: ${options.category}`));
274
+ console.log(
275
+ chalk2.gray("Available categories: primitives, components, blocks")
276
+ );
277
+ return;
278
+ }
279
+ categories = [
280
+ options.category
281
+ ];
282
+ }
283
+ for (const category of categories) {
284
+ const items = registry[category];
285
+ const filteredItems = options.search ? items.filter(
286
+ (item) => item.name.toLowerCase().includes(options.search.toLowerCase()) || item.description.toLowerCase().includes(options.search.toLowerCase())
287
+ ) : items;
288
+ if (filteredItems.length === 0) continue;
289
+ console.log(`
290
+ ${chalk2.cyan.bold(category.toUpperCase())}`);
291
+ console.log(chalk2.gray("\u2500".repeat(40)));
292
+ for (const item of filteredItems) {
293
+ console.log(`${chalk2.green("\u25CF")} ${chalk2.bold(item.name)}`);
294
+ console.log(` ${chalk2.gray(item.description)}`);
295
+ if (item.tags && item.tags.length > 0) {
296
+ console.log(
297
+ ` ${chalk2.blue(item.tags.map((tag) => `#${tag}`).join(" "))}`
298
+ );
299
+ }
300
+ console.log();
301
+ }
302
+ }
303
+ console.log(chalk2.cyan("\n\u{1F4A1} Usage:"));
304
+ console.log(chalk2.gray(" foundrykit add <component-name>"));
305
+ console.log(chalk2.gray(" foundrykit add button --with-animation"));
306
+ } catch (error) {
307
+ console.error(chalk2.red("\u274C Failed to fetch component registry:"));
308
+ console.error(
309
+ chalk2.red(error instanceof Error ? error.message : String(error))
310
+ );
311
+ console.log(chalk2.yellow("\n\u{1F4CB} Using local registry:"));
312
+ displayLocalRegistry(options);
313
+ }
314
+ });
315
+ }
316
+ async function getRegistry() {
317
+ try {
318
+ const response = await fetch("http://localhost:3001/api/components");
319
+ if (response.ok) {
320
+ const data = await response.json();
321
+ return data;
322
+ }
323
+ } catch (error) {
324
+ }
325
+ return getLocalRegistry();
326
+ }
327
+ function getLocalRegistry() {
328
+ return {
329
+ primitives: [
330
+ {
331
+ name: "button",
332
+ description: "Displays a button or a component that looks like a button.",
333
+ category: "primitives",
334
+ tags: ["form", "interactive"]
335
+ },
336
+ {
337
+ name: "input",
338
+ description: "Displays a form input field or a component that looks like an input.",
339
+ category: "primitives",
340
+ tags: ["form"]
341
+ },
342
+ {
343
+ name: "badge",
344
+ description: "Displays a badge or a component that looks like a badge.",
345
+ category: "primitives",
346
+ tags: ["status", "label"]
347
+ },
348
+ {
349
+ name: "card",
350
+ description: "Displays a card with header, content, and footer.",
351
+ category: "primitives",
352
+ tags: ["layout", "container"]
353
+ },
354
+ {
355
+ name: "avatar",
356
+ description: "An image element with a fallback for representing the user.",
357
+ category: "primitives",
358
+ tags: ["user", "profile"]
359
+ }
360
+ ],
361
+ components: [
362
+ {
363
+ name: "search-bar",
364
+ description: "A search input with suggestions and keyboard navigation.",
365
+ category: "components",
366
+ dependencies: ["input", "popover"],
367
+ tags: ["search", "form"]
368
+ },
369
+ {
370
+ name: "combobox",
371
+ description: "Combines a text input with a listbox, allowing users to filter a list.",
372
+ category: "components",
373
+ dependencies: ["input", "popover", "command"],
374
+ tags: ["form", "selection"]
375
+ },
376
+ {
377
+ name: "date-picker",
378
+ description: "A date picker component with calendar popup.",
379
+ category: "components",
380
+ dependencies: ["input", "popover", "calendar"],
381
+ tags: ["form", "date"]
382
+ }
383
+ ],
384
+ blocks: [
385
+ {
386
+ name: "hero-minimal",
387
+ description: "A minimal hero section with heading, description, and CTA button.",
388
+ category: "blocks",
389
+ dependencies: ["button"],
390
+ tags: ["landing", "marketing"]
391
+ },
392
+ {
393
+ name: "hero-with-image",
394
+ description: "A hero section with background image and content overlay.",
395
+ category: "blocks",
396
+ dependencies: ["button"],
397
+ tags: ["landing", "marketing", "image"]
398
+ },
399
+ {
400
+ name: "pricing",
401
+ description: "A pricing section with multiple tiers and feature comparison.",
402
+ category: "blocks",
403
+ dependencies: ["card", "button", "badge"],
404
+ tags: ["pricing", "marketing"]
405
+ },
406
+ {
407
+ name: "testimonials",
408
+ description: "A testimonials section with customer quotes and avatars.",
409
+ category: "blocks",
410
+ dependencies: ["avatar", "card"],
411
+ tags: ["social-proof", "marketing"]
412
+ }
413
+ ]
414
+ };
415
+ }
416
+ function displayLocalRegistry(options) {
417
+ const registry = getLocalRegistry();
418
+ let categories = [
419
+ "primitives",
420
+ "components",
421
+ "blocks"
422
+ ];
423
+ if (options.category) {
424
+ categories = [options.category];
425
+ }
426
+ for (const category of categories) {
427
+ const items = registry[category];
428
+ const filteredItems = options.search ? items.filter(
429
+ (item) => item.name.toLowerCase().includes(options.search.toLowerCase()) || item.description.toLowerCase().includes(options.search.toLowerCase())
430
+ ) : items;
431
+ if (filteredItems.length === 0) continue;
432
+ console.log(`
433
+ ${chalk2.cyan.bold(category.toUpperCase())}`);
434
+ console.log(chalk2.gray("\u2500".repeat(40)));
435
+ for (const item of filteredItems) {
436
+ console.log(`${chalk2.green("\u25CF")} ${chalk2.bold(item.name)}`);
437
+ console.log(` ${chalk2.gray(item.description)}`);
438
+ if (item.tags && item.tags.length > 0) {
439
+ console.log(
440
+ ` ${chalk2.blue(item.tags.map((tag) => `#${tag}`).join(" "))}`
441
+ );
442
+ }
443
+ console.log();
444
+ }
445
+ }
446
+ }
447
+
448
+ // src/commands/add.ts
449
+ import { Command as Command3 } from "commander";
450
+ import chalk3 from "chalk";
451
+ import fs2 from "fs-extra";
452
+ import path2 from "path";
453
+ import fetch2 from "node-fetch";
454
+ import inquirer2 from "inquirer";
455
+ function addCommand() {
456
+ return new Command3("add").description("Add a component or block to your project").argument("<id>", "Component or block ID").option("--with-animation", "Include animation variants").option("--path <path>", "Custom installation path").option("--force", "Force overwrite existing files").action(async (id, options) => {
457
+ try {
458
+ console.log(chalk3.blue(`\u{1F4E6} Adding ${id} to your project...`));
459
+ await validateFoundryKitProject();
460
+ const componentData = await getComponentData(id);
461
+ if (!componentData) {
462
+ console.error(chalk3.red(`\u274C Component "${id}" not found.`));
463
+ console.log(
464
+ chalk3.gray('\nUse "foundrykit list" to see available components.')
465
+ );
466
+ return;
467
+ }
468
+ if (!options.force && await hasConflictingFiles(componentData, options)) {
469
+ const { shouldContinue } = await inquirer2.prompt([
470
+ {
471
+ type: "confirm",
472
+ name: "shouldContinue",
473
+ message: "Some files already exist. Continue and overwrite?",
474
+ default: false
475
+ }
476
+ ]);
477
+ if (!shouldContinue) {
478
+ console.log(chalk3.yellow("\u274C Installation cancelled."));
479
+ return;
480
+ }
481
+ }
482
+ if (componentData.registryDependencies && componentData.registryDependencies.length > 0) {
483
+ console.log(chalk3.blue("\u{1F4E6} Installing required components..."));
484
+ for (const dep of componentData.registryDependencies) {
485
+ await addComponent(dep, { ...options, force: true });
486
+ }
487
+ }
488
+ await installComponentFiles(componentData, options);
489
+ await updateImports(componentData);
490
+ console.log(
491
+ chalk3.green(`
492
+ \u2705 ${componentData.name} added successfully!`)
493
+ );
494
+ showUsageExample(componentData);
495
+ } catch (error) {
496
+ console.error(chalk3.red("\u274C Failed to add component:"));
497
+ console.error(
498
+ chalk3.red(error instanceof Error ? error.message : String(error))
499
+ );
500
+ process.exit(1);
501
+ }
502
+ });
503
+ }
504
+ async function validateFoundryKitProject() {
505
+ const tailwindConfigPath = path2.join(process.cwd(), "tailwind.config.ts");
506
+ const tailwindConfigJsPath = path2.join(process.cwd(), "tailwind.config.js");
507
+ if (!fs2.existsSync(tailwindConfigPath) && !fs2.existsSync(tailwindConfigJsPath)) {
508
+ throw new Error('FoundryKit not initialized. Run "foundrykit init" first.');
509
+ }
510
+ const configPath = fs2.existsSync(tailwindConfigPath) ? tailwindConfigPath : tailwindConfigJsPath;
511
+ const config = await fs2.readFile(configPath, "utf-8");
512
+ if (!config.includes("@foundrykit/tailwind-config")) {
513
+ throw new Error(
514
+ 'FoundryKit not properly configured. Run "foundrykit init" first.'
515
+ );
516
+ }
517
+ }
518
+ async function getComponentData(id) {
519
+ try {
520
+ const response = await fetch2(`http://localhost:3001/api/components/${id}`);
521
+ if (response.ok) {
522
+ const data = await response.json();
523
+ return data;
524
+ }
525
+ } catch (error) {
526
+ }
527
+ return getLocalComponentData(id);
528
+ }
529
+ function getLocalComponentData(id) {
530
+ const components = {
531
+ button: {
532
+ name: "Button",
533
+ category: "primitives",
534
+ description: "A button component with multiple variants.",
535
+ files: [
536
+ {
537
+ path: "components/ui/button.tsx",
538
+ type: "component",
539
+ content: `import * as React from "react"
540
+ import { Slot } from "@radix-ui/react-slot"
541
+ import { cva, type VariantProps } from "class-variance-authority"
542
+
543
+ import { cn } from "@/lib/utils"
544
+
545
+ const buttonVariants = cva(
546
+ "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",
547
+ {
548
+ variants: {
549
+ variant: {
550
+ default:
551
+ "bg-primary text-primary-foreground shadow hover:bg-primary/90",
552
+ destructive:
553
+ "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
554
+ outline:
555
+ "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
556
+ secondary:
557
+ "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
558
+ ghost: "hover:bg-accent hover:text-accent-foreground",
559
+ link: "text-primary underline-offset-4 hover:underline",
560
+ },
561
+ size: {
562
+ default: "h-9 px-4 py-2",
563
+ sm: "h-8 rounded-md px-3 text-xs",
564
+ lg: "h-10 rounded-md px-8",
565
+ icon: "h-9 w-9",
566
+ },
567
+ },
568
+ defaultVariants: {
569
+ variant: "default",
570
+ size: "default",
571
+ },
572
+ }
573
+ )
574
+
575
+ export interface ButtonProps
576
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
577
+ VariantProps<typeof buttonVariants> {
578
+ asChild?: boolean
579
+ }
580
+
581
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
582
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
583
+ const Comp = asChild ? Slot : "button"
584
+ return (
585
+ <Comp
586
+ className={cn(buttonVariants({ variant, size, className }))}
587
+ ref={ref}
588
+ {...props}
589
+ />
590
+ )
591
+ }
592
+ )
593
+ Button.displayName = "Button"
594
+
595
+ export { Button, buttonVariants }
596
+ `
597
+ }
598
+ ]
599
+ },
600
+ input: {
601
+ name: "Input",
602
+ category: "primitives",
603
+ description: "A form input component.",
604
+ files: [
605
+ {
606
+ path: "components/ui/input.tsx",
607
+ type: "component",
608
+ content: `import * as React from "react"
609
+
610
+ import { cn } from "@/lib/utils"
611
+
612
+ export interface InputProps
613
+ extends React.InputHTMLAttributes<HTMLInputElement> {}
614
+
615
+ const Input = React.forwardRef<HTMLInputElement, InputProps>(
616
+ ({ className, type, ...props }, ref) => {
617
+ return (
618
+ <input
619
+ type={type}
620
+ className={cn(
621
+ "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",
622
+ className
623
+ )}
624
+ ref={ref}
625
+ {...props}
626
+ />
627
+ )
628
+ }
629
+ )
630
+ Input.displayName = "Input"
631
+
632
+ export { Input }
633
+ `
634
+ }
635
+ ]
636
+ },
637
+ "hero-minimal": {
638
+ name: "Hero Minimal",
639
+ category: "blocks",
640
+ description: "A minimal hero section with heading, description, and CTA.",
641
+ registryDependencies: ["button"],
642
+ files: [
643
+ {
644
+ path: "components/blocks/hero-minimal.tsx",
645
+ type: "component",
646
+ content: `import { Button } from "@/components/ui/button"
647
+
648
+ export function HeroMinimal() {
649
+ return (
650
+ <section className="w-full py-12 md:py-24 lg:py-32">
651
+ <div className="container px-4 md:px-6">
652
+ <div className="flex flex-col items-center space-y-4 text-center">
653
+ <div className="space-y-2">
654
+ <h1 className="text-3xl font-bold tracking-tighter sm:text-4xl md:text-5xl lg:text-6xl/none">
655
+ Welcome to FoundryKit
656
+ </h1>
657
+ <p className="mx-auto max-w-[700px] text-gray-500 md:text-xl dark:text-gray-400">
658
+ Build beautiful, accessible React components with our comprehensive design system.
659
+ Fast, flexible, and ready for production.
660
+ </p>
661
+ </div>
662
+ <div className="space-x-4">
663
+ <Button>Get Started</Button>
664
+ <Button variant="outline">Learn More</Button>
665
+ </div>
666
+ </div>
667
+ </div>
668
+ </section>
669
+ )
670
+ }
671
+ `
672
+ }
673
+ ]
674
+ }
675
+ };
676
+ return components[id] || null;
677
+ }
678
+ async function hasConflictingFiles(componentData, options) {
679
+ const basePath = options.path || process.cwd();
680
+ for (const file of componentData.files) {
681
+ const filePath = path2.join(basePath, file.path);
682
+ if (fs2.existsSync(filePath)) {
683
+ return true;
684
+ }
685
+ }
686
+ return false;
687
+ }
688
+ async function installComponentFiles(componentData, options) {
689
+ const basePath = options.path || process.cwd();
690
+ console.log(chalk3.blue("\u{1F4DD} Installing component files..."));
691
+ for (const file of componentData.files) {
692
+ const filePath = path2.join(basePath, file.path);
693
+ await fs2.ensureDir(path2.dirname(filePath));
694
+ await fs2.writeFile(filePath, file.content);
695
+ console.log(chalk3.green(` \u2713 ${file.path}`));
696
+ }
697
+ }
698
+ async function updateImports(componentData) {
699
+ }
700
+ async function addComponent(id, options) {
701
+ const componentData = await getComponentData(id);
702
+ if (!componentData) {
703
+ throw new Error(`Dependency component "${id}" not found.`);
704
+ }
705
+ await installComponentFiles(componentData, options);
706
+ }
707
+ function showUsageExample(componentData) {
708
+ console.log(chalk3.cyan("\n\u{1F4A1} Usage:"));
709
+ if (componentData.category === "primitives") {
710
+ console.log(
711
+ chalk3.gray(
712
+ `import { ${componentData.name} } from "@/components/ui/${componentData.name.toLowerCase()}"`
713
+ )
714
+ );
715
+ } else if (componentData.category === "blocks") {
716
+ console.log(
717
+ chalk3.gray(
718
+ `import { ${componentData.name.replace(/\s+/g, "")} } from "@/components/blocks/${componentData.name.toLowerCase().replace(/\s+/g, "-")}"`
719
+ )
720
+ );
721
+ }
722
+ if (componentData.name === "Button") {
723
+ console.log(chalk3.gray("\n<Button>Click me</Button>"));
724
+ console.log(chalk3.gray('<Button variant="outline">Outline</Button>'));
725
+ } else if (componentData.name === "Input") {
726
+ console.log(chalk3.gray('\n<Input placeholder="Enter text..." />'));
727
+ } else if (componentData.name === "Hero Minimal") {
728
+ console.log(chalk3.gray("\n<HeroMinimal />"));
729
+ }
730
+ }
731
+
732
+ // src/commands/update.ts
733
+ import { Command as Command4 } from "commander";
734
+ import chalk4 from "chalk";
735
+ function updateCommand() {
736
+ return new Command4("update").description("Update an existing component or block").argument("<id>", "Component or block ID").action(async (id) => {
737
+ console.log(chalk4.blue(`\u{1F504} Updating ${id}...`));
738
+ console.log(chalk4.green(`\u2705 ${id} updated successfully!`));
739
+ });
740
+ }
741
+
742
+ // src/commands/doctor.ts
743
+ import { Command as Command5 } from "commander";
744
+ import chalk5 from "chalk";
745
+ function doctorCommand() {
746
+ return new Command5("doctor").description("Check project health and configuration").action(async () => {
747
+ console.log(chalk5.blue("\u{1F50D} Checking project health..."));
748
+ console.log(chalk5.green("\u2705 All checks passed!"));
749
+ });
750
+ }
751
+
752
+ // src/index.ts
753
+ var program = new Command6();
754
+ program.name("foundrykit").description("FoundryKit CLI - Component library management tool").version("0.1.0");
755
+ program.addCommand(initCommand());
756
+ program.addCommand(listCommand());
757
+ program.addCommand(addCommand());
758
+ program.addCommand(updateCommand());
759
+ program.addCommand(doctorCommand());
760
+ program.parse();
761
+ //# sourceMappingURL=index.js.map