const { execFileSync } = require("node:child_process"); // Build metadata, injected into `extra.build` and read at runtime via // expo-constants (see utils/version.ts). Sources in priority order: // EAS cloud build → GitHub Actions → explicit EXPO_PUBLIC_* → local git → null. const git = (args) => { try { return execFileSync("git", args, { stdio: ["ignore", "pipe", "ignore"] }) .toString() .trim(); } catch { return null; } }; const buildMeta = { commit: ( process.env.EAS_BUILD_GIT_COMMIT_HASH || process.env.GITHUB_SHA || process.env.EXPO_PUBLIC_GIT_COMMIT || git(["rev-parse", "HEAD"]) || "" ).slice(0, 7) || null, branch: process.env.EAS_BUILD_GIT_BRANCH || process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME || process.env.EXPO_PUBLIC_GIT_BRANCH || git(["rev-parse", "--abbrev-ref", "HEAD"]) || null, profile: process.env.EAS_BUILD_PROFILE || process.env.EXPO_PUBLIC_BUILD_PROFILE || null, builtAt: new Date().toISOString(), }; module.exports = ({ config }) => { if (process.env.EXPO_TV !== "1") { config.plugins.push("expo-background-task"); config.plugins.push([ "react-native-google-cast", { useDefaultExpandedMediaControls: true }, ]); config.plugins.push([ "expo-camera", { cameraPermission: "Allow Streamyfin to access the camera to scan QR codes for TV login.", }, ]); } // Only override googleServicesFile if env var is set const androidConfig = {}; if (process.env.GOOGLE_SERVICES_JSON) { androidConfig.googleServicesFile = process.env.GOOGLE_SERVICES_JSON; } config.extra = { ...config.extra, build: buildMeta }; return { ...(Object.keys(androidConfig).length > 0 && { android: androidConfig }), ...config, }; };