u1s1-cli 0.13.4 → 0.13.5

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/dist/update.js +19 -8
  2. package/package.json +1 -1
package/dist/update.js CHANGED
@@ -1,4 +1,4 @@
1
- import { execSync, spawn } from "node:child_process";
1
+ import { execSync, spawnSync } from "node:child_process";
2
2
  import { mkdtempSync, writeFileSync } from "node:fs";
3
3
  import { createRequire } from "node:module";
4
4
  import { tmpdir } from "node:os";
@@ -65,14 +65,25 @@ async function portableSelfUpdate(latest) {
65
65
  if (process.platform === "win32") {
66
66
  console.log(`正在打开更新窗口(升级到 v${latest})…`);
67
67
  console.log("更新在新窗口里进行,本窗口会退出;装完后重新打开终端运行 u1s1 即可。");
68
+ console.log("若新窗口没有出现,可手动在 PowerShell 运行: irm https://u1s1.io/releases/install.ps1 | iex");
68
69
  // 不走 `cmd /c start`:start 只把**带引号**的首参当窗口标题,而 node 对
69
- // 无空格参数不加引号,标题会被当成命令执行(0.13.1 翻车现场)。node 在
70
- // Windows 上 detached + stdio ignore 的子进程自带新控制台,直接 spawn
71
- // powershell 即可,参数按 Win32 规则原样传递,没有二次解析。
72
- const tmp = join(mkdtempSync(join(tmpdir(), "u1s1-update-")), "update.ps1");
73
- writeFileSync(tmp, "irm https://u1s1.io/releases/install.ps1 | iex\n");
74
- const child = spawn("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-NoExit", "-File", tmp], { detached: true, stdio: "ignore" });
75
- child.unref();
70
+ // 无空格参数不加引号,标题会被当成命令执行(0.13.1 翻车现场)。也不走
71
+ // spawn detached:Windows 上 detached DETACHED_PROCESS——子进程**没有**
72
+ // 控制台,窗口根本不出现,0.13.2-0.13.4 的更新其实在隐形 powershell
73
+ // 跑完的(当时的注释把这个标志理解反了)。可靠开窗走 ShellExecute 语义:
74
+ // 同步跑一个无窗 launcher,由它 Start-Process 弹真窗口(ShellExecute 出的
75
+ // 进程完全独立,不随本进程退出)。路径经 $PSScriptRoot 传递,不往命令行
76
+ // 拼字符串,没有引号二次解析问题。
77
+ const dir = mkdtempSync(join(tmpdir(), "u1s1-update-"));
78
+ writeFileSync(join(dir, "update.ps1"), "irm https://u1s1.io/releases/install.ps1 | iex\n");
79
+ writeFileSync(join(dir, "launch.ps1"), "$inner = '-NoProfile -ExecutionPolicy Bypass -NoExit -File \"' + $PSScriptRoot + '\\update.ps1\"'\n" +
80
+ "Start-Process powershell -ArgumentList $inner\n");
81
+ const res = spawnSync("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", join(dir, "launch.ps1")], { stdio: "ignore", windowsHide: true, timeout: 30_000 });
82
+ if (res.error || res.status !== 0) {
83
+ console.error("无法拉起更新窗口。请手动在 PowerShell 里运行:");
84
+ console.error(" irm https://u1s1.io/releases/install.ps1 | iex");
85
+ process.exit(1);
86
+ }
76
87
  // 立刻退出释放 node.exe 的文件锁,让安装器能替换安装目录
77
88
  process.exit(0);
78
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u1s1-cli",
3
- "version": "0.13.4",
3
+ "version": "0.13.5",
4
4
  "description": "u1s1 — 有一说一,最省心的 AI 编程搭子。终端里用中文说需求,AI 帮你读文件、改代码、跑命令。",
5
5
  "type": "module",
6
6
  "bin": {