Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions env.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,23 @@ const APP_ENV =

const isEASBuild = process.env.EAS_BUILD === 'true';

const LOCAL_BUILD_SCRIPT_PATTERNS = ['--local', 'eas-cli-local-build-plugin'];
const LOCAL_BUILD_SCRIPT_PATTERNS = [
'--local',
'eas-cli-local-build-plugin',
'expo export',
];
const isLocalBuild = LOCAL_BUILD_SCRIPT_PATTERNS.some((pattern) =>
process.env.npm_lifecycle_script?.includes(pattern)
);

const EXPO_RUN_COMMANDS = ['expo start', 'expo run'];

const ENVIRONMENT_DEPENDANT_SCRIPTS = [
'expo start',
...EXPO_RUN_COMMANDS,
'expo prebuild',
'eas build',
'expo run',
'eas-cli-local-build-plugin',
'expo export',
];

const scriptIsEnvironmentDependant = ENVIRONMENT_DEPENDANT_SCRIPTS.some(
Expand All @@ -42,18 +48,12 @@ const scriptIsEnvironmentDependant = ENVIRONMENT_DEPENDANT_SCRIPTS.some(

// Check if the environment file has to be validated for the current running script and build method
const isBuilding = isEASBuild || isLocalBuild;
const isRunning = process.env.npm_lifecycle_script?.includes('expo run');
const isRunning = EXPO_RUN_COMMANDS.some((script) =>
process.env.npm_lifecycle_script?.includes(script)
);
const shouldValidateEnv =
(isBuilding && scriptIsEnvironmentDependant) || isRunning;

console.log({
npm_lifecycle_script: process.env.npm_lifecycle_script,
scriptIsEnvironmentDependant,
isLocalBuild,
isEASBuild,
shouldValidateEnv,
});

const easEnvironmentFileVariable = `ENVIRONMENT_FILE_${APP_ENV.toUpperCase()}`;
const easEnvironmentFilePath = process.env[easEnvironmentFileVariable];
const localEnvironmentFilePath = path.resolve(__dirname, `.env.${APP_ENV}`);
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,34 @@
"prebuild:development": "cross-env APP_ENV=development pnpm run prebuild",
"android": "cross-env EXPO_NO_DOTENV=1 expo run:android",
"ios": "cross-env EXPO_NO_DOTENV=1 expo run:ios",
"web": "cross-env EXPO_NO_DOTENV=1 expo start --web --reset-cache",
"build:development:android": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 eas build --profile development --platform android ",
"build:development:ios": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 eas build --profile development --platform ios",
"build:development:web": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 expo export -c --platform web",
"start:staging": "cross-env APP_ENV=staging pnpm run start",
"prebuild:staging": "cross-env APP_ENV=staging pnpm run prebuild",
"android:staging": "cross-env APP_ENV=staging pnpm run android",
"ios:staging": "cross-env APP_ENV=staging pnpm run ios",
"web:staging": "cross-env APP_ENV=staging pnpm run web",
"build:staging:android": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform android ",
"build:staging:ios": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform ios",
"build:staging:web": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 expo export -c --platform web",
"start:qa": "cross-env APP_ENV=qa pnpm run start",
"prebuild:qa": "cross-env APP_ENV=qa pnpm run prebuild",
"android:qa": "cross-env APP_ENV=qa pnpm run android",
"ios:qa": "cross-env APP_ENV=qa pnpm run ios",
"web:qa": "cross-env APP_ENV=qa pnpm run web",
"build:qa:ios": "cross-env APP_ENV=qa EXPO_NO_DOTENV=1 eas build --profile qa --platform ios",
"build:qa:android": "cross-env APP_ENV=qa EXPO_NO_DOTENV=1 eas build --profile qa --platform android ",
"build:qa:web": "cross-env APP_ENV=qa EXPO_NO_DOTENV=1 expo export -c --platform web",
"start:production": "cross-env APP_ENV=production pnpm run start",
"prebuild:production": "cross-env APP_ENV=production pnpm run prebuild",
"android:production": "cross-env APP_ENV=production pnpm run android",
"ios:production": "cross-env APP_ENV=production pnpm run ios",
"web:production": "cross-env APP_ENV=production pnpm run web",
"build:production:android": "cross-env APP_ENV=production EXPO_NO_DOTENV=1 eas build --profile production --platform android ",
"build:production:ios": "cross-env APP_ENV=production EXPO_NO_DOTENV=1 eas build --profile production --platform ios",
"build:production:web": "cross-env APP_ENV=production EXPO_NO_DOTENV=1 expo export -c --platform web",
"xcode": "xed -b ios",
"doctor": "npx expo-doctor@latest",
"preinstall": "npx only-allow pnpm",
Expand Down