@nikala-ui/cli 0.11.0 ā 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/add.js +0 -3
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +4 -2
- package/dist/index.js +3 -2
- package/dist/utils/init/configure-alias.js +14 -7
- package/dist/utils/pkg.js +12 -21
- package/dist/utils/theme.js +7 -7
- package/package.json +1 -1
package/dist/commands/add.js
CHANGED
|
@@ -61,9 +61,6 @@ export async function add(components = [], options = {}) {
|
|
|
61
61
|
const componentsDir = path.resolve(cwd, config.alias.components);
|
|
62
62
|
console.log(pc.cyan(`\nšØ Adding items to project...\n`));
|
|
63
63
|
const requiredNpmDeps = new Set();
|
|
64
|
-
if (isHookMode) {
|
|
65
|
-
requiredNpmDeps.add("@nikala-ui/hooks");
|
|
66
|
-
}
|
|
67
64
|
for (const target of resolvedTargets) {
|
|
68
65
|
const item = await getRegistryItem(target, config.registries);
|
|
69
66
|
if (!item) {
|
package/dist/commands/init.d.ts
CHANGED
package/dist/commands/init.js
CHANGED
|
@@ -101,8 +101,10 @@ export async function init(options) {
|
|
|
101
101
|
else {
|
|
102
102
|
requiredDeps.push("tailwindcss", "@tailwindcss/vite");
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
if (!options.skipDependencies) {
|
|
105
|
+
console.log(pc.yellow("\nš¦ Installing required runtime & Tailwind CSS dependencies..."));
|
|
106
|
+
await installDependencies(requiredDeps, cwd);
|
|
107
|
+
}
|
|
106
108
|
// 2. Configure path aliases
|
|
107
109
|
await configureAliases(cwd);
|
|
108
110
|
// 3. Generate cn.ts helper
|
package/dist/index.js
CHANGED
|
@@ -10,18 +10,19 @@ import { upgradeCommand } from "./commands/upgrade.js";
|
|
|
10
10
|
import { removeCommand } from "./commands/remove.js";
|
|
11
11
|
import { listCommand } from "./commands/list.js";
|
|
12
12
|
import { setupAiRules } from "./utils/init/setup-ai-rules.js";
|
|
13
|
-
console.log(`\nšØ ${pc.bold(pc.red("Nikala UI"))} ${pc.dim("v0.
|
|
13
|
+
console.log(`\nšØ ${pc.bold(pc.red("Nikala UI"))} ${pc.dim("v0.12.0")} ā SolidJS + Tailwind v4 components`);
|
|
14
14
|
console.log(` ${pc.italic(pc.dim("Honoring Niko Pirosmani (Nikala)"))}\n`);
|
|
15
15
|
console.log(` ${pc.dim("Docs:")} ${pc.underline(pc.cyan("https://nikala.dev"))}\n`);
|
|
16
16
|
const program = new Command();
|
|
17
17
|
program
|
|
18
18
|
.name("nikala")
|
|
19
19
|
.description("Nikala UI ā SolidJS + Tailwind v4 components")
|
|
20
|
-
.version("0.
|
|
20
|
+
.version("0.12.0");
|
|
21
21
|
program
|
|
22
22
|
.command("init")
|
|
23
23
|
.description("Initialize Nikala UI in your project")
|
|
24
24
|
.option("-d, --defaults", "Skip prompts and use defaults")
|
|
25
|
+
.option("--skip-dependencies", "Skip dependency installation (used by higher-level tooling)")
|
|
25
26
|
.option("--ai", "Generate AI assistant rules (.cursor/rules/nikala.mdc, .cursorrules, AGENTS.md)")
|
|
26
27
|
.action(init);
|
|
27
28
|
program
|
|
@@ -12,36 +12,43 @@ export async function configureAliases(cwd) {
|
|
|
12
12
|
if (await fs.pathExists(targetConfigPath)) {
|
|
13
13
|
let configContent = await fs.readFile(targetConfigPath, "utf-8");
|
|
14
14
|
let modified = false;
|
|
15
|
+
// 1. Inject Tailwind CSS v4 Vite plugin if missing
|
|
15
16
|
if (!configContent.includes("@tailwindcss/vite")) {
|
|
16
17
|
configContent = `import tailwindcss from "@tailwindcss/vite";\n${configContent}`;
|
|
17
18
|
if (configContent.includes("plugins: [")) {
|
|
18
19
|
configContent = configContent.replace("plugins: [", "plugins: [\n tailwindcss(), ");
|
|
20
|
+
modified = true;
|
|
19
21
|
}
|
|
20
|
-
else
|
|
21
|
-
|
|
22
|
+
else {
|
|
23
|
+
const defineConfigRegex = /(defineConfig\s*\(\s*(?:async\s*)?(?:\([^)]*\)\s*=>\s*)?\{)/;
|
|
24
|
+
if (defineConfigRegex.test(configContent)) {
|
|
25
|
+
configContent = configContent.replace(defineConfigRegex, "$1\n plugins: [tailwindcss()],");
|
|
26
|
+
modified = true;
|
|
27
|
+
}
|
|
22
28
|
}
|
|
23
|
-
modified = true;
|
|
24
29
|
}
|
|
30
|
+
// 2. Inject path alias (@ -> ./src)
|
|
25
31
|
if (!configContent.includes('"@"') && !configContent.includes("'@'")) {
|
|
26
32
|
if (!configContent.includes('import path from "node:path"') && !configContent.includes('import path from "path"')) {
|
|
27
33
|
configContent = `import path from "node:path";\n${configContent}`;
|
|
28
34
|
}
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
const defineConfigRegex = /(defineConfig\s*\(\s*(?:async\s*)?(?:\([^)]*\)\s*=>\s*)?\{)/;
|
|
36
|
+
if (defineConfigRegex.test(configContent)) {
|
|
37
|
+
configContent = configContent.replace(defineConfigRegex, `$1\n resolve: {\n alias: {\n "@": path.resolve(process.cwd(), "./src"),\n },\n },`);
|
|
38
|
+
modified = true;
|
|
31
39
|
}
|
|
32
|
-
modified = true;
|
|
33
40
|
}
|
|
34
41
|
if (modified) {
|
|
35
42
|
await fs.writeFile(targetConfigPath, configContent, "utf-8");
|
|
36
43
|
console.log(pc.green(`ā Configured Tailwind CSS v4 plugin and path alias in ${path.basename(targetConfigPath)}`));
|
|
37
44
|
}
|
|
38
45
|
}
|
|
46
|
+
// 3. Configure tsconfig.json path mappings (@/* -> ./src/*)
|
|
39
47
|
const tsconfigPath = path.join(cwd, "tsconfig.json");
|
|
40
48
|
if (await fs.pathExists(tsconfigPath)) {
|
|
41
49
|
const tsconfig = await readTsConfig(cwd);
|
|
42
50
|
if (tsconfig) {
|
|
43
51
|
tsconfig.compilerOptions = tsconfig.compilerOptions || {};
|
|
44
|
-
tsconfig.compilerOptions.baseUrl = ".";
|
|
45
52
|
tsconfig.compilerOptions.paths = tsconfig.compilerOptions.paths || {};
|
|
46
53
|
// Correct path mapping with leading relative dot ./src/*
|
|
47
54
|
tsconfig.compilerOptions.paths["@/*"] = ["./src/*"];
|
package/dist/utils/pkg.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import fs from "fs-extra";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
4
|
import pc from "picocolors";
|
|
5
5
|
import stripJsonComments from "strip-json-comments";
|
|
6
|
+
// Standard npm package name regex validator (supports scoped packages and version specifiers)
|
|
7
|
+
const NPM_PACKAGE_REGEX = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*(@[a-zA-Z0-9^~.*><=-]+)?$/;
|
|
6
8
|
/**
|
|
7
9
|
* Detects the package manager used in the target project workspace by checking lockfiles.
|
|
8
10
|
*
|
|
@@ -47,27 +49,16 @@ export async function installDependencies(dependencies, cwd = process.cwd()) {
|
|
|
47
49
|
// Failed to parse original package.json
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
case "pnpm":
|
|
57
|
-
command = `pnpm add ${depsString}`;
|
|
58
|
-
break;
|
|
59
|
-
case "yarn":
|
|
60
|
-
command = `yarn add ${depsString}`;
|
|
61
|
-
break;
|
|
62
|
-
case "npm":
|
|
63
|
-
default:
|
|
64
|
-
command = `npm install ${depsString}`;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
52
|
+
// Validate and sanitize dependency names to prevent any shell metacharacter injection
|
|
53
|
+
const validDeps = dependencies.filter((dep) => NPM_PACKAGE_REGEX.test(dep));
|
|
54
|
+
if (validDeps.length === 0)
|
|
55
|
+
return;
|
|
56
|
+
const subCommand = pkgManager === "npm" ? "install" : "add";
|
|
57
|
+
const args = [subCommand, ...validDeps];
|
|
67
58
|
console.log(pc.yellow(`\nš¦ Installing required component dependencies (${pkgManager})...`));
|
|
68
|
-
console.log(pc.white(` ${
|
|
59
|
+
console.log(pc.white(` ${pkgManager} ${args.join(" ")}\n`));
|
|
69
60
|
try {
|
|
70
|
-
|
|
61
|
+
execFileSync(pkgManager, args, { cwd, stdio: "inherit" });
|
|
71
62
|
// 2. Validate package.json integrity after installation and restore stripped fields if necessary
|
|
72
63
|
if (originalPkgJson && (await fs.pathExists(pkgPath))) {
|
|
73
64
|
try {
|
|
@@ -97,6 +88,6 @@ export async function installDependencies(dependencies, cwd = process.cwd()) {
|
|
|
97
88
|
}
|
|
98
89
|
catch (error) {
|
|
99
90
|
console.log(pc.red(`ā Failed to install dependencies automatically.`));
|
|
100
|
-
console.log(pc.yellow(` Please run manually: ${
|
|
91
|
+
console.log(pc.yellow(` Please run manually: ${pkgManager} ${args.join(" ")}`));
|
|
101
92
|
}
|
|
102
93
|
}
|
package/dist/utils/theme.js
CHANGED
|
@@ -171,16 +171,16 @@ export const PRIMARY_COLORS = {
|
|
|
171
171
|
},
|
|
172
172
|
},
|
|
173
173
|
yellow: {
|
|
174
|
-
light: "oklch(0.
|
|
175
|
-
dark: "oklch(0.
|
|
174
|
+
light: "oklch(0.795 0.184 86.047)",
|
|
175
|
+
dark: "oklch(0.852 0.199 91.936)",
|
|
176
176
|
lightFg: "oklch(0.1450 0 0)",
|
|
177
177
|
darkFg: "oklch(0.1450 0 0)",
|
|
178
178
|
charts: {
|
|
179
|
-
chart1: "oklch(0.
|
|
180
|
-
chart2: "oklch(0.
|
|
181
|
-
chart3: "oklch(0.
|
|
182
|
-
chart4: "oklch(0.
|
|
183
|
-
chart5: "oklch(0.
|
|
179
|
+
chart1: "oklch(0.795 0.184 86.047)",
|
|
180
|
+
chart2: "oklch(0.65 0.16 50)",
|
|
181
|
+
chart3: "oklch(0.55 0.15 85)",
|
|
182
|
+
chart4: "oklch(0.85 0.12 60)",
|
|
183
|
+
chart5: "oklch(0.45 0.14 75)",
|
|
184
184
|
},
|
|
185
185
|
},
|
|
186
186
|
lime: {
|