ionbit-ui 0.1.14 → 0.1.15
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/README.md +16 -0
- package/dist/index.js +175 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,22 @@ List all available components in the registry.
|
|
|
46
46
|
npx ionbit-ui@latest list
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
### `theme [id]`
|
|
50
|
+
|
|
51
|
+
Install a preset theme or a custom theme. The command writes `theme.css` to
|
|
52
|
+
the configured styles directory and adds it to the configured global CSS file.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npx ionbit-ui@latest theme nord
|
|
56
|
+
npx ionbit-ui@latest theme banana-cake
|
|
57
|
+
npx ionbit-ui@latest theme --custom '<theme-json>'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Options:
|
|
61
|
+
|
|
62
|
+
- `--custom <json>` — install a custom theme configuration generated by the docs theme editor
|
|
63
|
+
- `--overwrite` — replace an existing `theme.css`
|
|
64
|
+
|
|
49
65
|
## Package manager support
|
|
50
66
|
|
|
51
67
|
The CLI auto-detects your package manager from lockfiles and uses the correct install command:
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { execSync } from "node:child_process";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
const REGISTRY_URL = "https://raw.githubusercontent.com/rostislaw9/ionbit-ui/main/registry.json";
|
|
9
9
|
const REGISTRY_ITEM_URL = "https://raw.githubusercontent.com/rostislaw9/ionbit-ui/main/registry/items";
|
|
10
|
+
const THEME_REGISTRY_URL = "https://raw.githubusercontent.com/rostislaw9/ionbit-ui/main/registry/themes.json";
|
|
10
11
|
const DEFAULT_CONFIG = {
|
|
11
12
|
$schema: "https://ui.shadcn.com/schema/registry.json",
|
|
12
13
|
style: "digital",
|
|
@@ -97,6 +98,17 @@ function findLocalRegistryItem(name) {
|
|
|
97
98
|
}
|
|
98
99
|
return null;
|
|
99
100
|
}
|
|
101
|
+
function findLocalThemes() {
|
|
102
|
+
const candidates = [
|
|
103
|
+
resolve(process.cwd(), "registry/themes.json"),
|
|
104
|
+
resolve(__dirname$1, "../../../registry/themes.json"),
|
|
105
|
+
resolve(__dirname$1, "../../../../registry/themes.json")
|
|
106
|
+
];
|
|
107
|
+
for (const p of candidates) {
|
|
108
|
+
if (existsSync(p)) return p;
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
100
112
|
async function fetchRegistry() {
|
|
101
113
|
const localPath = findLocalRegistry();
|
|
102
114
|
if (localPath) {
|
|
@@ -126,6 +138,19 @@ async function fetchRegistryItem(name) {
|
|
|
126
138
|
async function fetchRegistryItems(names) {
|
|
127
139
|
return Promise.all(names.map(fetchRegistryItem));
|
|
128
140
|
}
|
|
141
|
+
async function fetchThemeRegistry() {
|
|
142
|
+
const localPath = findLocalThemes();
|
|
143
|
+
if (localPath) {
|
|
144
|
+
return JSON.parse(readFileSync(localPath, "utf-8"));
|
|
145
|
+
}
|
|
146
|
+
const res = await fetch(THEME_REGISTRY_URL);
|
|
147
|
+
if (!res.ok) {
|
|
148
|
+
throw new Error(
|
|
149
|
+
`Failed to fetch theme registry: ${res.status} ${res.statusText}`
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
return await res.json();
|
|
153
|
+
}
|
|
129
154
|
async function add(components, options) {
|
|
130
155
|
const cwd = process.cwd();
|
|
131
156
|
const config = loadConfig(cwd);
|
|
@@ -378,10 +403,158 @@ ${label}`));
|
|
|
378
403
|
console.log(chalk.dim(`Install with: ionbit-ui add <name>`));
|
|
379
404
|
console.log("");
|
|
380
405
|
}
|
|
406
|
+
async function theme(id, options) {
|
|
407
|
+
const cwd = process.cwd();
|
|
408
|
+
const config = loadConfig(cwd);
|
|
409
|
+
if (!config) {
|
|
410
|
+
console.log(
|
|
411
|
+
chalk.red("No ionbit-ui.config.json found. Run `ionbit-ui init` first.")
|
|
412
|
+
);
|
|
413
|
+
process.exitCode = 1;
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (id && options.custom) {
|
|
417
|
+
console.log(chalk.red("Choose a preset theme or --custom, not both."));
|
|
418
|
+
process.exitCode = 1;
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
let css;
|
|
422
|
+
let label;
|
|
423
|
+
if (options.custom) {
|
|
424
|
+
let custom;
|
|
425
|
+
try {
|
|
426
|
+
custom = JSON.parse(options.custom);
|
|
427
|
+
validateCustomTheme(custom);
|
|
428
|
+
} catch (error) {
|
|
429
|
+
const message = error instanceof Error ? error.message : "invalid JSON";
|
|
430
|
+
console.log(chalk.red(`Invalid custom theme: ${message}`));
|
|
431
|
+
process.exitCode = 1;
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
label = "Custom";
|
|
435
|
+
css = generateThemeCss(custom, label);
|
|
436
|
+
} else {
|
|
437
|
+
if (!id) {
|
|
438
|
+
console.log(chalk.red("Provide a theme id or use --custom <json>."));
|
|
439
|
+
process.exitCode = 1;
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
const registry = await fetchThemeRegistry();
|
|
443
|
+
const preset = registry.themes.find((entry) => entry.id === id);
|
|
444
|
+
if (!preset) {
|
|
445
|
+
printThemeError(id, registry.themes);
|
|
446
|
+
process.exitCode = 1;
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
label = preset.label;
|
|
450
|
+
css = preset.css;
|
|
451
|
+
}
|
|
452
|
+
const themePath = resolve(cwd, config.aliases.styles, "theme.css");
|
|
453
|
+
if (existsSync(themePath) && !options.overwrite) {
|
|
454
|
+
console.log(
|
|
455
|
+
chalk.yellow(
|
|
456
|
+
`${config.aliases.styles}/theme.css already exists. Use --overwrite to replace it.`
|
|
457
|
+
)
|
|
458
|
+
);
|
|
459
|
+
process.exitCode = 1;
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
ensureDir(themePath);
|
|
463
|
+
writeFileSync(themePath, css + "\n");
|
|
464
|
+
addThemeImport(config, cwd, themePath);
|
|
465
|
+
console.log(chalk.green(`✓ Installed ${label} theme`));
|
|
466
|
+
console.log(chalk.dim(` ${config.aliases.styles}/theme.css`));
|
|
467
|
+
}
|
|
468
|
+
function printThemeError(id, themes) {
|
|
469
|
+
console.log(chalk.red(`Theme "${id}" not found. Available themes:`));
|
|
470
|
+
console.log(themes.map((entry) => ` ${entry.id}`).join("\n"));
|
|
471
|
+
}
|
|
472
|
+
function validateCustomTheme(themeConfig) {
|
|
473
|
+
for (const mode of ["dark", "light"]) {
|
|
474
|
+
if (!themeConfig[mode] || typeof themeConfig[mode] !== "object") {
|
|
475
|
+
throw new Error(`missing ${mode} colors`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
if (!themeConfig.radius || !themeConfig.settings) {
|
|
479
|
+
throw new Error("missing radius or settings");
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
function addThemeImport(config, cwd, themePath) {
|
|
483
|
+
const cssPath = resolve(cwd, config.tailwind.css);
|
|
484
|
+
const importPath = relative(dirname(cssPath), themePath).replace(/\\/g, "/");
|
|
485
|
+
const importLine = `@import "./${importPath}";`;
|
|
486
|
+
const existing = existsSync(cssPath) ? readFileSync(cssPath, "utf-8") : "";
|
|
487
|
+
if (!existing.includes(importLine)) {
|
|
488
|
+
writeFileSync(cssPath, `${existing.trimEnd()}
|
|
489
|
+
${importLine}
|
|
490
|
+
`);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
function colorMix(color, amount) {
|
|
494
|
+
return `color-mix(in oklab, ${color} ${amount}%, transparent)`;
|
|
495
|
+
}
|
|
496
|
+
function hoverColor(color) {
|
|
497
|
+
return `color-mix(in oklab, ${color} 88%, black)`;
|
|
498
|
+
}
|
|
499
|
+
function colorsToCss(colors, translucency, light) {
|
|
500
|
+
const muted = Math.round(translucency * 160);
|
|
501
|
+
const subtle = Math.round(translucency * 80);
|
|
502
|
+
const borderBase = light ? "0 0 0" : "1 0 0";
|
|
503
|
+
return [
|
|
504
|
+
` --background: ${colors.background};`,
|
|
505
|
+
` --surface: ${colors.surface};`,
|
|
506
|
+
` --surface-elevated: ${colors.surfaceElevated};`,
|
|
507
|
+
` --surface-hover: ${colors.surfaceHover};`,
|
|
508
|
+
` --foreground: ${colors.foreground};`,
|
|
509
|
+
` --foreground-muted: ${colors.foregroundMuted};`,
|
|
510
|
+
` --foreground-subtle: ${colors.foregroundSubtle};`,
|
|
511
|
+
` --accent: ${colors.accent};`,
|
|
512
|
+
` --accent-hover: ${colors.accentHover};`,
|
|
513
|
+
` --accent-foreground: ${colors.accentForeground};`,
|
|
514
|
+
` --accent-muted: ${colorMix(colors.accent, muted)};`,
|
|
515
|
+
` --accent-subtle: ${colorMix(colors.accent, subtle)};`,
|
|
516
|
+
...statusCss("success", colors.success, muted, subtle, light, "155"),
|
|
517
|
+
...statusCss("warning", colors.warning, muted, subtle, light, "80"),
|
|
518
|
+
...statusCss("error", colors.error, muted, subtle, light, "5"),
|
|
519
|
+
...statusCss("info", colors.info, muted, subtle, light, "230"),
|
|
520
|
+
` --ring: ${colors.ring};`,
|
|
521
|
+
` --border: oklch(${borderBase} / ${translucency.toFixed(2)});`,
|
|
522
|
+
` --border-strong: oklch(${borderBase} / ${(translucency * 1.75).toFixed(2)});`,
|
|
523
|
+
` --border-accent: ${colorMix(colors.accent, 50)};`,
|
|
524
|
+
` --border-error: ${colorMix(colors.error, 50)};`,
|
|
525
|
+
` --border-success: ${colorMix(colors.success, 50)};`,
|
|
526
|
+
` --border-warning: ${colorMix(colors.warning, 50)};`,
|
|
527
|
+
` --border-info: ${colorMix(colors.info, 50)};`
|
|
528
|
+
].join("\n");
|
|
529
|
+
}
|
|
530
|
+
function statusCss(name, color, muted, subtle, light, hue) {
|
|
531
|
+
return [
|
|
532
|
+
` --${name}: ${color};`,
|
|
533
|
+
` --${name}-hover: ${hoverColor(color)};`,
|
|
534
|
+
` --${name}-muted: ${colorMix(color, muted)};`,
|
|
535
|
+
` --${name}-subtle: ${colorMix(color, subtle)};`,
|
|
536
|
+
` --${name}-foreground: ${light ? "oklch(0.99 0 0)" : `oklch(0.1 0.03 ${hue})`};`
|
|
537
|
+
];
|
|
538
|
+
}
|
|
539
|
+
function generateThemeCss(theme2, label) {
|
|
540
|
+
const radius = Object.entries(theme2.radius).map(([key, value]) => ` --radius-${key}: ${value};`).join("\n");
|
|
541
|
+
const settings = Object.entries(theme2.settings).filter(([key]) => key.endsWith("Intensity")).map(
|
|
542
|
+
([key, value]) => ` --${key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}: ${value};`
|
|
543
|
+
).join("\n");
|
|
544
|
+
const block = (colors, light) => `${light ? ".light" : ":root"} {
|
|
545
|
+
${colorsToCss(colors, Number(theme2.settings.translucency), light)}
|
|
546
|
+
${radius}
|
|
547
|
+
${settings}
|
|
548
|
+
}`;
|
|
549
|
+
return `/* Ionbit UI — Theme: ${label} */
|
|
550
|
+
${block(theme2.dark, false)}
|
|
551
|
+
|
|
552
|
+
${block(theme2.light, true)}`;
|
|
553
|
+
}
|
|
381
554
|
const program = new Command();
|
|
382
555
|
program.name("ionbit-ui").description(
|
|
383
556
|
"Ionbit UI CLI — install source-owned components from the Ionbit UI registry."
|
|
384
|
-
).version("0.1.
|
|
557
|
+
).version("0.1.15");
|
|
385
558
|
program.command("init").description(
|
|
386
559
|
"Initialize Ionbit UI in your project. Creates a ionbit-ui.config.json and installs design tokens."
|
|
387
560
|
).option("-y, --yes", "Skip confirmation prompts and use defaults").option("-f, --force", "Force overwrite of existing configuration").option(
|
|
@@ -392,5 +565,6 @@ program.command("add <components...>").description(
|
|
|
392
565
|
"Add components to your project. e.g. ionbit-ui add button card accordion"
|
|
393
566
|
).option("-o, --overwrite", "Overwrite existing files").action(add);
|
|
394
567
|
program.command("list").description("List all available components in the registry.").action(list);
|
|
568
|
+
program.command("theme [id]").description("Install a preset or custom theme.").option("--custom <json>", "Install a custom theme from JSON").option("-o, --overwrite", "Overwrite the existing theme.css").action(theme);
|
|
395
569
|
program.parse();
|
|
396
570
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/config.ts","../src/utils/fs.ts","../src/utils/npm.ts","../src/utils/registry.ts","../src/commands/add.ts","../src/commands/init.ts","../src/commands/list.ts","../src/index.ts"],"sourcesContent":["export const REGISTRY_URL =\n \"https://raw.githubusercontent.com/rostislaw9/ionbit-ui/main/registry.json\";\n\nexport const REGISTRY_ITEM_URL =\n \"https://raw.githubusercontent.com/rostislaw9/ionbit-ui/main/registry/items\";\n\nexport interface RegistryItem {\n name: string;\n type: string;\n title: string;\n description: string;\n dependencies?: string[];\n devDependencies?: string[];\n registryDependencies?: string[];\n files: RegistryFile[];\n}\n\nexport interface RegistryFile {\n path: string;\n type: string;\n content: string;\n}\n\nexport interface Registry {\n $schema: string;\n name: string;\n homepage: string;\n items: RegistryItem[];\n}\n\nexport interface Config {\n $schema: string;\n style: string;\n tailwind: {\n css: string;\n cssVariables: boolean;\n };\n aliases: {\n components: string;\n motion: string;\n lib: string;\n styles: string;\n };\n}\n\nexport const DEFAULT_CONFIG: Config = {\n $schema: \"https://ui.shadcn.com/schema/registry.json\",\n style: \"digital\",\n tailwind: {\n css: \"src/index.css\",\n cssVariables: true,\n },\n aliases: {\n components: \"src/components/ui\",\n motion: \"src/components/motion\",\n lib: \"src/lib\",\n styles: \"src/styles\",\n },\n};\n\nexport const CONFIG_FILE = \"ionbit-ui.config.json\";\n","import type { Config } from \"../config\";\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\n\nimport { CONFIG_FILE } from \"../config\";\n\nexport function loadConfig(cwd = process.cwd()): Config | null {\n const configPath = resolve(cwd, CONFIG_FILE);\n if (!existsSync(configPath)) return null;\n return JSON.parse(readFileSync(configPath, \"utf-8\")) as Config;\n}\n\nexport function saveConfig(config: Config, cwd = process.cwd()): void {\n const configPath = resolve(cwd, CONFIG_FILE);\n writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n}\n\nexport function ensureDir(filePath: string): void {\n const dir = dirname(filePath);\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n}\n\nexport function writeFile(filePath: string, content: string): void {\n ensureDir(filePath);\n writeFileSync(filePath, content);\n}\n\nexport function resolveTargetPath(\n target: string,\n config: Config,\n cwd = process.cwd(),\n): string {\n // Map registry target paths to the user's configured aliases.\n // e.g. \"components/ui/button.tsx\" -> \"{cwd}/components/ui/button.tsx\"\n // \"components/motion/spotlight.tsx\" -> \"{cwd}/components/motion/spotlight.tsx\"\n // \"lib/utils.ts\" -> \"{cwd}/lib/utils.ts\"\n // \"styles/tokens.css\" -> \"{cwd}/styles/tokens.css\"\n let resolved = target;\n\n if (target.startsWith(\"components/ui/\")) {\n resolved = target.replace(\n \"components/ui/\",\n config.aliases.components + \"/\",\n );\n } else if (target.startsWith(\"components/motion/\")) {\n resolved = target.replace(\n \"components/motion/\",\n config.aliases.motion + \"/\",\n );\n } else if (target.startsWith(\"lib/\")) {\n resolved = target.replace(\"lib/\", config.aliases.lib + \"/\");\n } else if (target.startsWith(\"styles/\")) {\n resolved = target.replace(\"styles/\", config.aliases.styles + \"/\");\n }\n\n return resolve(cwd, resolved);\n}\n","import { execSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nexport type PackageManager = \"npm\" | \"pnpm\" | \"yarn\" | \"bun\";\n\nexport function detectPackageManager(cwd: string): PackageManager {\n if (existsSync(resolve(cwd, \"bun.lockb\"))) return \"bun\";\n if (existsSync(resolve(cwd, \"bun.lock\"))) return \"bun\";\n if (existsSync(resolve(cwd, \"pnpm-lock.yaml\"))) return \"pnpm\";\n if (existsSync(resolve(cwd, \"yarn.lock\"))) return \"yarn\";\n return \"npm\";\n}\n\nexport function installNpmDeps(deps: string[], cwd: string): void {\n if (deps.length === 0) return;\n const pm = detectPackageManager(cwd);\n const cmd =\n pm === \"pnpm\"\n ? `pnpm add ${deps.join(\" \")}`\n : pm === \"yarn\"\n ? `yarn add ${deps.join(\" \")}`\n : pm === \"bun\"\n ? `bun add ${deps.join(\" \")}`\n : `npm install ${deps.join(\" \")}`;\n execSync(cmd, { cwd, stdio: \"inherit\" });\n}\n","import type { Registry, RegistryItem } from \"../config\";\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { REGISTRY_ITEM_URL, REGISTRY_URL } from \"../config\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\n/**\n * Find the registry.json — checks local paths first, then falls back to the\n * remote GitHub URL. This allows development/testing without pushing to GitHub.\n */\nfunction findLocalRegistry(): string | null {\n const candidates = [\n // Relative to cwd (user's project)\n resolve(process.cwd(), \"registry.json\"),\n // Relative to CLI dist (packages/cli/dist -> ../../../registry.json)\n resolve(__dirname, \"../../../registry.json\"),\n // Relative to CLI src/utils (packages/cli/src/utils -> ../../../../registry.json)\n resolve(__dirname, \"../../../../registry.json\"),\n ];\n for (const p of candidates) {\n if (existsSync(p)) return p;\n }\n return null;\n}\n\nfunction findLocalRegistryItem(name: string): string | null {\n const candidates = [\n resolve(process.cwd(), \"registry/items\", `${name}.json`),\n resolve(__dirname, \"../../../registry/items\", `${name}.json`),\n resolve(__dirname, \"../../../../registry/items\", `${name}.json`),\n ];\n for (const p of candidates) {\n if (existsSync(p)) return p;\n }\n return null;\n}\n\nexport async function fetchRegistry(): Promise<Registry> {\n const localPath = findLocalRegistry();\n if (localPath) {\n return JSON.parse(readFileSync(localPath, \"utf-8\")) as Registry;\n }\n\n const res = await fetch(REGISTRY_URL);\n if (!res.ok) {\n throw new Error(\n `Failed to fetch registry: ${res.status} ${res.statusText}`,\n );\n }\n return (await res.json()) as Registry;\n}\n\nexport async function fetchRegistryItem(name: string): Promise<RegistryItem> {\n const localPath = findLocalRegistryItem(name);\n if (localPath) {\n return JSON.parse(readFileSync(localPath, \"utf-8\")) as RegistryItem;\n }\n\n const res = await fetch(`${REGISTRY_ITEM_URL}/${name}.json`);\n if (!res.ok) {\n throw new Error(\n `Failed to fetch registry item \"${name}\": ${res.status} ${res.statusText}`,\n );\n }\n return (await res.json()) as RegistryItem;\n}\n\nexport async function fetchRegistryItems(\n names: string[],\n): Promise<RegistryItem[]> {\n return Promise.all(names.map(fetchRegistryItem));\n}\n","import type { Config, RegistryItem } from \"../config\";\n\nimport chalk from \"chalk\";\nimport { existsSync } from \"node:fs\";\n\nimport { loadConfig, resolveTargetPath, writeFile } from \"../utils/fs\";\nimport { installNpmDeps } from \"../utils/npm\";\nimport { fetchRegistry, fetchRegistryItems } from \"../utils/registry\";\n\nexport async function add(\n components: string[],\n options: { overwrite?: boolean },\n): Promise<void> {\n const cwd = process.cwd();\n const config = loadConfig(cwd);\n\n if (!config) {\n console.log(\n chalk.red(\"No ionbit-ui.config.json found. Run `ionbit-ui init` first.\"),\n );\n process.exit(1);\n }\n\n // Fetch the full registry to resolve names and dependencies\n const registry = await fetchRegistry();\n const allNames = new Set(registry.items.map((i) => i.name));\n\n // Validate requested components\n for (const name of components) {\n if (!allNames.has(name)) {\n console.log(\n chalk.red(\n `Component \"${name}\" not found in registry. Run \\`ionbit-ui list\\` to see available components.`,\n ),\n );\n process.exit(1);\n }\n }\n\n // Resolve transitive registry dependencies\n const toInstall = resolveDependencies(components, registry.items);\n\n console.log(chalk.dim(`Installing ${toInstall.length} item(s)...`));\n console.log(\"\");\n\n // Fetch all items with embedded content\n const items = await fetchRegistryItems(toInstall);\n\n for (const item of items) {\n await installItem(item, config, cwd, options.overwrite ?? false);\n }\n\n // Collect and install npm dependencies\n const npmDeps = new Set<string>();\n for (const item of items) {\n for (const dep of item.dependencies ?? []) {\n npmDeps.add(dep);\n }\n }\n\n if (npmDeps.size > 0) {\n console.log(\"\");\n installNpmDeps([...npmDeps], cwd);\n }\n\n console.log(\"\");\n console.log(chalk.green(`✓ Added ${items.length} component(s).`));\n}\n\nfunction resolveDependencies(\n names: string[],\n allItems: { name: string; registryDependencies?: string[] }[],\n): string[] {\n const resolved = new Set<string>();\n const queue = [...names];\n\n while (queue.length > 0) {\n const name = queue.shift()!;\n if (resolved.has(name)) continue;\n resolved.add(name);\n\n const item = allItems.find((i) => i.name === name);\n if (item?.registryDependencies) {\n for (const dep of item.registryDependencies) {\n if (!resolved.has(dep)) queue.push(dep);\n }\n }\n }\n\n return [...resolved];\n}\n\nasync function installItem(\n item: RegistryItem,\n config: Config,\n cwd: string,\n overwrite: boolean,\n): Promise<void> {\n for (const file of item.files) {\n const targetPath = resolveTargetPath(file.path, config, cwd);\n\n if (existsSync(targetPath) && !overwrite) {\n console.log(\n chalk.yellow(\n ` ⚠ ${file.path} already exists — skipping (use --overwrite)`,\n ),\n );\n continue;\n }\n\n writeFile(targetPath, file.content);\n console.log(chalk.green(` ✓ ${file.path}`));\n }\n}\n","import type { Config, RegistryItem } from \"../config\";\n\nimport chalk from \"chalk\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { relative, resolve } from \"node:path\";\n\nimport { CONFIG_FILE, DEFAULT_CONFIG } from \"../config\";\nimport { resolveTargetPath, saveConfig, writeFile } from \"../utils/fs\";\nimport { installNpmDeps } from \"../utils/npm\";\nimport { fetchRegistryItems } from \"../utils/registry\";\n\nconst CURSOR_CSS = `@layer base {\n button:not(:disabled),\n [role=\"button\"]:not(:disabled) {\n cursor: pointer;\n }\n}`;\n\n/** Items that every project needs — installed automatically during init. */\nconst BASE_ITEMS = [\"cn\", \"tokens\"];\n\nexport async function init(options: {\n yes?: boolean;\n force?: boolean;\n pointer?: boolean;\n}): Promise<void> {\n const cwd = process.cwd();\n const configPath = resolve(cwd, CONFIG_FILE);\n\n if (existsSync(configPath) && !options.force) {\n console.log(\n chalk.yellow(\n `${CONFIG_FILE} already exists. Use --force to reinitialize.`,\n ),\n );\n return;\n }\n\n const config: Config = { ...DEFAULT_CONFIG };\n\n saveConfig(config, cwd);\n console.log(chalk.green(`✓ Created ${CONFIG_FILE}`));\n\n // Create directory structure\n const dirs = [\n config.aliases.components,\n config.aliases.motion,\n config.aliases.lib,\n config.aliases.styles,\n ];\n\n for (const dir of dirs) {\n const dirPath = resolve(cwd, dir);\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n console.log(chalk.dim(` Created ${dir}/`));\n }\n }\n\n // Install base items (cn utility + design tokens)\n console.log(chalk.dim(\"Installing base items (cn, tokens)...\"));\n const items = await fetchRegistryItems(BASE_ITEMS);\n for (const item of items) {\n installBaseItem(item, config, cwd);\n }\n\n // Add token CSS imports to the user's stylesheet\n setupCssImports(config, cwd);\n\n // Collect and install npm dependencies for base items\n const npmDeps = new Set<string>();\n for (const item of items) {\n for (const dep of item.dependencies ?? []) {\n npmDeps.add(dep);\n }\n }\n installNpmDeps([...npmDeps], cwd);\n\n // Optionally add cursor: pointer CSS\n if (options.pointer) {\n const cssPath = resolve(cwd, config.tailwind.css);\n if (existsSync(cssPath)) {\n const existing = readFileSync(cssPath, \"utf-8\");\n if (!existing.includes(\"cursor: pointer\")) {\n writeFileSync(cssPath, existing + \"\\n\" + CURSOR_CSS);\n console.log(\n chalk.green(`✓ Added cursor: pointer to ${config.tailwind.css}`),\n );\n } else {\n console.log(\n chalk.dim(\n ` ${config.tailwind.css} already has cursor: pointer — skipping`,\n ),\n );\n }\n } else {\n writeFileSync(cssPath, CURSOR_CSS);\n console.log(\n chalk.green(`✓ Created ${config.tailwind.css} with cursor: pointer`),\n );\n }\n }\n\n console.log(\"\");\n console.log(chalk.bold(\"Ionbit UI initialized!\"));\n console.log(\"\");\n console.log(chalk.dim(\"Next steps:\"));\n console.log(` ${chalk.cyan(\"ionbit-ui add button\")} — add a component`);\n console.log(\n ` ${chalk.cyan(\"ionbit-ui list\")} — browse available components`,\n );\n console.log(\"\");\n}\n\nfunction installBaseItem(\n item: RegistryItem,\n config: Config,\n cwd: string,\n): void {\n for (const file of item.files) {\n const targetPath = resolveTargetPath(file.path, config, cwd);\n if (existsSync(targetPath)) {\n console.log(chalk.dim(` ⚠ ${file.path} already exists — skipping`));\n continue;\n }\n writeFile(targetPath, file.content);\n console.log(chalk.green(` ✓ ${file.path}`));\n }\n}\n\nfunction setupCssImports(config: Config, cwd: string): void {\n const cssPath = resolve(cwd, config.tailwind.css);\n const stylesDir = config.aliases.styles;\n\n // Build the import lines relative to the CSS file's directory\n const tokensImport = `@import \"./${relativePath(cssPath, resolve(cwd, stylesDir, \"tokens.css\"))}\";`;\n const baseImport = `@import \"./${relativePath(cssPath, resolve(cwd, stylesDir, \"base.css\"))}\";`;\n const utilitiesImport = `@import \"./${relativePath(cssPath, resolve(cwd, stylesDir, \"utilities.css\"))}\";`;\n\n if (!existsSync(cssPath)) {\n // Create the CSS file with token imports\n const content = `@import \"tailwindcss\";\\n\\n${tokensImport}\\n${baseImport}\\n${utilitiesImport}\\n`;\n writeFileSync(cssPath, content);\n console.log(\n chalk.green(`✓ Created ${config.tailwind.css} with token imports`),\n );\n return;\n }\n\n const existing = readFileSync(cssPath, \"utf-8\");\n const lines: string[] = [];\n\n if (!existing.includes(\"tokens.css\")) {\n lines.push(tokensImport);\n }\n if (!existing.includes(\"base.css\")) {\n lines.push(baseImport);\n }\n if (!existing.includes(\"utilities.css\")) {\n lines.push(utilitiesImport);\n }\n\n if (lines.length > 0) {\n // Add imports after @import \"tailwindcss\" if present, otherwise at the top\n let updated: string;\n if (existing.includes('@import \"tailwindcss\"')) {\n updated = existing.replace(\n /(@import\\s+\"tailwindcss\"[^\\n]*)/,\n `$1\\n${lines.join(\"\\n\")}`,\n );\n } else {\n updated = lines.join(\"\\n\") + \"\\n\" + existing;\n }\n writeFileSync(cssPath, updated);\n console.log(chalk.green(`✓ Added token imports to ${config.tailwind.css}`));\n } else {\n console.log(\n chalk.dim(\n ` ${config.tailwind.css} already has token imports — skipping`,\n ),\n );\n }\n}\n\nfunction relativePath(from: string, to: string): string {\n let rel = relative(from, to).replace(/\\\\/g, \"/\");\n // Remove the leading \"../\" if the CSS file is in the same or parent directory\n if (rel.startsWith(\"../\")) rel = rel.slice(3);\n return rel;\n}\n","import chalk from \"chalk\";\n\nimport { fetchRegistry } from \"../utils/registry\";\n\nexport async function list(): Promise<void> {\n const registry = await fetchRegistry();\n\n const groups: Record<string, typeof registry.items> = {};\n\n for (const item of registry.items) {\n const category = item.type.replace(\"registry:\", \"\");\n if (!groups[category]) groups[category] = [];\n groups[category].push(item);\n }\n\n const categoryOrder = [\"lib\", \"base\", \"ui\"];\n const sortedCategories = Object.keys(groups).sort((a, b) => {\n const ai = categoryOrder.indexOf(a);\n const bi = categoryOrder.indexOf(b);\n if (ai !== -1 && bi !== -1) return ai - bi;\n if (ai !== -1) return -1;\n if (bi !== -1) return 1;\n return a.localeCompare(b);\n });\n\n for (const category of sortedCategories) {\n const items = groups[category];\n if (!items) continue;\n const label =\n category === \"lib\"\n ? \"Libraries\"\n : category === \"base\"\n ? \"Foundation\"\n : \"Components\";\n\n console.log(chalk.bold(`\\n${label}`));\n\n for (const item of items) {\n const deps = item.dependencies?.length\n ? chalk.dim(` (${item.dependencies.length} deps)`)\n : \"\";\n console.log(` ${chalk.cyan(item.name.padEnd(18))} ${item.title}${deps}`);\n }\n }\n\n console.log(\"\");\n console.log(chalk.dim(`Total: ${registry.items.length} items`));\n console.log(chalk.dim(`Install with: ionbit-ui add <name>`));\n console.log(\"\");\n}\n","import { Command } from \"commander\";\n\nimport { add } from \"./commands/add\";\nimport { init } from \"./commands/init\";\nimport { list } from \"./commands/list\";\n\nconst program = new Command();\n\nprogram\n .name(\"ionbit-ui\")\n .description(\n \"Ionbit UI CLI — install source-owned components from the Ionbit UI registry.\",\n )\n .version(\"0.1.14\");\n\nprogram\n .command(\"init\")\n .description(\n \"Initialize Ionbit UI in your project. Creates a ionbit-ui.config.json and installs design tokens.\",\n )\n .option(\"-y, --yes\", \"Skip confirmation prompts and use defaults\")\n .option(\"-f, --force\", \"Force overwrite of existing configuration\")\n .option(\n \"--pointer\",\n \"Add cursor: pointer CSS for buttons (Tailwind v4 defaults to cursor: default)\",\n )\n .action(init);\n\nprogram\n .command(\"add <components...>\")\n .description(\n \"Add components to your project. e.g. ionbit-ui add button card accordion\",\n )\n .option(\"-o, --overwrite\", \"Overwrite existing files\")\n .action(add);\n\nprogram\n .command(\"list\")\n .description(\"List all available components in the registry.\")\n .action(list);\n\nprogram.parse();\n"],"names":["__dirname"],"mappings":";;;;;;;AAAO,MAAM,eACX;AAEK,MAAM,oBACX;AAyCK,MAAM,iBAAyB;AAAA,EACpC,SAAS;AAAA,EACT,OAAO;AAAA,EACP,UAAU;AAAA,IACR,KAAK;AAAA,IACL,cAAc;AAAA,EAAA;AAAA,EAEhB,SAAS;AAAA,IACP,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,KAAK;AAAA,IACL,QAAQ;AAAA,EAAA;AAEZ;AAEO,MAAM,cAAc;ACrDpB,SAAS,WAAW,MAAM,QAAQ,OAAsB;AAC7D,QAAM,aAAa,QAAQ,KAAK,WAAW;AAC3C,MAAI,CAAC,WAAW,UAAU,EAAG,QAAO;AACpC,SAAO,KAAK,MAAM,aAAa,YAAY,OAAO,CAAC;AACrD;AAEO,SAAS,WAAW,QAAgB,MAAM,QAAQ,OAAa;AACpE,QAAM,aAAa,QAAQ,KAAK,WAAW;AAC3C,gBAAc,YAAY,KAAK,UAAU,QAAQ,MAAM,CAAC,IAAI,IAAI;AAClE;AAEO,SAAS,UAAU,UAAwB;AAChD,QAAM,MAAM,QAAQ,QAAQ;AAC5B,MAAI,CAAC,WAAW,GAAG,aAAa,KAAK,EAAE,WAAW,MAAM;AAC1D;AAEO,SAAS,UAAU,UAAkB,SAAuB;AACjE,YAAU,QAAQ;AAClB,gBAAc,UAAU,OAAO;AACjC;AAEO,SAAS,kBACd,QACA,QACA,MAAM,QAAQ,OACN;A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ACF,EACC,OAAO,IAAI;AAEd,QACG,QAAQ,qBAAqB,EAC7B;AAAA,EACC;AACF,EACC,OAAO,mBAAmB,0BAA0B,EACpD,OAAO,GAAG;AAEb,QACG,QAAQ,MAAM,EACd,YAAY,gDAAgD,EAC5D,OAAO,IAAI;AAEd,QAAQ,MAAA;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/config.ts","../src/utils/fs.ts","../src/utils/npm.ts","../src/utils/registry.ts","../src/commands/add.ts","../src/commands/init.ts","../src/commands/list.ts","../src/commands/theme.ts","../src/index.ts"],"sourcesContent":["export const REGISTRY_URL =\n \"https://raw.githubusercontent.com/rostislaw9/ionbit-ui/main/registry.json\";\n\nexport const REGISTRY_ITEM_URL =\n \"https://raw.githubusercontent.com/rostislaw9/ionbit-ui/main/registry/items\";\nexport const THEME_REGISTRY_URL =\n \"https://raw.githubusercontent.com/rostislaw9/ionbit-ui/main/registry/themes.json\";\n\nexport interface RegistryItem {\n name: string;\n type: string;\n title: string;\n description: string;\n dependencies?: string[];\n devDependencies?: string[];\n registryDependencies?: string[];\n files: RegistryFile[];\n}\n\nexport interface RegistryFile {\n path: string;\n type: string;\n content: string;\n}\n\nexport interface Registry {\n $schema: string;\n name: string;\n homepage: string;\n items: RegistryItem[];\n}\n\nexport interface ThemeEntry {\n id: string;\n label: string;\n description: string;\n css: string;\n}\n\nexport interface ThemeRegistry {\n themes: ThemeEntry[];\n}\n\nexport interface Config {\n $schema: string;\n style: string;\n tailwind: {\n css: string;\n cssVariables: boolean;\n };\n aliases: {\n components: string;\n motion: string;\n lib: string;\n styles: string;\n };\n}\n\nexport const DEFAULT_CONFIG: Config = {\n $schema: \"https://ui.shadcn.com/schema/registry.json\",\n style: \"digital\",\n tailwind: {\n css: \"src/index.css\",\n cssVariables: true,\n },\n aliases: {\n components: \"src/components/ui\",\n motion: \"src/components/motion\",\n lib: \"src/lib\",\n styles: \"src/styles\",\n },\n};\n\nexport const CONFIG_FILE = \"ionbit-ui.config.json\";\n","import type { Config } from \"../config\";\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\n\nimport { CONFIG_FILE } from \"../config\";\n\nexport function loadConfig(cwd = process.cwd()): Config | null {\n const configPath = resolve(cwd, CONFIG_FILE);\n if (!existsSync(configPath)) return null;\n return JSON.parse(readFileSync(configPath, \"utf-8\")) as Config;\n}\n\nexport function saveConfig(config: Config, cwd = process.cwd()): void {\n const configPath = resolve(cwd, CONFIG_FILE);\n writeFileSync(configPath, JSON.stringify(config, null, 2) + \"\\n\");\n}\n\nexport function ensureDir(filePath: string): void {\n const dir = dirname(filePath);\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n}\n\nexport function writeFile(filePath: string, content: string): void {\n ensureDir(filePath);\n writeFileSync(filePath, content);\n}\n\nexport function resolveTargetPath(\n target: string,\n config: Config,\n cwd = process.cwd(),\n): string {\n // Map registry target paths to the user's configured aliases.\n // e.g. \"components/ui/button.tsx\" -> \"{cwd}/components/ui/button.tsx\"\n // \"components/motion/spotlight.tsx\" -> \"{cwd}/components/motion/spotlight.tsx\"\n // \"lib/utils.ts\" -> \"{cwd}/lib/utils.ts\"\n // \"styles/tokens.css\" -> \"{cwd}/styles/tokens.css\"\n let resolved = target;\n\n if (target.startsWith(\"components/ui/\")) {\n resolved = target.replace(\n \"components/ui/\",\n config.aliases.components + \"/\",\n );\n } else if (target.startsWith(\"components/motion/\")) {\n resolved = target.replace(\n \"components/motion/\",\n config.aliases.motion + \"/\",\n );\n } else if (target.startsWith(\"lib/\")) {\n resolved = target.replace(\"lib/\", config.aliases.lib + \"/\");\n } else if (target.startsWith(\"styles/\")) {\n resolved = target.replace(\"styles/\", config.aliases.styles + \"/\");\n }\n\n return resolve(cwd, resolved);\n}\n","import { execSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nexport type PackageManager = \"npm\" | \"pnpm\" | \"yarn\" | \"bun\";\n\nexport function detectPackageManager(cwd: string): PackageManager {\n if (existsSync(resolve(cwd, \"bun.lockb\"))) return \"bun\";\n if (existsSync(resolve(cwd, \"bun.lock\"))) return \"bun\";\n if (existsSync(resolve(cwd, \"pnpm-lock.yaml\"))) return \"pnpm\";\n if (existsSync(resolve(cwd, \"yarn.lock\"))) return \"yarn\";\n return \"npm\";\n}\n\nexport function installNpmDeps(deps: string[], cwd: string): void {\n if (deps.length === 0) return;\n const pm = detectPackageManager(cwd);\n const cmd =\n pm === \"pnpm\"\n ? `pnpm add ${deps.join(\" \")}`\n : pm === \"yarn\"\n ? `yarn add ${deps.join(\" \")}`\n : pm === \"bun\"\n ? `bun add ${deps.join(\" \")}`\n : `npm install ${deps.join(\" \")}`;\n execSync(cmd, { cwd, stdio: \"inherit\" });\n}\n","import type { Registry, RegistryItem, ThemeRegistry } from \"../config\";\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { REGISTRY_ITEM_URL, REGISTRY_URL, THEME_REGISTRY_URL } from \"../config\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\n/**\n * Find the registry.json — checks local paths first, then falls back to the\n * remote GitHub URL. This allows development/testing without pushing to GitHub.\n */\nfunction findLocalRegistry(): string | null {\n const candidates = [\n // Relative to cwd (user's project)\n resolve(process.cwd(), \"registry.json\"),\n // Relative to CLI dist (packages/cli/dist -> ../../../registry.json)\n resolve(__dirname, \"../../../registry.json\"),\n // Relative to CLI src/utils (packages/cli/src/utils -> ../../../../registry.json)\n resolve(__dirname, \"../../../../registry.json\"),\n ];\n for (const p of candidates) {\n if (existsSync(p)) return p;\n }\n return null;\n}\n\nfunction findLocalRegistryItem(name: string): string | null {\n const candidates = [\n resolve(process.cwd(), \"registry/items\", `${name}.json`),\n resolve(__dirname, \"../../../registry/items\", `${name}.json`),\n resolve(__dirname, \"../../../../registry/items\", `${name}.json`),\n ];\n for (const p of candidates) {\n if (existsSync(p)) return p;\n }\n return null;\n}\n\nfunction findLocalThemes(): string | null {\n const candidates = [\n resolve(process.cwd(), \"registry/themes.json\"),\n resolve(__dirname, \"../../../registry/themes.json\"),\n resolve(__dirname, \"../../../../registry/themes.json\"),\n ];\n for (const p of candidates) {\n if (existsSync(p)) return p;\n }\n return null;\n}\n\nexport async function fetchRegistry(): Promise<Registry> {\n const localPath = findLocalRegistry();\n if (localPath) {\n return JSON.parse(readFileSync(localPath, \"utf-8\")) as Registry;\n }\n\n const res = await fetch(REGISTRY_URL);\n if (!res.ok) {\n throw new Error(\n `Failed to fetch registry: ${res.status} ${res.statusText}`,\n );\n }\n return (await res.json()) as Registry;\n}\n\nexport async function fetchRegistryItem(name: string): Promise<RegistryItem> {\n const localPath = findLocalRegistryItem(name);\n if (localPath) {\n return JSON.parse(readFileSync(localPath, \"utf-8\")) as RegistryItem;\n }\n\n const res = await fetch(`${REGISTRY_ITEM_URL}/${name}.json`);\n if (!res.ok) {\n throw new Error(\n `Failed to fetch registry item \"${name}\": ${res.status} ${res.statusText}`,\n );\n }\n return (await res.json()) as RegistryItem;\n}\n\nexport async function fetchRegistryItems(\n names: string[],\n): Promise<RegistryItem[]> {\n return Promise.all(names.map(fetchRegistryItem));\n}\n\nexport async function fetchThemeRegistry(): Promise<ThemeRegistry> {\n const localPath = findLocalThemes();\n if (localPath) {\n return JSON.parse(readFileSync(localPath, \"utf-8\")) as ThemeRegistry;\n }\n\n const res = await fetch(THEME_REGISTRY_URL);\n if (!res.ok) {\n throw new Error(\n `Failed to fetch theme registry: ${res.status} ${res.statusText}`,\n );\n }\n return (await res.json()) as ThemeRegistry;\n}\n","import type { Config, RegistryItem } from \"../config\";\n\nimport chalk from \"chalk\";\nimport { existsSync } from \"node:fs\";\n\nimport { loadConfig, resolveTargetPath, writeFile } from \"../utils/fs\";\nimport { installNpmDeps } from \"../utils/npm\";\nimport { fetchRegistry, fetchRegistryItems } from \"../utils/registry\";\n\nexport async function add(\n components: string[],\n options: { overwrite?: boolean },\n): Promise<void> {\n const cwd = process.cwd();\n const config = loadConfig(cwd);\n\n if (!config) {\n console.log(\n chalk.red(\"No ionbit-ui.config.json found. Run `ionbit-ui init` first.\"),\n );\n process.exit(1);\n }\n\n // Fetch the full registry to resolve names and dependencies\n const registry = await fetchRegistry();\n const allNames = new Set(registry.items.map((i) => i.name));\n\n // Validate requested components\n for (const name of components) {\n if (!allNames.has(name)) {\n console.log(\n chalk.red(\n `Component \"${name}\" not found in registry. Run \\`ionbit-ui list\\` to see available components.`,\n ),\n );\n process.exit(1);\n }\n }\n\n // Resolve transitive registry dependencies\n const toInstall = resolveDependencies(components, registry.items);\n\n console.log(chalk.dim(`Installing ${toInstall.length} item(s)...`));\n console.log(\"\");\n\n // Fetch all items with embedded content\n const items = await fetchRegistryItems(toInstall);\n\n for (const item of items) {\n await installItem(item, config, cwd, options.overwrite ?? false);\n }\n\n // Collect and install npm dependencies\n const npmDeps = new Set<string>();\n for (const item of items) {\n for (const dep of item.dependencies ?? []) {\n npmDeps.add(dep);\n }\n }\n\n if (npmDeps.size > 0) {\n console.log(\"\");\n installNpmDeps([...npmDeps], cwd);\n }\n\n console.log(\"\");\n console.log(chalk.green(`✓ Added ${items.length} component(s).`));\n}\n\nfunction resolveDependencies(\n names: string[],\n allItems: { name: string; registryDependencies?: string[] }[],\n): string[] {\n const resolved = new Set<string>();\n const queue = [...names];\n\n while (queue.length > 0) {\n const name = queue.shift()!;\n if (resolved.has(name)) continue;\n resolved.add(name);\n\n const item = allItems.find((i) => i.name === name);\n if (item?.registryDependencies) {\n for (const dep of item.registryDependencies) {\n if (!resolved.has(dep)) queue.push(dep);\n }\n }\n }\n\n return [...resolved];\n}\n\nasync function installItem(\n item: RegistryItem,\n config: Config,\n cwd: string,\n overwrite: boolean,\n): Promise<void> {\n for (const file of item.files) {\n const targetPath = resolveTargetPath(file.path, config, cwd);\n\n if (existsSync(targetPath) && !overwrite) {\n console.log(\n chalk.yellow(\n ` ⚠ ${file.path} already exists — skipping (use --overwrite)`,\n ),\n );\n continue;\n }\n\n writeFile(targetPath, file.content);\n console.log(chalk.green(` ✓ ${file.path}`));\n }\n}\n","import type { Config, RegistryItem } from \"../config\";\n\nimport chalk from \"chalk\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { relative, resolve } from \"node:path\";\n\nimport { CONFIG_FILE, DEFAULT_CONFIG } from \"../config\";\nimport { resolveTargetPath, saveConfig, writeFile } from \"../utils/fs\";\nimport { installNpmDeps } from \"../utils/npm\";\nimport { fetchRegistryItems } from \"../utils/registry\";\n\nconst CURSOR_CSS = `@layer base {\n button:not(:disabled),\n [role=\"button\"]:not(:disabled) {\n cursor: pointer;\n }\n}`;\n\n/** Items that every project needs — installed automatically during init. */\nconst BASE_ITEMS = [\"cn\", \"tokens\"];\n\nexport async function init(options: {\n yes?: boolean;\n force?: boolean;\n pointer?: boolean;\n}): Promise<void> {\n const cwd = process.cwd();\n const configPath = resolve(cwd, CONFIG_FILE);\n\n if (existsSync(configPath) && !options.force) {\n console.log(\n chalk.yellow(\n `${CONFIG_FILE} already exists. Use --force to reinitialize.`,\n ),\n );\n return;\n }\n\n const config: Config = { ...DEFAULT_CONFIG };\n\n saveConfig(config, cwd);\n console.log(chalk.green(`✓ Created ${CONFIG_FILE}`));\n\n // Create directory structure\n const dirs = [\n config.aliases.components,\n config.aliases.motion,\n config.aliases.lib,\n config.aliases.styles,\n ];\n\n for (const dir of dirs) {\n const dirPath = resolve(cwd, dir);\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n console.log(chalk.dim(` Created ${dir}/`));\n }\n }\n\n // Install base items (cn utility + design tokens)\n console.log(chalk.dim(\"Installing base items (cn, tokens)...\"));\n const items = await fetchRegistryItems(BASE_ITEMS);\n for (const item of items) {\n installBaseItem(item, config, cwd);\n }\n\n // Add token CSS imports to the user's stylesheet\n setupCssImports(config, cwd);\n\n // Collect and install npm dependencies for base items\n const npmDeps = new Set<string>();\n for (const item of items) {\n for (const dep of item.dependencies ?? []) {\n npmDeps.add(dep);\n }\n }\n installNpmDeps([...npmDeps], cwd);\n\n // Optionally add cursor: pointer CSS\n if (options.pointer) {\n const cssPath = resolve(cwd, config.tailwind.css);\n if (existsSync(cssPath)) {\n const existing = readFileSync(cssPath, \"utf-8\");\n if (!existing.includes(\"cursor: pointer\")) {\n writeFileSync(cssPath, existing + \"\\n\" + CURSOR_CSS);\n console.log(\n chalk.green(`✓ Added cursor: pointer to ${config.tailwind.css}`),\n );\n } else {\n console.log(\n chalk.dim(\n ` ${config.tailwind.css} already has cursor: pointer — skipping`,\n ),\n );\n }\n } else {\n writeFileSync(cssPath, CURSOR_CSS);\n console.log(\n chalk.green(`✓ Created ${config.tailwind.css} with cursor: pointer`),\n );\n }\n }\n\n console.log(\"\");\n console.log(chalk.bold(\"Ionbit UI initialized!\"));\n console.log(\"\");\n console.log(chalk.dim(\"Next steps:\"));\n console.log(` ${chalk.cyan(\"ionbit-ui add button\")} — add a component`);\n console.log(\n ` ${chalk.cyan(\"ionbit-ui list\")} — browse available components`,\n );\n console.log(\"\");\n}\n\nfunction installBaseItem(\n item: RegistryItem,\n config: Config,\n cwd: string,\n): void {\n for (const file of item.files) {\n const targetPath = resolveTargetPath(file.path, config, cwd);\n if (existsSync(targetPath)) {\n console.log(chalk.dim(` ⚠ ${file.path} already exists — skipping`));\n continue;\n }\n writeFile(targetPath, file.content);\n console.log(chalk.green(` ✓ ${file.path}`));\n }\n}\n\nfunction setupCssImports(config: Config, cwd: string): void {\n const cssPath = resolve(cwd, config.tailwind.css);\n const stylesDir = config.aliases.styles;\n\n // Build the import lines relative to the CSS file's directory\n const tokensImport = `@import \"./${relativePath(cssPath, resolve(cwd, stylesDir, \"tokens.css\"))}\";`;\n const baseImport = `@import \"./${relativePath(cssPath, resolve(cwd, stylesDir, \"base.css\"))}\";`;\n const utilitiesImport = `@import \"./${relativePath(cssPath, resolve(cwd, stylesDir, \"utilities.css\"))}\";`;\n\n if (!existsSync(cssPath)) {\n // Create the CSS file with token imports\n const content = `@import \"tailwindcss\";\\n\\n${tokensImport}\\n${baseImport}\\n${utilitiesImport}\\n`;\n writeFileSync(cssPath, content);\n console.log(\n chalk.green(`✓ Created ${config.tailwind.css} with token imports`),\n );\n return;\n }\n\n const existing = readFileSync(cssPath, \"utf-8\");\n const lines: string[] = [];\n\n if (!existing.includes(\"tokens.css\")) {\n lines.push(tokensImport);\n }\n if (!existing.includes(\"base.css\")) {\n lines.push(baseImport);\n }\n if (!existing.includes(\"utilities.css\")) {\n lines.push(utilitiesImport);\n }\n\n if (lines.length > 0) {\n // Add imports after @import \"tailwindcss\" if present, otherwise at the top\n let updated: string;\n if (existing.includes('@import \"tailwindcss\"')) {\n updated = existing.replace(\n /(@import\\s+\"tailwindcss\"[^\\n]*)/,\n `$1\\n${lines.join(\"\\n\")}`,\n );\n } else {\n updated = lines.join(\"\\n\") + \"\\n\" + existing;\n }\n writeFileSync(cssPath, updated);\n console.log(chalk.green(`✓ Added token imports to ${config.tailwind.css}`));\n } else {\n console.log(\n chalk.dim(\n ` ${config.tailwind.css} already has token imports — skipping`,\n ),\n );\n }\n}\n\nfunction relativePath(from: string, to: string): string {\n let rel = relative(from, to).replace(/\\\\/g, \"/\");\n // Remove the leading \"../\" if the CSS file is in the same or parent directory\n if (rel.startsWith(\"../\")) rel = rel.slice(3);\n return rel;\n}\n","import chalk from \"chalk\";\n\nimport { fetchRegistry } from \"../utils/registry\";\n\nexport async function list(): Promise<void> {\n const registry = await fetchRegistry();\n\n const groups: Record<string, typeof registry.items> = {};\n\n for (const item of registry.items) {\n const category = item.type.replace(\"registry:\", \"\");\n if (!groups[category]) groups[category] = [];\n groups[category].push(item);\n }\n\n const categoryOrder = [\"lib\", \"base\", \"ui\"];\n const sortedCategories = Object.keys(groups).sort((a, b) => {\n const ai = categoryOrder.indexOf(a);\n const bi = categoryOrder.indexOf(b);\n if (ai !== -1 && bi !== -1) return ai - bi;\n if (ai !== -1) return -1;\n if (bi !== -1) return 1;\n return a.localeCompare(b);\n });\n\n for (const category of sortedCategories) {\n const items = groups[category];\n if (!items) continue;\n const label =\n category === \"lib\"\n ? \"Libraries\"\n : category === \"base\"\n ? \"Foundation\"\n : \"Components\";\n\n console.log(chalk.bold(`\\n${label}`));\n\n for (const item of items) {\n const deps = item.dependencies?.length\n ? chalk.dim(` (${item.dependencies.length} deps)`)\n : \"\";\n console.log(` ${chalk.cyan(item.name.padEnd(18))} ${item.title}${deps}`);\n }\n }\n\n console.log(\"\");\n console.log(chalk.dim(`Total: ${registry.items.length} items`));\n console.log(chalk.dim(`Install with: ionbit-ui add <name>`));\n console.log(\"\");\n}\n","import type { Config, ThemeEntry } from \"../config\";\n\nimport chalk from \"chalk\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, relative, resolve } from \"node:path\";\n\nimport { ensureDir, loadConfig } from \"../utils/fs\";\nimport { fetchThemeRegistry } from \"../utils/registry\";\n\ninterface CustomTheme {\n dark: Record<string, string>;\n light: Record<string, string>;\n radius: Record<string, string>;\n settings: Record<string, string | number>;\n}\n\nexport async function theme(\n id: string | undefined,\n options: { custom?: string; overwrite?: boolean },\n): Promise<void> {\n const cwd = process.cwd();\n const config = loadConfig(cwd);\n\n if (!config) {\n console.log(\n chalk.red(\"No ionbit-ui.config.json found. Run `ionbit-ui init` first.\"),\n );\n process.exitCode = 1;\n return;\n }\n\n if (id && options.custom) {\n console.log(chalk.red(\"Choose a preset theme or --custom, not both.\"));\n process.exitCode = 1;\n return;\n }\n\n let css: string;\n let label: string;\n if (options.custom) {\n let custom: CustomTheme;\n try {\n custom = JSON.parse(options.custom) as CustomTheme;\n validateCustomTheme(custom);\n } catch (error) {\n const message = error instanceof Error ? error.message : \"invalid JSON\";\n console.log(chalk.red(`Invalid custom theme: ${message}`));\n process.exitCode = 1;\n return;\n }\n label = \"Custom\";\n css = generateThemeCss(custom, label);\n } else {\n if (!id) {\n console.log(chalk.red(\"Provide a theme id or use --custom <json>.\"));\n process.exitCode = 1;\n return;\n }\n const registry = await fetchThemeRegistry();\n const preset = registry.themes.find((entry) => entry.id === id);\n if (!preset) {\n printThemeError(id, registry.themes);\n process.exitCode = 1;\n return;\n }\n label = preset.label;\n css = preset.css;\n }\n\n const themePath = resolve(cwd, config.aliases.styles, \"theme.css\");\n if (existsSync(themePath) && !options.overwrite) {\n console.log(\n chalk.yellow(\n `${config.aliases.styles}/theme.css already exists. Use --overwrite to replace it.`,\n ),\n );\n process.exitCode = 1;\n return;\n }\n\n ensureDir(themePath);\n writeFileSync(themePath, css + \"\\n\");\n addThemeImport(config, cwd, themePath);\n console.log(chalk.green(`✓ Installed ${label} theme`));\n console.log(chalk.dim(` ${config.aliases.styles}/theme.css`));\n}\n\nfunction printThemeError(id: string, themes: ThemeEntry[]): void {\n console.log(chalk.red(`Theme \"${id}\" not found. Available themes:`));\n console.log(themes.map((entry) => ` ${entry.id}`).join(\"\\n\"));\n}\n\nfunction validateCustomTheme(themeConfig: CustomTheme): void {\n for (const mode of [\"dark\", \"light\"] as const) {\n if (!themeConfig[mode] || typeof themeConfig[mode] !== \"object\") {\n throw new Error(`missing ${mode} colors`);\n }\n }\n if (!themeConfig.radius || !themeConfig.settings) {\n throw new Error(\"missing radius or settings\");\n }\n}\n\nfunction addThemeImport(config: Config, cwd: string, themePath: string): void {\n const cssPath = resolve(cwd, config.tailwind.css);\n const importPath = relative(dirname(cssPath), themePath).replace(/\\\\/g, \"/\");\n const importLine = `@import \"./${importPath}\";`;\n const existing = existsSync(cssPath) ? readFileSync(cssPath, \"utf-8\") : \"\";\n\n if (!existing.includes(importLine)) {\n writeFileSync(cssPath, `${existing.trimEnd()}\\n${importLine}\\n`);\n }\n}\n\nfunction colorMix(color: string, amount: number): string {\n return `color-mix(in oklab, ${color} ${amount}%, transparent)`;\n}\n\nfunction hoverColor(color: string): string {\n return `color-mix(in oklab, ${color} 88%, black)`;\n}\n\nfunction colorsToCss(\n colors: Record<string, string>,\n translucency: number,\n light: boolean,\n): string {\n const muted = Math.round(translucency * 160);\n const subtle = Math.round(translucency * 80);\n const borderBase = light ? \"0 0 0\" : \"1 0 0\";\n return [\n ` --background: ${colors.background};`,\n ` --surface: ${colors.surface};`,\n ` --surface-elevated: ${colors.surfaceElevated};`,\n ` --surface-hover: ${colors.surfaceHover};`,\n ` --foreground: ${colors.foreground};`,\n ` --foreground-muted: ${colors.foregroundMuted};`,\n ` --foreground-subtle: ${colors.foregroundSubtle};`,\n ` --accent: ${colors.accent};`,\n ` --accent-hover: ${colors.accentHover};`,\n ` --accent-foreground: ${colors.accentForeground};`,\n ` --accent-muted: ${colorMix(colors.accent!, muted)};`,\n ` --accent-subtle: ${colorMix(colors.accent!, subtle)};`,\n ...statusCss(\"success\", colors.success!, muted, subtle, light, \"155\"),\n ...statusCss(\"warning\", colors.warning!, muted, subtle, light, \"80\"),\n ...statusCss(\"error\", colors.error!, muted, subtle, light, \"5\"),\n ...statusCss(\"info\", colors.info!, muted, subtle, light, \"230\"),\n ` --ring: ${colors.ring};`,\n ` --border: oklch(${borderBase} / ${translucency.toFixed(2)});`,\n ` --border-strong: oklch(${borderBase} / ${(translucency * 1.75).toFixed(2)});`,\n ` --border-accent: ${colorMix(colors.accent!, 50)};`,\n ` --border-error: ${colorMix(colors.error!, 50)};`,\n ` --border-success: ${colorMix(colors.success!, 50)};`,\n ` --border-warning: ${colorMix(colors.warning!, 50)};`,\n ` --border-info: ${colorMix(colors.info!, 50)};`,\n ].join(\"\\n\");\n}\n\nfunction statusCss(\n name: string,\n color: string,\n muted: number,\n subtle: number,\n light: boolean,\n hue: string,\n): string[] {\n return [\n ` --${name}: ${color};`,\n ` --${name}-hover: ${hoverColor(color)};`,\n ` --${name}-muted: ${colorMix(color, muted)};`,\n ` --${name}-subtle: ${colorMix(color, subtle)};`,\n ` --${name}-foreground: ${light ? \"oklch(0.99 0 0)\" : `oklch(0.1 0.03 ${hue})`};`,\n ];\n}\n\nfunction generateThemeCss(theme: CustomTheme, label: string): string {\n const radius = Object.entries(theme.radius)\n .map(([key, value]) => ` --radius-${key}: ${value};`)\n .join(\"\\n\");\n const settings = Object.entries(theme.settings)\n .filter(([key]) => key.endsWith(\"Intensity\"))\n .map(\n ([key, value]) =>\n ` --${key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}: ${value};`,\n )\n .join(\"\\n\");\n const block = (colors: Record<string, string>, light: boolean) =>\n `${light ? \".light\" : \":root\"} {\\n${colorsToCss(colors, Number(theme.settings.translucency), light)}\\n${radius}\\n${settings}\\n}`;\n return `/* Ionbit UI — Theme: ${label} */\\n${block(theme.dark, false)}\\n\\n${block(theme.light, true)}`;\n}\n","import { Command } from \"commander\";\n\nimport { add } from \"./commands/add\";\nimport { init } from \"./commands/init\";\nimport { list } from \"./commands/list\";\nimport { theme } from \"./commands/theme\";\n\nconst program = new Command();\n\nprogram\n .name(\"ionbit-ui\")\n .description(\n \"Ionbit UI CLI — install source-owned components from the Ionbit UI registry.\",\n )\n .version(\"0.1.15\");\n\nprogram\n .command(\"init\")\n .description(\n \"Initialize Ionbit UI in your project. Creates a ionbit-ui.config.json and installs design tokens.\",\n )\n .option(\"-y, --yes\", \"Skip confirmation prompts and use defaults\")\n .option(\"-f, --force\", \"Force overwrite of existing configuration\")\n .option(\n \"--pointer\",\n \"Add cursor: pointer CSS for buttons (Tailwind v4 defaults to cursor: default)\",\n )\n .action(init);\n\nprogram\n .command(\"add <components...>\")\n .description(\n \"Add components to your project. e.g. ionbit-ui add button card accordion\",\n )\n .option(\"-o, --overwrite\", \"Overwrite existing files\")\n .action(add);\n\nprogram\n .command(\"list\")\n .description(\"List all available components in the registry.\")\n .action(list);\n\nprogram\n .command(\"theme [id]\")\n .description(\"Install a preset or custom theme.\")\n .option(\"--custom <json>\", \"Install a custom theme from JSON\")\n .option(\"-o, --overwrite\", \"Overwrite the existing theme.css\")\n .action(theme);\n\nprogram.parse();\n"],"names":["__dirname","theme"],"mappings":";;;;;;;AAAO,MAAM,eACX;AAEK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