@yeaft/webchat-agent 0.1.77 → 0.1.78

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/cli.js CHANGED
@@ -223,6 +223,7 @@ function upgradeWindows(latestVersion) {
223
223
 
224
224
  writeFileSync(batPath, batLines.join('\r\n'));
225
225
  const child = spawn('cmd.exe', ['/c', batPath], {
226
+ detached: true,
226
227
  stdio: 'ignore',
227
228
  windowsHide: true,
228
229
  });
@@ -76,7 +76,7 @@ try {
76
76
  log('Temp dir: ' + tmpDir);
77
77
 
78
78
  const packOutput = execFileSync('npm', ['pack', PKG, '--pack-destination', tmpDir], {
79
- shell: true, encoding: 'utf8', cwd: tmpDir, timeout: 120000
79
+ shell: process.platform === 'win32', encoding: 'utf8', cwd: tmpDir, timeout: 120000
80
80
  }).trim();
81
81
  const tgzName = packOutput.split('\n').pop().trim();
82
82
  const tgzPath = path.join(tmpDir, tgzName);
@@ -100,7 +100,7 @@ try {
100
100
  log('Installing dependencies...');
101
101
  try {
102
102
  execFileSync('npm', ['install', '--omit=dev'], {
103
- shell: true, cwd: TARGET, encoding: 'utf8', timeout: 120000
103
+ shell: process.platform === 'win32', cwd: TARGET, encoding: 'utf8', timeout: 120000
104
104
  });
105
105
  log('Dependencies installed');
106
106
  } catch (depErr) {
@@ -46,7 +46,7 @@ export async function handleUpgradeAgent() {
46
46
  const pkgName = ctx.pkgName || '@yeaft/webchat-agent';
47
47
  // Check latest version (async to avoid blocking heartbeat)
48
48
  const latestVersion = await new Promise((resolve, reject) => {
49
- execFile('npm', ['view', pkgName, 'version'], { stdio: 'pipe', shell: true }, (err, stdout) => {
49
+ execFile('npm', ['view', pkgName, 'version'], { stdio: 'pipe', shell: process.platform === 'win32' }, (err, stdout) => {
50
50
  if (err) reject(err); else resolve(stdout.toString().trim());
51
51
  });
52
52
  });
@@ -74,7 +74,7 @@ export async function handleUpgradeAgent() {
74
74
 
75
75
  // 判断全局安装 vs 局部安装
76
76
  const isGlobalInstall = await new Promise((resolve) => {
77
- execFile('npm', ['prefix', '-g'], { shell: true }, (err, stdout) => {
77
+ execFile('npm', ['prefix', '-g'], { shell: process.platform === 'win32' }, (err, stdout) => {
78
78
  if (err) { resolve(false); return; }
79
79
  const globalPrefix = stdout.toString().trim().replace(/\\/g, '/');
80
80
  resolve(installDir === globalPrefix || installDir === globalPrefix + '/lib');
@@ -94,7 +94,7 @@ export async function handleUpgradeAgent() {
94
94
  const isPm2 = !!process.env.pm_id;
95
95
  if (isPm2) {
96
96
  try {
97
- execFileSync('pm2', ['delete', PM2_APP_NAME], { shell: true, stdio: 'pipe' });
97
+ execFileSync('pm2', ['delete', PM2_APP_NAME], { shell: process.platform === 'win32', stdio: 'pipe' });
98
98
  console.log(`[Agent] PM2 app deleted to prevent auto-restart during upgrade`);
99
99
  } catch {
100
100
  console.log(`[Agent] PM2 delete skipped (app may not be registered)`);
@@ -201,8 +201,9 @@ function spawnWindowsUpgradeScript(pkgName, installDir, isGlobalInstall, latestV
201
201
 
202
202
  writeFileSync(batPath, batLines.join('\r\n'));
203
203
  const child = spawn('cmd.exe', ['/c', batPath], {
204
+ detached: true,
204
205
  stdio: 'ignore',
205
- windowsHide: true
206
+ windowsHide: true,
206
207
  });
207
208
  child.unref();
208
209
  console.log(`[Agent] Spawned upgrade script (PID wait for ${pid}, pm2=${isPm2}, dir=${installDir}): ${batPath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.77",
3
+ "version": "0.1.78",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",