create-bearnie 0.2.0 → 0.3.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.
Files changed (3) hide show
  1. package/README.md +25 -6
  2. package/dist/index.js +149 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -12,15 +12,25 @@ npx create-bearnie
12
12
  npm create bearnie my-app
13
13
  ```
14
14
 
15
- ## Custom Theme
15
+ ## Options
16
16
 
17
- Create your own theme at [bearnie.dev/create](https://bearnie.dev/create), then use the generated command:
17
+ ### `--full`
18
+
19
+ Include all components from the start:
18
20
 
19
21
  ```bash
20
- npm create bearnie my-app --theme=https://bearnie.dev/create#YOUR_THEME_HASH
22
+ npx create-bearnie my-app --full
21
23
  ```
22
24
 
23
- This applies your custom colors, radius, and font to the project's CSS.
25
+ This fetches all components from the registry and installs them in your project.
26
+
27
+ ### `--theme`
28
+
29
+ Apply a custom theme from the [theme builder](https://bearnie.dev/create-bearnie-theme):
30
+
31
+ ```bash
32
+ npx create-bearnie my-app --theme="https://bearnie.dev/create-bearnie-theme#..."
33
+ ```
24
34
 
25
35
  ## What's included
26
36
 
@@ -30,18 +40,27 @@ This applies your custom colors, radius, and font to the project's CSS.
30
40
  - Simple landing page to get started
31
41
  - Ready for components via `npx bearnie add`
32
42
 
43
+ With `--full` flag:
44
+ - All Bearnie UI components
45
+ - Utility functions (`cn`, `focus-trap`)
46
+ - Additional dependencies (`clsx`, `tailwind-merge`)
47
+
33
48
  ## After creating your project
34
49
 
35
50
  ```bash
36
51
  cd my-app
37
52
  npm install
38
- npx bearnie add button card dialog
39
53
  npm run dev
40
54
  ```
41
55
 
56
+ Without `--full`, add components as needed:
57
+
58
+ ```bash
59
+ npx bearnie add button card dialog
60
+ ```
61
+
42
62
  ## Learn more
43
63
 
44
64
  - [Bearnie Documentation](https://bearnie.dev/docs)
45
- - [Theme Builder](https://bearnie.dev/create)
46
65
  - [Browse Components](https://bearnie.dev/docs/components)
47
66
  - [GitHub](https://github.com/michael-andreuzza/bearnie)
package/dist/index.js CHANGED
@@ -15,6 +15,77 @@ function parseThemeArg() {
15
15
  if (!themeArg) return null;
16
16
  return themeArg.split("=")[1];
17
17
  }
18
+ function parseFullArg() {
19
+ return process.argv.includes("--full");
20
+ }
21
+ var REGISTRY_URL = "https://bearnie.dev/registry";
22
+ var COMPONENT_NAMES = [
23
+ "accordion",
24
+ "alert",
25
+ "alert-dialog",
26
+ "aspect-ratio",
27
+ "avatar",
28
+ "badge",
29
+ "breadcrumb",
30
+ "button",
31
+ "button-group",
32
+ "card",
33
+ "carousel",
34
+ "checkbox",
35
+ "collapsible",
36
+ "command",
37
+ "context-menu",
38
+ "dialog",
39
+ "dropdown-menu",
40
+ "empty",
41
+ "file-upload",
42
+ "hover-card",
43
+ "input",
44
+ "input-group",
45
+ "input-otp",
46
+ "kbd",
47
+ "label",
48
+ "menubar",
49
+ "pagination",
50
+ "popover",
51
+ "progress",
52
+ "radio",
53
+ "scroll-area",
54
+ "select",
55
+ "separator",
56
+ "sheet",
57
+ "sidebar",
58
+ "skeleton",
59
+ "slider",
60
+ "spinner",
61
+ "stepper",
62
+ "switch",
63
+ "table",
64
+ "tabs",
65
+ "textarea",
66
+ "toast",
67
+ "toggle",
68
+ "tooltip",
69
+ "tree"
70
+ ];
71
+ async function fetchComponent(name) {
72
+ try {
73
+ const response = await fetch(`${REGISTRY_URL}/${name}.json`);
74
+ if (!response.ok) return null;
75
+ return await response.json();
76
+ } catch {
77
+ return null;
78
+ }
79
+ }
80
+ async function fetchUtility(name) {
81
+ try {
82
+ const response = await fetch(`${REGISTRY_URL}/${name}.json`);
83
+ if (!response.ok) return null;
84
+ return await response.json();
85
+ } catch {
86
+ return null;
87
+ }
88
+ }
18
89
  function extractThemeHash(themeUrl) {
19
90
  try {
20
91
  const hashIndex = themeUrl.indexOf("#");
@@ -204,6 +275,7 @@ function generateThemeCSS(config) {
204
275
  }
205
276
  async function main() {
206
277
  const themeUrl = parseThemeArg();
278
+ const fullInstall = parseFullArg();
207
279
  let themeConfig = null;
208
280
  if (themeUrl) {
209
281
  const hash = extractThemeHash(themeUrl);
@@ -216,6 +288,7 @@ async function main() {
216
288
 
217
289
  ${amber("Hey!")} Let's create your Bearnie project.
218
290
  ${themeConfig ? ` ${pc.dim("Using custom theme from URL")}
291
+ ` : ""}${fullInstall ? ` ${pc.dim("Full install: including all components")}
219
292
  ` : ""}
220
293
  `);
221
294
  let projectName = process.argv.find(
@@ -274,6 +347,60 @@ ${themeConfig ? ` ${pc.dim("Using custom theme from URL")}
274
347
  await fs.writeFile(globalCssPath, customCSS);
275
348
  console.log(` ${pc.green("\u2713")} Applied custom theme`);
276
349
  }
350
+ if (fullInstall) {
351
+ console.log(`
352
+ ${pc.dim("Fetching components from registry...")}
353
+ `);
354
+ await fs.ensureDir(path.join(targetDir, "src", "components", "ui"));
355
+ await fs.ensureDir(path.join(targetDir, "src", "utils"));
356
+ const focusTrap = await fetchUtility("focus-trap");
357
+ if (focusTrap?.files) {
358
+ for (const file of focusTrap.files) {
359
+ const filePath = path.join(targetDir, "src", file.name);
360
+ await fs.ensureDir(path.dirname(filePath));
361
+ await fs.writeFile(filePath, file.content);
362
+ }
363
+ console.log(` ${pc.green("\u2713")} Added focus-trap utility`);
364
+ }
365
+ const cnContent = `import { clsx, type ClassValue } from "clsx";
366
+ import { twMerge } from "tailwind-merge";
367
+
368
+ export function cn(...inputs: ClassValue[]) {
369
+ return twMerge(clsx(inputs));
370
+ }
371
+ `;
372
+ await fs.writeFile(path.join(targetDir, "src", "utils", "cn.ts"), cnContent);
373
+ console.log(` ${pc.green("\u2713")} Added cn utility`);
374
+ let installed = 0;
375
+ let failed = 0;
376
+ for (const componentName of COMPONENT_NAMES) {
377
+ const component = await fetchComponent(componentName);
378
+ if (component?.files) {
379
+ for (const file of component.files) {
380
+ const filePath = path.join(targetDir, "src", file.name);
381
+ await fs.ensureDir(path.dirname(filePath));
382
+ await fs.writeFile(filePath, file.content);
383
+ }
384
+ installed++;
385
+ process.stdout.write(`\r ${pc.green("\u2713")} Installed ${installed}/${COMPONENT_NAMES.length} components`);
386
+ } else {
387
+ failed++;
388
+ }
389
+ }
390
+ console.log("");
391
+ if (failed > 0) {
392
+ console.log(` ${pc.yellow("!")} ${failed} components failed to fetch`);
393
+ }
394
+ const pkgPath2 = path.join(targetDir, "package.json");
395
+ const pkg2 = await fs.readJson(pkgPath2);
396
+ pkg2.dependencies = {
397
+ ...pkg2.dependencies,
398
+ "clsx": "^2.1.1",
399
+ "tailwind-merge": "^3.3.0"
400
+ };
401
+ await fs.writeJson(pkgPath2, pkg2, { spaces: 2 });
402
+ console.log(` ${pc.green("\u2713")} Added component dependencies`);
403
+ }
277
404
  await fs.writeFile(
278
405
  path.join(targetDir, ".gitignore"),
279
406
  `# Dependencies
@@ -300,7 +427,24 @@ Thumbs.db
300
427
  `
301
428
  );
302
429
  console.log(` ${pc.green("\u2713")} Created project files`);
303
- console.log(`
430
+ if (fullInstall) {
431
+ console.log(`
432
+ ${pc.green("Done!")} Your Bearnie project is ready with all components.
433
+
434
+ ${pc.bold("Next steps:")}
435
+
436
+ ${pc.dim("1.")} cd ${pc.cyan(finalName)}
437
+ ${pc.dim("2.")} npm install
438
+ ${pc.dim("3.")} npm run dev
439
+
440
+ ${pc.dim("All components are in")} ${pc.cyan("src/components/ui/")}
441
+
442
+ ${pc.dim("Browse components at")} ${link("bearnie.dev/docs/components", "https://bearnie.dev/docs/components")}
443
+
444
+ ${pc.dim("Made by")} ${link("Michael", "https://michaelandreuzza.com")} ${pc.dim("at")} ${link("Lexington Themes", "https://lexingtonthemes.com")}
445
+ `);
446
+ } else {
447
+ console.log(`
304
448
  ${pc.green("Done!")} Your Bearnie project is ready.
305
449
 
306
450
  ${pc.bold("Next steps:")}
@@ -310,10 +454,14 @@ Thumbs.db
310
454
  ${pc.dim("3.")} npx bearnie add button card
311
455
  ${pc.dim("4.")} npm run dev
312
456
 
457
+ ${pc.dim("Or use")} ${pc.cyan("--full")} ${pc.dim("to include all components:")}
458
+ npx create-bearnie my-app --full
459
+
313
460
  ${pc.dim("Browse components at")} ${link("bearnie.dev/docs/components", "https://bearnie.dev/docs/components")}
314
461
 
315
462
  ${pc.dim("Made by")} ${link("Michael", "https://michaelandreuzza.com")} ${pc.dim("at")} ${link("Lexington Themes", "https://lexingtonthemes.com")}
316
463
  `);
464
+ }
317
465
  }
318
466
  main().catch((err) => {
319
467
  console.error(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bearnie",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Create a new Astro project with Bearnie UI components",
5
5
  "type": "module",
6
6
  "license": "MIT",