cicy-desktop 2.1.123 → 2.1.124
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/package.json +1 -1
- package/src/sidecar/docker.js +13 -10
- package/src/sidecar/wsl-docker.js +15 -10
package/package.json
CHANGED
package/src/sidecar/docker.js
CHANGED
|
@@ -556,16 +556,19 @@ function launchElevated(exe, args, { emit } = {}) {
|
|
|
556
556
|
// hangs on "正在启动 Docker Desktop". Detect a missing WSL. `wsl` prints UTF-16
|
|
557
557
|
// and a fresh Windows without the feature says "未安装 / not installed / can be
|
|
558
558
|
// installed by running wsl.exe --install".
|
|
559
|
-
function wslMissing() {
|
|
559
|
+
async function wslMissing() {
|
|
560
560
|
if (process.platform !== "win32") return false;
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
561
|
+
// ASYNC execFile, NOT execFileSync: this runs on the homepage's status poll,
|
|
562
|
+
// and a cold post-reboot WSL can take many seconds to answer `wsl --status`.
|
|
563
|
+
// A sync call there blocked the whole Electron main process → the window went
|
|
564
|
+
// "未响应". Capture stdout+stderr even on a non-zero exit (a fresh Windows
|
|
565
|
+
// without WSL prints the "not installed / --install" hint and exits non-zero).
|
|
566
|
+
return await new Promise((resolve) => {
|
|
567
|
+
execFile("wsl", ["--status"], { timeout: 8000, windowsHide: true, encoding: "utf16le" }, (err, stdout, stderr) => {
|
|
568
|
+
const s = String((stdout || "") + (stderr || "") + (err && err.message ? err.message : ""));
|
|
569
|
+
resolve(/未安装|not installed|--install/i.test(s));
|
|
570
|
+
});
|
|
571
|
+
});
|
|
569
572
|
}
|
|
570
573
|
|
|
571
574
|
// Read-only, works without elevation. True iff a Windows optional feature
|
|
@@ -601,7 +604,7 @@ async function dismEnableFeature(feature, label, { emit } = {}) {
|
|
|
601
604
|
// features are verified-enabled (a Windows reboot is then needed before Docker
|
|
602
605
|
// can use WSL2), or { failed } if a feature couldn't be enabled.
|
|
603
606
|
async function ensureWsl({ emit } = {}) {
|
|
604
|
-
if (!wslMissing()) return { ok: true };
|
|
607
|
+
if (!(await wslMissing())) return { ok: true };
|
|
605
608
|
emit && emit({ phase: "install-docker", status: "running", message: "Docker 需要 WSL2 后端,开始启用所需的 Windows 功能…" });
|
|
606
609
|
const a = await dismEnableFeature("Microsoft-Windows-Subsystem-Linux", "启用 WSL 功能 1/2 · Linux 子系统", { emit });
|
|
607
610
|
const b = await dismEnableFeature("VirtualMachinePlatform", "启用 WSL 功能 2/2 · 虚拟机平台", { emit });
|
|
@@ -89,13 +89,18 @@ function wslRunStream(cmd, { emit, phase = "install-docker", timeout = 900000, d
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// Is `DISTRO` registered? `wsl -l -q` lists installed distros (UTF-16LE).
|
|
92
|
-
function distroInstalled(distro = DISTRO) {
|
|
92
|
+
async function distroInstalled(distro = DISTRO) {
|
|
93
93
|
if (process.platform !== "win32") return false;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
// ASYNC execFile, NOT execFileSync: this runs on the homepage's status poll,
|
|
95
|
+
// and a sync `wsl -l -q` on a cold post-reboot WSL blocked the Electron main
|
|
96
|
+
// process for seconds → window "未响应". (waitUntil awaits the promise fine.)
|
|
97
|
+
return await new Promise((resolve) => {
|
|
98
|
+
execFile("wsl", ["-l", "-q"], { timeout: 8000, windowsHide: true, encoding: "utf16le" }, (err, stdout) => {
|
|
99
|
+
if (err) return resolve(false);
|
|
100
|
+
resolve(String(stdout || "").split(/\r?\n/).map((s) => s.replace(/\0/g, "").trim()).filter(Boolean)
|
|
101
|
+
.some((d) => d.toLowerCase() === distro.toLowerCase()));
|
|
102
|
+
});
|
|
103
|
+
});
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
// Install the Ubuntu distro WITHOUT launching its interactive first-run setup
|
|
@@ -359,8 +364,8 @@ function ensureDesktopShortcut(volume = "cicy-team-8009", port = 8009) {
|
|
|
359
364
|
|
|
360
365
|
// Composite status for the card.
|
|
361
366
|
async function status(port = 8009) {
|
|
362
|
-
const wsl = !docker.wslMissing();
|
|
363
|
-
const distro = wsl && distroInstalled();
|
|
367
|
+
const wsl = !(await docker.wslMissing());
|
|
368
|
+
const distro = wsl && (await distroInstalled());
|
|
364
369
|
const engineUp = distro && (await dockerEngineUp());
|
|
365
370
|
const running = engineUp && (await probeHealth(port));
|
|
366
371
|
return { wsl, distro, engineUp, running };
|
|
@@ -414,7 +419,7 @@ async function _bootstrap({ onProgress, port = 8009, container = "cicy-code-dock
|
|
|
414
419
|
|
|
415
420
|
// 1) WSL2 platform
|
|
416
421
|
begin("ensure-wsl");
|
|
417
|
-
if (docker.wslMissing()) {
|
|
422
|
+
if (await docker.wslMissing()) {
|
|
418
423
|
const w = await docker.ensureWsl({ emit });
|
|
419
424
|
if (w.needsReboot) { fail("wsl_reboot_required"); emit({ phase: "done", status: "reboot", message: "WSL2 正在安装——请【重启 Windows】后回来点「重试」继续。" }); finish(false, "wsl_reboot_required"); return { ok: false, reason: "wsl_reboot_required" }; }
|
|
420
425
|
done();
|
|
@@ -422,7 +427,7 @@ async function _bootstrap({ onProgress, port = 8009, container = "cicy-code-dock
|
|
|
422
427
|
|
|
423
428
|
// 2) Ubuntu distro
|
|
424
429
|
begin("ensure-distro");
|
|
425
|
-
if (!distroInstalled()) {
|
|
430
|
+
if (!(await distroInstalled())) {
|
|
426
431
|
try { await installDistro({ emit }); } catch (e) { fail("distro_install_failed", e.message); emit({ phase: "install-docker", status: "error", message: `Ubuntu 安装失败:${e.message}(点重试)` }); finish(false, "distro_install_failed"); return { ok: false, reason: "distro_install_failed" }; }
|
|
427
432
|
const t0 = Date.now();
|
|
428
433
|
const ok = await docker.waitUntil(() => distroInstalled(), { totalMs: 600000, everyMs: 5000, onTick: () => emit({ phase: "install-docker", status: "running", message: `正在下载/注册 Ubuntu…(已 ${Math.round((Date.now() - t0) / 1000)}s,首次较慢请耐心)` }) });
|