kira-kit 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/README.md +132 -43
- package/dist/index.mjs +2472 -0
- package/package.json +38 -17
- package/templates/monorepo/components.json +23 -0
- package/templates/monorepo/package.json +13 -0
- package/templates/monorepo/packages/app/index.html +13 -0
- package/templates/monorepo/packages/app/package.json +27 -0
- package/templates/monorepo/packages/app/src/App.tsx +21 -0
- package/templates/monorepo/packages/app/src/index.css +3 -0
- package/templates/monorepo/packages/app/src/main.tsx +10 -0
- package/templates/monorepo/packages/app/tsconfig.json +8 -0
- package/templates/monorepo/packages/app/vite.config.ts +10 -0
- package/templates/monorepo/packages/ui/package.json +32 -0
- package/templates/monorepo/packages/ui/src/components/ui/welcome.tsx +52 -0
- package/templates/monorepo/packages/ui/src/index.css +123 -0
- package/templates/monorepo/packages/ui/src/index.ts +3 -0
- package/templates/monorepo/packages/ui/src/lib/utils.ts +1 -0
- package/templates/monorepo/packages/ui/tsconfig.json +7 -0
- package/templates/monorepo/tsconfig.json +23 -0
- package/templates/next/app/globals.css +124 -0
- package/templates/next/app/layout.tsx +18 -0
- package/templates/next/app/page.tsx +9 -0
- package/templates/next/components/ui/welcome.tsx +62 -0
- package/templates/next/components.json +23 -0
- package/templates/next/lib/utils.ts +1 -0
- package/templates/next/next-env.d.ts +2 -0
- package/templates/next/next.config.ts +5 -0
- package/templates/next/package.json +28 -0
- package/templates/next/postcss.config.mjs +7 -0
- package/templates/next/tsconfig.json +24 -0
- package/templates/tanstack-start/README.md +16 -0
- package/templates/tanstack-start/components.json +23 -0
- package/templates/tanstack-start/package.json +30 -0
- package/templates/tanstack-start/src/components/ui/welcome.tsx +52 -0
- package/templates/tanstack-start/src/index.css +123 -0
- package/templates/tanstack-start/src/lib/utils.ts +1 -0
- package/templates/tanstack-start/src/router.tsx +15 -0
- package/templates/tanstack-start/src/routes/__root.tsx +41 -0
- package/templates/tanstack-start/src/routes/index.tsx +26 -0
- package/{tsconfig.json → templates/tanstack-start/tsconfig.json} +6 -7
- package/templates/tanstack-start/vite.config.ts +11 -0
- package/templates/vite/components.json +23 -0
- package/templates/vite/index.html +16 -0
- package/templates/vite/package.json +28 -0
- package/templates/vite/src/App.tsx +9 -0
- package/templates/vite/src/components/ui/welcome.tsx +60 -0
- package/templates/vite/src/index.css +124 -0
- package/templates/vite/src/lib/utils.ts +1 -0
- package/templates/vite/src/main.tsx +10 -0
- package/templates/vite/tsconfig.json +29 -0
- package/templates/vite/tsconfig.node.json +22 -0
- package/templates/vite/vite.config.ts +13 -0
- package/bin/kira-kit.js +0 -27329
- package/bun.lock +0 -247
- package/src/commands/add.ts +0 -146
- package/src/commands/build.ts +0 -212
- package/src/commands/init.ts +0 -160
- package/src/commands/list.ts +0 -31
- package/src/index.ts +0 -118
- package/src/lib/build-config.ts +0 -81
- package/src/lib/config.ts +0 -109
- package/src/lib/deps.ts +0 -135
- package/src/lib/file.ts +0 -64
- package/src/lib/logger.ts +0 -102
- package/src/lib/registry.ts +0 -81
- package/src/lib/templates.ts +0 -123
- package/src/lib/theme-generator.ts +0 -246
- package/src/prompts/base-color.ts +0 -20
- package/src/prompts/primary-color.ts +0 -23
- package/src/prompts/project-type.ts +0 -71
- package/src/types.ts +0 -61
package/src/commands/init.ts
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
import { welcome, info, success, warning, dim } from "../lib/logger";
|
|
4
|
-
import { selectBaseColor } from "../prompts/base-color";
|
|
5
|
-
import { selectPrimaryColor } from "../prompts/primary-color";
|
|
6
|
-
import { detectProjectType, inputAlias } from "../prompts/project-type";
|
|
7
|
-
import { writeConfig, readConfig } from "../lib/config";
|
|
8
|
-
import { generateCss } from "../lib/theme-generator";
|
|
9
|
-
import { execSync } from "child_process";
|
|
10
|
-
import type { InitOptions } from "../types";
|
|
11
|
-
|
|
12
|
-
const UTILS_TEMPLATE = `import { type ClassValue, clsx } from "clsx";
|
|
13
|
-
import { twMerge } from "tailwind-merge";
|
|
14
|
-
|
|
15
|
-
export function cn(...inputs: ClassValue[]) {
|
|
16
|
-
return twMerge(clsx(inputs));
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
const COLOR_MAPPING: Record<string, string> = {
|
|
21
|
-
blue: "#3b82f6",
|
|
22
|
-
green: "#22c55e",
|
|
23
|
-
orange: "#f97316",
|
|
24
|
-
pink: "#ec4899",
|
|
25
|
-
purple: "#a855f7",
|
|
26
|
-
red: "#ef4444",
|
|
27
|
-
violet: "#8b5cf6",
|
|
28
|
-
yellow: "#eab308",
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export async function init(options: InitOptions): Promise<void> {
|
|
32
|
-
const cwd = options.cwd || process.cwd();
|
|
33
|
-
|
|
34
|
-
welcome("Kira Kit CLI");
|
|
35
|
-
|
|
36
|
-
const existingConfig = readConfig(cwd);
|
|
37
|
-
if (existingConfig) {
|
|
38
|
-
warning("Kira Kit is already initialized in this project.");
|
|
39
|
-
const inquirer = await import("inquirer");
|
|
40
|
-
const { confirm } = await inquirer.prompt([
|
|
41
|
-
{
|
|
42
|
-
type: "confirm",
|
|
43
|
-
name: "confirm",
|
|
44
|
-
message: "Reinitialize? This will overwrite your config.",
|
|
45
|
-
default: false,
|
|
46
|
-
},
|
|
47
|
-
]);
|
|
48
|
-
if (!confirm) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const baseColor = options.baseColor || (await selectBaseColor());
|
|
54
|
-
const primaryColor = options.primaryColor || (await selectPrimaryColor());
|
|
55
|
-
const projectType = await detectProjectType(cwd);
|
|
56
|
-
|
|
57
|
-
info(`Project type: ${projectType}`);
|
|
58
|
-
info(`Base color: ${baseColor}`);
|
|
59
|
-
info(`Primary color: ${primaryColor}`);
|
|
60
|
-
|
|
61
|
-
const componentsAlias = await inputAlias("components", "@/components");
|
|
62
|
-
const utilsAlias = await inputAlias("utils", "@/lib/utils");
|
|
63
|
-
|
|
64
|
-
const utilsDir = join(cwd, utilsAlias.replace("@/", "src/"));
|
|
65
|
-
const componentsUiDir = join(
|
|
66
|
-
cwd,
|
|
67
|
-
componentsAlias.replace("@/", "src/"),
|
|
68
|
-
"ui",
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
if (!existsSync(utilsDir)) {
|
|
72
|
-
mkdirSync(utilsDir, { recursive: true });
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (!existsSync(componentsUiDir)) {
|
|
76
|
-
mkdirSync(componentsUiDir, { recursive: true });
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const utilsFilePath = join(utilsDir, "cn.ts");
|
|
80
|
-
writeFileSync(utilsFilePath, UTILS_TEMPLATE, "utf-8");
|
|
81
|
-
success(`Created ${utilsAlias}/cn.ts`);
|
|
82
|
-
|
|
83
|
-
const cssFilePath = join(cwd, "src", "index.css");
|
|
84
|
-
|
|
85
|
-
// Resolve primary color to hex
|
|
86
|
-
const primaryHex = COLOR_MAPPING[primaryColor] || primaryColor;
|
|
87
|
-
// Fallback if user somehow passed a value not in mapping and not a valid hex,
|
|
88
|
-
// generateCss will throw or handle it (currently throws if invalid).
|
|
89
|
-
// basic check:
|
|
90
|
-
const isHex = /^#[0-9A-F]{6}$/i.test(primaryHex);
|
|
91
|
-
const colorToUse = isHex ? primaryHex : "#3b82f6"; // Default to blue if invalid
|
|
92
|
-
|
|
93
|
-
if (existsSync(cssFilePath)) {
|
|
94
|
-
const content = readFileSync(cssFilePath, "utf-8");
|
|
95
|
-
const hasVariables = content.includes(":root {");
|
|
96
|
-
if (!hasVariables) {
|
|
97
|
-
const cssContent = generateCss(colorToUse);
|
|
98
|
-
writeFileSync(cssFilePath, cssContent, "utf-8");
|
|
99
|
-
success("Generated src/index.css with dynamic palette");
|
|
100
|
-
}
|
|
101
|
-
} else {
|
|
102
|
-
// Create it if it doesn't exist
|
|
103
|
-
const cssContent = generateCss(colorToUse);
|
|
104
|
-
writeFileSync(cssFilePath, cssContent, "utf-8");
|
|
105
|
-
success("Created src/index.css with dynamic palette");
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
writeConfig(cwd, {
|
|
109
|
-
tailwind: {
|
|
110
|
-
config: "",
|
|
111
|
-
css: "src/index.css",
|
|
112
|
-
baseColor,
|
|
113
|
-
cssVariables: true,
|
|
114
|
-
prefix: "",
|
|
115
|
-
},
|
|
116
|
-
aliases: {
|
|
117
|
-
components: componentsAlias,
|
|
118
|
-
utils: utilsAlias,
|
|
119
|
-
ui: `${componentsAlias}/ui`,
|
|
120
|
-
lib: "@/lib",
|
|
121
|
-
hooks: "@/hooks",
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
success("Created components.json");
|
|
126
|
-
|
|
127
|
-
info("Installing base dependencies...");
|
|
128
|
-
|
|
129
|
-
const packageManager = process.env.BUN_INSTALL
|
|
130
|
-
? "bun"
|
|
131
|
-
: process.env.PNPM_HOME
|
|
132
|
-
? "pnpm"
|
|
133
|
-
: process.env.YARN_ENABLE_IMMUTABLE_CACHE === "false"
|
|
134
|
-
? "yarn"
|
|
135
|
-
: "npm";
|
|
136
|
-
|
|
137
|
-
try {
|
|
138
|
-
execSync(
|
|
139
|
-
`${packageManager} add clsx tailwind-merge class-variance-authority @tabler/icons-react`,
|
|
140
|
-
{
|
|
141
|
-
stdio: "inherit",
|
|
142
|
-
cwd,
|
|
143
|
-
env: { ...process.env, ADBLOCK: "1", DISABLE_OPENCOLLECTIVE: "1" },
|
|
144
|
-
},
|
|
145
|
-
);
|
|
146
|
-
success("Dependencies installed");
|
|
147
|
-
} catch {
|
|
148
|
-
warning("Failed to install dependencies. Please run manually:");
|
|
149
|
-
console.log(
|
|
150
|
-
` ${packageManager} add clsx tailwind-merge class-variance-authority @tabler/icons-react`,
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
console.log("\n");
|
|
155
|
-
success("Kira Kit initialized successfully!");
|
|
156
|
-
console.log("\nNext steps:");
|
|
157
|
-
console.log(` ${dim("Add a component:")} kira-kit add button`);
|
|
158
|
-
console.log(` ${dim("List components:")} kira-kit list`);
|
|
159
|
-
console.log("\n");
|
|
160
|
-
}
|
package/src/commands/list.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { fetchRegistryIndex } from "../lib/registry";
|
|
2
|
-
import { table } from "../lib/logger";
|
|
3
|
-
import { info, error } from "../lib/logger";
|
|
4
|
-
|
|
5
|
-
export async function listComponents(): Promise<void> {
|
|
6
|
-
try {
|
|
7
|
-
info("Fetching registry index...");
|
|
8
|
-
|
|
9
|
-
const index = await fetchRegistryIndex();
|
|
10
|
-
|
|
11
|
-
console.log(`\n📦 Kira Kit Components (${index.components.length} total)\n`);
|
|
12
|
-
|
|
13
|
-
const rows = [
|
|
14
|
-
["Name", "Title", "Dependencies", "Registry Deps"],
|
|
15
|
-
...index.components.map((c) => [
|
|
16
|
-
c.name,
|
|
17
|
-
c.title,
|
|
18
|
-
c.dependencies.length.toString(),
|
|
19
|
-
c.registryDependencies.length.toString(),
|
|
20
|
-
]),
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
table(rows);
|
|
24
|
-
|
|
25
|
-
console.log("\n");
|
|
26
|
-
info("Use 'kira-kit add <component>' to install a component.");
|
|
27
|
-
} catch (err) {
|
|
28
|
-
error("Failed to fetch registry index. Make sure you're connected to the internet.");
|
|
29
|
-
console.error(err);
|
|
30
|
-
}
|
|
31
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { spawn } from "child_process";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { dirname, resolve } from "path";
|
|
5
|
-
import { init } from "./commands/init";
|
|
6
|
-
import { addComponents } from "./commands/add";
|
|
7
|
-
import { buildRegistry } from "./commands/build";
|
|
8
|
-
import { listComponents } from "./commands/list";
|
|
9
|
-
import type { InitOptions, AddOptions } from "./types";
|
|
10
|
-
|
|
11
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
-
const __dirname = dirname(__filename);
|
|
13
|
-
|
|
14
|
-
const program = new Command();
|
|
15
|
-
|
|
16
|
-
program
|
|
17
|
-
.name("kira-kit")
|
|
18
|
-
.description("CLI tool for Kira Kit - Component library and project scaffolding")
|
|
19
|
-
.version("1.0.0");
|
|
20
|
-
|
|
21
|
-
program
|
|
22
|
-
.command("create [name]")
|
|
23
|
-
.description("Create a new project with Kira Kit")
|
|
24
|
-
.option("-f, --framework <type>", "Framework: nextjs, vite-react, vite-router, remix")
|
|
25
|
-
.option("--router <type>", "Router type for vite-router: file, code")
|
|
26
|
-
.option("--install", "Install dependencies")
|
|
27
|
-
.option("--no-install", "Don't install dependencies")
|
|
28
|
-
.option("--git", "Initialize Git repository")
|
|
29
|
-
.option("--no-git", "Don't initialize Git")
|
|
30
|
-
.action((name: string | undefined, options: Record<string, unknown>) => {
|
|
31
|
-
const createPath = resolve(__dirname, "..", "..", "create", "node_modules", "tsx", "cli.js");
|
|
32
|
-
const createSrcPath = resolve(__dirname, "..", "..", "create", "src", "index.ts");
|
|
33
|
-
|
|
34
|
-
const args = [createSrcPath];
|
|
35
|
-
if (name) args.push(name);
|
|
36
|
-
if (options.framework) args.push("--framework", String(options.framework));
|
|
37
|
-
if (options.router) args.push("--router", String(options.router));
|
|
38
|
-
if (options.install === true) args.push("--install");
|
|
39
|
-
if (options.install === false) args.push("--no-install");
|
|
40
|
-
if (options.git === true) args.push("--git");
|
|
41
|
-
if (options.git === false) args.push("--no-git");
|
|
42
|
-
|
|
43
|
-
const child = spawn(
|
|
44
|
-
process.execPath,
|
|
45
|
-
[createPath, ...args],
|
|
46
|
-
{
|
|
47
|
-
stdio: "inherit",
|
|
48
|
-
cwd: process.cwd(),
|
|
49
|
-
env: process.env,
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
child.on("exit", (code) => {
|
|
54
|
-
process.exit(code ?? 0);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
program
|
|
59
|
-
.command("init")
|
|
60
|
-
.description("Initialize Kira Kit in your project")
|
|
61
|
-
.option("-c, --cwd <directory>", "Working directory", process.cwd())
|
|
62
|
-
.option("--base-color <color>", "Base color (slate, gray, zinc, neutral, stone)")
|
|
63
|
-
.option("--primary-color <color>", "Primary color (blue, green, orange, pink, purple, red, violet, yellow)")
|
|
64
|
-
.option("-y, --yes", "Skip prompts and use defaults")
|
|
65
|
-
.action(async (options: InitOptions) => {
|
|
66
|
-
try {
|
|
67
|
-
await init(options);
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error(error);
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
program
|
|
75
|
-
.command("add")
|
|
76
|
-
.description("Add component(s) to your project")
|
|
77
|
-
.argument("[components...]", "Component names to add")
|
|
78
|
-
.option("-c, --cwd <directory>", "Working directory", process.cwd())
|
|
79
|
-
.option("-o, --overwrite", "Overwrite existing files")
|
|
80
|
-
.option("-y, --yes", "Skip prompts")
|
|
81
|
-
.option("--all", "Add all components")
|
|
82
|
-
.action(async (components: string[], options: AddOptions) => {
|
|
83
|
-
try {
|
|
84
|
-
await addComponents({
|
|
85
|
-
...options,
|
|
86
|
-
components,
|
|
87
|
-
});
|
|
88
|
-
} catch (error) {
|
|
89
|
-
console.error(error);
|
|
90
|
-
process.exit(1);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
program
|
|
95
|
-
.command("build")
|
|
96
|
-
.description("Build registry files for all components")
|
|
97
|
-
.action(() => {
|
|
98
|
-
try {
|
|
99
|
-
buildRegistry();
|
|
100
|
-
} catch (error) {
|
|
101
|
-
console.error(error);
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
program
|
|
107
|
-
.command("list")
|
|
108
|
-
.description("List all available components in the registry")
|
|
109
|
-
.action(async () => {
|
|
110
|
-
try {
|
|
111
|
-
await listComponents();
|
|
112
|
-
} catch (error) {
|
|
113
|
-
console.error(error);
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
program.parse();
|
package/src/lib/build-config.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
export const NPM_DEPENDENCY_MAP: Record<string, string[]> = {
|
|
2
|
-
"@base-ui/react": ["@base-ui/react"],
|
|
3
|
-
animejs: ["animejs"],
|
|
4
|
-
"class-variance-authority": ["class-variance-authority"],
|
|
5
|
-
"@tabler/icons-react": ["@tabler/icons-react"],
|
|
6
|
-
datefns: ["date-fns"],
|
|
7
|
-
"react-day-picker": ["react-day-picker"],
|
|
8
|
-
"react-resizable-panels": ["react-resizable-panels"],
|
|
9
|
-
"@tanstack/react-table": ["@tanstack/react-table"],
|
|
10
|
-
"@tanstack/react-virtual": ["@tanstack/react-virtual"],
|
|
11
|
-
"@uiw/color-convert": ["@uiw/color-convert"],
|
|
12
|
-
"@uiw/react-color-hue": ["@uiw/react-color-hue"],
|
|
13
|
-
"@uiw/react-color-saturation": ["@uiw/react-color-saturation"],
|
|
14
|
-
"@dnd-kit/core": ["@dnd-kit/core"],
|
|
15
|
-
"@dnd-kit/sortable": ["@dnd-kit/sortable"],
|
|
16
|
-
"@dnd-kit/utilities": ["@dnd-kit/utilities"],
|
|
17
|
-
cmdk: ["cmdk"],
|
|
18
|
-
"embla-carousel-react": ["embla-carousel-react"],
|
|
19
|
-
sonner: ["sonner"],
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const REGISTRY_DEPENDENCY_MAP: Record<string, string[]> = {
|
|
23
|
-
accordion: [],
|
|
24
|
-
alert: [],
|
|
25
|
-
"alert-dialog": ["button"],
|
|
26
|
-
"announcement-bar": [],
|
|
27
|
-
"aspect-ratio": [],
|
|
28
|
-
avatar: [],
|
|
29
|
-
badge: [],
|
|
30
|
-
breadcrumb: [],
|
|
31
|
-
button: [],
|
|
32
|
-
"button-group": ["button"],
|
|
33
|
-
calendar: [],
|
|
34
|
-
card: [],
|
|
35
|
-
carousel: [],
|
|
36
|
-
checkbox: ["label"],
|
|
37
|
-
"color-picker": ["button", "popover", "input", "slider", "tabs"],
|
|
38
|
-
combobox: ["button"],
|
|
39
|
-
command: ["dialog"],
|
|
40
|
-
"context-menu": [],
|
|
41
|
-
"data-table": ["button", "checkbox", "input", "dropdown-menu", "table"],
|
|
42
|
-
"date-picker": ["button", "popover", "calendar"],
|
|
43
|
-
dialog: [],
|
|
44
|
-
drawer: [],
|
|
45
|
-
"dropdown-menu": [],
|
|
46
|
-
empty: [],
|
|
47
|
-
field: ["label"],
|
|
48
|
-
"file-upload": ["button", "dialog"],
|
|
49
|
-
"hover-card": [],
|
|
50
|
-
input: [],
|
|
51
|
-
"input-group": ["input"],
|
|
52
|
-
kbd: [],
|
|
53
|
-
kanban: [],
|
|
54
|
-
label: [],
|
|
55
|
-
menubar: [],
|
|
56
|
-
"navigation-menu": [],
|
|
57
|
-
pagination: ["button"],
|
|
58
|
-
popover: [],
|
|
59
|
-
progress: [],
|
|
60
|
-
"radio-group": ["label"],
|
|
61
|
-
resizable: [],
|
|
62
|
-
select: ["button", "popover"],
|
|
63
|
-
separator: [],
|
|
64
|
-
sidebar: ["button", "separator"],
|
|
65
|
-
skeleton: [],
|
|
66
|
-
slider: [],
|
|
67
|
-
sonner: [],
|
|
68
|
-
spotlight: ["command"],
|
|
69
|
-
stepper: [],
|
|
70
|
-
stats: [],
|
|
71
|
-
"stats-card": [],
|
|
72
|
-
switch: [],
|
|
73
|
-
table: [],
|
|
74
|
-
tabs: [],
|
|
75
|
-
textarea: [],
|
|
76
|
-
timeline: [],
|
|
77
|
-
toggle: [],
|
|
78
|
-
"toggle-group": ["toggle"],
|
|
79
|
-
tooltip: [],
|
|
80
|
-
"tree-view": ["checkbox"],
|
|
81
|
-
};
|
package/src/lib/config.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
import type { ComponentsConfig } from "../types";
|
|
4
|
-
|
|
5
|
-
export const DEFAULT_REGISTRY_URL = "https://kira-kit.vercel.app/r";
|
|
6
|
-
|
|
7
|
-
const DEFAULT_CONFIG = {
|
|
8
|
-
$schema: "https://ui.shadcn.com/schema.json",
|
|
9
|
-
style: "base-nova",
|
|
10
|
-
rsc: false,
|
|
11
|
-
tsx: true,
|
|
12
|
-
registryUrl: DEFAULT_REGISTRY_URL,
|
|
13
|
-
tailwind: {
|
|
14
|
-
config: "",
|
|
15
|
-
css: "src/index.css",
|
|
16
|
-
baseColor: "neutral",
|
|
17
|
-
cssVariables: true,
|
|
18
|
-
prefix: "",
|
|
19
|
-
},
|
|
20
|
-
iconLibrary: "tabler",
|
|
21
|
-
aliases: {
|
|
22
|
-
components: "@/components",
|
|
23
|
-
utils: "@/lib/utils",
|
|
24
|
-
ui: "@/components/ui",
|
|
25
|
-
lib: "@/lib",
|
|
26
|
-
hooks: "@/hooks",
|
|
27
|
-
},
|
|
28
|
-
menuColor: "default",
|
|
29
|
-
menuAccent: "subtle",
|
|
30
|
-
registries: {},
|
|
31
|
-
} as const;
|
|
32
|
-
|
|
33
|
-
export function findConfigFile(cwd: string): string | null {
|
|
34
|
-
const paths = [join(cwd, "components.json"), join(cwd, "kira-kit.json")];
|
|
35
|
-
|
|
36
|
-
for (const path of paths) {
|
|
37
|
-
if (existsSync(path)) {
|
|
38
|
-
return path;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function readConfig(cwd: string): ComponentsConfig | null {
|
|
46
|
-
const configPath = findConfigFile(cwd);
|
|
47
|
-
|
|
48
|
-
if (!configPath) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
const content = readFileSync(configPath, "utf-8");
|
|
54
|
-
return JSON.parse(content) as ComponentsConfig;
|
|
55
|
-
} catch {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function writeConfig(
|
|
61
|
-
cwd: string,
|
|
62
|
-
config: Partial<ComponentsConfig>,
|
|
63
|
-
): void {
|
|
64
|
-
const existingConfig = readConfig(cwd);
|
|
65
|
-
const newConfig = { ...DEFAULT_CONFIG, ...existingConfig, ...config };
|
|
66
|
-
|
|
67
|
-
const configPath = join(cwd, "components.json");
|
|
68
|
-
writeFileSync(configPath, JSON.stringify(newConfig, null, 2) + "\n");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function updateAliases(
|
|
72
|
-
cwd: string,
|
|
73
|
-
aliases: Partial<ComponentsConfig["aliases"]>,
|
|
74
|
-
): void {
|
|
75
|
-
const config = readConfig(cwd);
|
|
76
|
-
|
|
77
|
-
if (!config) {
|
|
78
|
-
throw new Error("No components.json found. Run 'kira-kit init' first.");
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
config.aliases = { ...config.aliases, ...aliases };
|
|
82
|
-
|
|
83
|
-
const configPath = join(cwd, "components.json");
|
|
84
|
-
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function getAliases(cwd: string): ComponentsConfig["aliases"] {
|
|
88
|
-
const config = readConfig(cwd);
|
|
89
|
-
|
|
90
|
-
if (!config) {
|
|
91
|
-
return DEFAULT_CONFIG.aliases;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return config.aliases;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function getRegistryUrl(cwd: string): string {
|
|
98
|
-
const config = readConfig(cwd);
|
|
99
|
-
|
|
100
|
-
if (!config) {
|
|
101
|
-
return "https://kira-kit.vercel.app/r";
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (config.registries && "@kira-kit" in config.registries) {
|
|
105
|
-
return config.registries["@kira-kit"];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return "https://kira-kit.vercel.app/r";
|
|
109
|
-
}
|
package/src/lib/deps.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { execSync } from "child_process";
|
|
2
|
-
import { existsSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import picocolors from "picocolors";
|
|
5
|
-
|
|
6
|
-
const PACKAGE_MANAGER = detectPackageManager();
|
|
7
|
-
|
|
8
|
-
function detectPackageManager(): "bun" | "pnpm" | "npm" | "yarn" {
|
|
9
|
-
const userAgent = process.env.npm_config_user_agent || "";
|
|
10
|
-
|
|
11
|
-
if (userAgent.startsWith("bun")) return "bun";
|
|
12
|
-
if (userAgent.startsWith("pnpm")) return "pnpm";
|
|
13
|
-
if (userAgent.startsWith("yarn")) return "yarn";
|
|
14
|
-
if (userAgent.startsWith("npm")) return "npm";
|
|
15
|
-
|
|
16
|
-
if (process.env.BUN_INSTALL) return "bun";
|
|
17
|
-
if (process.env.PNPM_HOME) return "pnpm";
|
|
18
|
-
if (process.env.YARN_ENABLE_IMMUTABLE_CACHE === "false") return "yarn";
|
|
19
|
-
|
|
20
|
-
return "bun";
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getInstallCmd(dependencies: string[]): string {
|
|
24
|
-
const pkgManager = PACKAGE_MANAGER;
|
|
25
|
-
|
|
26
|
-
switch (pkgManager) {
|
|
27
|
-
case "bun":
|
|
28
|
-
return `bun add ${dependencies.join(" ")}`;
|
|
29
|
-
case "pnpm":
|
|
30
|
-
return `pnpm add ${dependencies.join(" ")}`;
|
|
31
|
-
case "yarn":
|
|
32
|
-
return `yarn add ${dependencies.join(" ")}`;
|
|
33
|
-
default:
|
|
34
|
-
return `npm install ${dependencies.join(" ")}`;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getDevInstallCmd(dependencies: string[]): string {
|
|
39
|
-
const pkgManager = PACKAGE_MANAGER;
|
|
40
|
-
|
|
41
|
-
switch (pkgManager) {
|
|
42
|
-
case "bun":
|
|
43
|
-
return `bun add -D ${dependencies.join(" ")}`;
|
|
44
|
-
case "pnpm":
|
|
45
|
-
return `pnpm add -D ${dependencies.join(" ")}`;
|
|
46
|
-
case "yarn":
|
|
47
|
-
return `yarn add -D ${dependencies.join(" ")}`;
|
|
48
|
-
default:
|
|
49
|
-
return `npm install -D ${dependencies.join(" ")}`;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export async function parseDependencies(
|
|
54
|
-
componentContent: string
|
|
55
|
-
): Promise<string[]> {
|
|
56
|
-
const deps = new Set<string>();
|
|
57
|
-
|
|
58
|
-
const npmPackages = [
|
|
59
|
-
"clsx",
|
|
60
|
-
"tailwind-merge",
|
|
61
|
-
"class-variance-authority",
|
|
62
|
-
"@tabler/icons-react",
|
|
63
|
-
"date-fns",
|
|
64
|
-
"react-day-picker",
|
|
65
|
-
"react-resizable-panels",
|
|
66
|
-
"@tanstack/react-table",
|
|
67
|
-
"@tanstack/react-virtual",
|
|
68
|
-
"@uiw/color-convert",
|
|
69
|
-
"@uiw/react-color-hue",
|
|
70
|
-
"@uiw/react-color-saturation",
|
|
71
|
-
"@dnd-kit/core",
|
|
72
|
-
"@dnd-kit/sortable",
|
|
73
|
-
"@dnd-kit/utilities",
|
|
74
|
-
"cmdk",
|
|
75
|
-
"embla-carousel-react",
|
|
76
|
-
"sonner",
|
|
77
|
-
"animejs",
|
|
78
|
-
"gsap",
|
|
79
|
-
"@gsap/react",
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
for (const pkg of npmPackages) {
|
|
83
|
-
const regex = new RegExp(
|
|
84
|
-
`from\\s+["']${pkg.replace("/", "\\/")}[@^~]?[\\d.]*["']`,
|
|
85
|
-
"g"
|
|
86
|
-
);
|
|
87
|
-
if (regex.test(componentContent)) {
|
|
88
|
-
deps.add(pkg);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
componentContent.includes('from "class-variance-authority"') ||
|
|
94
|
-
componentContent.includes("from 'class-variance-authority'")
|
|
95
|
-
) {
|
|
96
|
-
deps.add("class-variance-authority");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return Array.from(deps).sort();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export async function installDependencies(
|
|
103
|
-
dependencies: string[],
|
|
104
|
-
isDev: boolean = false
|
|
105
|
-
): Promise<void> {
|
|
106
|
-
if (dependencies.length === 0) return;
|
|
107
|
-
|
|
108
|
-
console.log(picocolors.cyan(`Installing dependencies...`));
|
|
109
|
-
|
|
110
|
-
const cmd = isDev
|
|
111
|
-
? getDevInstallCmd(dependencies)
|
|
112
|
-
: getInstallCmd(dependencies);
|
|
113
|
-
|
|
114
|
-
try {
|
|
115
|
-
execSync(cmd, {
|
|
116
|
-
stdio: "inherit",
|
|
117
|
-
cwd: process.cwd(),
|
|
118
|
-
env: { ...process.env, ADBLOCK: "1", DISABLE_OPENCOLLECTIVE: "1" },
|
|
119
|
-
});
|
|
120
|
-
} catch (error) {
|
|
121
|
-
throw new Error(`Failed to install dependencies: ${error}`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function getPackageManager(): string {
|
|
126
|
-
return PACKAGE_MANAGER;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export async function initPackageJson(): Promise<void> {
|
|
130
|
-
const packageJsonPath = join(process.cwd(), "package.json");
|
|
131
|
-
|
|
132
|
-
if (!existsSync(packageJsonPath)) {
|
|
133
|
-
execSync('echo "{}" > package.json', { stdio: "inherit" });
|
|
134
|
-
}
|
|
135
|
-
}
|
package/src/lib/file.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync, mkdirSync, cpSync, rmSync } from "fs";
|
|
2
|
-
import { dirname, join, relative } from "path";
|
|
3
|
-
|
|
4
|
-
export async function readFile(filePath: string): Promise<string> {
|
|
5
|
-
return readFileSync(filePath, "utf-8");
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export async function writeFile(
|
|
9
|
-
filePath: string,
|
|
10
|
-
content: string
|
|
11
|
-
): Promise<void> {
|
|
12
|
-
const dir = dirname(filePath);
|
|
13
|
-
if (!existsSync(dir)) {
|
|
14
|
-
mkdirSync(dir, { recursive: true });
|
|
15
|
-
}
|
|
16
|
-
writeFileSync(filePath, content, "utf-8");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export async function copyFile(
|
|
20
|
-
source: string,
|
|
21
|
-
destination: string
|
|
22
|
-
): Promise<void> {
|
|
23
|
-
const dir = dirname(destination);
|
|
24
|
-
if (!existsSync(dir)) {
|
|
25
|
-
mkdirSync(dir, { recursive: true });
|
|
26
|
-
}
|
|
27
|
-
cpSync(source, destination);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function copyDirectory(
|
|
31
|
-
source: string,
|
|
32
|
-
destination: string
|
|
33
|
-
): Promise<void> {
|
|
34
|
-
if (!existsSync(destination)) {
|
|
35
|
-
mkdirSync(destination, { recursive: true });
|
|
36
|
-
}
|
|
37
|
-
cpSync(source, destination, { recursive: true });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function fileExists(filePath: string): boolean {
|
|
41
|
-
return existsSync(filePath);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export async function removeFile(filePath: string): Promise<void> {
|
|
45
|
-
if (existsSync(filePath)) {
|
|
46
|
-
rmSync(filePath);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export async function removeDirectory(dirPath: string): Promise<void> {
|
|
51
|
-
if (existsSync(dirPath)) {
|
|
52
|
-
rmSync(dirPath, { recursive: true });
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function getRelativePath(from: string, to: string): string {
|
|
57
|
-
return relative(from, to);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function ensureDir(dirPath: string): void {
|
|
61
|
-
if (!existsSync(dirPath)) {
|
|
62
|
-
mkdirSync(dirPath, { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
}
|