Skip to content

Commit 006ba11

Browse files
committed
build(expo): refactor local build script
1 parent c7abd7e commit 006ba11

File tree

4 files changed

+45
-8
lines changed

4 files changed

+45
-8
lines changed

.easignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
node_modules/
2+
.expo/
3+
dist/
4+
npm-debug.*
5+
*.jks
6+
*.p8
7+
*.p12
8+
*.key
9+
*.mobileprovision
10+
*.orig.*
11+
web-build/
12+
yarn-error.log
13+
/coverage
14+
15+
# Allow local environment files to be copied to the build directory
16+
!.env.*
17+
18+
/ios
19+
/android
20+
21+
# macOS
22+
.DS_Store
23+
*.apk
24+
*.ipa
25+
26+
expo-env.d.ts
27+
28+
# cli
29+
cli/README.md

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ web-build/
1212
yarn-error.log
1313
/coverage
1414

15-
.env.development
16-
.env.production
17-
.env.staging
18-
.env.qa
15+
.env.*
16+
!.env.sample
1917

2018
/ios
2119
/android

env.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,26 @@ const APP_ENV =
2323

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

26+
const LOCAL_BUILD_SCRIPT_PATTERNS = ['--local', 'eas-cli-local-build-plugin'];
27+
const isLocalBuild = LOCAL_BUILD_SCRIPT_PATTERNS.some((pattern) =>
28+
process.env.npm_lifecycle_script?.includes(pattern)
29+
);
30+
2631
const ENVIRONMENT_DEPENDANT_SCRIPTS = [
2732
'expo start',
2833
'expo prebuild',
2934
'eas build',
3035
'expo run',
36+
'eas-cli-local-build-plugin',
3137
];
3238

3339
const scriptIsEnvironmentDependant = ENVIRONMENT_DEPENDANT_SCRIPTS.some(
3440
(script) => process.env.npm_lifecycle_script?.includes(script)
3541
);
3642

3743
// Check if the environment file has to be validated for the current running script and build method
38-
const shouldValidateEnv = isEASBuild && scriptIsEnvironmentDependant;
44+
const shouldValidateEnv =
45+
(isEASBuild || isLocalBuild) && scriptIsEnvironmentDependant;
3946

4047
const easEnvironmentFileVariable = `ENVIRONMENT_FILE_${APP_ENV.toUpperCase()}`;
4148
const easEnvironmentFilePath = process.env[easEnvironmentFileVariable];
@@ -181,9 +188,14 @@ if (shouldValidateEnv) {
181188
parsedWholeEnv.error.flatten().fieldErrors,
182189

183190
`\n❌ Missing variables in \x1b[1m\x1b[4m\x1b[31m${envFile}\x1b[0m file. Make sure all required variables are defined in the \x1b[1m\x1b[4m\x1b[31m${envFile}\x1b[0m file.`,
184-
`\n💡 Tip: If you recently updated the \x1b[1m\x1b[4m\x1b[31m${envFile}\x1b[0m file and the error still persists, try restarting the server with the -cc flag to clear the cache.`,
185191
];
186192

193+
if (isLocalBuild) {
194+
messages.push(
195+
`\n💡 Tip: If you recently updated the \x1b[1m\x1b[4m\x1b[31m${envFile}\x1b[0m file and the error still persists, try restarting the server with the -cc flag to clear the cache.`
196+
);
197+
}
198+
187199
if (isEASBuild) {
188200
messages.push(
189201
`\n☁️ For \x1b[1m\x1b[32mEAS Build\x1b[0m deployments, ensure the secret\x1b[1m\x1b[4m\x1b[31m${easEnvironmentFileVariable} \x1b[0m is defined in Project Secrets and has the proper environment file attached.`

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
"build:development:android": "cross-env APP_ENV=development EXPO_NO_DOTENV=1 eas build --profile development --platform android ",
2424
"build:staging:ios": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform ios",
2525
"build:staging:android": "cross-env APP_ENV=staging EXPO_NO_DOTENV=1 eas build --profile staging --platform android ",
26-
"build:staging:ios:local": "cross-env APP_ENV=staging sh -c './scripts/set-env.sh EXPO_NO_DOTENV=1 eas build --profile staging --platform ios --local'",
27-
"build:staging:android:local": "cross-env APP_ENV=staging sh -c './scripts/set-env.sh EXPO_NO_DOTENV=1 eas build --profile staging --platform android --local'",
2826
"build:production:ios": "cross-env APP_ENV=production EXPO_NO_DOTENV=1 eas build --profile production --platform ios",
2927
"build:production:android": "cross-env APP_ENV=production EXPO_NO_DOTENV=1 eas build --profile production --platform android ",
3028
"postinstall": "husky install",

0 commit comments

Comments
 (0)