@srcroot/ui 0.0.20 → 0.0.22
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 +50 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -511,12 +511,35 @@ async function init(options) {
|
|
|
511
511
|
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
512
512
|
const tailwindVersion = allDeps["tailwindcss"] || "";
|
|
513
513
|
const isTailwind4 = tailwindVersion.includes("^4") || tailwindVersion.startsWith("4") || allDeps["@tailwindcss/postcss"];
|
|
514
|
-
const
|
|
515
|
-
const
|
|
516
|
-
const
|
|
517
|
-
const
|
|
518
|
-
const
|
|
519
|
-
const
|
|
514
|
+
const hasSrc = fs.existsSync(path.join(cwd, "src"));
|
|
515
|
+
const srcPath = hasSrc ? path.join(cwd, "src") : cwd;
|
|
516
|
+
const appPath = path.join(srcPath, "app");
|
|
517
|
+
const pagesPath = path.join(srcPath, "pages");
|
|
518
|
+
const hasAppDir = fs.existsSync(appPath);
|
|
519
|
+
const hasPagesDir = fs.existsSync(pagesPath);
|
|
520
|
+
const libDir = path.join(srcPath, "lib");
|
|
521
|
+
const componentsDir = path.join(srcPath, "components", "ui");
|
|
522
|
+
let globalsPath = "";
|
|
523
|
+
if (hasAppDir) {
|
|
524
|
+
if (fs.existsSync(path.join(appPath, "globals.css"))) {
|
|
525
|
+
globalsPath = path.join(appPath, "globals.css");
|
|
526
|
+
} else if (fs.existsSync(path.join(appPath, "global.css"))) {
|
|
527
|
+
globalsPath = path.join(appPath, "global.css");
|
|
528
|
+
} else {
|
|
529
|
+
globalsPath = path.join(appPath, "globals.css");
|
|
530
|
+
}
|
|
531
|
+
} else if (hasPagesDir) {
|
|
532
|
+
const stylesPath = path.join(srcPath, "styles");
|
|
533
|
+
if (fs.existsSync(path.join(stylesPath, "globals.css"))) {
|
|
534
|
+
globalsPath = path.join(stylesPath, "globals.css");
|
|
535
|
+
} else if (fs.existsSync(path.join(stylesPath, "global.css"))) {
|
|
536
|
+
globalsPath = path.join(stylesPath, "global.css");
|
|
537
|
+
} else {
|
|
538
|
+
globalsPath = path.join(stylesPath, "globals.css");
|
|
539
|
+
}
|
|
540
|
+
} else {
|
|
541
|
+
globalsPath = path.join(srcPath, "globals.css");
|
|
542
|
+
}
|
|
520
543
|
let selectedTheme = options.theme || "slate";
|
|
521
544
|
if (!options.yes && !options.theme) {
|
|
522
545
|
const themeChoices = Object.entries(THEMES).map(([key, theme]) => ({
|
|
@@ -986,10 +1009,16 @@ async function add(components, options) {
|
|
|
986
1009
|
resolveDeps(comp);
|
|
987
1010
|
}
|
|
988
1011
|
const componentsToAdd = Array.from(toInstall);
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
1012
|
+
if (componentsToAdd.length > 10) {
|
|
1013
|
+
console.log(chalk2.cyan(`
|
|
1014
|
+
\u{1F4E6} Adding ${componentsToAdd.length} components...
|
|
1015
|
+
`));
|
|
1016
|
+
} else {
|
|
1017
|
+
console.log(chalk2.cyan("\n\u{1F4E6} Adding components:\n"));
|
|
1018
|
+
componentsToAdd.forEach((name) => {
|
|
1019
|
+
console.log(chalk2.dim(` - ${name}`));
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
993
1022
|
console.log();
|
|
994
1023
|
if (!options.yes) {
|
|
995
1024
|
const response = await prompts2({
|
|
@@ -1004,14 +1033,18 @@ async function add(components, options) {
|
|
|
1004
1033
|
}
|
|
1005
1034
|
}
|
|
1006
1035
|
const spinner = ora2("Adding components...").start();
|
|
1007
|
-
const
|
|
1036
|
+
const hasSrc = fs2.existsSync(path2.join(cwd, "src"));
|
|
1037
|
+
const srcPath = hasSrc ? path2.join(cwd, "src") : cwd;
|
|
1038
|
+
const componentsDir = path2.join(srcPath, "components", "ui");
|
|
1008
1039
|
try {
|
|
1009
1040
|
await fs2.ensureDir(componentsDir);
|
|
1010
1041
|
for (const name of componentsToAdd) {
|
|
1011
1042
|
const comp = REGISTRY[name];
|
|
1012
1043
|
const targetPath = path2.join(componentsDir, comp.file);
|
|
1013
1044
|
if (fs2.existsSync(targetPath) && !options.overwrite) {
|
|
1014
|
-
|
|
1045
|
+
if (componentsToAdd.length <= 10) {
|
|
1046
|
+
spinner.info(`${chalk2.cyan(comp.file)} already exists, skipping`);
|
|
1047
|
+
}
|
|
1015
1048
|
continue;
|
|
1016
1049
|
}
|
|
1017
1050
|
const registryPath = path2.resolve(__dirname3, "..", "registry", comp.file);
|
|
@@ -1021,7 +1054,11 @@ async function add(components, options) {
|
|
|
1021
1054
|
}
|
|
1022
1055
|
const content = await fs2.readFile(registryPath, "utf-8");
|
|
1023
1056
|
await fs2.writeFile(targetPath, content);
|
|
1024
|
-
|
|
1057
|
+
if (componentsToAdd.length > 10) {
|
|
1058
|
+
spinner.text = `Added ${chalk2.cyan(comp.file)}`;
|
|
1059
|
+
} else {
|
|
1060
|
+
spinner.succeed(`Added ${chalk2.cyan(comp.file)}`);
|
|
1061
|
+
}
|
|
1025
1062
|
}
|
|
1026
1063
|
console.log(chalk2.green("\n\u2705 Components added successfully!\n"));
|
|
1027
1064
|
} catch (error) {
|