@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 +1 -0
- package/connection/upgrade-worker-template.js +2 -2
- package/connection/upgrade.js +5 -4
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -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:
|
|
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:
|
|
103
|
+
shell: process.platform === 'win32', cwd: TARGET, encoding: 'utf8', timeout: 120000
|
|
104
104
|
});
|
|
105
105
|
log('Dependencies installed');
|
|
106
106
|
} catch (depErr) {
|
package/connection/upgrade.js
CHANGED
|
@@ -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:
|
|
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:
|
|
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:
|
|
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}`);
|