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.
@@ -117,12 +117,18 @@ function checkForUpdates() {
117
117
  log('╚════════════════════════════════════════════════════════╝', colors.yellow);
118
118
  log('');
119
119
 
120
- // npx-Lauf (npx scu / npx sitecheckultra): automatisch auf die
121
- // neue Version heben und danach die GLOBALE Installation starten
122
- // (npm install -g ersetzt die Dateien; der npx-Cache-Code bleibt alt).
123
- const runningViaNpx = String(process.argv[1] || '').includes(`${sep}_npx${sep}`);
124
- if (runningViaNpx) {
125
- log('ℹ npx-Lauf erkannt – starte Update auf die neueste Version…', colors.cyan);
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(true);
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 (asynchron, blockiert nicht)
339
- checkForUpdates();
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sitecheckultra",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Site Check Ultra – Website Audit Tool (SEO, AEO, Speed, Mobile, WCAG, H-Baum, Redirects, Schema, Tracking, Link-Check)",
5
5
  "type": "module",
6
6
  "main": "server.js",