livedesk 0.1.279 → 0.1.280
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/hub/src/live-desk-update.js +16 -11
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
|
|
3
3
|
export const LIVE_DESK_UPDATE_COMMAND = 'livedesk.client-update';
|
|
4
|
-
export const LIVE_DESK_DEDICATED_CLIENT_UPDATE_MIN_VERSION = '0.1.
|
|
4
|
+
export const LIVE_DESK_DEDICATED_CLIENT_UPDATE_MIN_VERSION = '0.1.141';
|
|
5
5
|
export const LIVE_DESK_UPDATE_TIMEOUT_MS = 120_000;
|
|
6
6
|
export const LIVE_DESK_UPDATE_CHECK_INTERVAL_MS = 60_000;
|
|
7
7
|
|
|
@@ -54,13 +54,16 @@ function buildWindowsLegacyUpdateCommand({ manager, pair, name, slot, targetVers
|
|
|
54
54
|
`$env:LIVEDESK_CLIENT_NAME = ${quotePowerShell(name)}`,
|
|
55
55
|
`$env:LIVEDESK_CLIENT_SLOT = ${quotePowerShell(slot || '')}`,
|
|
56
56
|
`$env:LIVEDESK_CLIENT_UPDATE_TARGET_VERSION = ${quotePowerShell(targetVersion)}`,
|
|
57
|
-
'$
|
|
58
|
-
'if ($
|
|
59
|
-
'if (-not $
|
|
60
|
-
'if (-not $
|
|
61
|
-
|
|
62
|
-
'
|
|
63
|
-
'
|
|
57
|
+
'$node = [string]$env:LIVEDESK_NODE_EXECUTABLE',
|
|
58
|
+
'if ($node -and -not (Test-Path -LiteralPath $node -PathType Leaf)) { $node = "" }',
|
|
59
|
+
'if (-not $node) { $node = (Get-Command node.exe -ErrorAction SilentlyContinue).Source }',
|
|
60
|
+
'if (-not $node) { throw "LiveDesk node executable was not found." }',
|
|
61
|
+
`$env:LIVEDESK_UPDATE_BOOTSTRAP_BASE64 = ${quotePowerShell(Buffer.from(buildUnixClientUpdateBootstrapScript(), 'utf8').toString('base64'))}`,
|
|
62
|
+
'$env:LIVEDESK_UPDATE_WAIT_PID = [string]$launcherPid',
|
|
63
|
+
'$env:LIVEDESK_UPDATE_AGENT_PID = "0"',
|
|
64
|
+
'$bootstrapRunner = "eval(Buffer.from(process.env.LIVEDESK_UPDATE_BOOTSTRAP_BASE64, \'base64\').toString(\'utf8\'))"',
|
|
65
|
+
'Start-Process -FilePath $node -ArgumentList @("-e", $bootstrapRunner) -WindowStyle Hidden',
|
|
66
|
+
'Start-Sleep -Milliseconds 750',
|
|
64
67
|
'Start-Process -FilePath "taskkill.exe" -ArgumentList @("/PID", [string]$launcherPid, "/T", "/F") -WindowStyle Hidden',
|
|
65
68
|
''
|
|
66
69
|
].join('\r\n');
|
|
@@ -78,10 +81,12 @@ function buildUnixClientUpdateBootstrapScript() {
|
|
|
78
81
|
'const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));',
|
|
79
82
|
'const waitForExit = async pid => { for (let attempt = 0; attempt < 360 && pid > 1; attempt += 1) { if (!isAlive(pid)) return; await sleep(500); } if (pid > 1 && isAlive(pid)) throw new Error("LiveDesk client process did not exit before update installation."); };',
|
|
80
83
|
'const nodeDir = path.dirname(process.execPath);',
|
|
81
|
-
'const npxCandidates = [process.env.LIVEDESK_NPX_EXECUTABLE, path.join(nodeDir, "npx"), "npx"].
|
|
84
|
+
'const npxCandidates = process.platform === "win32" ? [process.env.LIVEDESK_NPX_EXECUTABLE, path.join(nodeDir, "npx.cmd"), path.join(nodeDir, "npx.exe"), "npx.cmd"] : [process.env.LIVEDESK_NPX_EXECUTABLE, path.join(nodeDir, "npx"), "npx"];',
|
|
82
85
|
'const npx = npxCandidates.find(candidate => !path.isAbsolute(candidate) || fs.existsSync(candidate)) || npxCandidates[npxCandidates.length - 1];',
|
|
83
86
|
'const npxArgs = ["-y", "--prefer-online", "livedesk@latest", "client", "--no-login"];',
|
|
84
|
-
'
|
|
87
|
+
'const command = process.platform === "win32" ? (process.env.ComSpec || "cmd.exe") : npx;',
|
|
88
|
+
'const commandArgs = process.platform === "win32" ? ["/d", "/s", "/c", "call \\"" + npx + "\\" " + npxArgs.join(" ")] : npxArgs;',
|
|
89
|
+
'(async () => { await waitForExit(waitPid); await waitForExit(agentPid); const updater = spawn(command, commandArgs, { detached: true, stdio: "ignore", windowsHide: true, env: process.env }); updater.once("error", error => { console.error("LiveDesk updater failed to start: " + error.message); process.exitCode = 1; }); updater.once("spawn", () => updater.unref()); })().catch(error => { console.error("LiveDesk updater failed: " + error.message); process.exitCode = 1; });',
|
|
85
90
|
''
|
|
86
91
|
].join('\n');
|
|
87
92
|
}
|
|
@@ -98,7 +103,7 @@ function buildUnixLegacyUpdateCommand({ manager, pair, name, slot, targetVersion
|
|
|
98
103
|
'let launcherPid = Number.isInteger(configuredLauncherPid) && configuredLauncherPid > 1 && isAlive(configuredLauncherPid) ? configuredLauncherPid : 0;',
|
|
99
104
|
'let agentPid = Number(process.env.LIVEDESK_CLIENT_AGENT_PID || 0);',
|
|
100
105
|
'let cursor = parentOf(process.pid);',
|
|
101
|
-
'for (let depth = 0; depth < 12 && cursor; depth++) { const command = commandOf(cursor); if (!agentPid && /livedesk-client-node\\.js/i.test(command)) agentPid = cursor; if (!launcherPid && /livedesk-client\\.js|livedesk\\.js/i.test(command)) launcherPid = cursor; cursor = parentOf(cursor); }',
|
|
106
|
+
'for (let depth = 0; depth < 12 && cursor; depth++) { const command = commandOf(cursor); if (!agentPid && /livedesk-client-node\\.js|livedesk-client-fast|RemoteAgent\\.Fast/i.test(command)) agentPid = cursor; if (!launcherPid && /livedesk-client\\.js|livedesk\\.js/i.test(command)) launcherPid = cursor; cursor = parentOf(cursor); }',
|
|
102
107
|
'if (launcherPid <= 1) throw new Error("LiveDesk client launcher process was not found.");',
|
|
103
108
|
'const waitPid = launcherPid;',
|
|
104
109
|
`process.env.LIVEDESK_CLIENT_MANAGER = ${JSON.stringify(String(manager || ''))};`,
|