@nikala-ui/cli 0.11.0-nightly.b01fa01 ā 0.11.0-nightly.b447b5b
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/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/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: {
|