@nucleoicons/skills 0.1.5 → 0.1.6

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/install.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  import { type SkillsReleaseData } from "./api.js";
2
2
  import { type InstallManifest, type PackageTarget } from "./config.js";
3
+ /**
4
+ * Resolve a real npm binary. Prefer the one next to the running Node
5
+ * (`process.execPath`) so we don't depend on PATH / shell aliases
6
+ * (common cause of `spawn npm ENOENT` even when `npm -v` works in zsh).
7
+ */
8
+ export declare function resolveNpmBin(): string;
3
9
  export declare function readInstallManifest(root?: string): Promise<InstallManifest | null>;
4
10
  export declare function cleanInstallRoot(root?: string): Promise<void>;
5
11
  /**
package/dist/install.js CHANGED
@@ -1,12 +1,47 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { cp, mkdir, readdir, readFile, rm, stat, writeFile } from "node:fs/promises";
3
- import { join } from "node:path";
3
+ import { dirname, join } from "node:path";
4
4
  import { execFile } from "node:child_process";
5
5
  import { promisify } from "node:util";
6
6
  import extract from "extract-zip";
7
7
  import { downloadUrlToFile, formatBytes } from "./api.js";
8
8
  import { installRoot, nucleoHomeDir } from "./config.js";
9
9
  const execFileAsync = promisify(execFile);
10
+ /**
11
+ * Resolve a real npm binary. Prefer the one next to the running Node
12
+ * (`process.execPath`) so we don't depend on PATH / shell aliases
13
+ * (common cause of `spawn npm ENOENT` even when `npm -v` works in zsh).
14
+ */
15
+ export function resolveNpmBin() {
16
+ const binDir = dirname(process.execPath);
17
+ const candidates = process.platform === "win32"
18
+ ? [join(binDir, "npm.cmd"), join(binDir, "npm.exe"), "npm.cmd", "npm"]
19
+ : [join(binDir, "npm"), "npm"];
20
+ for (const candidate of candidates) {
21
+ if (candidate === "npm" || candidate === "npm.cmd" || existsSync(candidate)) {
22
+ return candidate;
23
+ }
24
+ }
25
+ return process.platform === "win32" ? "npm.cmd" : "npm";
26
+ }
27
+ async function runNpm(args, cwd) {
28
+ const npmBin = resolveNpmBin();
29
+ try {
30
+ await execFileAsync(npmBin, args, {
31
+ cwd,
32
+ env: process.env,
33
+ // Windows .cmd shims need a shell; Unix absolute paths do not.
34
+ shell: process.platform === "win32",
35
+ });
36
+ }
37
+ catch (error) {
38
+ const detail = error instanceof Error ? error.message : String(error);
39
+ throw new Error(`${detail}\n` +
40
+ `Tried to run: ${npmBin} ${args.join(" ")}\n` +
41
+ `If npm is installed, ensure it sits next to node (${process.execPath}), or run:\n` +
42
+ ` cd ${cwd} && npm ${args.join(" ")}`);
43
+ }
44
+ }
10
45
  export async function readInstallManifest(root = installRoot()) {
11
46
  const path = join(root, "manifest.json");
12
47
  if (!existsSync(path)) {
@@ -191,10 +226,7 @@ export async function buildMcp(root = installRoot()) {
191
226
  const hasDist = existsSync(distEntry);
192
227
  console.log(" npm install (mcp)…");
193
228
  try {
194
- await execFileAsync("npm", ["install", "--omit=dev"], {
195
- cwd: mcpDir,
196
- env: process.env,
197
- });
229
+ await runNpm(["install", "--omit=dev"], mcpDir);
198
230
  }
199
231
  catch (error) {
200
232
  const detail = error instanceof Error ? error.message : String(error);
@@ -203,10 +235,7 @@ export async function buildMcp(root = installRoot()) {
203
235
  if (!hasDist || existsSync(join(mcpDir, "src"))) {
204
236
  console.log(" npm run build (mcp)…");
205
237
  try {
206
- await execFileAsync("npm", ["run", "build"], {
207
- cwd: mcpDir,
208
- env: process.env,
209
- });
238
+ await runNpm(["run", "build"], mcpDir);
210
239
  }
211
240
  catch (error) {
212
241
  if (!existsSync(distEntry)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nucleoicons/skills",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "CLI to install and update Nucleo Pro MCP + icon skills",
5
5
  "type": "module",
6
6
  "bin": {