From fa535575c508a36ea3164aa73ba2cdd702b46f38 Mon Sep 17 00:00:00 2001 From: Ajay Ghanwat Date: Mon, 24 Aug 2026 17:23:35 +0530 Subject: [PATCH] fix(cli): resolve package updates on Windows --- bun.lock | 2 +- packages/cli/package.json | 2 +- packages/cli/src/update.ts | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/bun.lock b/bun.lock index 38455ae7..8678b3ac 100644 --- a/bun.lock +++ b/bun.lock @@ -292,7 +292,7 @@ }, "packages/cli": { "name": "@wrnexus/cli", - "version": "0.8.63", + "version": "0.8.64", "bin": { "wrnexus": "src/index.ts", }, diff --git a/packages/cli/package.json b/packages/cli/package.json index d814d2ac..67bec01b 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/cli", - "version": "0.8.63", + "version": "0.8.64", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/cli/src/update.ts b/packages/cli/src/update.ts index 6c3f1566..1cf97cf0 100644 --- a/packages/cli/src/update.ts +++ b/packages/cli/src/update.ts @@ -63,14 +63,16 @@ const execFileAsync = promisify(execFile); /** Resolve every installed WRNexus dependency independently and in parallel. */ export async function latestPackageVersions(names: string[]): Promise> { - const npm = process.platform === "win32" ? "npm.cmd" : "npm"; const unique = [...new Set(names.filter((name) => name.startsWith("@wrnexus/")))]; const entries = await Promise.all( unique.map(async (name) => { try { - const { stdout } = await execFileAsync(npm, ["view", name, "version", "--json"], { - encoding: "utf8", - }); + const command = process.platform === "win32" ? (process.env.ComSpec ?? "cmd.exe") : "npm"; + const args = + process.platform === "win32" + ? ["/d", "/s", "/c", "npm", "view", name, "version", "--json"] + : ["view", name, "version", "--json"]; + const { stdout } = await execFileAsync(command, args, { encoding: "utf8" }); const parsed = JSON.parse(stdout.trim()) as string | string[]; const version = Array.isArray(parsed) ? parsed.at(-1) : parsed; return typeof version === "string" && /^\d+\.\d+\.\d+/.test(version) @@ -1274,6 +1276,13 @@ export async function runUpdate(dir: string, args: string[]): Promise { ? new Map() : await latestPackageVersions(dependencyNames); + if (!versionArg && dependencyNames.length > 0 && packageVersions.size === 0) { + throw new Error( + `Unable to resolve any of ${new Set(dependencyNames).size} installed WRNexus package ` + + `version(s) from npm. Check the @wrnexus registry and authentication before retrying.`, + ); + } + console.log(`\n ⚡ wrnexus update → migrations ${target}${dryRun ? " (dry run)" : ""}`); if (!versionArg) { console.log(