- Drei Design-Vorlagen (Kreis, Klar, Kacheln) mit Feinschliff: vier gut lesbare Schriften, eckig/rund/sehr rund, Hausfarben mit Live-Kontrastprüfung und „Farbe anpassen“; der Server lehnt zu helle Farben mit Vorschlag ab - Fertige Farbpaare alle mit mindestens 4,5:1 zu Weiß - Markenfarben greifen jetzt zuverlässig (Spezifität der eingebetteten Variablen); dunkle Darstellung wird aus der Hauptfarbe abgeleitet statt fest Indigo - Checkliste „Erste Schritte“ im Dashboard für neue Einrichtungen - Startwerte (APP_NAME, ORG_NAME, BRAND_COLOR, ACCENT_COLOR) beim ersten Start - deploy/: neue-einrichtung.sh, aktualisieren.sh, sichern.sh für eine Installation je Kunde mit gemeinsamem Image - mobile/: KUNDE=<kurzname> baut die App einer Einrichtung aus mobile/kunden/<kurzname>/ inklusive deren Firebase-Dateien Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
63 lines
2.6 KiB
JavaScript
63 lines
2.6 KiB
JavaScript
/**
|
|
* Holt App-Symbol und Benachrichtigungssymbole vom Server (aus Logo und Markenfarbe
|
|
* in der Redaktion) und erzeugt daraus alle Größen für iOS und Android.
|
|
* npm run assets
|
|
* Optional: ASSET_URL=http://localhost:5173 npm run assets (andere Quelle als APP_URL)
|
|
*/
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { execFileSync } from 'node:child_process';
|
|
import { fileURLToPath } from 'node:url';
|
|
import sharp from 'sharp';
|
|
import { loadEnv } from '../env.mjs';
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const env = loadEnv();
|
|
const base = (process.env.ASSET_URL || env.appUrl).replace(/\/+$/, '');
|
|
|
|
async function download(url) {
|
|
const res = await fetch(url);
|
|
if (!res.ok) throw new Error(`${url} → ${res.status}. Läuft die Web-App unter dieser Adresse?`);
|
|
return Buffer.from(await res.arrayBuffer());
|
|
}
|
|
|
|
// 1) Symbol in voller Größe (randlos, für App-Symbol und Startbildschirm)
|
|
fs.mkdirSync(path.join(root, 'assets'), { recursive: true });
|
|
const icon = await download(`${base}/app-icon/1024?maskable`);
|
|
fs.writeFileSync(path.join(root, 'assets', 'logo.png'), icon);
|
|
|
|
// Hintergrundfarbe aus der Ecke des Symbols lesen (Markenfarbe oder Weiß bei hochgeladenem Logo)
|
|
const { data } = await sharp(icon).extract({ left: 2, top: 2, width: 1, height: 1 }).raw().toBuffer({ resolveWithObject: true });
|
|
const bg = `#${[data[0], data[1], data[2]].map((v) => v.toString(16).padStart(2, '0')).join('')}`;
|
|
console.log(`Hintergrundfarbe: ${bg}`);
|
|
|
|
// 2) Android-Benachrichtigungssymbol (weiß auf transparent) in allen Dichten
|
|
const densities = { mdpi: 24, hdpi: 36, xhdpi: 48, xxhdpi: 72, xxxhdpi: 96 };
|
|
if (fs.existsSync(path.join(root, 'android'))) {
|
|
for (const [density, size] of Object.entries(densities)) {
|
|
const dir = path.join(root, 'android', 'app', 'src', 'main', 'res', `drawable-${density}`);
|
|
fs.mkdirSync(dir, { recursive: true });
|
|
fs.writeFileSync(path.join(dir, 'ic_stat_notify.png'), await download(`${base}/app-icon/${size}?notification`));
|
|
}
|
|
console.log('✔ Android-Benachrichtigungssymbol');
|
|
}
|
|
|
|
// 3) Alle Symbole und Startbildschirme erzeugen
|
|
execFileSync(
|
|
'npx',
|
|
[
|
|
'capacitor-assets',
|
|
'generate',
|
|
'--ios',
|
|
'--android',
|
|
'--iconBackgroundColor', bg,
|
|
'--iconBackgroundColorDark', bg,
|
|
'--splashBackgroundColor', env.brandColor,
|
|
'--splashBackgroundColorDark', env.brandColor,
|
|
'--logoSplashScale', '0.25'
|
|
],
|
|
{ cwd: root, stdio: 'inherit' }
|
|
);
|
|
// Merken, für welche Einrichtung die Symbole erzeugt wurden (prüft `npm run sync`)
|
|
fs.writeFileSync(path.join(root, 'assets', '.einrichtung'), env.appId);
|
|
console.log('✔ Symbole und Startbildschirme erzeugt. Danach `npm run sync`.');
|