tt-help-cli-ycl 1.4.93 → 1.4.95
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/watchdog/upgrader.js +17 -4
package/package.json
CHANGED
package/src/watchdog/upgrader.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { exec, spawn } from "child_process";
|
|
10
10
|
import { readFileSync, openSync } from "fs";
|
|
11
|
-
import { fileURLToPath } from "url";
|
|
11
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
12
12
|
import { dirname, join } from "path";
|
|
13
13
|
import { homedir, tmpdir } from "os";
|
|
14
14
|
|
|
@@ -135,7 +135,10 @@ async function verifyUpgradedPackage(beforeVersion) {
|
|
|
135
135
|
/** 冒烟:spawn 子进程加载新版主模块(仅加载不执行业务),能加载则代码/依赖基本可用 */
|
|
136
136
|
function smokeTestMainModule(timeoutMs = 15_000) {
|
|
137
137
|
return new Promise((resolve) => {
|
|
138
|
-
|
|
138
|
+
// 必须转成 file:// URL:Windows 上裸的 C:\... 路径会被 ESM loader 当作协议 c: 而报错
|
|
139
|
+
const mainModulePath = pathToFileURL(
|
|
140
|
+
join(__dirname, "..", "..", "src", "main.js"),
|
|
141
|
+
).href;
|
|
139
142
|
const code = `import(${JSON.stringify(
|
|
140
143
|
mainModulePath,
|
|
141
144
|
)}).then(()=>process.exit(0)).catch((e)=>{console.error(e&&e.message||e);process.exit(1)})`;
|
|
@@ -340,7 +343,12 @@ export async function runUpgradeMode(argv) {
|
|
|
340
343
|
// 4) 旧进程已退,启新版 watchdog(无并存窗口,一定能起来)
|
|
341
344
|
console.error(`[upgrade-proc] 启动新版 watchdog ...`);
|
|
342
345
|
const cliPath = join(__dirname, "..", "..", "cli.js");
|
|
343
|
-
const args = buildWatchdogArgs({
|
|
346
|
+
const args = buildWatchdogArgs({
|
|
347
|
+
serverUrl,
|
|
348
|
+
clientId,
|
|
349
|
+
intervalSec,
|
|
350
|
+
noDaemon,
|
|
351
|
+
});
|
|
344
352
|
const logFd = openLogFile(
|
|
345
353
|
"tt-help-watchdog",
|
|
346
354
|
"upgrade-proc",
|
|
@@ -388,7 +396,12 @@ export function spawnUpgrader({
|
|
|
388
396
|
}
|
|
389
397
|
|
|
390
398
|
// 直接运行时自动进入独立升级器模式
|
|
391
|
-
|
|
399
|
+
// 必须显式 --upgrade 才执行(防误调用:如 --help 或无参数时不应触发真实 npm install)
|
|
400
|
+
if (
|
|
401
|
+
process.argv[1] &&
|
|
402
|
+
fileURLToPath(import.meta.url) === process.argv[1] &&
|
|
403
|
+
process.argv.includes("--upgrade")
|
|
404
|
+
) {
|
|
392
405
|
runUpgradeMode(process.argv.slice(2)).catch((e) => {
|
|
393
406
|
console.error(`[upgrade-proc] 升级器异常: ${e.message}`);
|
|
394
407
|
process.exit(1);
|