tt-help-cli-ycl 1.4.58 → 1.4.59

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-help-cli-ycl",
3
- "version": "1.4.58",
3
+ "version": "1.4.59",
4
4
  "description": "TikTok user & video data scraper - extract ttSeller, verified, locationCreated from HTML source",
5
5
  "type": "module",
6
6
  "bin": {
@@ -35,6 +35,9 @@ export class WatchdogAgent {
35
35
  this.maxFailures = 10;
36
36
  this.upgradeChecker = null;
37
37
  this.ttHelpVersion = getVersion();
38
+ this._heartbeatSeq = 0; // 心跳序号
39
+ this._lastProcCount = -1; // 上次进程数
40
+ this._lastCmdCount = -1; // 上次命令数
38
41
  }
39
42
 
40
43
  /**
@@ -156,10 +159,19 @@ export class WatchdogAgent {
156
159
  }
157
160
  }
158
161
 
159
- const ts = new Date().toLocaleTimeString("zh-CN", { hour12: false });
160
- console.error(
161
- `[watchdog ${ts}] 心跳 OK (${procCount}进程, ${data.commands?.length || 0}条)`,
162
- );
162
+ // 心跳日志:仅状态变化或每 10 次打印一次
163
+ this._heartbeatSeq++;
164
+ const cmdCount = data.commands?.length || 0;
165
+ const changed =
166
+ procCount !== this._lastProcCount || cmdCount !== this._lastCmdCount;
167
+ if (changed || this._heartbeatSeq % 10 === 1) {
168
+ const ts = new Date().toLocaleTimeString("zh-CN", { hour12: false });
169
+ console.error(
170
+ `[watchdog ${ts}] 心跳 OK (${procCount}进程, ${cmdCount}条)`,
171
+ );
172
+ this._lastProcCount = procCount;
173
+ this._lastCmdCount = cmdCount;
174
+ }
163
175
  } catch (e) {
164
176
  this.consecutiveFailures++;
165
177
  console.error(
@@ -11,8 +11,13 @@
11
11
 
12
12
  import { spawn, execSync } from "child_process";
13
13
  import { EventEmitter } from "events";
14
+ import os from "os";
14
15
 
15
16
  const MAX_RESTART = 3;
17
+ const SHELL =
18
+ os.platform() === "win32"
19
+ ? { cmd: process.env.COMSPEC || "cmd.exe", flag: "/c" }
20
+ : { cmd: "sh", flag: "-c" };
16
21
 
17
22
  function getProcessStats(pid) {
18
23
  try {
@@ -67,7 +72,7 @@ export class ProcessManager extends EventEmitter {
67
72
  detached: false,
68
73
  });
69
74
  } else {
70
- child = spawn("sh", ["-c", command], {
75
+ child = spawn(SHELL.cmd, [SHELL.flag, command], {
71
76
  stdio: ["ignore", "pipe", "pipe"],
72
77
  detached: false,
73
78
  });
@@ -26,9 +26,11 @@ export function getVersion() {
26
26
 
27
27
  /** 是否通过全局 npm 安装运行 */
28
28
  export function isGlobalInstall() {
29
- const entry = process.argv[1] || "";
29
+ const entry = (process.argv[1] || "").replace(/\\/g, "/");
30
30
  return (
31
- entry.includes(`/node_modules/${PACKAGE}/`) || entry.endsWith("/tt-help")
31
+ entry.includes(`/node_modules/${PACKAGE}/`) ||
32
+ entry.endsWith("/tt-help") ||
33
+ entry.endsWith("/tt-help.cmd")
32
34
  );
33
35
  }
34
36