@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.
@@ -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 { execSync } from "node:child_process";
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
- const depsString = dependencies.join(" ");
51
- let command = "";
52
- switch (pkgManager) {
53
- case "bun":
54
- command = `bun add ${depsString}`;
55
- break;
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(` ${command}\n`));
59
+ console.log(pc.white(` ${pkgManager} ${args.join(" ")}\n`));
69
60
  try {
70
- execSync(command, { cwd, stdio: "inherit" });
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: ${command}`));
91
+ console.log(pc.yellow(` Please run manually: ${pkgManager} ${args.join(" ")}`));
101
92
  }
102
93
  }
@@ -171,16 +171,16 @@ export const PRIMARY_COLORS = {
171
171
  },
172
172
  },
173
173
  yellow: {
174
- light: "oklch(0.75 0.18 90)",
175
- dark: "oklch(0.82 0.16 90)",
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.82 0.18 90)",
180
- chart2: "oklch(0.72 0.16 80)",
181
- chart3: "oklch(0.62 0.14 100)",
182
- chart4: "oklch(0.88 0.12 95)",
183
- chart5: "oklch(0.52 0.15 85)",
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: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nikala-ui/cli",
3
- "version": "0.11.0-nightly.b01fa01",
3
+ "version": "0.11.0-nightly.b447b5b",
4
4
  "description": "Command line interface for Nikala UI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",