@dinachi/cli 0.2.0 → 0.2.1
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 +84 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -556,18 +556,21 @@ var initCommand = new Command2("init").description("Initialize Dinachi UI in you
|
|
|
556
556
|
console.log(chalk2.red("\u274C No package.json found. Please run this command in a valid project."));
|
|
557
557
|
process.exit(1);
|
|
558
558
|
}
|
|
559
|
+
const projectConfig = detectProjectType();
|
|
560
|
+
console.log(chalk2.gray(`Detected ${projectConfig.framework} project`));
|
|
561
|
+
console.log();
|
|
559
562
|
const response = await prompts([
|
|
560
563
|
{
|
|
561
564
|
type: "text",
|
|
562
565
|
name: "componentsPath",
|
|
563
566
|
message: "Where would you like to install components?",
|
|
564
|
-
initial:
|
|
567
|
+
initial: projectConfig.componentsPath
|
|
565
568
|
},
|
|
566
569
|
{
|
|
567
570
|
type: "text",
|
|
568
571
|
name: "utilsPath",
|
|
569
572
|
message: "Where would you like to install utilities?",
|
|
570
|
-
initial:
|
|
573
|
+
initial: projectConfig.utilsPath
|
|
571
574
|
},
|
|
572
575
|
{
|
|
573
576
|
type: "confirm",
|
|
@@ -603,13 +606,14 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
603
606
|
const installCmd = `${packageManager} ${packageManager === "npm" ? "install" : "add"} ${deps.join(" ")}`;
|
|
604
607
|
execSync2(installCmd, { stdio: "inherit" });
|
|
605
608
|
}
|
|
609
|
+
const rscEnabled = projectConfig.framework === "next.js";
|
|
606
610
|
const configContent = `{
|
|
607
611
|
"style": "default",
|
|
608
|
-
"rsc":
|
|
612
|
+
"rsc": ${rscEnabled},
|
|
609
613
|
"tsx": true,
|
|
610
614
|
"tailwind": {
|
|
611
|
-
"config": "
|
|
612
|
-
"css": "
|
|
615
|
+
"config": "${projectConfig.tailwindConfig}",
|
|
616
|
+
"css": "${projectConfig.cssPath}",
|
|
613
617
|
"baseColor": "slate",
|
|
614
618
|
"cssVariables": true
|
|
615
619
|
},
|
|
@@ -629,6 +633,18 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
629
633
|
console.log(` 1. Add a component: ${chalk2.cyan("npx @dinachi/cli add button")}`);
|
|
630
634
|
console.log(` 2. Components will be installed to: ${chalk2.cyan("@/components/ui")}`);
|
|
631
635
|
console.log(` 3. Utils available at: ${chalk2.cyan("@/lib/utils")}`);
|
|
636
|
+
if (projectConfig.framework === "next.js") {
|
|
637
|
+
console.log();
|
|
638
|
+
console.log(chalk2.blue("\u{1F4DD} Next.js specific notes:"));
|
|
639
|
+
console.log(` - RSC (React Server Components) enabled in config`);
|
|
640
|
+
console.log(` - Make sure to add "use client" directive if needed`);
|
|
641
|
+
console.log(` - Tailwind config set to: ${chalk2.cyan(projectConfig.tailwindConfig)}`);
|
|
642
|
+
} else if (projectConfig.framework === "remix") {
|
|
643
|
+
console.log();
|
|
644
|
+
console.log(chalk2.blue("\u{1F4DD} Remix specific notes:"));
|
|
645
|
+
console.log(` - Components will be installed to: ${chalk2.cyan(projectConfig.componentsPath)}`);
|
|
646
|
+
console.log(` - Utils will be installed to: ${chalk2.cyan(projectConfig.utilsPath)}`);
|
|
647
|
+
}
|
|
632
648
|
console.log();
|
|
633
649
|
console.log("\u{1F4A1} Tip: Install globally for shorter commands:");
|
|
634
650
|
console.log(` ${chalk2.cyan("npm install -g @dinachi/cli")}`);
|
|
@@ -643,6 +659,69 @@ function getPackageManager2() {
|
|
|
643
659
|
if (fs3.existsSync("yarn.lock")) return "yarn";
|
|
644
660
|
return "npm";
|
|
645
661
|
}
|
|
662
|
+
function detectProjectType() {
|
|
663
|
+
const packageJsonPath = path3.join(process.cwd(), "package.json");
|
|
664
|
+
if (!fs3.existsSync(packageJsonPath)) {
|
|
665
|
+
return {
|
|
666
|
+
framework: "react",
|
|
667
|
+
componentsPath: "./src/components/ui",
|
|
668
|
+
utilsPath: "./src/lib",
|
|
669
|
+
tailwindConfig: "tailwind.config.js",
|
|
670
|
+
cssPath: "src/index.css",
|
|
671
|
+
srcDir: "src"
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
|
|
675
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
676
|
+
if (deps.next) {
|
|
677
|
+
return {
|
|
678
|
+
framework: "next.js",
|
|
679
|
+
componentsPath: "./src/components/ui",
|
|
680
|
+
utilsPath: "./src/lib",
|
|
681
|
+
tailwindConfig: "tailwind.config.ts",
|
|
682
|
+
cssPath: "src/app/globals.css",
|
|
683
|
+
srcDir: "src"
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
if (deps.vite || deps["@vitejs/plugin-react"]) {
|
|
687
|
+
return {
|
|
688
|
+
framework: "vite",
|
|
689
|
+
componentsPath: "./src/components/ui",
|
|
690
|
+
utilsPath: "./src/lib",
|
|
691
|
+
tailwindConfig: "tailwind.config.js",
|
|
692
|
+
cssPath: "src/index.css",
|
|
693
|
+
srcDir: "src"
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
if (deps["react-scripts"]) {
|
|
697
|
+
return {
|
|
698
|
+
framework: "create-react-app",
|
|
699
|
+
componentsPath: "./src/components/ui",
|
|
700
|
+
utilsPath: "./src/lib",
|
|
701
|
+
tailwindConfig: "tailwind.config.js",
|
|
702
|
+
cssPath: "src/index.css",
|
|
703
|
+
srcDir: "src"
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
if (deps["@remix-run/react"]) {
|
|
707
|
+
return {
|
|
708
|
+
framework: "remix",
|
|
709
|
+
componentsPath: "./app/components/ui",
|
|
710
|
+
utilsPath: "./app/lib",
|
|
711
|
+
tailwindConfig: "tailwind.config.ts",
|
|
712
|
+
cssPath: "app/tailwind.css",
|
|
713
|
+
srcDir: "app"
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
return {
|
|
717
|
+
framework: "react",
|
|
718
|
+
componentsPath: "./src/components/ui",
|
|
719
|
+
utilsPath: "./src/lib",
|
|
720
|
+
tailwindConfig: "tailwind.config.js",
|
|
721
|
+
cssPath: "src/index.css",
|
|
722
|
+
srcDir: "src"
|
|
723
|
+
};
|
|
724
|
+
}
|
|
646
725
|
|
|
647
726
|
// src/index.ts
|
|
648
727
|
var program = new Command3();
|