@srcroot/ui 0.0.14 → 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 +50 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -574,26 +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
616
  execSync(`${packageManager} ${installCmd} ${missing.join(" ")}`, {
582
617
  stdio: "pipe",
583
618
  cwd
584
619
  });
585
620
  spinner.succeed("Dependencies installed");
586
621
  } catch (error) {
587
- spinner.fail("Failed to install dependencies automatically");
588
- if (error.stdout) {
589
- console.log(chalk.dim("\\n=== stdout ==="));
590
- console.log(chalk.dim(error.stdout.toString()));
591
- }
592
- if (error.stderr) {
593
- console.log(chalk.red("\\n=== stderr ==="));
594
- console.error(chalk.red(error.stderr.toString()));
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);
595
636
  }
596
- console.log(chalk.dim(`\\nPlease manually run: ${packageManager} ${installCmd} ${missing.join(" ")}\\n`));
597
637
  }
598
638
  } else {
599
639
  spinner.succeed("All dependencies already installed");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srcroot/ui",
3
- "version": "0.0.14",
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": {