CI / Build & test (Node 24) (push) Has been cancelled
CI / Pack & boot smoke (Node 22) (push) Has been cancelled
CI / No em/en dashes (push) Has been cancelled
CI / Build & test (Node 22) (push) Has been cancelled
Deploy site (production) / build-and-deploy (push) Successful in 20s
Remplace les 547 tirets cadratins (U+2014) et demi-cadratins (U+2013) des fichiers versionnés par la ponctuation contextuelle adaptée (point médian, deux-points, virgule, parenthèses ; tiret simple pour les plages), sur 122 fichiers (appli, vitrine, doc, tests, workflows, scripts). Ajoute le job CI « lint-dashes » (git grep -P) qui échoue si un tiret cadratin/demi-cadratin réapparaît, hors logo binaire et captures brutes du terminal (fidélité des fixtures de détection de dialogue).
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
// Planificateur de la découverte auto des repos : scan au démarrage + re-scan périodique.
|
|
// Calqué sur DiscoveryService (sessions) : start()/stop() avec timer .unref(). Démarré depuis
|
|
// runDaemon() UNIQUEMENT (jamais buildApp), ce qui isole naturellement les tests vitest du scan.
|
|
// Lui-même sans état : il lit les racines/l'intervalle dans `settings` et délègue à WorktreeManager.
|
|
import type { Db } from '../db/index.js';
|
|
import type { WorktreeManager } from './worktree-manager.js';
|
|
import { readScanIntervalMin, readScanRoots } from './scan-settings.js';
|
|
|
|
export class RepoDiscoveryService {
|
|
private timer: NodeJS.Timeout | null = null;
|
|
|
|
constructor(
|
|
private readonly db: Db,
|
|
private readonly worktrees: WorktreeManager,
|
|
) {}
|
|
|
|
start(): void {
|
|
if (this.timer) return;
|
|
void this.refresh(); // scan initial asynchrone : ne bloque pas le boot
|
|
const intervalMin = readScanIntervalMin(this.db);
|
|
if (intervalMin > 0) {
|
|
this.timer = setInterval(() => void this.refresh(), intervalMin * 60_000);
|
|
this.timer.unref(); // ne maintient pas le process en vie
|
|
}
|
|
}
|
|
|
|
stop(): void {
|
|
if (this.timer) {
|
|
clearInterval(this.timer);
|
|
this.timer = null;
|
|
}
|
|
}
|
|
|
|
/** Relit les racines (changement effectif sans redémarrage) et lance un scan. Ne lève jamais. */
|
|
private async refresh(): Promise<void> {
|
|
try {
|
|
await this.worktrees.discoverRepos({ roots: readScanRoots(this.db) });
|
|
} catch {
|
|
/* scan tolérant : une erreur ne doit pas tuer le timer */
|
|
}
|
|
}
|
|
}
|