dsh-deepseek-balance-widget 2.3.0 → 2.3.1

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.
Files changed (2) hide show
  1. package/lib/index.js +34 -10
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -567,16 +567,27 @@ async function runPackageUpdate() {
567
567
  const target = versionInfo.latest;
568
568
  const pm = await detectPackageManager();
569
569
  const isWin = process.platform === "win32";
570
- const cmd = isWin ? (pm === "pnpm" ? "pnpm.cmd" : "npm.cmd") : pm;
570
+ const cmd = isWin ? (pm === "pnpm" ? "pnpm" : "npm") : pm;
571
571
  const args = pm === "pnpm"
572
572
  ? ["add", `dsh-deepseek-balance-widget@${target}`]
573
573
  : ["install", `dsh-deepseek-balance-widget@${target}`];
574
574
  return new Promise((resolve) => {
575
- const child = spawn(cmd, args, {
576
- cwd: UPDATE_CWD,
577
- shell: isWin,
578
- env: { ...process.env, NPM_CONFIG_FUND: "false", NPM_CONFIG_AUDIT: "false" }
579
- });
575
+ let child;
576
+ if (isWin) {
577
+ // Avoid Node.js DEP0190: spawn with shell:true and a separate args array is deprecated.
578
+ // Build a single command string and let cmd.exe parse it; hide the console window.
579
+ const quotedArgs = args.map((a) => `"${a.replace(/"/g, '\\"')}"`).join(" ");
580
+ child = spawn("cmd.exe", ["/d", "/s", "/c", `${cmd} ${quotedArgs}`], {
581
+ cwd: UPDATE_CWD,
582
+ windowsHide: true,
583
+ env: { ...process.env, NPM_CONFIG_FUND: "false", NPM_CONFIG_AUDIT: "false" }
584
+ });
585
+ } else {
586
+ child = spawn(cmd, args, {
587
+ cwd: UPDATE_CWD,
588
+ env: { ...process.env, NPM_CONFIG_FUND: "false", NPM_CONFIG_AUDIT: "false" }
589
+ });
590
+ }
580
591
  let stdout = "";
581
592
  let stderr = "";
582
593
  child.stdout.on("data", (chunk) => { stdout += String(chunk); });
@@ -584,13 +595,26 @@ async function runPackageUpdate() {
584
595
  child.on("error", (error) => {
585
596
  resolve({ ok: false, output: stdout + stderr, error: String(error?.message ?? error) });
586
597
  });
587
- child.on("close", (code) => {
598
+ child.on("close", async (code) => {
588
599
  const output = (stdout + "\n" + stderr).trim();
589
- if (code === 0) {
590
- resolve({ ok: true, output: output.slice(-800) });
591
- } else {
600
+ if (code !== 0) {
592
601
  resolve({ ok: false, output, error: `${pm} ${args.join(" ")} exited with code ${code}` });
602
+ return;
603
+ }
604
+ // Verify the on-disk version actually changed so the user can't be misled into
605
+ // restarting dsh when the install silently wrote to a different location.
606
+ try {
607
+ const installedPkgPath = resolve(UPDATE_CWD, "node_modules", "dsh-deepseek-balance-widget", "package.json");
608
+ const installedPkg = JSON.parse(await readFile(installedPkgPath, "utf8"));
609
+ if (installedPkg.version !== target) {
610
+ resolve({ ok: false, output, error: `installed version mismatch: expected ${target}, found ${installedPkg.version}` });
611
+ return;
612
+ }
613
+ } catch (verifyError) {
614
+ resolve({ ok: false, output, error: `update appeared to succeed but could not verify installed version: ${String(verifyError?.message ?? verifyError)}` });
615
+ return;
593
616
  }
617
+ resolve({ ok: true, output: output.slice(-800) });
594
618
  });
595
619
  });
596
620
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-deepseek-balance-widget",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "type": "module",
5
5
  "description": "Multi-provider AI balance widget for the dsh web sidebar: a live, auto-refreshing balance pill plus a detail popover listing DeepSeek and any added providers (MiMo etc.). Keys are stored per-machine in ~/.dsh/ai-balances.json and resolved from the local credential seam, never hardcoded.",
6
6
  "keywords": [