@quarklab/rad-ui 0.2.0 → 0.3.0
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 +218 -93
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { Command } from "commander";
|
|
|
7
7
|
import path3 from "path";
|
|
8
8
|
import fs3 from "fs-extra";
|
|
9
9
|
import * as p from "@clack/prompts";
|
|
10
|
-
import
|
|
10
|
+
import chalk2 from "chalk";
|
|
11
11
|
|
|
12
12
|
// src/utils/detect-project.ts
|
|
13
13
|
import path from "path";
|
|
@@ -34,6 +34,76 @@ async function detectPackageManager(cwd) {
|
|
|
34
34
|
if (await fs.pathExists(path.resolve(cwd, "yarn.lock"))) return "yarn";
|
|
35
35
|
return "npm";
|
|
36
36
|
}
|
|
37
|
+
async function detectTailwindVersion(cwd, cssPath) {
|
|
38
|
+
const pkgPath = path.resolve(cwd, "package.json");
|
|
39
|
+
if (await fs.pathExists(pkgPath)) {
|
|
40
|
+
try {
|
|
41
|
+
const pkg = await fs.readJson(pkgPath);
|
|
42
|
+
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
43
|
+
const twVersion = allDeps["tailwindcss"];
|
|
44
|
+
if (twVersion) {
|
|
45
|
+
const cleanVersion = twVersion.replace(/^[\^~>=<]+/, "");
|
|
46
|
+
if (cleanVersion.startsWith("4")) return "v4";
|
|
47
|
+
if (cleanVersion.startsWith("3")) return "v3";
|
|
48
|
+
}
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (cssPath) {
|
|
53
|
+
const fullCssPath = path.resolve(cwd, cssPath);
|
|
54
|
+
if (await fs.pathExists(fullCssPath)) {
|
|
55
|
+
try {
|
|
56
|
+
const cssContent = await fs.readFile(fullCssPath, "utf-8");
|
|
57
|
+
if (cssContent.includes('@import "tailwindcss"') || cssContent.includes("@import 'tailwindcss'")) {
|
|
58
|
+
return "v4";
|
|
59
|
+
}
|
|
60
|
+
if (cssContent.includes("@tailwind base")) {
|
|
61
|
+
return "v3";
|
|
62
|
+
}
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const configFiles = [
|
|
68
|
+
"tailwind.config.ts",
|
|
69
|
+
"tailwind.config.js",
|
|
70
|
+
"tailwind.config.cjs",
|
|
71
|
+
"tailwind.config.mjs"
|
|
72
|
+
];
|
|
73
|
+
for (const file of configFiles) {
|
|
74
|
+
if (await fs.pathExists(path.resolve(cwd, file))) {
|
|
75
|
+
return "v3";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return "v4";
|
|
79
|
+
}
|
|
80
|
+
async function detectSrcDir(cwd) {
|
|
81
|
+
const tsconfigPath = path.resolve(cwd, "tsconfig.json");
|
|
82
|
+
if (await fs.pathExists(tsconfigPath)) {
|
|
83
|
+
try {
|
|
84
|
+
const raw = await fs.readFile(tsconfigPath, "utf-8");
|
|
85
|
+
const cleaned = raw.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
86
|
+
const tsconfig = JSON.parse(cleaned);
|
|
87
|
+
const paths = tsconfig?.compilerOptions?.paths;
|
|
88
|
+
if (paths) {
|
|
89
|
+
const aliasKey = Object.keys(paths).find(
|
|
90
|
+
(k) => k === "@/*" || k === "~/*"
|
|
91
|
+
);
|
|
92
|
+
if (aliasKey) {
|
|
93
|
+
const aliasTargets = paths[aliasKey];
|
|
94
|
+
if (Array.isArray(aliasTargets) && aliasTargets.length > 0) {
|
|
95
|
+
const target = aliasTargets[0].replace(/^\.\//, "").replace(/\/\*$/, "");
|
|
96
|
+
if (target) return target;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (await fs.pathExists(path.resolve(cwd, "src"))) return "src";
|
|
104
|
+
if (await fs.pathExists(path.resolve(cwd, "app"))) return "app";
|
|
105
|
+
return "src";
|
|
106
|
+
}
|
|
37
107
|
function getDefaultCssPath(projectType) {
|
|
38
108
|
switch (projectType) {
|
|
39
109
|
case "nextjs":
|
|
@@ -72,7 +142,7 @@ async function readConfig(cwd) {
|
|
|
72
142
|
const exists = await fs2.pathExists(configPath);
|
|
73
143
|
if (!exists) {
|
|
74
144
|
throw new Error(
|
|
75
|
-
`Configuration file not found. Run
|
|
145
|
+
`Configuration file not found. Run \`rad-ui init\` first.`
|
|
76
146
|
);
|
|
77
147
|
}
|
|
78
148
|
return fs2.readJson(configPath);
|
|
@@ -81,19 +151,19 @@ async function writeConfig(cwd, config) {
|
|
|
81
151
|
const configPath = getConfigPath(cwd);
|
|
82
152
|
await fs2.writeJson(configPath, config, { spaces: 2 });
|
|
83
153
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
154
|
+
function resolveAlias(alias, srcDir) {
|
|
155
|
+
return alias.replace(/^@\//, srcDir + "/").replace(/^~\//, srcDir + "/");
|
|
86
156
|
}
|
|
87
157
|
function resolveComponentsDir(cwd, config) {
|
|
88
|
-
const
|
|
89
|
-
return path2.resolve(cwd,
|
|
158
|
+
const relPath = resolveAlias(config.aliases.components, config.srcDir);
|
|
159
|
+
return path2.resolve(cwd, relPath);
|
|
90
160
|
}
|
|
91
161
|
|
|
92
162
|
// src/registry/themes.ts
|
|
93
163
|
var themes = [
|
|
94
164
|
{
|
|
95
165
|
name: "kahgel",
|
|
96
|
-
label: "Kahgel
|
|
166
|
+
label: "Kahgel \u2014 Warm Clay",
|
|
97
167
|
cssVars: {
|
|
98
168
|
light: {
|
|
99
169
|
"--background": "40 20% 98%",
|
|
@@ -132,7 +202,7 @@ var themes = [
|
|
|
132
202
|
},
|
|
133
203
|
{
|
|
134
204
|
name: "firouzeh",
|
|
135
|
-
label: "Firouzeh
|
|
205
|
+
label: "Firouzeh \u2014 Persian Turquoise",
|
|
136
206
|
cssVars: {
|
|
137
207
|
light: {
|
|
138
208
|
"--background": "180 20% 98%",
|
|
@@ -171,7 +241,7 @@ var themes = [
|
|
|
171
241
|
},
|
|
172
242
|
{
|
|
173
243
|
name: "lajvard",
|
|
174
|
-
label: "Lajvard
|
|
244
|
+
label: "Lajvard \u2014 Lapis Lazuli",
|
|
175
245
|
cssVars: {
|
|
176
246
|
light: {
|
|
177
247
|
"--background": "225 25% 98%",
|
|
@@ -210,7 +280,7 @@ var themes = [
|
|
|
210
280
|
},
|
|
211
281
|
{
|
|
212
282
|
name: "puste",
|
|
213
|
-
label: "Puste
|
|
283
|
+
label: "Puste \u2014 Pistachio",
|
|
214
284
|
cssVars: {
|
|
215
285
|
light: {
|
|
216
286
|
"--background": "80 20% 98%",
|
|
@@ -249,7 +319,7 @@ var themes = [
|
|
|
249
319
|
},
|
|
250
320
|
{
|
|
251
321
|
name: "anar",
|
|
252
|
-
label: "Anar
|
|
322
|
+
label: "Anar \u2014 Pomegranate",
|
|
253
323
|
cssVars: {
|
|
254
324
|
light: {
|
|
255
325
|
"--background": "0 20% 98%",
|
|
@@ -287,7 +357,29 @@ var themes = [
|
|
|
287
357
|
}
|
|
288
358
|
}
|
|
289
359
|
];
|
|
290
|
-
|
|
360
|
+
var COLOR_VARS = [
|
|
361
|
+
"background",
|
|
362
|
+
"foreground",
|
|
363
|
+
"primary",
|
|
364
|
+
"primary-foreground",
|
|
365
|
+
"secondary",
|
|
366
|
+
"secondary-foreground",
|
|
367
|
+
"destructive",
|
|
368
|
+
"destructive-foreground",
|
|
369
|
+
"card",
|
|
370
|
+
"card-foreground",
|
|
371
|
+
"border",
|
|
372
|
+
"muted",
|
|
373
|
+
"muted-foreground",
|
|
374
|
+
"ring"
|
|
375
|
+
];
|
|
376
|
+
function generateThemeCSS(theme, tailwindVersion = "v3") {
|
|
377
|
+
if (tailwindVersion === "v4") {
|
|
378
|
+
return generateV4CSS(theme);
|
|
379
|
+
}
|
|
380
|
+
return generateV3CSS(theme);
|
|
381
|
+
}
|
|
382
|
+
function generateV3CSS(theme) {
|
|
291
383
|
const lightVars = Object.entries(theme.cssVars.light).map(([key, value]) => ` ${key}: ${value};`).join("\n");
|
|
292
384
|
const darkVars = Object.entries(theme.cssVars.dark).map(([key, value]) => ` ${key}: ${value};`).join("\n");
|
|
293
385
|
return `@tailwind base;
|
|
@@ -314,21 +406,49 @@ ${darkVars}
|
|
|
314
406
|
}
|
|
315
407
|
`;
|
|
316
408
|
}
|
|
409
|
+
function generateV4CSS(theme) {
|
|
410
|
+
const lightVars = Object.entries(theme.cssVars.light).map(([key, value]) => {
|
|
411
|
+
if (key === "--radius") return ` ${key}: ${value};`;
|
|
412
|
+
return ` ${key}: hsl(${value});`;
|
|
413
|
+
}).join("\n");
|
|
414
|
+
const darkVars = Object.entries(theme.cssVars.dark).map(([key, value]) => {
|
|
415
|
+
if (key === "--radius") return ` ${key}: ${value};`;
|
|
416
|
+
return ` ${key}: hsl(${value});`;
|
|
417
|
+
}).join("\n");
|
|
418
|
+
const themeColorMappings = COLOR_VARS.map((name) => ` --color-${name}: var(--${name});`).join("\n");
|
|
419
|
+
return `@import "tailwindcss";
|
|
420
|
+
|
|
421
|
+
:root {
|
|
422
|
+
${lightVars}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.dark {
|
|
426
|
+
${darkVars}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
@theme inline {
|
|
430
|
+
${themeColorMappings}
|
|
431
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
432
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
433
|
+
--radius-lg: var(--radius);
|
|
434
|
+
}
|
|
435
|
+
`;
|
|
436
|
+
}
|
|
317
437
|
|
|
318
438
|
// src/utils/logger.ts
|
|
319
|
-
import
|
|
439
|
+
import chalk from "chalk";
|
|
320
440
|
var logger = {
|
|
321
|
-
info: (msg) => console.log(
|
|
322
|
-
success: (msg) => console.log(
|
|
323
|
-
warn: (msg) => console.log(
|
|
324
|
-
error: (msg) => console.log(
|
|
441
|
+
info: (msg) => console.log(chalk.cyan("\u2139"), msg),
|
|
442
|
+
success: (msg) => console.log(chalk.green("\u2713"), msg),
|
|
443
|
+
warn: (msg) => console.log(chalk.yellow("\u26A0"), msg),
|
|
444
|
+
error: (msg) => console.log(chalk.red("\u2717"), msg),
|
|
325
445
|
break: () => console.log("")
|
|
326
446
|
};
|
|
327
447
|
|
|
328
448
|
// src/commands/init.ts
|
|
329
449
|
async function initCommand(opts) {
|
|
330
450
|
const cwd = process.cwd();
|
|
331
|
-
p.intro(
|
|
451
|
+
p.intro(chalk2.bold("Welcome to Rad UI"));
|
|
332
452
|
if (await configExists(cwd)) {
|
|
333
453
|
const shouldContinue = await p.confirm({
|
|
334
454
|
message: "Rad UI is already initialized in this project. Reinitialize?",
|
|
@@ -341,53 +461,52 @@ async function initCommand(opts) {
|
|
|
341
461
|
}
|
|
342
462
|
const projectType = await detectProjectType(cwd);
|
|
343
463
|
const packageManager = await detectPackageManager(cwd);
|
|
464
|
+
const detectedSrcDir = await detectSrcDir(cwd);
|
|
465
|
+
const defaultCssPath = getDefaultCssPath(projectType);
|
|
466
|
+
const tailwindVersion = await detectTailwindVersion(cwd, defaultCssPath);
|
|
344
467
|
if (projectType !== "unknown") {
|
|
345
|
-
p.log.info(`Detected project: ${
|
|
468
|
+
p.log.info(`Detected project: ${chalk2.cyan(projectType)}`);
|
|
346
469
|
}
|
|
347
|
-
p.log.info(`Package manager: ${
|
|
470
|
+
p.log.info(`Package manager: ${chalk2.cyan(packageManager)}`);
|
|
471
|
+
p.log.info(`Tailwind CSS: ${chalk2.cyan(tailwindVersion)}`);
|
|
472
|
+
p.log.info(`Source directory: ${chalk2.cyan(detectedSrcDir + "/")}`);
|
|
348
473
|
const responses = await p.group(
|
|
349
474
|
{
|
|
350
|
-
platform: () => p.select({
|
|
351
|
-
message: "Which platform are you building for?",
|
|
352
|
-
options: [
|
|
353
|
-
{ value: "web", label: "Web", hint: "React + Tailwind CSS" },
|
|
354
|
-
{
|
|
355
|
-
value: "mobile",
|
|
356
|
-
label: "Mobile",
|
|
357
|
-
hint: "React Native + NativeWind (coming soon)"
|
|
358
|
-
},
|
|
359
|
-
{ value: "both", label: "Both", hint: "Web + Mobile" }
|
|
360
|
-
],
|
|
361
|
-
initialValue: "web"
|
|
362
|
-
}),
|
|
363
475
|
theme: () => p.select({
|
|
364
|
-
message: "Choose a theme:",
|
|
476
|
+
message: "Choose a color theme for your project:",
|
|
365
477
|
options: themes.map((t) => ({
|
|
366
478
|
value: t.name,
|
|
367
479
|
label: t.label
|
|
368
480
|
})),
|
|
369
481
|
initialValue: "kahgel"
|
|
370
482
|
}),
|
|
483
|
+
srcDir: () => p.text({
|
|
484
|
+
message: `Base directory that @ resolves to:`,
|
|
485
|
+
placeholder: detectedSrcDir,
|
|
486
|
+
defaultValue: detectedSrcDir
|
|
487
|
+
}),
|
|
371
488
|
componentsPath: () => p.text({
|
|
372
|
-
message:
|
|
489
|
+
message: `Where to add UI components (e.g. ${detectedSrcDir}/components/ui):`,
|
|
373
490
|
placeholder: "@/components/ui",
|
|
374
491
|
defaultValue: "@/components/ui"
|
|
375
492
|
}),
|
|
376
493
|
utilsPath: () => p.text({
|
|
377
|
-
message:
|
|
494
|
+
message: `Where to create the cn() helper (e.g. ${detectedSrcDir}/lib/utils.ts):`,
|
|
378
495
|
placeholder: "@/lib/utils",
|
|
379
496
|
defaultValue: "@/lib/utils"
|
|
380
497
|
}),
|
|
381
498
|
cssPath: () => p.text({
|
|
382
|
-
message:
|
|
383
|
-
placeholder:
|
|
384
|
-
defaultValue:
|
|
499
|
+
message: `Path to your global CSS file:`,
|
|
500
|
+
placeholder: defaultCssPath,
|
|
501
|
+
defaultValue: defaultCssPath
|
|
385
502
|
}),
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
503
|
+
...tailwindVersion === "v3" ? {
|
|
504
|
+
tailwindConfig: () => p.text({
|
|
505
|
+
message: `Path to your Tailwind config file:`,
|
|
506
|
+
placeholder: getDefaultTailwindConfig(projectType),
|
|
507
|
+
defaultValue: getDefaultTailwindConfig(projectType)
|
|
508
|
+
})
|
|
509
|
+
} : {}
|
|
391
510
|
},
|
|
392
511
|
{
|
|
393
512
|
onCancel: () => {
|
|
@@ -396,15 +515,18 @@ async function initCommand(opts) {
|
|
|
396
515
|
}
|
|
397
516
|
}
|
|
398
517
|
);
|
|
518
|
+
const srcDir = responses.srcDir || detectedSrcDir;
|
|
399
519
|
const s = p.spinner();
|
|
400
520
|
s.start("Creating configuration...");
|
|
401
521
|
const config = {
|
|
402
522
|
$schema: "https://www.quarklab.dev/schema.json",
|
|
403
523
|
registry: "https://www.quarklab.dev/r",
|
|
404
|
-
|
|
524
|
+
tailwindVersion,
|
|
525
|
+
srcDir,
|
|
526
|
+
platform: "web",
|
|
405
527
|
theme: responses.theme,
|
|
406
528
|
tailwind: {
|
|
407
|
-
config: responses.tailwindConfig,
|
|
529
|
+
...tailwindVersion === "v3" && responses.tailwindConfig ? { config: responses.tailwindConfig } : {},
|
|
408
530
|
css: responses.cssPath
|
|
409
531
|
},
|
|
410
532
|
aliases: {
|
|
@@ -420,13 +542,13 @@ async function initCommand(opts) {
|
|
|
420
542
|
const cssPath = path3.resolve(cwd, config.tailwind.css);
|
|
421
543
|
const cssDir = path3.dirname(cssPath);
|
|
422
544
|
await fs3.ensureDir(cssDir);
|
|
423
|
-
const cssContent = generateThemeCSS(selectedTheme);
|
|
545
|
+
const cssContent = generateThemeCSS(selectedTheme, tailwindVersion);
|
|
424
546
|
await fs3.writeFile(cssPath, cssContent, "utf-8");
|
|
425
547
|
}
|
|
426
548
|
s.stop("Theme configured.");
|
|
427
549
|
s.start("Setting up utilities...");
|
|
428
550
|
const utilsAlias = config.aliases.utils;
|
|
429
|
-
const utilsRelPath = utilsAlias.replace(/^@\//, "
|
|
551
|
+
const utilsRelPath = utilsAlias.replace(/^@\//, srcDir + "/").replace(/^~\//, srcDir + "/") + ".ts";
|
|
430
552
|
const utilsDestPath = path3.resolve(cwd, utilsRelPath);
|
|
431
553
|
const utilsDir = path3.dirname(utilsDestPath);
|
|
432
554
|
await fs3.ensureDir(utilsDir);
|
|
@@ -439,29 +561,30 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
439
561
|
`;
|
|
440
562
|
await fs3.writeFile(utilsDestPath, utilsContent, "utf-8");
|
|
441
563
|
s.stop("Utilities ready.");
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
564
|
+
if (tailwindVersion === "v3" && config.tailwind.config) {
|
|
565
|
+
s.start("Configuring Tailwind CSS...");
|
|
566
|
+
const tailwindConfigPath = path3.resolve(cwd, config.tailwind.config);
|
|
567
|
+
const componentsRelPath = config.aliases.components.replace(/^@\//, srcDir + "/").replace(/^~\//, srcDir + "/");
|
|
568
|
+
if (await fs3.pathExists(tailwindConfigPath)) {
|
|
569
|
+
let tailwindContent = await fs3.readFile(tailwindConfigPath, "utf-8");
|
|
570
|
+
const contentPath = `./${componentsRelPath}/**/*.{ts,tsx}`;
|
|
571
|
+
if (!tailwindContent.includes(contentPath)) {
|
|
572
|
+
tailwindContent = tailwindContent.replace(
|
|
573
|
+
/(content\s*:\s*\[)/,
|
|
574
|
+
`$1
|
|
452
575
|
"${contentPath}",`
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
576
|
+
);
|
|
577
|
+
await fs3.writeFile(tailwindConfigPath, tailwindContent, "utf-8");
|
|
578
|
+
p.log.info(`Added component path to ${config.tailwind.config}`);
|
|
579
|
+
}
|
|
580
|
+
} else {
|
|
581
|
+
const isTS = config.tailwind.config.endsWith(".ts");
|
|
582
|
+
const newConfig = isTS ? `import type { Config } from "tailwindcss";
|
|
460
583
|
|
|
461
584
|
const config: Config = {
|
|
462
585
|
darkMode: ["class"],
|
|
463
586
|
content: [
|
|
464
|
-
"
|
|
587
|
+
"./${srcDir}/**/*.{js,ts,jsx,tsx,mdx}",
|
|
465
588
|
"./${componentsRelPath}/**/*.{ts,tsx}",
|
|
466
589
|
],
|
|
467
590
|
theme: {
|
|
@@ -516,7 +639,7 @@ export default config;
|
|
|
516
639
|
module.exports = {
|
|
517
640
|
darkMode: ["class"],
|
|
518
641
|
content: [
|
|
519
|
-
"
|
|
642
|
+
"./${srcDir}/**/*.{js,ts,jsx,tsx,mdx}",
|
|
520
643
|
"./${componentsRelPath}/**/*.{ts,tsx}",
|
|
521
644
|
],
|
|
522
645
|
theme: {
|
|
@@ -566,16 +689,17 @@ module.exports = {
|
|
|
566
689
|
plugins: [],
|
|
567
690
|
};
|
|
568
691
|
`;
|
|
569
|
-
|
|
692
|
+
await fs3.writeFile(tailwindConfigPath, newConfig, "utf-8");
|
|
693
|
+
}
|
|
694
|
+
s.stop("Tailwind CSS configured.");
|
|
695
|
+
} else {
|
|
696
|
+
p.log.info(
|
|
697
|
+
`Tailwind v4 detected \u2014 theme variables added directly to ${chalk2.cyan(config.tailwind.css)}`
|
|
698
|
+
);
|
|
570
699
|
}
|
|
571
|
-
s.stop("Tailwind CSS configured.");
|
|
572
700
|
s.start("Installing base dependencies...");
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
"clsx",
|
|
576
|
-
"tailwind-merge",
|
|
577
|
-
"class-variance-authority"
|
|
578
|
-
]);
|
|
701
|
+
const baseDeps = ["clsx", "tailwind-merge", "class-variance-authority"];
|
|
702
|
+
const installCmd = getInstallCommand(packageManager, baseDeps);
|
|
579
703
|
try {
|
|
580
704
|
const { execa } = await import("execa");
|
|
581
705
|
await execa(installCmd.command, installCmd.args, {
|
|
@@ -586,20 +710,21 @@ module.exports = {
|
|
|
586
710
|
} catch {
|
|
587
711
|
s.stop("Could not auto-install dependencies.");
|
|
588
712
|
p.log.warn(
|
|
589
|
-
`Please manually install: ${
|
|
713
|
+
`Please manually install: ${chalk2.cyan(baseDeps.join(" "))}`
|
|
590
714
|
);
|
|
591
715
|
}
|
|
592
716
|
logger.break();
|
|
593
717
|
p.note(
|
|
594
718
|
[
|
|
595
|
-
`${
|
|
719
|
+
`${chalk2.green("Rad UI has been initialized!")}`,
|
|
596
720
|
"",
|
|
597
|
-
`Add components with: ${
|
|
598
|
-
`Add all components: ${
|
|
721
|
+
`Add components with: ${chalk2.cyan("npx @quarklab/rad-ui add <component>")}`,
|
|
722
|
+
`Add all components: ${chalk2.cyan("npx @quarklab/rad-ui add --all")}`,
|
|
599
723
|
"",
|
|
600
|
-
`Theme: ${
|
|
601
|
-
`
|
|
602
|
-
`
|
|
724
|
+
`Theme: ${chalk2.cyan(selectedTheme?.label || config.theme)}`,
|
|
725
|
+
`Tailwind: ${chalk2.cyan(tailwindVersion)}`,
|
|
726
|
+
`Components: ${chalk2.cyan(config.aliases.components)} \u2192 ${chalk2.dim(srcDir + "/" + config.aliases.components.replace(/^@\//, "").replace(/^~\//, ""))}`,
|
|
727
|
+
`Utils: ${chalk2.cyan(config.aliases.utils)} \u2192 ${chalk2.dim(srcDir + "/" + config.aliases.utils.replace(/^@\//, "").replace(/^~\//, "") + ".ts")}`
|
|
603
728
|
].join("\n"),
|
|
604
729
|
"Next steps"
|
|
605
730
|
);
|
|
@@ -623,7 +748,7 @@ import path4 from "path";
|
|
|
623
748
|
import { fileURLToPath } from "url";
|
|
624
749
|
import fs4 from "fs-extra";
|
|
625
750
|
import * as p2 from "@clack/prompts";
|
|
626
|
-
import
|
|
751
|
+
import chalk3 from "chalk";
|
|
627
752
|
|
|
628
753
|
// src/registry/index.ts
|
|
629
754
|
var components = [
|
|
@@ -956,10 +1081,10 @@ async function getComponentContent(name, config) {
|
|
|
956
1081
|
}
|
|
957
1082
|
async function addCommand(componentNames, opts) {
|
|
958
1083
|
const cwd = process.cwd();
|
|
959
|
-
p2.intro(
|
|
1084
|
+
p2.intro(chalk3.bold("Add Rad UI Components"));
|
|
960
1085
|
if (!await configExists(cwd)) {
|
|
961
1086
|
p2.log.error(
|
|
962
|
-
`Configuration not found. Run ${
|
|
1087
|
+
`Configuration not found. Run ${chalk3.cyan("npx @quarklab/rad-ui init")} first.`
|
|
963
1088
|
);
|
|
964
1089
|
process.exit(1);
|
|
965
1090
|
}
|
|
@@ -987,10 +1112,10 @@ async function addCommand(componentNames, opts) {
|
|
|
987
1112
|
const invalid = componentNames.filter((n) => !availableNames.includes(n));
|
|
988
1113
|
if (invalid.length > 0) {
|
|
989
1114
|
p2.log.error(
|
|
990
|
-
`Unknown component(s): ${invalid.map((n) =>
|
|
1115
|
+
`Unknown component(s): ${invalid.map((n) => chalk3.red(n)).join(", ")}`
|
|
991
1116
|
);
|
|
992
1117
|
p2.log.info(
|
|
993
|
-
`Available: ${availableNames.map((n) =>
|
|
1118
|
+
`Available: ${availableNames.map((n) => chalk3.cyan(n)).join(", ")}`
|
|
994
1119
|
);
|
|
995
1120
|
process.exit(1);
|
|
996
1121
|
}
|
|
@@ -1015,7 +1140,7 @@ async function addCommand(componentNames, opts) {
|
|
|
1015
1140
|
const extraDeps = allNames.filter((n) => !selectedNames.includes(n));
|
|
1016
1141
|
if (extraDeps.length > 0) {
|
|
1017
1142
|
p2.log.info(
|
|
1018
|
-
`Also adding dependencies: ${extraDeps.map((n) =>
|
|
1143
|
+
`Also adding dependencies: ${extraDeps.map((n) => chalk3.cyan(n)).join(", ")}`
|
|
1019
1144
|
);
|
|
1020
1145
|
}
|
|
1021
1146
|
const componentsDir = opts.path ? path4.resolve(cwd, opts.path) : resolveComponentsDir(cwd, config);
|
|
@@ -1034,7 +1159,7 @@ async function addCommand(componentNames, opts) {
|
|
|
1034
1159
|
}
|
|
1035
1160
|
if (existing.length > 0) {
|
|
1036
1161
|
const shouldOverwrite = await p2.confirm({
|
|
1037
|
-
message: `The following components already exist: ${existing.map((n) =>
|
|
1162
|
+
message: `The following components already exist: ${existing.map((n) => chalk3.yellow(n)).join(", ")}. Overwrite?`,
|
|
1038
1163
|
initialValue: false
|
|
1039
1164
|
});
|
|
1040
1165
|
if (p2.isCancel(shouldOverwrite) || !shouldOverwrite) {
|
|
@@ -1098,19 +1223,19 @@ async function addCommand(componentNames, opts) {
|
|
|
1098
1223
|
s.stop("Could not auto-install dependencies.");
|
|
1099
1224
|
p2.log.warn(
|
|
1100
1225
|
`Please manually install:
|
|
1101
|
-
${
|
|
1226
|
+
${chalk3.cyan(depsToInstall.join(" "))}`
|
|
1102
1227
|
);
|
|
1103
1228
|
}
|
|
1104
1229
|
}
|
|
1105
1230
|
logger.break();
|
|
1106
1231
|
p2.note(
|
|
1107
1232
|
[
|
|
1108
|
-
`Components added to ${
|
|
1233
|
+
`Components added to ${chalk3.cyan(componentsDir.replace(cwd + "/", ""))}:`,
|
|
1109
1234
|
"",
|
|
1110
|
-
...allNames.map((n) => ` ${
|
|
1235
|
+
...allNames.map((n) => ` ${chalk3.green("+")} ${n}`),
|
|
1111
1236
|
"",
|
|
1112
1237
|
"Import example:",
|
|
1113
|
-
|
|
1238
|
+
chalk3.gray(
|
|
1114
1239
|
` import { Button } from "${config.aliases.components}/button";`
|
|
1115
1240
|
)
|
|
1116
1241
|
].join("\n"),
|
package/package.json
CHANGED