Files
musicshare/apps/mobile/app.config.ts
T
chrisandClaude Opus 5.5 a4dad724ad
CI / check (push) Canceled after 0s
Get the repo ready for F-Droid
- License: AGPL-3.0-or-later (LICENSE, every package.json, README).
- MUSICSHARE_FOSS=1 builds leave out the only closed-source code, Google's
  ML Kit / Play Services barcode scanner bundled by expo-camera; the scan
  screen then decodes small camera snapshots with jsQR instead.
- Expo modules build from source rather than from precompiled AARs, as
  F-Droid requires (that's also what makes the scanner switch take effect).
  Verified: a FOSS build contains no ML Kit or Play Services classes.
- Release builds default to the production server, and come out unsigned
  without our upload key (F-Droid signs with its own). versionCode 1.
- Store listing in fastlane/metadata/android, a draft fdroiddata recipe in
  fdroid/, and docs/FDROID.md with the submission steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8
2026-10-06 15:26:59 -04:00

27 lines
1.2 KiB
TypeScript

import type { ConfigContext, ExpoConfig } from 'expo/config';
/**
* app.json holds the real config; this only adds build-time switches.
*
* Local test builds point at a dev server over plain http://, which Android
* blocks by default in release builds. Allow cleartext only when the API URL
* itself is http://, so store builds (https) stay locked down.
*/
export default ({ config }: ConfigContext): ExpoConfig => {
const apiUrl = process.env.EXPO_PUBLIC_API_URL ?? '';
const localHttp = apiUrl.startsWith('http://');
// F-Droid (MUSICSHARE_FOSS=1): no closed-source libraries. The only one is the Google ML Kit /
// Play Services barcode scanner expo-camera bundles; the scan screen decodes QR codes in JS instead.
const foss = process.env.MUSICSHARE_FOSS === '1';
type Plugin = NonNullable<ExpoConfig['plugins']>[number];
const plugins = (config.plugins ?? []).map(
(plugin): Plugin =>
foss && Array.isArray(plugin) && plugin[0] === 'expo-camera' ? ['expo-camera', { ...plugin[1], barcodeScannerEnabled: false }] : plugin,
);
return {
...(config as ExpoConfig),
extra: { ...config.extra, foss },
plugins: [...plugins, ['expo-build-properties', { android: { usesCleartextTraffic: localHttp } }] satisfies Plugin],
};
};