@nikala-ui/cli 0.6.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 +39 -0
- package/dist/commands/add.d.ts +9 -0
- package/dist/commands/add.js +89 -0
- package/dist/commands/diff.d.ts +7 -0
- package/dist/commands/diff.js +87 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.js +116 -0
- package/dist/commands/theme.d.ts +5 -0
- package/dist/commands/theme.js +64 -0
- package/dist/commands/validate.d.ts +5 -0
- package/dist/commands/validate.js +38 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +49 -0
- package/dist/types/registry.d.ts +23 -0
- package/dist/types/registry.js +1 -0
- package/dist/utils/add/write-component-files.d.ts +10 -0
- package/dist/utils/add/write-component-files.js +31 -0
- package/dist/utils/cn.d.ts +5 -0
- package/dist/utils/cn.js +18 -0
- package/dist/utils/diff/compare-lines.d.ts +12 -0
- package/dist/utils/diff/compare-lines.js +31 -0
- package/dist/utils/diff/format-diff.d.ts +8 -0
- package/dist/utils/diff/format-diff.js +27 -0
- package/dist/utils/file.d.ts +4 -0
- package/dist/utils/file.js +23 -0
- package/dist/utils/init/configure-alias.d.ts +4 -0
- package/dist/utils/init/configure-alias.js +51 -0
- package/dist/utils/init/setup-css.d.ts +4 -0
- package/dist/utils/init/setup-css.js +57 -0
- package/dist/utils/pkg.d.ts +15 -0
- package/dist/utils/pkg.js +102 -0
- package/dist/utils/registry.d.ts +25 -0
- package/dist/utils/registry.js +123 -0
- package/dist/utils/theme.d.ts +26 -0
- package/dist/utils/theme.js +173 -0
- package/dist/utils/validate/check-config.d.ts +11 -0
- package/dist/utils/validate/check-config.js +47 -0
- package/dist/utils/validate/check-css.d.ts +7 -0
- package/dist/utils/validate/check-css.js +50 -0
- package/dist/utils/validate/check-deps.d.ts +7 -0
- package/dist/utils/validate/check-deps.js +52 -0
- package/package.json +33 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
export const BASE_PALETTES = {
|
|
2
|
+
zinc: {
|
|
3
|
+
lightBg: "#ffffff",
|
|
4
|
+
lightFg: "#09090b",
|
|
5
|
+
darkBg: "#09090b",
|
|
6
|
+
darkFg: "#fafafa",
|
|
7
|
+
lightMuted: "#f4f4f5",
|
|
8
|
+
lightMutedFg: "#71717a",
|
|
9
|
+
darkMuted: "#27272a",
|
|
10
|
+
darkMutedFg: "#a1a1aa",
|
|
11
|
+
lightBorder: "#e4e4e7",
|
|
12
|
+
darkBorder: "#27272a",
|
|
13
|
+
lightRing: "#18181b",
|
|
14
|
+
darkRing: "#d4d4d8",
|
|
15
|
+
},
|
|
16
|
+
slate: {
|
|
17
|
+
lightBg: "#ffffff",
|
|
18
|
+
lightFg: "#020617",
|
|
19
|
+
darkBg: "#020617",
|
|
20
|
+
darkFg: "#f8fafc",
|
|
21
|
+
lightMuted: "#f1f5f9",
|
|
22
|
+
lightMutedFg: "#64748b",
|
|
23
|
+
darkMuted: "#1e293b",
|
|
24
|
+
darkMutedFg: "#94a3b8",
|
|
25
|
+
lightBorder: "#e2e8f0",
|
|
26
|
+
darkBorder: "#1e293b",
|
|
27
|
+
lightRing: "#0f172a",
|
|
28
|
+
darkRing: "#cbd5e1",
|
|
29
|
+
},
|
|
30
|
+
gray: {
|
|
31
|
+
lightBg: "#ffffff",
|
|
32
|
+
lightFg: "#030712",
|
|
33
|
+
darkBg: "#030712",
|
|
34
|
+
darkFg: "#f9fafb",
|
|
35
|
+
lightMuted: "#f3f4f6",
|
|
36
|
+
lightMutedFg: "#6b7280",
|
|
37
|
+
darkMuted: "#1f2937",
|
|
38
|
+
darkMutedFg: "#9ca3af",
|
|
39
|
+
lightBorder: "#e5e7eb",
|
|
40
|
+
darkBorder: "#1f2937",
|
|
41
|
+
lightRing: "#111827",
|
|
42
|
+
darkRing: "#d1d5db",
|
|
43
|
+
},
|
|
44
|
+
neutral: {
|
|
45
|
+
lightBg: "#ffffff",
|
|
46
|
+
lightFg: "#0a0a0a",
|
|
47
|
+
darkBg: "#0a0a0a",
|
|
48
|
+
darkFg: "#fafafa",
|
|
49
|
+
lightMuted: "#f5f5f5",
|
|
50
|
+
lightMutedFg: "#737373",
|
|
51
|
+
darkMuted: "#262626",
|
|
52
|
+
darkMutedFg: "#a3a3a3",
|
|
53
|
+
lightBorder: "#e5e5e5",
|
|
54
|
+
darkBorder: "#262626",
|
|
55
|
+
lightRing: "#171717",
|
|
56
|
+
darkRing: "#d4d4d4",
|
|
57
|
+
},
|
|
58
|
+
stone: {
|
|
59
|
+
lightBg: "#ffffff",
|
|
60
|
+
lightFg: "#0c0a09",
|
|
61
|
+
darkBg: "#0c0a09",
|
|
62
|
+
darkFg: "#fafaf9",
|
|
63
|
+
lightMuted: "#f5f5f4",
|
|
64
|
+
lightMutedFg: "#78716c",
|
|
65
|
+
darkMuted: "#292524",
|
|
66
|
+
darkMutedFg: "#a8a29e",
|
|
67
|
+
lightBorder: "#e7e5e4",
|
|
68
|
+
darkBorder: "#292524",
|
|
69
|
+
lightRing: "#1c1917",
|
|
70
|
+
darkRing: "#d6d3d1",
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
export const PRIMARY_COLORS = {
|
|
74
|
+
wine: { light: "#722f37", dark: "#9e3b47", lightFg: "#ffffff", darkFg: "#ffffff" },
|
|
75
|
+
violet: { light: "#7c3aed", dark: "#8b5cf6", lightFg: "#ffffff", darkFg: "#ffffff" },
|
|
76
|
+
sky: { light: "#0284c7", dark: "#38bdf8", lightFg: "#ffffff", darkFg: "#0f172a" },
|
|
77
|
+
emerald: { light: "#059669", dark: "#34d399", lightFg: "#ffffff", darkFg: "#052e16" },
|
|
78
|
+
rose: { light: "#e11d48", dark: "#fb7185", lightFg: "#ffffff", darkFg: "#ffffff" },
|
|
79
|
+
amber: { light: "#d97706", dark: "#fbbf24", lightFg: "#ffffff", darkFg: "#111827" },
|
|
80
|
+
zinc: { light: "#18181b", dark: "#fafafa", lightFg: "#fafafa", darkFg: "#18181b" },
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Generates Tailwind CSS v4 theme variables based on base palette and primary accent color.
|
|
84
|
+
*/
|
|
85
|
+
export function generateThemeCss(baseColor = "zinc", primaryColor = "wine") {
|
|
86
|
+
const base = BASE_PALETTES[baseColor] || BASE_PALETTES.zinc;
|
|
87
|
+
const primary = PRIMARY_COLORS[primaryColor] || PRIMARY_COLORS.wine;
|
|
88
|
+
return `@import "tailwindcss";
|
|
89
|
+
|
|
90
|
+
@theme inline {
|
|
91
|
+
--color-background: var(--background);
|
|
92
|
+
--color-foreground: var(--foreground);
|
|
93
|
+
--color-card: var(--card);
|
|
94
|
+
--color-card-foreground: var(--card-foreground);
|
|
95
|
+
--color-popover: var(--popover);
|
|
96
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
97
|
+
--color-primary: var(--primary);
|
|
98
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
99
|
+
--color-secondary: var(--secondary);
|
|
100
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
101
|
+
--color-muted: var(--muted);
|
|
102
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
103
|
+
--color-accent: var(--accent);
|
|
104
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
105
|
+
--color-destructive: var(--destructive);
|
|
106
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
107
|
+
--color-border: var(--border);
|
|
108
|
+
--color-input: var(--input);
|
|
109
|
+
--color-ring: var(--ring);
|
|
110
|
+
--radius-lg: var(--radius);
|
|
111
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
112
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:root {
|
|
116
|
+
color-scheme: light;
|
|
117
|
+
--background: ${base.lightBg};
|
|
118
|
+
--foreground: ${base.lightFg};
|
|
119
|
+
--card: ${base.lightBg};
|
|
120
|
+
--card-foreground: ${base.lightFg};
|
|
121
|
+
--popover: ${base.lightBg};
|
|
122
|
+
--popover-foreground: ${base.lightFg};
|
|
123
|
+
--primary: ${primary.light};
|
|
124
|
+
--primary-foreground: ${primary.lightFg};
|
|
125
|
+
--secondary: ${base.lightMuted};
|
|
126
|
+
--secondary-foreground: ${base.lightFg};
|
|
127
|
+
--muted: ${base.lightMuted};
|
|
128
|
+
--muted-foreground: ${base.lightMutedFg};
|
|
129
|
+
--accent: ${base.lightMuted};
|
|
130
|
+
--accent-foreground: ${base.lightFg};
|
|
131
|
+
--destructive: #ef4444;
|
|
132
|
+
--destructive-foreground: #ffffff;
|
|
133
|
+
--border: ${base.lightBorder};
|
|
134
|
+
--input: ${base.lightBorder};
|
|
135
|
+
--ring: ${base.lightRing};
|
|
136
|
+
--radius: 0.5rem;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.dark {
|
|
140
|
+
color-scheme: dark;
|
|
141
|
+
--background: ${base.darkBg};
|
|
142
|
+
--foreground: ${base.darkFg};
|
|
143
|
+
--card: ${base.darkBg};
|
|
144
|
+
--card-foreground: ${base.darkFg};
|
|
145
|
+
--popover: ${base.darkBg};
|
|
146
|
+
--popover-foreground: ${base.darkFg};
|
|
147
|
+
--primary: ${primary.dark};
|
|
148
|
+
--primary-foreground: ${primary.darkFg};
|
|
149
|
+
--secondary: ${base.darkMuted};
|
|
150
|
+
--secondary-foreground: ${base.darkFg};
|
|
151
|
+
--muted: ${base.darkMuted};
|
|
152
|
+
--muted-foreground: ${base.darkMutedFg};
|
|
153
|
+
--accent: ${base.darkMuted};
|
|
154
|
+
--accent-foreground: ${base.darkFg};
|
|
155
|
+
--destructive: #7f1d1d;
|
|
156
|
+
--destructive-foreground: #ffffff;
|
|
157
|
+
--border: ${base.darkBorder};
|
|
158
|
+
--input: ${base.darkBorder};
|
|
159
|
+
--ring: ${base.darkRing};
|
|
160
|
+
--radius: 0.5rem;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@layer base {
|
|
164
|
+
* {
|
|
165
|
+
border-color: var(--border);
|
|
166
|
+
}
|
|
167
|
+
body {
|
|
168
|
+
background-color: var(--background);
|
|
169
|
+
color: var(--foreground);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
`;
|
|
173
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface CheckResult {
|
|
2
|
+
passed: boolean;
|
|
3
|
+
message: string;
|
|
4
|
+
details?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Diagnostic check verifying existence and valid alias mapping in nikala.config.json.
|
|
8
|
+
*
|
|
9
|
+
* @param cwd - Working directory path of the target project
|
|
10
|
+
*/
|
|
11
|
+
export declare function checkConfig(cwd?: string): Promise<CheckResult>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { readConfig } from "../file.js";
|
|
4
|
+
/**
|
|
5
|
+
* Diagnostic check verifying existence and valid alias mapping in nikala.config.json.
|
|
6
|
+
*
|
|
7
|
+
* @param cwd - Working directory path of the target project
|
|
8
|
+
*/
|
|
9
|
+
export async function checkConfig(cwd = process.cwd()) {
|
|
10
|
+
const configPath = path.join(cwd, "nikala.config.json");
|
|
11
|
+
if (!(await fs.pathExists(configPath))) {
|
|
12
|
+
return {
|
|
13
|
+
passed: false,
|
|
14
|
+
message: "nikala.config.json manifest missing",
|
|
15
|
+
details: "Run `nikala init` to initialize workspace configuration.",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const config = await readConfig(cwd);
|
|
20
|
+
if (!config || !config.alias || !config.alias.components || !config.alias.utils) {
|
|
21
|
+
return {
|
|
22
|
+
passed: false,
|
|
23
|
+
message: "Invalid nikala.config.json structure",
|
|
24
|
+
details: "Required properties (alias.components, alias.utils) are missing.",
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const componentsDir = path.resolve(cwd, config.alias.components);
|
|
28
|
+
if (!(await fs.pathExists(componentsDir))) {
|
|
29
|
+
return {
|
|
30
|
+
passed: false,
|
|
31
|
+
message: `Components directory not found: ${config.alias.components}`,
|
|
32
|
+
details: "Create the folder manually or update nikala.config.json alias.",
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
passed: true,
|
|
37
|
+
message: "nikala.config.json configuration valid",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return {
|
|
42
|
+
passed: false,
|
|
43
|
+
message: "Failed to parse nikala.config.json",
|
|
44
|
+
details: String(error),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CheckResult } from "./check-config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Diagnostic check verifying existence and Tailwind v4 setup in target CSS file.
|
|
4
|
+
*
|
|
5
|
+
* @param cwd - Working directory path of the target project
|
|
6
|
+
*/
|
|
7
|
+
export declare function checkCss(cwd?: string): Promise<CheckResult>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { readConfig } from "../file.js";
|
|
4
|
+
/**
|
|
5
|
+
* Diagnostic check verifying existence and Tailwind v4 setup in target CSS file.
|
|
6
|
+
*
|
|
7
|
+
* @param cwd - Working directory path of the target project
|
|
8
|
+
*/
|
|
9
|
+
export async function checkCss(cwd = process.cwd()) {
|
|
10
|
+
const config = await readConfig(cwd);
|
|
11
|
+
const cssPathRelative = config?.css || "src/index.css";
|
|
12
|
+
const cssPath = path.resolve(cwd, cssPathRelative);
|
|
13
|
+
if (!(await fs.pathExists(cssPath))) {
|
|
14
|
+
return {
|
|
15
|
+
passed: false,
|
|
16
|
+
message: `CSS file missing: ${cssPathRelative}`,
|
|
17
|
+
details: "Ensure the primary CSS file specified in nikala.config.json exists.",
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const cssContent = await fs.readFile(cssPath, "utf-8");
|
|
22
|
+
if (!cssContent.includes('@import "tailwindcss"') && !cssContent.includes("@import 'tailwindcss'")) {
|
|
23
|
+
return {
|
|
24
|
+
passed: false,
|
|
25
|
+
message: `Tailwind CSS import missing in ${cssPathRelative}`,
|
|
26
|
+
details: 'Add `@import "tailwindcss";` to the top of your CSS file.',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const requiredTokens = ["--primary", "--background", "--foreground", "--border"];
|
|
30
|
+
const missingTokens = requiredTokens.filter((token) => !cssContent.includes(token));
|
|
31
|
+
if (missingTokens.length > 0) {
|
|
32
|
+
return {
|
|
33
|
+
passed: false,
|
|
34
|
+
message: `Incomplete CSS theme tokens in ${cssPathRelative}`,
|
|
35
|
+
details: `Missing variables: ${missingTokens.join(", ")}. Run \`nikala theme set\` to regenerate CSS setup.`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
passed: true,
|
|
40
|
+
message: `CSS theme configuration valid in ${cssPathRelative}`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return {
|
|
45
|
+
passed: false,
|
|
46
|
+
message: `Failed to read ${cssPathRelative}`,
|
|
47
|
+
details: String(error),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CheckResult } from "./check-config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Diagnostic check verifying required runtime and Tailwind CSS v4 packages in target package.json.
|
|
4
|
+
*
|
|
5
|
+
* @param cwd - Working directory path of the target project
|
|
6
|
+
*/
|
|
7
|
+
export declare function checkDeps(cwd?: string): Promise<CheckResult>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import stripJsonComments from "strip-json-comments";
|
|
4
|
+
/**
|
|
5
|
+
* Diagnostic check verifying required runtime and Tailwind CSS v4 packages in target package.json.
|
|
6
|
+
*
|
|
7
|
+
* @param cwd - Working directory path of the target project
|
|
8
|
+
*/
|
|
9
|
+
export async function checkDeps(cwd = process.cwd()) {
|
|
10
|
+
const pkgPath = path.join(cwd, "package.json");
|
|
11
|
+
if (!(await fs.pathExists(pkgPath))) {
|
|
12
|
+
return {
|
|
13
|
+
passed: false,
|
|
14
|
+
message: "package.json file missing",
|
|
15
|
+
details: "Ensure you are running the command in the root of a Node/Bun workspace.",
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const raw = await fs.readFile(pkgPath, "utf-8");
|
|
20
|
+
const pkg = JSON.parse(stripJsonComments(raw));
|
|
21
|
+
const installed = {
|
|
22
|
+
...pkg.dependencies,
|
|
23
|
+
...pkg.devDependencies,
|
|
24
|
+
};
|
|
25
|
+
const coreDeps = [
|
|
26
|
+
"clsx",
|
|
27
|
+
"tailwind-merge",
|
|
28
|
+
"class-variance-authority",
|
|
29
|
+
"tailwindcss",
|
|
30
|
+
"@tailwindcss/vite",
|
|
31
|
+
];
|
|
32
|
+
const missing = coreDeps.filter((dep) => !installed[dep]);
|
|
33
|
+
if (missing.length > 0) {
|
|
34
|
+
return {
|
|
35
|
+
passed: false,
|
|
36
|
+
message: `Missing ${missing.length} core dependencies`,
|
|
37
|
+
details: `Missing packages: ${missing.join(", ")}. Run \`bun add ${missing.join(" ")}\` to install.`,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
passed: true,
|
|
42
|
+
message: "All core runtime and Tailwind CSS v4 packages installed",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return {
|
|
47
|
+
passed: false,
|
|
48
|
+
message: "Failed to parse package.json",
|
|
49
|
+
details: String(error),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nikala-ui/cli",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Command line interface for Nikala UI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"nikala": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.build.json"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"commander": "^15.0.0",
|
|
21
|
+
"fs-extra": "^11.3.6",
|
|
22
|
+
"picocolors": "^1.1.1",
|
|
23
|
+
"prompts": "^2.4.2",
|
|
24
|
+
"strip-json-comments": "^5.0.3"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/bun": "latest",
|
|
28
|
+
"@types/fs-extra": "^11.0.4",
|
|
29
|
+
"@types/node": "^26.1.1",
|
|
30
|
+
"@types/prompts": "^2.4.9",
|
|
31
|
+
"typescript": "^5.7.2"
|
|
32
|
+
}
|
|
33
|
+
}
|