@brxndxndiaz/ui 0.1.2 → 0.1.3

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.
@@ -116,23 +116,49 @@ function detectPackageManager(projectRoot) {
116
116
  return "npm";
117
117
  }
118
118
 
119
- function installDependencies(dependencies) {
120
- if (!dependencies || dependencies.length === 0) return;
119
+ function installDependencies(dependencies, devDependencies) {
120
+ const deps = dependencies || [];
121
+ const devDeps = devDependencies || [];
122
+ if (deps.length === 0 && devDeps.length === 0) return;
121
123
  const projectRoot = process.cwd();
122
124
  if (!fileExists(path.join(projectRoot, "package.json"))) {
123
125
  console.warn("Skipping dependency install: package.json not found.");
124
126
  return;
125
127
  }
126
128
  const pkgManager = detectPackageManager(projectRoot);
127
- const args =
128
- pkgManager === "yarn"
129
- ? ["add", ...dependencies]
130
- : pkgManager === "pnpm" || pkgManager === "bun"
131
- ? ["add", ...dependencies]
132
- : ["install", ...dependencies];
133
- const result = spawnSync(pkgManager, args, { stdio: "inherit" });
134
- if (result.status !== 0) {
135
- throw new Error(`Failed to install dependencies with ${pkgManager}.`);
129
+ const installArgs = (items, isDev) => {
130
+ if (items.length === 0) return null;
131
+ if (pkgManager === "npm") {
132
+ return isDev ? ["install", "--save-dev", ...items] : ["install", ...items];
133
+ }
134
+ if (pkgManager === "yarn") {
135
+ return isDev ? ["add", "-D", ...items] : ["add", ...items];
136
+ }
137
+ if (pkgManager === "pnpm") {
138
+ return isDev ? ["add", "-D", ...items] : ["add", ...items];
139
+ }
140
+ if (pkgManager === "bun") {
141
+ return isDev ? ["add", "-d", ...items] : ["add", ...items];
142
+ }
143
+ return null;
144
+ };
145
+
146
+ if (deps.length > 0) {
147
+ console.log(`Installing dependencies with ${pkgManager}: ${deps.join(", ")}`);
148
+ const args = installArgs(deps, false);
149
+ const result = spawnSync(pkgManager, args, { stdio: "inherit" });
150
+ if (result.status !== 0) {
151
+ throw new Error(`Failed to install dependencies with ${pkgManager}.`);
152
+ }
153
+ }
154
+
155
+ if (devDeps.length > 0) {
156
+ console.log(`Installing dev dependencies with ${pkgManager}: ${devDeps.join(", ")}`);
157
+ const args = installArgs(devDeps, true);
158
+ const result = spawnSync(pkgManager, args, { stdio: "inherit" });
159
+ if (result.status !== 0) {
160
+ throw new Error(`Failed to install dev dependencies with ${pkgManager}.`);
161
+ }
136
162
  }
137
163
  }
138
164
 
@@ -219,7 +245,8 @@ async function addComponent(
219
245
  name,
220
246
  componentsRoot,
221
247
  seen = new Set(),
222
- dependencies = new Set()
248
+ dependencies = new Set(),
249
+ devDependencies = new Set()
223
250
  ) {
224
251
  if (seen.has(name)) return;
225
252
  seen.add(name);
@@ -247,12 +274,24 @@ async function addComponent(
247
274
 
248
275
  if (item.registryDependencies && item.registryDependencies.length > 0) {
249
276
  for (const dependency of item.registryDependencies) {
250
- await addComponent(dependency, componentsRoot, seen, dependencies);
277
+ await addComponent(
278
+ dependency,
279
+ componentsRoot,
280
+ seen,
281
+ dependencies,
282
+ devDependencies
283
+ );
251
284
  }
252
285
  }
253
- if (item.dependencies && item.dependencies.length > 0) {
286
+ if (Array.isArray(item.dependencies)) {
254
287
  item.dependencies.forEach((dep) => dependencies.add(dep));
255
288
  }
289
+ if (Array.isArray(item.devDependencies)) {
290
+ item.devDependencies.forEach((dep) => devDependencies.add(dep));
291
+ }
292
+ if (Array.isArray(item.peerDependencies)) {
293
+ item.peerDependencies.forEach((dep) => dependencies.add(dep));
294
+ }
256
295
 
257
296
  for (const file of item.files) {
258
297
  const targetPath = file.target || file.path;
@@ -398,10 +437,11 @@ async function main() {
398
437
 
399
438
  const seen = new Set();
400
439
  const dependencies = new Set();
440
+ const devDependencies = new Set();
401
441
  for (const component of components) {
402
- await addComponent(component, componentsRoot, seen, dependencies);
442
+ await addComponent(component, componentsRoot, seen, dependencies, devDependencies);
403
443
  }
404
- installDependencies(Array.from(dependencies));
444
+ installDependencies(Array.from(dependencies), Array.from(devDependencies));
405
445
  }
406
446
 
407
447
  main().catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brxndxndiaz/ui",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "description": "CLI for the brxndxndiaz UI registry.",
6
6
  "scripts": {