@dinachi/cli 0.1.1 → 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 +97 -14
- package/package.json +1 -1
- package/templates/select/select.tsx +2 -1
package/dist/index.js
CHANGED
|
@@ -431,7 +431,7 @@ var addCommand = new Command("add").description("Add a component to your project
|
|
|
431
431
|
}
|
|
432
432
|
const componentsToInstall = [componentName, ...getComponentDependencies(componentName)];
|
|
433
433
|
spinner.text = `Installing ${componentsToInstall.join(", ")}...`;
|
|
434
|
-
const componentDir = path2.join(process.cwd(), config.aliases.
|
|
434
|
+
const componentDir = path2.join(process.cwd(), config.aliases.ui.replace("@/", "src/"));
|
|
435
435
|
await fs2.ensureDir(componentDir);
|
|
436
436
|
let allFilesAdded = [];
|
|
437
437
|
let allDepsInstalled = [];
|
|
@@ -445,7 +445,7 @@ var addCommand = new Command("add").description("Add a component to your project
|
|
|
445
445
|
}
|
|
446
446
|
const utilityRegistry = getUtilityRegistry();
|
|
447
447
|
const uniqueUtilityDeps = [...new Set(allUtilityDeps)];
|
|
448
|
-
const utilsDir = path2.join(process.cwd(), config.aliases.
|
|
448
|
+
const utilsDir = path2.join(process.cwd(), config.aliases.lib.replace("@/", "src/"));
|
|
449
449
|
if (uniqueUtilityDeps.length > 0) {
|
|
450
450
|
await fs2.ensureDir(utilsDir);
|
|
451
451
|
for (const utilityName of uniqueUtilityDeps) {
|
|
@@ -460,7 +460,7 @@ var addCommand = new Command("add").description("Add a component to your project
|
|
|
460
460
|
await fs2.writeFile(targetPath, content);
|
|
461
461
|
allFilesAdded.push({
|
|
462
462
|
name: utilityFilename,
|
|
463
|
-
path: path2.join(config.aliases.
|
|
463
|
+
path: path2.join(config.aliases.lib, utilityFilename)
|
|
464
464
|
});
|
|
465
465
|
if (utility.dependencies?.length) {
|
|
466
466
|
allDepsInstalled.push(...utility.dependencies);
|
|
@@ -481,7 +481,7 @@ var addCommand = new Command("add").description("Add a component to your project
|
|
|
481
481
|
let content = await fs2.readFile(sourcePath, "utf-8");
|
|
482
482
|
content = content.replace(/^\/\/ @ts-nocheck\s*\n/m, "");
|
|
483
483
|
await fs2.writeFile(targetPath, content);
|
|
484
|
-
allFilesAdded.push({ name: file.name, path: path2.join(config.aliases.
|
|
484
|
+
allFilesAdded.push({ name: file.name, path: path2.join(config.aliases.ui, file.name) });
|
|
485
485
|
}
|
|
486
486
|
if (comp.dependencies?.length) {
|
|
487
487
|
allDepsInstalled.push(...comp.dependencies);
|
|
@@ -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,28 +606,45 @@ 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
|
},
|
|
616
620
|
"aliases": {
|
|
617
|
-
"components": "
|
|
618
|
-
"utils": "
|
|
619
|
-
|
|
621
|
+
"components": "@/components",
|
|
622
|
+
"utils": "@/lib/utils",
|
|
623
|
+
"ui": "@/components/ui",
|
|
624
|
+
"lib": "@/lib",
|
|
625
|
+
"hooks": "@/hooks"
|
|
626
|
+
},
|
|
627
|
+
"iconLibrary": "lucide"
|
|
620
628
|
}`;
|
|
621
629
|
await fs3.writeFile("components.json", configContent);
|
|
622
630
|
spinner.succeed("\u2705 Dinachi UI setup complete!");
|
|
623
631
|
console.log();
|
|
624
632
|
console.log("Next steps:");
|
|
625
633
|
console.log(` 1. Add a component: ${chalk2.cyan("npx @dinachi/cli add button")}`);
|
|
626
|
-
console.log(` 2. Components will be installed to: ${chalk2.cyan(
|
|
627
|
-
console.log(` 3. Utils available at: ${chalk2.cyan(
|
|
634
|
+
console.log(` 2. Components will be installed to: ${chalk2.cyan("@/components/ui")}`);
|
|
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
|
+
}
|
|
628
648
|
console.log();
|
|
629
649
|
console.log("\u{1F4A1} Tip: Install globally for shorter commands:");
|
|
630
650
|
console.log(` ${chalk2.cyan("npm install -g @dinachi/cli")}`);
|
|
@@ -639,6 +659,69 @@ function getPackageManager2() {
|
|
|
639
659
|
if (fs3.existsSync("yarn.lock")) return "yarn";
|
|
640
660
|
return "npm";
|
|
641
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
|
+
}
|
|
642
725
|
|
|
643
726
|
// src/index.ts
|
|
644
727
|
var program = new Command3();
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
"use client"
|
|
2
3
|
|
|
3
4
|
import * as React from "react"
|
|
4
5
|
import { Select as SelectPrimitive } from "@base-ui-components/react/select"
|
|
5
|
-
import { cn } from "
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
6
7
|
import { Check, ChevronDown } from "lucide-react"
|
|
7
8
|
|
|
8
9
|
|