diff --git a/.gitignore b/.gitignore index 47ca577..37f6dfd 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ ios/App/public/ # Secrets .env .env.local +coach-ios.local.json *.p8 *.p12 *.mobileprovision diff --git a/README.md b/README.md index f4a3489..e04981a 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,23 @@ Le code web n'est pas embarqué — l'app pointe vers la prod via `server.url` d ### 1. Cloner le repo sur le Mac mini ```bash -git clone git@gitea:sylvain/coach-ios.git +git clone https://git.nexus.hypnotruck.ch/sylvain/coach-ios.git cd coach-ios npm install ``` +### 1bis. Configurer le token d'auth (auto-login) + +Le repo ne contient **pas** le token `COACH_WEB_TOKEN` (gitignored). Crée le fichier sur le Mac : + +```bash +cp coach-ios.local.json.example coach-ios.local.json +# Édite coach-ios.local.json et remplace par la vraie valeur +# (visible dans ~/.config/infomaniak.env sur le VPS, ligne export COACH_WEB_TOKEN=) +``` + +L'app utilisera ce token pour se connecter automatiquement à `coach.hypnotruck.ch/login?token=...` au lancement. + ### 2. Générer les icônes & splash ```bash diff --git a/capacitor.config.ts b/capacitor.config.ts index 58e2696..4b99874 100644 --- a/capacitor.config.ts +++ b/capacitor.config.ts @@ -1,4 +1,19 @@ import type { CapacitorConfig } from '@capacitor/cli'; +import { readFileSync, existsSync } from 'fs'; +import { resolve } from 'path'; + +// Token d'auth coach.hypnotruck.ch chargé depuis coach-ios.local.json (gitignored). +// Sur le Mac mini : créer ce fichier avec { "coachWebToken": "..." } avant de builder. +const localConfigPath = resolve(__dirname, 'coach-ios.local.json'); +const localConfig = existsSync(localConfigPath) + ? JSON.parse(readFileSync(localConfigPath, 'utf-8')) + : {}; +const coachWebToken: string = localConfig.coachWebToken || ''; + +const baseUrl = 'https://coach.hypnotruck.ch'; +const startUrl = coachWebToken + ? `${baseUrl}/login?token=${encodeURIComponent(coachWebToken)}` + : baseUrl; const config: CapacitorConfig = { appId: 'ch.hypnotruck.coach', @@ -6,7 +21,7 @@ const config: CapacitorConfig = { webDir: 'www', server: { - url: 'https://coach.hypnotruck.ch', + url: startUrl, cleartext: false, androidScheme: 'https', }, diff --git a/coach-ios.local.json.example b/coach-ios.local.json.example new file mode 100644 index 0000000..c28e9d8 --- /dev/null +++ b/coach-ios.local.json.example @@ -0,0 +1,3 @@ +{ + "coachWebToken": "REMPLACE_PAR_LA_VALEUR_DE_COACH_WEB_TOKEN" +}