dd-timer/docs/plans/2026-04-04-electron-updater-design.md
POL Mickaël 2893013093 docs: README, CLAUDE.md, changelog, plans de conception
- README : fonctionnalités, installation, build, tests (302 + 20 E2E),
  couverture 94%, workflow mise à jour latest.yml, changelog v1.1.6
- CLAUDE.md : règles de collaboration, architecture, conventions
- Plans de conception : DDD, electron-updater, accouplement, toast

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 05:43:38 +02:00

2.2 KiB

Migration electron-updater + Gitea — Design

Objectif

Remplacer le système de mise à jour custom (download HTTP manuel + script batch NSIS) par electron-updater, tout en conservant Gitea comme hébergeur de releases.

Contrainte Gitea

Gitea ne supporte pas l'URL /releases/latest/download/{filename} (issue #31408 ouverte). On utilise donc une approche hybride :

  1. Appel API Gitea pour découvrir la dernière version
  2. electron-updater (generic provider) pour le cycle download → vérification sha512 → installation NSIS → restart

Workflow de release

  1. npm run build → génère .exe + latest.yml dans dist/
  2. Créer le tag git, push
  3. Sur Gitea : créer la release, uploader le .exe ET latest.yml

Architecture

Flux côté app

Démarrage (3s) → GET /api/v1/repos/mickael/dd-timer/releases/latest
  → Compare versions (tag_name vs app.getVersion())
  → Si update dispo :
      autoUpdater.setFeedURL({
        provider: "generic",
        url: "https://gitea.mickael-pol.fr/mickael/dd-timer/releases/download/{tag}/"
      })
      autoUpdater.checkForUpdates()
      → electron-updater lit latest.yml
      → Télécharge le .exe (download-progress events)
      → update-downloaded → prêt à installer
      → quitAndInstall() au clic utilisateur

Changements par fichier

Fichier Action
package.json Ajouter electron-updater dep + config publish generic
main.ts Supprimer download HTTP, redirections, script batch. Garder appel API Gitea. Ajouter autoUpdater events.
preload.ts Inchangé (mêmes IPC channels)
UpdateBanner.ts Inchangé

IPC channels (conservés)

  • update-available → bannière disponible
  • update-downloading → bannière téléchargement
  • update-progress → { percent }
  • update-ready → bouton "Installer et redémarrer"
  • update-error → message erreur
  • install-update → déclenche quitAndInstall()

Avantages

  • Suppression du script batch hack (~80 lignes)
  • Vérification d'intégrité sha512 automatique
  • Gestion NSIS install + restart native
  • Code main.ts simplifié (~40 lignes vs ~200)
  • Zéro infra supplémentaire