benflux-ui 0.1.2 → 0.1.4

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.
@@ -28,11 +28,11 @@ var import_commander = require("commander");
28
28
  var import_picocolors5 = __toESM(require("picocolors"));
29
29
 
30
30
  // src/commands/init.ts
31
- var import_path2 = __toESM(require("path"));
32
31
  var clack = __toESM(require("@clack/prompts"));
33
- var import_picocolors = __toESM(require("picocolors"));
34
- var import_fs_extra2 = __toESM(require("fs-extra"));
35
32
  var import_execa = require("execa");
33
+ var import_fs_extra2 = __toESM(require("fs-extra"));
34
+ var import_path2 = __toESM(require("path"));
35
+ var import_picocolors = __toESM(require("picocolors"));
36
36
 
37
37
  // src/utils/detect-framework.ts
38
38
  var import_path = __toESM(require("path"));
@@ -70,6 +70,9 @@ async function hasTailwind(cwd) {
70
70
  const version = await detectTailwindVersion(cwd);
71
71
  return version !== null;
72
72
  }
73
+ async function hasSrcDir(cwd) {
74
+ return import_fs_extra.default.pathExists(import_path.default.join(cwd, "src"));
75
+ }
73
76
  async function getComponentsPath(cwd) {
74
77
  const candidates = [
75
78
  "src/components/ui",
@@ -83,11 +86,8 @@ async function getComponentsPath(cwd) {
83
86
  return candidate;
84
87
  }
85
88
  }
86
- const framework = await detectFramework(cwd);
87
- if (framework === "next") {
88
- return "src/components/ui";
89
- }
90
- return "src/components/ui";
89
+ const useSrc = await hasSrcDir(cwd);
90
+ return useSrc ? "src/components/ui" : "components/ui";
91
91
  }
92
92
 
93
93
  // src/commands/init.ts
@@ -97,6 +97,7 @@ async function initCommand(options) {
97
97
  const framework = await detectFramework(cwd);
98
98
  const pm = await detectPackageManager(cwd);
99
99
  const hasTw = await hasTailwind(cwd);
100
+ const useSrc = await hasSrcDir(cwd);
100
101
  const defaultPath = await getComponentsPath(cwd);
101
102
  clack.note(
102
103
  [
@@ -149,25 +150,28 @@ async function initCommand(options) {
149
150
  const componentsPath = import_path2.default.join(cwd, settings.componentsDir);
150
151
  await import_fs_extra2.default.ensureDir(componentsPath);
151
152
  spinner3.stop(`Components directory: ${import_picocolors.default.cyan(settings.componentsDir)}`);
153
+ const libDir = useSrc ? "src/lib" : "lib";
154
+ const globalsCss = useSrc ? "src/app/globals.css" : "app/globals.css";
155
+ const componentsAlias = `@/${settings.componentsDir.replace(/^src\//, "")}`;
152
156
  spinner3.start("Creating benflux-ui.json config...");
153
157
  const config = {
154
158
  $schema: "https://benflux-ui.vercel.app/schema.json",
155
159
  style: "default",
156
160
  typescript: settings.typescript,
157
161
  tailwind: {
158
- config: hasTw ? "tailwind.config.ts" : "tailwind.config.ts",
159
- css: "src/app/globals.css",
162
+ config: "tailwind.config.ts",
163
+ css: globalsCss,
160
164
  baseColor: "default"
161
165
  },
162
166
  aliases: {
163
- components: `@/${settings.componentsDir.replace("src/", "")}`,
167
+ components: componentsAlias,
164
168
  utils: "@/lib/utils"
165
169
  }
166
170
  };
167
171
  await import_fs_extra2.default.writeJson(import_path2.default.join(cwd, "benflux-ui.json"), config, { spaces: 2 });
168
172
  spinner3.stop("benflux-ui.json created");
169
173
  spinner3.start("Creating utility functions...");
170
- const utilsDir = import_path2.default.join(cwd, "src/lib");
174
+ const utilsDir = import_path2.default.join(cwd, libDir);
171
175
  await import_fs_extra2.default.ensureDir(utilsDir);
172
176
  await import_fs_extra2.default.writeFile(
173
177
  import_path2.default.join(utilsDir, "utils.ts"),
@@ -179,7 +183,7 @@ export function cn(...inputs: ClassValue[]) {
179
183
  }
180
184
  `
181
185
  );
182
- spinner3.stop("lib/utils.ts created");
186
+ spinner3.stop(`${libDir}/utils.ts created`);
183
187
  if (settings.installDeps) {
184
188
  spinner3.start(`Installing core dependencies with ${pm}...`);
185
189
  try {
@@ -209,11 +213,11 @@ export function cn(...inputs: ClassValue[]) {
209
213
  }
210
214
 
211
215
  // src/commands/add.ts
212
- var import_path3 = __toESM(require("path"));
213
216
  var clack2 = __toESM(require("@clack/prompts"));
214
- var import_picocolors2 = __toESM(require("picocolors"));
215
- var import_fs_extra3 = __toESM(require("fs-extra"));
216
217
  var import_execa2 = require("execa");
218
+ var import_fs_extra3 = __toESM(require("fs-extra"));
219
+ var import_path3 = __toESM(require("path"));
220
+ var import_picocolors2 = __toESM(require("picocolors"));
217
221
 
218
222
  // src/utils/registry.ts
219
223
  var REGISTRY = [
@@ -815,26 +819,23 @@ async function addCommand(components, options) {
815
819
  const defaultDir = options.path ?? await getComponentsPath(cwd);
816
820
  let selectedComponents = components;
817
821
  if (selectedComponents.length === 0) {
818
- const categories = [...new Set(REGISTRY.map((c) => c.category))];
819
- const category = await clack2.select({
820
- message: "Select component category:",
821
- options: [
822
- { label: "All components", value: "all" },
823
- ...categories.map((c) => ({
824
- label: c.charAt(0).toUpperCase() + c.slice(1),
825
- value: c
826
- }))
827
- ]
828
- });
829
- if (clack2.isCancel(category)) {
830
- clack2.cancel("Cancelled.");
831
- process.exit(0);
832
- }
833
- const componentOptions = category === "all" ? REGISTRY : REGISTRY.filter((c) => c.category === category);
822
+ const categoryLabel = {
823
+ layout: "Layout",
824
+ inputs: "Inputs",
825
+ navigation: "Navigation",
826
+ feedback: "Feedback",
827
+ "data-display": "Data Display",
828
+ ai: "AI",
829
+ wow: "WOW Effects"
830
+ };
831
+ const sorted = [...REGISTRY].sort(
832
+ (a, b) => a.category === b.category ? a.name.localeCompare(b.name) : a.category.localeCompare(b.category)
833
+ );
834
834
  const selected = await clack2.multiselect({
835
- message: "Select components to add:",
836
- options: componentOptions.map((c) => ({
837
- label: `${c.name} \u2014 ${c.description}`,
835
+ message: "Which components would you like to add? \u2191\u2193 navigate \xB7 Space select \xB7 Enter confirm",
836
+ options: sorted.map((c) => ({
837
+ label: c.name,
838
+ hint: `${categoryLabel[c.category] ?? c.category} \u2014 ${c.description}`,
838
839
  value: c.name
839
840
  }))
840
841
  });
@@ -847,7 +848,9 @@ async function addCommand(components, options) {
847
848
  const validComponents = selectedComponents.map((name) => {
848
849
  const component = getComponent(name);
849
850
  if (!component) {
850
- clack2.log.warn(`Component ${import_picocolors2.default.yellow(name)} not found. Use ${import_picocolors2.default.cyan("benflux-ui list")} to see available components.`);
851
+ clack2.log.warn(
852
+ `Component ${import_picocolors2.default.yellow(name)} not found. Use ${import_picocolors2.default.cyan("benflux-ui list")} to see available components.`
853
+ );
851
854
  return null;
852
855
  }
853
856
  return component;
@@ -896,25 +899,26 @@ async function addCommand(components, options) {
896
899
  for (const file of component.files) {
897
900
  const targetPath = import_path3.default.join(cwd, defaultDir, import_path3.default.basename(file));
898
901
  if (await import_fs_extra3.default.pathExists(targetPath) && !options.overwrite) {
899
- spinner3.stop(`${import_picocolors2.default.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`);
902
+ spinner3.stop(
903
+ `${import_picocolors2.default.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`
904
+ );
900
905
  continue;
901
906
  }
902
- const sourcePath = import_path3.default.join(
903
- cwd,
904
- "node_modules/@benflux-ui/react/src",
905
- file
906
- );
907
- if (await import_fs_extra3.default.pathExists(sourcePath)) {
908
- await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
909
- await import_fs_extra3.default.copy(sourcePath, targetPath);
907
+ await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
908
+ const localSrc = import_path3.default.join(cwd, "node_modules/@benflux-ui/react/src", file);
909
+ if (await import_fs_extra3.default.pathExists(localSrc)) {
910
+ await import_fs_extra3.default.copy(localSrc, targetPath);
910
911
  } else {
911
- await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
912
- await import_fs_extra3.default.writeFile(
913
- targetPath,
914
- `// ${component.name} \u2014 Install @benflux-ui/react to get the full component
915
- export {} from "@benflux-ui/react"
916
- `
917
- );
912
+ const url = `https://unpkg.com/@benflux-ui/react@latest/src/${file}`;
913
+ try {
914
+ const res = await fetch(url);
915
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
916
+ const source = await res.text();
917
+ await import_fs_extra3.default.writeFile(targetPath, source, "utf-8");
918
+ } catch (err) {
919
+ spinner3.stop(import_picocolors2.default.red(`Failed to fetch ${file}: ${err.message}`));
920
+ clack2.log.warn(`Download manually from: ${url}`);
921
+ }
918
922
  }
919
923
  }
920
924
  spinner3.stop(`${import_picocolors2.default.green("\u2713")} Added ${component.name}`);
@@ -924,7 +928,11 @@ export {} from "@benflux-ui/react"
924
928
  import_picocolors2.default.green("\u2713") + " Components added successfully!",
925
929
  "",
926
930
  import_picocolors2.default.bold("Usage:"),
927
- ` ${import_picocolors2.default.cyan(`import { ${validComponents.map((c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")).join(", ")} } from "@benflux-ui/react"`)}`
931
+ ` ${import_picocolors2.default.cyan(
932
+ `import { ${validComponents.map(
933
+ (c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")
934
+ ).join(", ")} } from "@benflux-ui/react"`
935
+ )}`
928
936
  ].join("\n")
929
937
  );
930
938
  }
package/dist/index.js CHANGED
@@ -46,11 +46,11 @@ __export(src_exports, {
46
46
  module.exports = __toCommonJS(src_exports);
47
47
 
48
48
  // src/commands/init.ts
49
- var import_path2 = __toESM(require("path"));
50
49
  var clack = __toESM(require("@clack/prompts"));
51
- var import_picocolors = __toESM(require("picocolors"));
52
- var import_fs_extra2 = __toESM(require("fs-extra"));
53
50
  var import_execa = require("execa");
51
+ var import_fs_extra2 = __toESM(require("fs-extra"));
52
+ var import_path2 = __toESM(require("path"));
53
+ var import_picocolors = __toESM(require("picocolors"));
54
54
 
55
55
  // src/utils/detect-framework.ts
56
56
  var import_path = __toESM(require("path"));
@@ -88,6 +88,9 @@ async function hasTailwind(cwd) {
88
88
  const version = await detectTailwindVersion(cwd);
89
89
  return version !== null;
90
90
  }
91
+ async function hasSrcDir(cwd) {
92
+ return import_fs_extra.default.pathExists(import_path.default.join(cwd, "src"));
93
+ }
91
94
  async function getComponentsPath(cwd) {
92
95
  const candidates = [
93
96
  "src/components/ui",
@@ -101,11 +104,8 @@ async function getComponentsPath(cwd) {
101
104
  return candidate;
102
105
  }
103
106
  }
104
- const framework = await detectFramework(cwd);
105
- if (framework === "next") {
106
- return "src/components/ui";
107
- }
108
- return "src/components/ui";
107
+ const useSrc = await hasSrcDir(cwd);
108
+ return useSrc ? "src/components/ui" : "components/ui";
109
109
  }
110
110
 
111
111
  // src/commands/init.ts
@@ -115,6 +115,7 @@ async function initCommand(options) {
115
115
  const framework = await detectFramework(cwd);
116
116
  const pm = await detectPackageManager(cwd);
117
117
  const hasTw = await hasTailwind(cwd);
118
+ const useSrc = await hasSrcDir(cwd);
118
119
  const defaultPath = await getComponentsPath(cwd);
119
120
  clack.note(
120
121
  [
@@ -167,25 +168,28 @@ async function initCommand(options) {
167
168
  const componentsPath = import_path2.default.join(cwd, settings.componentsDir);
168
169
  await import_fs_extra2.default.ensureDir(componentsPath);
169
170
  spinner3.stop(`Components directory: ${import_picocolors.default.cyan(settings.componentsDir)}`);
171
+ const libDir = useSrc ? "src/lib" : "lib";
172
+ const globalsCss = useSrc ? "src/app/globals.css" : "app/globals.css";
173
+ const componentsAlias = `@/${settings.componentsDir.replace(/^src\//, "")}`;
170
174
  spinner3.start("Creating benflux-ui.json config...");
171
175
  const config = {
172
176
  $schema: "https://benflux-ui.vercel.app/schema.json",
173
177
  style: "default",
174
178
  typescript: settings.typescript,
175
179
  tailwind: {
176
- config: hasTw ? "tailwind.config.ts" : "tailwind.config.ts",
177
- css: "src/app/globals.css",
180
+ config: "tailwind.config.ts",
181
+ css: globalsCss,
178
182
  baseColor: "default"
179
183
  },
180
184
  aliases: {
181
- components: `@/${settings.componentsDir.replace("src/", "")}`,
185
+ components: componentsAlias,
182
186
  utils: "@/lib/utils"
183
187
  }
184
188
  };
185
189
  await import_fs_extra2.default.writeJson(import_path2.default.join(cwd, "benflux-ui.json"), config, { spaces: 2 });
186
190
  spinner3.stop("benflux-ui.json created");
187
191
  spinner3.start("Creating utility functions...");
188
- const utilsDir = import_path2.default.join(cwd, "src/lib");
192
+ const utilsDir = import_path2.default.join(cwd, libDir);
189
193
  await import_fs_extra2.default.ensureDir(utilsDir);
190
194
  await import_fs_extra2.default.writeFile(
191
195
  import_path2.default.join(utilsDir, "utils.ts"),
@@ -197,7 +201,7 @@ export function cn(...inputs: ClassValue[]) {
197
201
  }
198
202
  `
199
203
  );
200
- spinner3.stop("lib/utils.ts created");
204
+ spinner3.stop(`${libDir}/utils.ts created`);
201
205
  if (settings.installDeps) {
202
206
  spinner3.start(`Installing core dependencies with ${pm}...`);
203
207
  try {
@@ -227,11 +231,11 @@ export function cn(...inputs: ClassValue[]) {
227
231
  }
228
232
 
229
233
  // src/commands/add.ts
230
- var import_path3 = __toESM(require("path"));
231
234
  var clack2 = __toESM(require("@clack/prompts"));
232
- var import_picocolors2 = __toESM(require("picocolors"));
233
- var import_fs_extra3 = __toESM(require("fs-extra"));
234
235
  var import_execa2 = require("execa");
236
+ var import_fs_extra3 = __toESM(require("fs-extra"));
237
+ var import_path3 = __toESM(require("path"));
238
+ var import_picocolors2 = __toESM(require("picocolors"));
235
239
 
236
240
  // src/utils/registry.ts
237
241
  var REGISTRY = [
@@ -842,26 +846,23 @@ async function addCommand(components, options) {
842
846
  const defaultDir = options.path ?? await getComponentsPath(cwd);
843
847
  let selectedComponents = components;
844
848
  if (selectedComponents.length === 0) {
845
- const categories = [...new Set(REGISTRY.map((c) => c.category))];
846
- const category = await clack2.select({
847
- message: "Select component category:",
848
- options: [
849
- { label: "All components", value: "all" },
850
- ...categories.map((c) => ({
851
- label: c.charAt(0).toUpperCase() + c.slice(1),
852
- value: c
853
- }))
854
- ]
855
- });
856
- if (clack2.isCancel(category)) {
857
- clack2.cancel("Cancelled.");
858
- process.exit(0);
859
- }
860
- const componentOptions = category === "all" ? REGISTRY : REGISTRY.filter((c) => c.category === category);
849
+ const categoryLabel = {
850
+ layout: "Layout",
851
+ inputs: "Inputs",
852
+ navigation: "Navigation",
853
+ feedback: "Feedback",
854
+ "data-display": "Data Display",
855
+ ai: "AI",
856
+ wow: "WOW Effects"
857
+ };
858
+ const sorted = [...REGISTRY].sort(
859
+ (a, b) => a.category === b.category ? a.name.localeCompare(b.name) : a.category.localeCompare(b.category)
860
+ );
861
861
  const selected = await clack2.multiselect({
862
- message: "Select components to add:",
863
- options: componentOptions.map((c) => ({
864
- label: `${c.name} \u2014 ${c.description}`,
862
+ message: "Which components would you like to add? \u2191\u2193 navigate \xB7 Space select \xB7 Enter confirm",
863
+ options: sorted.map((c) => ({
864
+ label: c.name,
865
+ hint: `${categoryLabel[c.category] ?? c.category} \u2014 ${c.description}`,
865
866
  value: c.name
866
867
  }))
867
868
  });
@@ -874,7 +875,9 @@ async function addCommand(components, options) {
874
875
  const validComponents = selectedComponents.map((name) => {
875
876
  const component = getComponent(name);
876
877
  if (!component) {
877
- clack2.log.warn(`Component ${import_picocolors2.default.yellow(name)} not found. Use ${import_picocolors2.default.cyan("benflux-ui list")} to see available components.`);
878
+ clack2.log.warn(
879
+ `Component ${import_picocolors2.default.yellow(name)} not found. Use ${import_picocolors2.default.cyan("benflux-ui list")} to see available components.`
880
+ );
878
881
  return null;
879
882
  }
880
883
  return component;
@@ -923,25 +926,26 @@ async function addCommand(components, options) {
923
926
  for (const file of component.files) {
924
927
  const targetPath = import_path3.default.join(cwd, defaultDir, import_path3.default.basename(file));
925
928
  if (await import_fs_extra3.default.pathExists(targetPath) && !options.overwrite) {
926
- spinner3.stop(`${import_picocolors2.default.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`);
929
+ spinner3.stop(
930
+ `${import_picocolors2.default.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`
931
+ );
927
932
  continue;
928
933
  }
929
- const sourcePath = import_path3.default.join(
930
- cwd,
931
- "node_modules/@benflux-ui/react/src",
932
- file
933
- );
934
- if (await import_fs_extra3.default.pathExists(sourcePath)) {
935
- await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
936
- await import_fs_extra3.default.copy(sourcePath, targetPath);
934
+ await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
935
+ const localSrc = import_path3.default.join(cwd, "node_modules/@benflux-ui/react/src", file);
936
+ if (await import_fs_extra3.default.pathExists(localSrc)) {
937
+ await import_fs_extra3.default.copy(localSrc, targetPath);
937
938
  } else {
938
- await import_fs_extra3.default.ensureDir(import_path3.default.dirname(targetPath));
939
- await import_fs_extra3.default.writeFile(
940
- targetPath,
941
- `// ${component.name} \u2014 Install @benflux-ui/react to get the full component
942
- export {} from "@benflux-ui/react"
943
- `
944
- );
939
+ const url = `https://unpkg.com/@benflux-ui/react@latest/src/${file}`;
940
+ try {
941
+ const res = await fetch(url);
942
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
943
+ const source = await res.text();
944
+ await import_fs_extra3.default.writeFile(targetPath, source, "utf-8");
945
+ } catch (err) {
946
+ spinner3.stop(import_picocolors2.default.red(`Failed to fetch ${file}: ${err.message}`));
947
+ clack2.log.warn(`Download manually from: ${url}`);
948
+ }
945
949
  }
946
950
  }
947
951
  spinner3.stop(`${import_picocolors2.default.green("\u2713")} Added ${component.name}`);
@@ -951,7 +955,11 @@ export {} from "@benflux-ui/react"
951
955
  import_picocolors2.default.green("\u2713") + " Components added successfully!",
952
956
  "",
953
957
  import_picocolors2.default.bold("Usage:"),
954
- ` ${import_picocolors2.default.cyan(`import { ${validComponents.map((c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")).join(", ")} } from "@benflux-ui/react"`)}`
958
+ ` ${import_picocolors2.default.cyan(
959
+ `import { ${validComponents.map(
960
+ (c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")
961
+ ).join(", ")} } from "@benflux-ui/react"`
962
+ )}`
955
963
  ].join("\n")
956
964
  );
957
965
  }
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  // src/commands/init.ts
2
- import path2 from "path";
3
2
  import * as clack from "@clack/prompts";
4
- import pc from "picocolors";
5
- import fs2 from "fs-extra";
6
3
  import { execa } from "execa";
4
+ import fs2 from "fs-extra";
5
+ import path2 from "path";
6
+ import pc from "picocolors";
7
7
 
8
8
  // src/utils/detect-framework.ts
9
9
  import path from "path";
@@ -41,6 +41,9 @@ async function hasTailwind(cwd) {
41
41
  const version = await detectTailwindVersion(cwd);
42
42
  return version !== null;
43
43
  }
44
+ async function hasSrcDir(cwd) {
45
+ return fs.pathExists(path.join(cwd, "src"));
46
+ }
44
47
  async function getComponentsPath(cwd) {
45
48
  const candidates = [
46
49
  "src/components/ui",
@@ -54,11 +57,8 @@ async function getComponentsPath(cwd) {
54
57
  return candidate;
55
58
  }
56
59
  }
57
- const framework = await detectFramework(cwd);
58
- if (framework === "next") {
59
- return "src/components/ui";
60
- }
61
- return "src/components/ui";
60
+ const useSrc = await hasSrcDir(cwd);
61
+ return useSrc ? "src/components/ui" : "components/ui";
62
62
  }
63
63
 
64
64
  // src/commands/init.ts
@@ -68,6 +68,7 @@ async function initCommand(options) {
68
68
  const framework = await detectFramework(cwd);
69
69
  const pm = await detectPackageManager(cwd);
70
70
  const hasTw = await hasTailwind(cwd);
71
+ const useSrc = await hasSrcDir(cwd);
71
72
  const defaultPath = await getComponentsPath(cwd);
72
73
  clack.note(
73
74
  [
@@ -120,25 +121,28 @@ async function initCommand(options) {
120
121
  const componentsPath = path2.join(cwd, settings.componentsDir);
121
122
  await fs2.ensureDir(componentsPath);
122
123
  spinner3.stop(`Components directory: ${pc.cyan(settings.componentsDir)}`);
124
+ const libDir = useSrc ? "src/lib" : "lib";
125
+ const globalsCss = useSrc ? "src/app/globals.css" : "app/globals.css";
126
+ const componentsAlias = `@/${settings.componentsDir.replace(/^src\//, "")}`;
123
127
  spinner3.start("Creating benflux-ui.json config...");
124
128
  const config = {
125
129
  $schema: "https://benflux-ui.vercel.app/schema.json",
126
130
  style: "default",
127
131
  typescript: settings.typescript,
128
132
  tailwind: {
129
- config: hasTw ? "tailwind.config.ts" : "tailwind.config.ts",
130
- css: "src/app/globals.css",
133
+ config: "tailwind.config.ts",
134
+ css: globalsCss,
131
135
  baseColor: "default"
132
136
  },
133
137
  aliases: {
134
- components: `@/${settings.componentsDir.replace("src/", "")}`,
138
+ components: componentsAlias,
135
139
  utils: "@/lib/utils"
136
140
  }
137
141
  };
138
142
  await fs2.writeJson(path2.join(cwd, "benflux-ui.json"), config, { spaces: 2 });
139
143
  spinner3.stop("benflux-ui.json created");
140
144
  spinner3.start("Creating utility functions...");
141
- const utilsDir = path2.join(cwd, "src/lib");
145
+ const utilsDir = path2.join(cwd, libDir);
142
146
  await fs2.ensureDir(utilsDir);
143
147
  await fs2.writeFile(
144
148
  path2.join(utilsDir, "utils.ts"),
@@ -150,7 +154,7 @@ export function cn(...inputs: ClassValue[]) {
150
154
  }
151
155
  `
152
156
  );
153
- spinner3.stop("lib/utils.ts created");
157
+ spinner3.stop(`${libDir}/utils.ts created`);
154
158
  if (settings.installDeps) {
155
159
  spinner3.start(`Installing core dependencies with ${pm}...`);
156
160
  try {
@@ -180,11 +184,11 @@ export function cn(...inputs: ClassValue[]) {
180
184
  }
181
185
 
182
186
  // src/commands/add.ts
183
- import path3 from "path";
184
187
  import * as clack2 from "@clack/prompts";
185
- import pc2 from "picocolors";
186
- import fs3 from "fs-extra";
187
188
  import { execa as execa2 } from "execa";
189
+ import fs3 from "fs-extra";
190
+ import path3 from "path";
191
+ import pc2 from "picocolors";
188
192
 
189
193
  // src/utils/registry.ts
190
194
  var REGISTRY = [
@@ -795,26 +799,23 @@ async function addCommand(components, options) {
795
799
  const defaultDir = options.path ?? await getComponentsPath(cwd);
796
800
  let selectedComponents = components;
797
801
  if (selectedComponents.length === 0) {
798
- const categories = [...new Set(REGISTRY.map((c) => c.category))];
799
- const category = await clack2.select({
800
- message: "Select component category:",
801
- options: [
802
- { label: "All components", value: "all" },
803
- ...categories.map((c) => ({
804
- label: c.charAt(0).toUpperCase() + c.slice(1),
805
- value: c
806
- }))
807
- ]
808
- });
809
- if (clack2.isCancel(category)) {
810
- clack2.cancel("Cancelled.");
811
- process.exit(0);
812
- }
813
- const componentOptions = category === "all" ? REGISTRY : REGISTRY.filter((c) => c.category === category);
802
+ const categoryLabel = {
803
+ layout: "Layout",
804
+ inputs: "Inputs",
805
+ navigation: "Navigation",
806
+ feedback: "Feedback",
807
+ "data-display": "Data Display",
808
+ ai: "AI",
809
+ wow: "WOW Effects"
810
+ };
811
+ const sorted = [...REGISTRY].sort(
812
+ (a, b) => a.category === b.category ? a.name.localeCompare(b.name) : a.category.localeCompare(b.category)
813
+ );
814
814
  const selected = await clack2.multiselect({
815
- message: "Select components to add:",
816
- options: componentOptions.map((c) => ({
817
- label: `${c.name} \u2014 ${c.description}`,
815
+ message: "Which components would you like to add? \u2191\u2193 navigate \xB7 Space select \xB7 Enter confirm",
816
+ options: sorted.map((c) => ({
817
+ label: c.name,
818
+ hint: `${categoryLabel[c.category] ?? c.category} \u2014 ${c.description}`,
818
819
  value: c.name
819
820
  }))
820
821
  });
@@ -827,7 +828,9 @@ async function addCommand(components, options) {
827
828
  const validComponents = selectedComponents.map((name) => {
828
829
  const component = getComponent(name);
829
830
  if (!component) {
830
- clack2.log.warn(`Component ${pc2.yellow(name)} not found. Use ${pc2.cyan("benflux-ui list")} to see available components.`);
831
+ clack2.log.warn(
832
+ `Component ${pc2.yellow(name)} not found. Use ${pc2.cyan("benflux-ui list")} to see available components.`
833
+ );
831
834
  return null;
832
835
  }
833
836
  return component;
@@ -876,25 +879,26 @@ async function addCommand(components, options) {
876
879
  for (const file of component.files) {
877
880
  const targetPath = path3.join(cwd, defaultDir, path3.basename(file));
878
881
  if (await fs3.pathExists(targetPath) && !options.overwrite) {
879
- spinner3.stop(`${pc2.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`);
882
+ spinner3.stop(
883
+ `${pc2.yellow("skipped")} ${component.name} (already exists \u2014 use --overwrite to replace)`
884
+ );
880
885
  continue;
881
886
  }
882
- const sourcePath = path3.join(
883
- cwd,
884
- "node_modules/@benflux-ui/react/src",
885
- file
886
- );
887
- if (await fs3.pathExists(sourcePath)) {
888
- await fs3.ensureDir(path3.dirname(targetPath));
889
- await fs3.copy(sourcePath, targetPath);
887
+ await fs3.ensureDir(path3.dirname(targetPath));
888
+ const localSrc = path3.join(cwd, "node_modules/@benflux-ui/react/src", file);
889
+ if (await fs3.pathExists(localSrc)) {
890
+ await fs3.copy(localSrc, targetPath);
890
891
  } else {
891
- await fs3.ensureDir(path3.dirname(targetPath));
892
- await fs3.writeFile(
893
- targetPath,
894
- `// ${component.name} \u2014 Install @benflux-ui/react to get the full component
895
- export {} from "@benflux-ui/react"
896
- `
897
- );
892
+ const url = `https://unpkg.com/@benflux-ui/react@latest/src/${file}`;
893
+ try {
894
+ const res = await fetch(url);
895
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
896
+ const source = await res.text();
897
+ await fs3.writeFile(targetPath, source, "utf-8");
898
+ } catch (err) {
899
+ spinner3.stop(pc2.red(`Failed to fetch ${file}: ${err.message}`));
900
+ clack2.log.warn(`Download manually from: ${url}`);
901
+ }
898
902
  }
899
903
  }
900
904
  spinner3.stop(`${pc2.green("\u2713")} Added ${component.name}`);
@@ -904,7 +908,11 @@ export {} from "@benflux-ui/react"
904
908
  pc2.green("\u2713") + " Components added successfully!",
905
909
  "",
906
910
  pc2.bold("Usage:"),
907
- ` ${pc2.cyan(`import { ${validComponents.map((c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")).join(", ")} } from "@benflux-ui/react"`)}`
911
+ ` ${pc2.cyan(
912
+ `import { ${validComponents.map(
913
+ (c) => c?.name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("")
914
+ ).join(", ")} } from "@benflux-ui/react"`
915
+ )}`
908
916
  ].join("\n")
909
917
  );
910
918
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benflux-ui",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "CLI for adding Benflux UI components to your project",
5
5
  "keywords": [
6
6
  "benflux-ui",