@srcroot/ui 0.0.13 → 0.0.15

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 (2) hide show
  1. package/dist/index.js +57 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -574,17 +574,66 @@ async function init(options) {
574
574
  missing.push(installCmd2);
575
575
  }
576
576
  }
577
+ async function installOneByOne(spinner2, packageManager2, installCmd2, missing2, cwd2, execSync) {
578
+ spinner2.warn("Batch installation failed. Attempting to install dependencies one by one...");
579
+ let allSucceeded = true;
580
+ for (const dep of missing2) {
581
+ spinner2.text = `Installing ${dep} via ${packageManager2}...`;
582
+ try {
583
+ execSync(`${packageManager2} ${installCmd2} ${dep}`, {
584
+ stdio: "pipe",
585
+ cwd: cwd2
586
+ });
587
+ spinner2.succeed(`Installed ${dep}`);
588
+ } catch (depError) {
589
+ allSucceeded = false;
590
+ spinner2.fail(`Failed to install ${dep}`);
591
+ if (depError.stdout) {
592
+ console.log(chalk.dim(`
593
+ === stdout for ${dep} ===`));
594
+ console.log(chalk.dim(depError.stdout.toString()));
595
+ }
596
+ if (depError.stderr) {
597
+ console.log(chalk.red(`
598
+ === stderr for ${dep} ===`));
599
+ console.error(chalk.red(depError.stderr.toString()));
600
+ }
601
+ }
602
+ }
603
+ if (allSucceeded) {
604
+ spinner2.succeed("All dependencies installed one by one.");
605
+ } else {
606
+ spinner2.fail("Some dependencies failed to install.");
607
+ console.log(chalk.dim(`
608
+ Please manually run: ${packageManager2} ${installCmd2} ${missing2.join(" ")}
609
+ `));
610
+ }
611
+ }
577
612
  if (missing.length > 0) {
613
+ const { execSync } = await import("child_process");
578
614
  spinner.text = `Installing dependencies via ${packageManager}: ${missing.join(", ")}...`;
579
615
  try {
580
- const { execSync } = await import("child_process");
581
- execSync(`${packageManager} ${installCmd} ${missing.join(" ")}`, { stdio: "ignore", cwd });
616
+ execSync(`${packageManager} ${installCmd} ${missing.join(" ")}`, {
617
+ stdio: "pipe",
618
+ cwd
619
+ });
582
620
  spinner.succeed("Dependencies installed");
583
- } catch {
584
- spinner.fail("Failed to install dependencies automatically");
585
- console.log(chalk.dim(`
586
- Please manually run: ${packageManager} ${installCmd} ${missing.join(" ")}
587
- `));
621
+ } catch (error) {
622
+ const stderr = error.stderr?.toString() || "";
623
+ if (packageManager === "npm" && (stderr.includes("ERESOLVE") || stderr.includes("peer dependency") || stderr.includes("conflicting peer dependency") || stderr.includes("Cannot read properties of null"))) {
624
+ spinner.text = "Batch installation failed. Retrying with --legacy-peer-deps...";
625
+ try {
626
+ execSync(`npm install --legacy-peer-deps ${missing.join(" ")}`, {
627
+ stdio: "pipe",
628
+ cwd
629
+ });
630
+ spinner.succeed("Dependencies installed (used --legacy-peer-deps)");
631
+ } catch (retryError) {
632
+ await installOneByOne(spinner, packageManager, installCmd, missing, cwd, execSync);
633
+ }
634
+ } else {
635
+ await installOneByOne(spinner, packageManager, installCmd, missing, cwd, execSync);
636
+ }
588
637
  }
589
638
  } else {
590
639
  spinner.succeed("All dependencies already installed");
@@ -1035,7 +1084,7 @@ async function add(components, options) {
1035
1084
  spinner.info(`${chalk2.cyan(comp.file)} already exists, skipping (use --overwrite to replace)`);
1036
1085
  continue;
1037
1086
  }
1038
- const registryPath = path2.resolve(__dirname3, "..", "..", "..", "registry", comp.file);
1087
+ const registryPath = path2.resolve(__dirname3, "..", "registry", comp.file);
1039
1088
  if (!fs2.existsSync(registryPath)) {
1040
1089
  spinner.warn(`Registry file not found for ${name}: ${registryPath}`);
1041
1090
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srcroot/ui",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "A shadcn-style CLI UI library with polymorphic, accessible React components",
5
5
  "type": "module",
6
6
  "bin": {