bearnie 0.1.5 → 0.1.6

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/README.md CHANGED
@@ -14,13 +14,15 @@ npx bearnie init
14
14
  # 3. Add components
15
15
  npx bearnie add button card input
16
16
 
17
- # 4. Use in your Astro pages
17
+ # 4. Optional: add barrel export for named imports
18
+ npx bearnie add barrel
19
+
20
+ # 5. Use in your Astro pages
18
21
  ```
19
22
 
20
23
  ```astro
21
24
  ---
22
- import Button from "@/components/ui/button/Button.astro";
23
- import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
25
+ import { Button, Card, CardHeader, CardTitle, CardContent } from "@/components/bearnie";
24
26
  ---
25
27
 
26
28
  <Card>
@@ -79,6 +81,9 @@ npx bearnie add button card input
79
81
  # Add all available components
80
82
  npx bearnie add --all
81
83
 
84
+ # Add barrel export (after components are installed)
85
+ npx bearnie add barrel
86
+
82
87
  # Interactive component selection
83
88
  npx bearnie add
84
89
  ```
@@ -113,6 +118,7 @@ After running `init`, a `bearnie.json` file is created in your project root:
113
118
  {
114
119
  "componentsDir": "src/components/bearnie",
115
120
  "utilsDir": "src/utils",
121
+ "stylesDir": "src/styles",
116
122
  "typescript": true
117
123
  }
118
124
  ```
@@ -123,6 +129,7 @@ After running `init`, a `bearnie.json` file is created in your project root:
123
129
  | --------------- | --------- | --------------------- | -------------------------------------------- |
124
130
  | `componentsDir` | `string` | `"src/components/bearnie"` | Directory where components will be installed |
125
131
  | `utilsDir` | `string` | `"src/utils"` | Directory for utility functions |
132
+ | `stylesDir` | `string` | `"src/styles"` | Directory for theme styles |
126
133
  | `typescript` | `boolean` | `true` | Whether to use TypeScript |
127
134
 
128
135
  ## Environment Variables
@@ -141,15 +148,14 @@ For local development and testing:
141
148
  git clone https://github.com/michael-andreuzza/bearnie.git
142
149
  cd bearnie
143
150
 
144
- # Install CLI dependencies
145
- cd packages/cli
151
+ # Install dependencies (npm workspaces)
146
152
  npm install
147
153
 
148
- # Build the CLI
149
- npm run build
154
+ # Build packages
155
+ npm run build:packages
150
156
 
151
- # Link for local testing
152
- npm link
157
+ # Link CLI for local testing
158
+ npm run cli:link
153
159
 
154
160
  # Now you can use it
155
161
  bearnie add button
@@ -195,7 +201,7 @@ BEARNIE_REGISTRY_URL=http://localhost:4321/registry bearnie add button
195
201
 
196
202
  ```astro
197
203
  ---
198
- import Button from "@/components/ui/button/Button.astro";
204
+ import Button from "@/components/bearnie/button/Button.astro";
199
205
  ---
200
206
 
201
207
  <Button>Default</Button>
@@ -210,9 +216,9 @@ import Button from "@/components/ui/button/Button.astro";
210
216
 
211
217
  ```astro
212
218
  ---
213
- import Input from "@/components/ui/input/Input.astro";
214
- import Label from "@/components/ui/label/Label.astro";
215
- import Button from "@/components/ui/button/Button.astro";
219
+ import Input from "@/components/bearnie/input/Input.astro";
220
+ import Label from "@/components/bearnie/label/Label.astro";
221
+ import Button from "@/components/bearnie/button/Button.astro";
216
222
  ---
217
223
 
218
224
  <form class="space-y-4">
@@ -232,13 +238,13 @@ import Button from "@/components/ui/button/Button.astro";
232
238
 
233
239
  ```astro
234
240
  ---
235
- import Card from "@/components/ui/card/Card.astro";
236
- import CardHeader from "@/components/ui/card/CardHeader.astro";
237
- import CardTitle from "@/components/ui/card/CardTitle.astro";
238
- import CardDescription from "@/components/ui/card/CardDescription.astro";
239
- import CardContent from "@/components/ui/card/CardContent.astro";
240
- import CardFooter from "@/components/ui/card/CardFooter.astro";
241
- import Button from "@/components/ui/button/Button.astro";
241
+ import Card from "@/components/bearnie/card/Card.astro";
242
+ import CardHeader from "@/components/bearnie/card/CardHeader.astro";
243
+ import CardTitle from "@/components/bearnie/card/CardTitle.astro";
244
+ import CardDescription from "@/components/bearnie/card/CardDescription.astro";
245
+ import CardContent from "@/components/bearnie/card/CardContent.astro";
246
+ import CardFooter from "@/components/bearnie/card/CardFooter.astro";
247
+ import Button from "@/components/bearnie/button/Button.astro";
242
248
  ---
243
249
 
244
250
  <Card class="w-96">
@@ -259,9 +265,9 @@ import Button from "@/components/ui/button/Button.astro";
259
265
 
260
266
  ```astro
261
267
  ---
262
- import Alert from "@/components/ui/alert/Alert.astro";
263
- import AlertTitle from "@/components/ui/alert/AlertTitle.astro";
264
- import AlertDescription from "@/components/ui/alert/AlertDescription.astro";
268
+ import Alert from "@/components/bearnie/alert/Alert.astro";
269
+ import AlertTitle from "@/components/bearnie/alert/AlertTitle.astro";
270
+ import AlertDescription from "@/components/bearnie/alert/AlertDescription.astro";
265
271
  ---
266
272
 
267
273
  <Alert>
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
+ import { readFileSync } from "fs";
5
+ import { dirname, join } from "path";
6
+ import { fileURLToPath } from "url";
4
7
  import { Command } from "commander";
5
8
  import chalk5 from "chalk";
6
9
 
@@ -18,6 +21,7 @@ import fs from "fs-extra";
18
21
  var DEFAULT_CONFIG = {
19
22
  componentsDir: "src/components/bearnie",
20
23
  utilsDir: "src/utils",
24
+ stylesDir: "src/styles",
21
25
  tailwindConfig: "tailwind.config.mjs",
22
26
  typescript: true
23
27
  };
@@ -26,7 +30,7 @@ async function getProjectConfig(cwd) {
26
30
  const configPath = path.join(cwd, CONFIG_FILE);
27
31
  if (await fs.pathExists(configPath)) {
28
32
  const content = await fs.readFile(configPath, "utf-8");
29
- return JSON.parse(content);
33
+ return { ...DEFAULT_CONFIG, ...JSON.parse(content) };
30
34
  }
31
35
  return null;
32
36
  }
@@ -58,6 +62,17 @@ async function hasTailwindInstalled(cwd) {
58
62
  };
59
63
  return "tailwindcss" in deps;
60
64
  }
65
+ function resolveInstallPath(cwd, config, filePath, componentType) {
66
+ const isUtilityFile = componentType === "utility" || filePath.startsWith("utils/");
67
+ const isStylesFile = componentType === "styles" || filePath.startsWith("styles/");
68
+ if (isUtilityFile) {
69
+ return path.join(cwd, config.utilsDir, filePath.replace(/^utils\//, ""));
70
+ }
71
+ if (isStylesFile) {
72
+ return path.join(cwd, config.stylesDir, filePath.replace(/^styles\//, ""));
73
+ }
74
+ return path.join(cwd, config.componentsDir, filePath);
75
+ }
61
76
 
62
77
  // src/utils/ui.ts
63
78
  import chalk from "chalk";
@@ -249,6 +264,7 @@ async function init(options) {
249
264
  try {
250
265
  await fs2.ensureDir(path2.join(cwd, config.componentsDir));
251
266
  await fs2.ensureDir(path2.join(cwd, config.utilsDir));
267
+ await fs2.ensureDir(path2.join(cwd, config.stylesDir));
252
268
  spinner.text = "Creating directories...";
253
269
  } catch (error) {
254
270
  spinner.fail("Couldn't create directories");
@@ -465,10 +481,12 @@ async function add(components, options) {
465
481
  component.dependencies?.forEach((d) => npmDeps.add(d));
466
482
  component.devDependencies?.forEach((d) => npmDevDeps.add(d));
467
483
  for (const file of component.files) {
468
- const isUtilityFile = component.type === "utility" || file.path.startsWith("utils/");
469
- const relativePath = isUtilityFile ? file.path.replace(/^utils\//, "") : file.path;
470
- const baseDir = isUtilityFile ? config.utilsDir : config.componentsDir;
471
- const filePath = path4.join(cwd, baseDir, relativePath);
484
+ const filePath = resolveInstallPath(
485
+ cwd,
486
+ config,
487
+ file.path,
488
+ component.type
489
+ );
472
490
  const exists = await fs4.pathExists(filePath);
473
491
  if (exists && !options.yes) {
474
492
  skippedFiles.push(file.path);
@@ -608,11 +626,15 @@ async function list(options) {
608
626
  }
609
627
 
610
628
  // src/index.ts
629
+ var __dirname = dirname(fileURLToPath(import.meta.url));
630
+ var pkg = JSON.parse(
631
+ readFileSync(join(__dirname, "../package.json"), "utf-8")
632
+ );
611
633
  var amber = chalk5.hex("#F59E0B");
612
634
  var logo2 = `${amber("\u{1F43B}")} ${chalk5.bold("bearnie")}`;
613
635
  var link = (text, url) => `\x1B]8;;${url}\x07${chalk5.cyan(text)}\x1B]8;;\x07`;
614
636
  var program = new Command();
615
- program.name("bearnie").description("UI components for Astro").version("0.1.0").configureOutput({
637
+ program.name("bearnie").description("UI components for Astro").version(pkg.version).configureOutput({
616
638
  writeOut: (str) => process.stdout.write(str),
617
639
  writeErr: (str) => process.stdout.write(str),
618
640
  outputError: (str, write) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bearnie",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "CLI for installing Bearnie UI components",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -9,7 +9,7 @@
9
9
  "dist"
10
10
  ],
11
11
  "scripts": {
12
- "build": "tsup src/index.ts --format esm --dts --clean",
12
+ "build": "tsup src/index.ts --format esm --clean",
13
13
  "dev": "tsup src/index.ts --format esm --watch",
14
14
  "typecheck": "tsc --noEmit"
15
15
  },
@@ -27,7 +27,7 @@
27
27
  "@types/node": "^20.14.9",
28
28
  "@types/prompts": "^2.4.9",
29
29
  "tsup": "^8.1.0",
30
- "typescript": "^5.5.3"
30
+ "typescript": "^5.7.3"
31
31
  },
32
32
  "engines": {
33
33
  "node": ">=18"
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node