import pick from 'lodash.pick'; import { ExpoConfig, ConfigContext } from '@expo/config'; import dotenv from 'dotenv'; const variables = ['SENTRY_AUTH_TOKEN', 'STAGE', 'SENTRY_PROJECT', 'SENTRY_ORG']; dotenv.config(); /** * Retrieves the config for the application from the environment * * @returns The environment variables if they are found in the environment */ export function getConfig() { const environmentVariables = pick(process.env, variables) as Record; const keys = Object.keys(environmentVariables); // if (keys.length !== variables.length) { // throw new Error('Missing environment variables'); // } return environmentVariables; } export default (context: ConfigContext): Partial => { const Config = getConfig(); return { ...context.config, hooks: { ...context.config.hooks, postPublish: [ { file: 'sentry-expo/upload-sourcemaps', config: { organization: Config.SENTRY_ORG, project: Config.SENTRY_PROJECT, authToken: Config.SENTRY_AUTH_TOKEN, }, }, ], }, extra: { ...context.config.extra, Config: { stage: Config.STAGE, }, }, }; };