- scripts/build-twa.mjs: baut TWA-Build - Pre-Flight-Checks (Manifest, sha256-Fingerprint-Warnung) - Versucht bubblewrap (npm-Paket) - Fallback: PWABuilder.com-Anleitung - webapp/TWA-BUILD.md: Schnellstart mit 'npm run build:twa'
81 lines
3.1 KiB
JavaScript
81 lines
3.1 KiB
JavaScript
#!/usr/bin/env node
|
|
// TWA-Build-Script (Phase 5)
|
|
// Versucht zuerst bubblewrap, faellt auf PWABuilder.com zurueck
|
|
|
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
import { execSync } from 'node:child_process';
|
|
import { join, resolve, dirname } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
const ROOT = resolve(__dirname, '..');
|
|
const WEBAPP = join(ROOT, 'webapp');
|
|
|
|
console.log('TWA-Build-Script fuer Mind-o-Mat');
|
|
console.log('====================================');
|
|
console.log('');
|
|
|
|
// 1. Pre-Flight-Checks
|
|
const manifestPath = join(WEBAPP, 'twa-manifest.json');
|
|
const assetlinksPath = join(WEBAPP, 'public', '.well-known', 'assetlinks.json');
|
|
|
|
if (!existsSync(manifestPath)) {
|
|
console.error(`FEHLER: twa-manifest.json nicht gefunden: ${manifestPath}`);
|
|
console.error('Bitte zuerst `npm install` ausfuehren.');
|
|
process.exit(1);
|
|
}
|
|
|
|
const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));
|
|
console.log(`Package-ID: ${manifest.packageId}`);
|
|
console.log(`Host: ${manifest.host}`);
|
|
console.log(`Version: ${manifest.versionName} (${manifest.versionCode})`);
|
|
|
|
if (manifest.sha256CertFingerprints?.[0] === 'REPLACE_WITH_YOUR_SHA256_FINGERPRINT') {
|
|
console.error('');
|
|
console.error('WARNUNG: sha256CertFingerprints ist noch ein Platzhalter.');
|
|
console.error('Bitte in webapp/twa-manifest.json eintragen, bevor du in den Play Store gehst.');
|
|
console.error('Siehe docs/SECRETS.md und webapp/TWA-BUILD.md fuer Details.');
|
|
console.error('');
|
|
}
|
|
|
|
// 2. Versuche bubblewrap
|
|
console.log('');
|
|
console.log('Versuche bubblewrap...');
|
|
|
|
try {
|
|
execSync('npx --yes @bubblewrap/cli --version', { stdio: 'inherit' });
|
|
console.log('bubblewrap gefunden. Starte Build...');
|
|
execSync(`npx --yes @bubblewrap/cli build --manifest="${manifestPath}"`, {
|
|
stdio: 'inherit',
|
|
cwd: ROOT,
|
|
});
|
|
console.log('');
|
|
console.log('Build erfolgreich. Output:');
|
|
console.log(' app-release-bundle.aab (Play Store)');
|
|
console.log(' app-release-signed.apk (Direkt-Install)');
|
|
process.exit(0);
|
|
} catch (err) {
|
|
console.log('bubblewrap fehlgeschlagen oder nicht verfuegbar.');
|
|
}
|
|
|
|
// 3. Fallback: PWABuilder.com-Anleitung
|
|
console.log('');
|
|
console.log('Fallback: Nutze PWABuilder.com (einfacher, online)');
|
|
console.log('');
|
|
console.log('Schritte:');
|
|
console.log('1. Gehe zu https://www.pwabuilder.com/');
|
|
console.log('2. Gib die URL deiner gehosteten PWA an (Manifest-URL:');
|
|
console.log(` https://${manifest.host}/manifest.webmanifest`);
|
|
console.log('3. Klicke "Build" -> "Android" -> "Trusted Web Activity"');
|
|
console.log('4. Lade die resultierende AAB-Datei herunter');
|
|
console.log('5. Lade sie im Google Play Console hoch');
|
|
console.log('');
|
|
console.log('Was du brauchst:');
|
|
console.log('- HTTPS-Domain mit deiner PWA (z. B. https://' + manifest.host + ')');
|
|
console.log('- Digital-Asset-Links-File: webapp/public/.well-known/assetlinks.json');
|
|
console.log(' (in PWABuilder einrichten unter "Package ID" + "SHA-256 Fingerprint")');
|
|
console.log('- Google-Play-Console-Account ($25 einmalig)');
|
|
console.log('');
|
|
console.log('Siehe webapp/TWA-BUILD.md fuer Details.');
|