@srcroot/ui 0.0.14 → 0.0.16

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 +55 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -574,29 +574,72 @@ async function init(options) {
574
574
  missing.push(installCmd2);
575
575
  }
576
576
  }
577
+ if (missing.length === 0) {
578
+ spinner.succeed(chalk.green("All dependencies already installed"));
579
+ } else {
580
+ spinner.info(`Found ${chalk.cyan(missing.length)} missing ${missing.length === 1 ? "dependency" : "dependencies"}: ${chalk.dim(missing.map((d) => d.split("@")[0]).join(", "))}`);
581
+ }
582
+ async function installOneByOne(spinner2, packageManager2, installCmd2, missing2, cwd2, execSync) {
583
+ spinner2.warn("Batch installation failed. Attempting to install dependencies one by one...");
584
+ let allSucceeded = true;
585
+ for (const dep of missing2) {
586
+ spinner2.start(`Installing ${chalk.cyan(dep)} via ${packageManager2}...`);
587
+ try {
588
+ execSync(`${packageManager2} ${installCmd2} ${dep}`, {
589
+ stdio: "pipe",
590
+ cwd: cwd2
591
+ });
592
+ spinner2.succeed(`Installed ${chalk.green(dep)}`);
593
+ } catch (depError) {
594
+ allSucceeded = false;
595
+ spinner2.fail(`Failed to install ${chalk.red(dep)}`);
596
+ if (depError.stdout) {
597
+ console.log(chalk.dim(`
598
+ === stdout for ${dep} ===`));
599
+ console.log(chalk.dim(depError.stdout.toString()));
600
+ }
601
+ if (depError.stderr) {
602
+ console.log(chalk.red(`
603
+ === stderr for ${dep} ===`));
604
+ console.error(chalk.red(depError.stderr.toString()));
605
+ }
606
+ }
607
+ }
608
+ if (allSucceeded) {
609
+ console.log(chalk.green("\n\u2705 All dependencies installed successfully!\n"));
610
+ } else {
611
+ console.log(chalk.yellow("\n\u26A0 Some dependencies failed to install."));
612
+ console.log(chalk.dim(`
613
+ Please manually run: ${packageManager2} ${installCmd2} ${missing2.join(" ")}
614
+ `));
615
+ }
616
+ }
577
617
  if (missing.length > 0) {
618
+ const { execSync } = await import("child_process");
578
619
  spinner.text = `Installing dependencies via ${packageManager}: ${missing.join(", ")}...`;
579
620
  try {
580
- const { execSync } = await import("child_process");
581
621
  execSync(`${packageManager} ${installCmd} ${missing.join(" ")}`, {
582
622
  stdio: "pipe",
583
623
  cwd
584
624
  });
585
625
  spinner.succeed("Dependencies installed");
586
626
  } 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()));
627
+ const stderr = error.stderr?.toString() || "";
628
+ if (packageManager === "npm" && (stderr.includes("ERESOLVE") || stderr.includes("peer dependency") || stderr.includes("conflicting peer dependency") || stderr.includes("Cannot read properties of null"))) {
629
+ spinner.text = "Batch installation failed. Retrying with --legacy-peer-deps...";
630
+ try {
631
+ execSync(`npm install --legacy-peer-deps ${missing.join(" ")}`, {
632
+ stdio: "pipe",
633
+ cwd
634
+ });
635
+ spinner.succeed("Dependencies installed (used --legacy-peer-deps)");
636
+ } catch (retryError) {
637
+ await installOneByOne(spinner, packageManager, installCmd, missing, cwd, execSync);
638
+ }
639
+ } else {
640
+ await installOneByOne(spinner, packageManager, installCmd, missing, cwd, execSync);
591
641
  }
592
- if (error.stderr) {
593
- console.log(chalk.red("\\n=== stderr ==="));
594
- console.error(chalk.red(error.stderr.toString()));
595
- }
596
- console.log(chalk.dim(`\\nPlease manually run: ${packageManager} ${installCmd} ${missing.join(" ")}\\n`));
597
642
  }
598
- } else {
599
- spinner.succeed("All dependencies already installed");
600
643
  }
601
644
  console.log(chalk.green("\n\u2705 Project initialized successfully!\n"));
602
645
  console.log(`Theme: ${chalk.cyan(THEMES[selectedTheme].name)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srcroot/ui",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "A shadcn-style CLI UI library with polymorphic, accessible React components",
5
5
  "type": "module",
6
6
  "bin": {