sitecheckultra 2.0.2 → 2.0.3
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/bin/sitecheckultra.js +26 -9
- package/package.json +1 -1
package/bin/sitecheckultra.js
CHANGED
|
@@ -117,12 +117,18 @@ function checkForUpdates() {
|
|
|
117
117
|
log('╚════════════════════════════════════════════════════════╝', colors.yellow);
|
|
118
118
|
log('');
|
|
119
119
|
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
// Auto-Update bei JEDEM Start (npx ODER globale Installation),
|
|
121
|
+
// außer SCU_NO_UPDATE=1. Grund: `npm exec scu` kann den CLI-Eintrag
|
|
122
|
+
// der GLOBALEN Installation auflösen — eine reine _npx-Pfaderkennung
|
|
123
|
+
// greift dann nicht und der Nutzer läuft dauerhaft auf der alten
|
|
124
|
+
// Version. Nach erfolgreichem Update startet dieser Prozess die
|
|
125
|
+
// neue globale Binärversion als Kindprozess und beendet sich selbst,
|
|
126
|
+
// OHNE selbst noch einen Server zu starten (sonst laufen zwei Server
|
|
127
|
+
// unterschiedlicher Versionen auf verschiedenen Ports).
|
|
128
|
+
if (process.env.SCU_NO_UPDATE === '1') {
|
|
129
|
+
log('ℹ Update-Prüfung übersprungen (SCU_NO_UPDATE=1).', colors.dim);
|
|
130
|
+
} else {
|
|
131
|
+
log(`ℹ Neue Version gefunden – update automatisch auf ${latest.version}…`, colors.cyan);
|
|
126
132
|
try {
|
|
127
133
|
execSync(updateCmd, { stdio: 'inherit' });
|
|
128
134
|
log('✓ Update installiert – starte neue Version…', colors.green);
|
|
@@ -130,6 +136,9 @@ function checkForUpdates() {
|
|
|
130
136
|
const globalBin = process.platform === 'win32'
|
|
131
137
|
? join(globalPrefix, 'sitecheckultra.cmd')
|
|
132
138
|
: join(globalPrefix, 'bin', 'sitecheckultra');
|
|
139
|
+
if (!existsSync(globalBin)) {
|
|
140
|
+
throw new Error(`Globale Binärdatei nach Update nicht gefunden: ${globalBin}`);
|
|
141
|
+
}
|
|
133
142
|
const child = spawn(process.execPath, [globalBin], {
|
|
134
143
|
env: { ...process.env, SITECHECK_UPDATED: String(latest.version) },
|
|
135
144
|
stdio: 'inherit'
|
|
@@ -137,7 +146,7 @@ function checkForUpdates() {
|
|
|
137
146
|
child.on('exit', (code) => process.exit(code || 0));
|
|
138
147
|
process.on('SIGINT', () => { child.kill('SIGINT'); process.exit(0); });
|
|
139
148
|
process.on('SIGTERM', () => { child.kill('SIGTERM'); process.exit(0); });
|
|
140
|
-
resolve(
|
|
149
|
+
resolve('replaced');
|
|
141
150
|
return;
|
|
142
151
|
} catch (err) {
|
|
143
152
|
log(`⚠ Auto-Update fehlgeschlagen: ${err.message}`, colors.yellow);
|
|
@@ -213,6 +222,8 @@ async function findFreePort(startPort = DEFAULT_PORT) {
|
|
|
213
222
|
* Öffnet den Browser
|
|
214
223
|
*/
|
|
215
224
|
function openBrowser(url) {
|
|
225
|
+
// SCU_NO_BROWSER=1 unterdrückt das Browser-Öffnen (z. B. für Tests/CI).
|
|
226
|
+
if (process.env.SCU_NO_BROWSER === '1') return;
|
|
216
227
|
const platform = process.platform;
|
|
217
228
|
let command;
|
|
218
229
|
|
|
@@ -335,8 +346,14 @@ async function main() {
|
|
|
335
346
|
// 1. Node.js Version prüfen
|
|
336
347
|
checkNodeVersion();
|
|
337
348
|
|
|
338
|
-
// 2. Auf Updates prüfen
|
|
339
|
-
|
|
349
|
+
// 2. Auf Updates prüfen und ggf. automatisch aktualisieren. Wird hier
|
|
350
|
+
// bewusst GEWARTET (statt parallel), damit nach einem Auto-Update nicht
|
|
351
|
+
// parallel ein alter Server auf einem anderen Port hochfährt.
|
|
352
|
+
const updateResult = await checkForUpdates();
|
|
353
|
+
if (updateResult === 'replaced') {
|
|
354
|
+
// Die neue Version läuft als Kindprozess weiter — hier nichts mehr tun.
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
340
357
|
|
|
341
358
|
// 3. Server starten
|
|
342
359
|
await startServer();
|
package/package.json
CHANGED