1import { boolish, int, string } from 'getenv'; 2 3// @expo/webpack-config -> expo-pwa -> @expo/image-utils: EXPO_IMAGE_UTILS_NO_SHARP 4 5// TODO: EXPO_CLI_USERNAME, EXPO_CLI_PASSWORD 6 7class Env { 8 /** Enable profiling metrics */ 9 get EXPO_PROFILE() { 10 return boolish('EXPO_PROFILE', false); 11 } 12 13 /** Enable debug logging */ 14 get EXPO_DEBUG() { 15 return boolish('EXPO_DEBUG', false); 16 } 17 18 /** Disable all network requests */ 19 get EXPO_OFFLINE() { 20 return boolish('EXPO_OFFLINE', false); 21 } 22 23 /** Enable the beta version of Expo (TODO: Should this just be in the beta version of expo releases?) */ 24 get EXPO_BETA() { 25 return boolish('EXPO_BETA', false); 26 } 27 28 /** Enable staging API environment */ 29 get EXPO_STAGING() { 30 return boolish('EXPO_STAGING', false); 31 } 32 33 /** Enable local API environment */ 34 get EXPO_LOCAL() { 35 return boolish('EXPO_LOCAL', false); 36 } 37 38 /** Is running in non-interactive CI mode */ 39 get CI() { 40 return boolish('CI', false); 41 } 42 43 /** Disable telemetry (analytics) */ 44 get EXPO_NO_TELEMETRY() { 45 return boolish('EXPO_NO_TELEMETRY', false); 46 } 47 48 /** local directory to the universe repo for testing locally */ 49 get EXPO_UNIVERSE_DIR() { 50 return string('EXPO_UNIVERSE_DIR', ''); 51 } 52 53 /** @deprecated Default Webpack host string */ 54 get WEB_HOST() { 55 return string('WEB_HOST', '0.0.0.0'); 56 } 57 58 /** Skip warning users about a dirty git status */ 59 get EXPO_NO_GIT_STATUS() { 60 return boolish('EXPO_NO_GIT_STATUS', false); 61 } 62 /** Disable auto web setup */ 63 get EXPO_NO_WEB_SETUP() { 64 return boolish('EXPO_NO_WEB_SETUP', false); 65 } 66 /** Disable auto TypeScript setup */ 67 get EXPO_NO_TYPESCRIPT_SETUP() { 68 return boolish('EXPO_NO_TYPESCRIPT_SETUP', false); 69 } 70 /** Disable all API caches. Does not disable bundler caches. */ 71 get EXPO_NO_CACHE() { 72 return boolish('EXPO_NO_CACHE', false); 73 } 74 /** Disable the app select redirect page. */ 75 get EXPO_NO_REDIRECT_PAGE() { 76 return boolish('EXPO_NO_REDIRECT_PAGE', false); 77 } 78 /** The React Metro port that's baked into react-native scripts and tools. */ 79 get RCT_METRO_PORT() { 80 return int('RCT_METRO_PORT', 0); 81 } 82 /** Skip validating the manifest during `export`. */ 83 get EXPO_SKIP_MANIFEST_VALIDATION_TOKEN(): boolean { 84 return !!string('EXPO_SKIP_MANIFEST_VALIDATION_TOKEN'); 85 } 86 87 /** Public folder path relative to the project root. Default to `public` */ 88 get EXPO_PUBLIC_FOLDER(): string { 89 return string('EXPO_PUBLIC_FOLDER', 'public'); 90 } 91 92 /** Higher priority `$EDIOTR` variable for indicating which editor to use when pressing `o` in the Terminal UI. */ 93 get EXPO_EDITOR(): string { 94 return string('EXPO_EDITOR', ''); 95 } 96 97 /** Enable auto server root detection for Metro. This will change the server root to the workspace root. */ 98 get EXPO_USE_METRO_WORKSPACE_ROOT(): boolean { 99 return boolish('EXPO_USE_METRO_WORKSPACE_ROOT', false); 100 } 101 102 /** 103 * Overwrite the dev server URL, disregarding the `--port`, `--host`, `--tunnel`, `--lan`, `--localhost` arguments. 104 * This is useful for browser editors that require custom proxy URLs. 105 */ 106 get EXPO_PACKAGER_PROXY_URL(): string { 107 return string('EXPO_PACKAGER_PROXY_URL', ''); 108 } 109 110 /** 111 * **Experimental** - Disable using `exp.direct` as the hostname for 112 * `--tunnel` connections. This enables **https://** forwarding which 113 * can be used to test universal links on iOS. 114 * 115 * This may cause issues with `expo-linking` and Expo Go. 116 * 117 * Select the exact subdomain by passing a string value that is not one of: `true`, `false`, `1`, `0`. 118 */ 119 get EXPO_TUNNEL_SUBDOMAIN(): string | boolean { 120 const subdomain = string('EXPO_TUNNEL_SUBDOMAIN', ''); 121 if (['0', 'false', ''].includes(subdomain)) { 122 return false; 123 } else if (['1', 'true'].includes(subdomain)) { 124 return true; 125 } 126 return subdomain; 127 } 128 129 /** 130 * Force Expo CLI to use the [`resolver.resolverMainFields`](https://facebook.github.io/metro/docs/configuration/#resolvermainfields) from the project `metro.config.js` for all platforms. 131 * 132 * By default, Expo CLI will use `['browser', 'module', 'main']` (default for Webpack) for web and the user-defined main fields for other platforms. 133 */ 134 get EXPO_METRO_NO_MAIN_FIELD_OVERRIDE(): boolean { 135 return boolish('EXPO_METRO_NO_MAIN_FIELD_OVERRIDE', false); 136 } 137 138 /** 139 * HTTP/HTTPS proxy to connect to for network requests. Configures [https-proxy-agent](https://www.npmjs.com/package/https-proxy-agent). 140 */ 141 get HTTP_PROXY(): string { 142 return process.env.HTTP_PROXY || process.env.http_proxy || ''; 143 } 144 145 /** Use the network inspector by overriding the metro inspector proxy with a custom version */ 146 get EXPO_NO_INSPECTOR_PROXY(): boolean { 147 return boolish('EXPO_NO_INSPECTOR_PROXY', false); 148 } 149 150 /** Disable lazy bundling in Metro bundler. */ 151 get EXPO_NO_METRO_LAZY() { 152 return boolish('EXPO_NO_METRO_LAZY', false); 153 } 154 155 /** Enable the unstable inverse dependency stack trace for Metro bundling errors. */ 156 get EXPO_METRO_UNSTABLE_ERRORS() { 157 return boolish('EXPO_METRO_UNSTABLE_ERRORS', false); 158 } 159} 160 161export const env = new Env(); 162