@quarklab/rad-ui 0.3.8 → 0.3.10
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 +29 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -84,8 +84,19 @@ async function detectSrcDir(cwd) {
|
|
|
84
84
|
if (await fs.pathExists(configPath)) {
|
|
85
85
|
try {
|
|
86
86
|
const raw = await fs.readFile(configPath, "utf-8");
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
let config;
|
|
88
|
+
try {
|
|
89
|
+
config = JSON.parse(raw);
|
|
90
|
+
} catch {
|
|
91
|
+
const cleaned = raw.replace(
|
|
92
|
+
/("(?:[^"\\]|\\.)*")|\/\/.*$/gm,
|
|
93
|
+
(_, str) => str || ""
|
|
94
|
+
).replace(
|
|
95
|
+
/("(?:[^"\\]|\\.)*")|\/\*[\s\S]*?\*\//g,
|
|
96
|
+
(_, str) => str || ""
|
|
97
|
+
).replace(/,\s*([\]}])/g, "$1");
|
|
98
|
+
config = JSON.parse(cleaned);
|
|
99
|
+
}
|
|
89
100
|
const paths = config?.compilerOptions?.paths;
|
|
90
101
|
if (paths) {
|
|
91
102
|
const aliasKey = Object.keys(paths).find(
|
|
@@ -94,7 +105,7 @@ async function detectSrcDir(cwd) {
|
|
|
94
105
|
if (aliasKey) {
|
|
95
106
|
const aliasTargets = paths[aliasKey];
|
|
96
107
|
if (Array.isArray(aliasTargets) && aliasTargets.length > 0) {
|
|
97
|
-
const target = aliasTargets[0].replace(/^\.\//, "").replace(
|
|
108
|
+
const target = aliasTargets[0].replace(/^\.\//, "").replace(/\/?\*$/, "");
|
|
98
109
|
return target === "" ? "." : target;
|
|
99
110
|
}
|
|
100
111
|
}
|
|
@@ -111,7 +122,7 @@ function getDefaultCssPath(projectType, srcDir) {
|
|
|
111
122
|
const prefix = srcDir === "." ? "" : srcDir ? `${srcDir}/` : "src/";
|
|
112
123
|
switch (projectType) {
|
|
113
124
|
case "nextjs":
|
|
114
|
-
return `${prefix}/globals.css`;
|
|
125
|
+
return `${prefix}app/globals.css`;
|
|
115
126
|
case "vite":
|
|
116
127
|
return `${prefix}index.css`;
|
|
117
128
|
case "cra":
|
|
@@ -488,7 +499,12 @@ async function initCommand(opts) {
|
|
|
488
499
|
p.log.info(`Tailwind CSS: ${chalk2.cyan(tailwindVersion)}`);
|
|
489
500
|
const srcDirDisplay = detectedSrcDir === "." ? "project root" : detectedSrcDir + "/";
|
|
490
501
|
p.log.info(`Source directory: ${chalk2.cyan(srcDirDisplay)}`);
|
|
491
|
-
const
|
|
502
|
+
const isRootNextJs = projectType === "nextjs" && detectedSrcDir === ".";
|
|
503
|
+
const aliasBase = isRootNextJs ? "@/app" : "@";
|
|
504
|
+
const defaultComponents = `${aliasBase}/components/ui`;
|
|
505
|
+
const defaultUtils = `${aliasBase}/lib/utils`;
|
|
506
|
+
const defaultHooks = `${aliasBase}/hooks`;
|
|
507
|
+
const examplePrefix = isRootNextJs ? "app/" : detectedSrcDir === "." ? "" : detectedSrcDir + "/";
|
|
492
508
|
const responses = await p.group(
|
|
493
509
|
{
|
|
494
510
|
theme: () => p.select({
|
|
@@ -506,18 +522,18 @@ async function initCommand(opts) {
|
|
|
506
522
|
}),
|
|
507
523
|
componentsPath: () => p.text({
|
|
508
524
|
message: `Where to add UI components (e.g. ${examplePrefix}components/ui):`,
|
|
509
|
-
placeholder:
|
|
510
|
-
defaultValue:
|
|
525
|
+
placeholder: defaultComponents,
|
|
526
|
+
defaultValue: defaultComponents
|
|
511
527
|
}),
|
|
512
528
|
utilsPath: () => p.text({
|
|
513
529
|
message: `Where to create the cn() helper (e.g. ${examplePrefix}lib/utils.ts):`,
|
|
514
|
-
placeholder:
|
|
515
|
-
defaultValue:
|
|
530
|
+
placeholder: defaultUtils,
|
|
531
|
+
defaultValue: defaultUtils
|
|
516
532
|
}),
|
|
517
533
|
hooksPath: () => p.text({
|
|
518
534
|
message: `Where to add hooks (e.g. ${examplePrefix}hooks):`,
|
|
519
|
-
placeholder:
|
|
520
|
-
defaultValue:
|
|
535
|
+
placeholder: defaultHooks,
|
|
536
|
+
defaultValue: defaultHooks
|
|
521
537
|
}),
|
|
522
538
|
cssPath: () => p.text({
|
|
523
539
|
message: `Path to your global CSS file:`,
|
|
@@ -1045,7 +1061,7 @@ function transformImports(source, config) {
|
|
|
1045
1061
|
);
|
|
1046
1062
|
result = result.replace(
|
|
1047
1063
|
/from\s+["']\.\/lib\/utils["']/g,
|
|
1048
|
-
`from "
|
|
1064
|
+
`from "${utilsAlias}"`
|
|
1049
1065
|
);
|
|
1050
1066
|
return result;
|
|
1051
1067
|
}
|
|
@@ -1247,7 +1263,7 @@ async function addCommand(componentNames, opts) {
|
|
|
1247
1263
|
const fileType = classifyFile(relPath);
|
|
1248
1264
|
let destPath;
|
|
1249
1265
|
if (fileType === "component") {
|
|
1250
|
-
destPath = path4.resolve(componentsDir,
|
|
1266
|
+
destPath = path4.resolve(componentsDir, fileName);
|
|
1251
1267
|
} else if (fileType === "hook") {
|
|
1252
1268
|
destPath = path4.resolve(hooksDir, fileName);
|
|
1253
1269
|
hooksCount++;
|
package/package.json
CHANGED