@srcroot/ui 0.0.19 → 0.0.20
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.
- package/dist/index.js +15 -87
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -556,96 +556,24 @@ async function init(options) {
|
|
|
556
556
|
} else {
|
|
557
557
|
spinner.info(`Tailwind 4 detected - skipping ${chalk.cyan("tailwind.config.ts")}`);
|
|
558
558
|
}
|
|
559
|
-
spinner.start("Checking dependencies...");
|
|
560
|
-
const currentPkg = await fs.readJson(packageJsonPath);
|
|
561
|
-
const currentDeps = { ...currentPkg.dependencies, ...currentPkg.devDependencies };
|
|
562
|
-
const missing = [];
|
|
563
|
-
const requiredDeps = {
|
|
564
|
-
"clsx": "clsx",
|
|
565
|
-
"tailwind-merge": "tailwind-merge",
|
|
566
|
-
"class-variance-authority": "class-variance-authority",
|
|
567
|
-
"lucide-react": "lucide-react"
|
|
568
|
-
};
|
|
569
|
-
if (!isTailwind4) {
|
|
570
|
-
requiredDeps["tailwindcss-animate"] = "tailwindcss-animate";
|
|
571
|
-
}
|
|
572
|
-
for (const [depName, installCmd2] of Object.entries(requiredDeps)) {
|
|
573
|
-
if (!currentDeps[depName]) {
|
|
574
|
-
missing.push(installCmd2);
|
|
575
|
-
}
|
|
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 runCommand(command, cwd2) {
|
|
583
|
-
const { exec } = await import("child_process");
|
|
584
|
-
const { promisify } = await import("util");
|
|
585
|
-
const execAsync = promisify(exec);
|
|
586
|
-
return await execAsync(command, { cwd: cwd2 });
|
|
587
|
-
}
|
|
588
|
-
async function installOneByOne(spinner2, packageManager2, installCmd2, missing2, cwd2) {
|
|
589
|
-
spinner2.warn("Batch installation failed. Attempting to install dependencies one by one...");
|
|
590
|
-
let allSucceeded = true;
|
|
591
|
-
const installFlags = packageManager2 === "npm" ? "--legacy-peer-deps" : "";
|
|
592
|
-
for (const dep of missing2) {
|
|
593
|
-
spinner2.start(`Installing ${chalk.cyan(dep)} via ${packageManager2}${installFlags ? " (with --legacy-peer-deps)" : ""}...`);
|
|
594
|
-
try {
|
|
595
|
-
const command = installFlags ? `${packageManager2} ${installCmd2} ${installFlags} ${dep}` : `${packageManager2} ${installCmd2} ${dep}`;
|
|
596
|
-
await runCommand(command, cwd2);
|
|
597
|
-
spinner2.succeed(`Installed ${chalk.green(dep)}`);
|
|
598
|
-
} catch (depError) {
|
|
599
|
-
allSucceeded = false;
|
|
600
|
-
spinner2.fail(`Failed to install ${chalk.red(dep)}`);
|
|
601
|
-
if (depError.stdout) {
|
|
602
|
-
console.log(chalk.dim(`
|
|
603
|
-
=== stdout for ${dep} ===`));
|
|
604
|
-
console.log(chalk.dim(depError.stdout.toString()));
|
|
605
|
-
}
|
|
606
|
-
if (depError.stderr) {
|
|
607
|
-
console.log(chalk.red(`
|
|
608
|
-
=== stderr for ${dep} ===`));
|
|
609
|
-
console.error(chalk.red(depError.stderr.toString()));
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
if (allSucceeded) {
|
|
614
|
-
console.log(chalk.green("\n\u2705 All dependencies installed successfully!\n"));
|
|
615
|
-
} else {
|
|
616
|
-
console.log(chalk.yellow("\n\u26A0 Some dependencies failed to install."));
|
|
617
|
-
const manualCmd = installFlags ? `${packageManager2} ${installCmd2} ${installFlags} ${missing2.join(" ")}` : `${packageManager2} ${installCmd2} ${missing2.join(" ")}`;
|
|
618
|
-
console.log(chalk.dim(`
|
|
619
|
-
Please manually run: ${manualCmd}
|
|
620
|
-
`));
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
if (missing.length > 0) {
|
|
624
|
-
spinner.start(`Installing dependencies via ${packageManager}: ${missing.join(", ")}...`);
|
|
625
|
-
try {
|
|
626
|
-
await runCommand(`${packageManager} ${installCmd} ${missing.join(" ")}`, cwd);
|
|
627
|
-
spinner.succeed("Dependencies installed");
|
|
628
|
-
} catch (error) {
|
|
629
|
-
const stderr = error.stderr?.toString() || "";
|
|
630
|
-
if (packageManager === "npm" && (stderr.includes("ERESOLVE") || stderr.includes("peer dependency") || stderr.includes("conflicting peer dependency") || stderr.includes("Cannot read properties of null"))) {
|
|
631
|
-
spinner.start("Batch installation failed. Retrying with --legacy-peer-deps...");
|
|
632
|
-
try {
|
|
633
|
-
await runCommand(`npm install --legacy-peer-deps ${missing.join(" ")}`, cwd);
|
|
634
|
-
spinner.succeed("Dependencies installed (used --legacy-peer-deps)");
|
|
635
|
-
} catch (retryError) {
|
|
636
|
-
await installOneByOne(spinner, packageManager, installCmd, missing, cwd);
|
|
637
|
-
}
|
|
638
|
-
} else {
|
|
639
|
-
await installOneByOne(spinner, packageManager, installCmd, missing, cwd);
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
559
|
console.log(chalk.green("\n\u2705 Project initialized successfully!\n"));
|
|
644
560
|
console.log(`Theme: ${chalk.cyan(THEMES[selectedTheme].name)}`);
|
|
645
561
|
console.log(`Tailwind: ${chalk.cyan(isTailwind4 ? "v4" : "v3")}`);
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
562
|
+
const requiredDeps = [
|
|
563
|
+
"clsx",
|
|
564
|
+
"tailwind-merge",
|
|
565
|
+
"class-variance-authority",
|
|
566
|
+
"lucide-react"
|
|
567
|
+
];
|
|
568
|
+
if (!isTailwind4) {
|
|
569
|
+
requiredDeps.push("tailwindcss-animate");
|
|
570
|
+
}
|
|
571
|
+
console.log(chalk.cyan("\n\u{1F4E6} Required dependencies:"));
|
|
572
|
+
console.log(chalk.dim(` ${packageManager} ${installCmd} ${requiredDeps.join(" ")}`));
|
|
573
|
+
console.log("\n\u2728 Next steps:");
|
|
574
|
+
console.log(chalk.dim(" 1. Install dependencies (command above)"));
|
|
575
|
+
console.log(chalk.dim(" 2. npx @srcroot/ui add button"));
|
|
576
|
+
console.log(chalk.dim(" 3. npx @srcroot/ui add --all"));
|
|
649
577
|
console.log();
|
|
650
578
|
} catch (error) {
|
|
651
579
|
spinner.fail("Failed to initialize project");
|