@expo/cli 55.0.6 → 55.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +13 -1
- package/build/bin/cli.map +1 -1
- package/build/src/api/user/actions.js +5 -2
- package/build/src/api/user/actions.js.map +1 -1
- package/build/src/api/user/expoSsoLauncher.js +22 -49
- package/build/src/api/user/expoSsoLauncher.js.map +1 -1
- package/build/src/api/user/user.js +6 -5
- package/build/src/api/user/user.js.map +1 -1
- package/build/src/config/configAsync.js +1 -1
- package/build/src/config/configAsync.js.map +1 -1
- package/build/src/customize/customizeAsync.js +1 -1
- package/build/src/customize/customizeAsync.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +1 -1
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/exportApp.js +1 -1
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +7 -11
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +1 -1
- package/build/src/export/web/exportWebAsync.js.map +1 -1
- package/build/src/install/installAsync.js +1 -1
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/lint/lintAsync.js +1 -1
- package/build/src/lint/lintAsync.js.map +1 -1
- package/build/src/login/index.js +6 -2
- package/build/src/login/index.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +1 -1
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/run/android/runAndroidAsync.js +1 -1
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +1 -1
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/serve/serveAsync.js +1 -1
- package/build/src/serve/serveAsync.js.map +1 -1
- package/build/src/start/interface/commandsTable.js +89 -69
- package/build/src/start/interface/commandsTable.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +29 -14
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/platforms/ios/devicectl.js +4 -1
- package/build/src/start/platforms/ios/devicectl.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +16 -9
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +5 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +17 -7
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +8 -8
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +20 -20
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/createServerComponentsMiddleware.js +1 -1
- package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
- package/build/src/start/server/metro/debugging/createDebugMiddleware.js +5 -1
- package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -1
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +18 -18
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +9 -5
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/log-box/LogBoxSymbolication.js +5 -1
- package/build/src/start/server/metro/log-box/LogBoxSymbolication.js.map +1 -1
- package/build/src/start/server/metro/resolveLoader.js +2 -0
- package/build/src/start/server/metro/resolveLoader.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +6 -5
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +4 -4
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/utils/downloadExpoGoAsync.js +36 -0
- package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
- package/build/src/utils/editor.js +404 -31
- package/build/src/utils/editor.js.map +1 -1
- package/build/src/utils/env.js +13 -11
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/getRunningProcess.js +80 -41
- package/build/src/utils/getRunningProcess.js.map +1 -1
- package/build/src/utils/ip.js +44 -8
- package/build/src/utils/ip.js.map +1 -1
- package/build/src/utils/nodeEnv.js +66 -1
- package/build/src/utils/nodeEnv.js.map +1 -1
- package/build/src/utils/port.js +2 -2
- package/build/src/utils/port.js.map +1 -1
- package/build/src/utils/qr.js +186 -0
- package/build/src/utils/qr.js.map +1 -0
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +16 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/env.ts"],"sourcesContent":["import { boolish, int, string } from 'getenv';\nimport process from 'node:process';\n\n// @expo/webpack-config -> expo-pwa -> @expo/image-utils: EXPO_IMAGE_UTILS_NO_SHARP\n\n// TODO: EXPO_CLI_USERNAME, EXPO_CLI_PASSWORD\n\nclass Env {\n /** Enable profiling metrics */\n get EXPO_PROFILE() {\n return boolish('EXPO_PROFILE', false);\n }\n\n /** Enable debug logging */\n get EXPO_DEBUG() {\n return boolish('EXPO_DEBUG', false);\n }\n\n /** Disable all network requests */\n get EXPO_OFFLINE() {\n return boolish('EXPO_OFFLINE', false);\n }\n\n /** Enable the beta version of Expo (TODO: Should this just be in the beta version of expo releases?) */\n get EXPO_BETA() {\n return boolish('EXPO_BETA', false);\n }\n\n /** Enable staging API environment */\n get EXPO_STAGING() {\n return boolish('EXPO_STAGING', false);\n }\n\n /** Enable local API environment */\n get EXPO_LOCAL() {\n return boolish('EXPO_LOCAL', false);\n }\n\n /** Is running in non-interactive CI mode */\n get CI() {\n return boolish('CI', false);\n }\n\n /** Disable telemetry (analytics) */\n get EXPO_NO_TELEMETRY() {\n return boolish('EXPO_NO_TELEMETRY', false);\n }\n\n /** Disable detaching telemetry to separate process */\n get EXPO_NO_TELEMETRY_DETACH() {\n return boolish('EXPO_NO_TELEMETRY_DETACH', false);\n }\n\n /** local directory to the universe repo for testing locally */\n get EXPO_UNIVERSE_DIR() {\n return string('EXPO_UNIVERSE_DIR', '');\n }\n\n /** @deprecated Default Webpack host string */\n get WEB_HOST() {\n return string('WEB_HOST', '0.0.0.0');\n }\n\n /** Skip warning users about a dirty git status */\n get EXPO_NO_GIT_STATUS() {\n return boolish('EXPO_NO_GIT_STATUS', true);\n }\n /** Disable auto web setup */\n get EXPO_NO_WEB_SETUP() {\n return boolish('EXPO_NO_WEB_SETUP', false);\n }\n /** Disable auto TypeScript setup */\n get EXPO_NO_TYPESCRIPT_SETUP() {\n return boolish('EXPO_NO_TYPESCRIPT_SETUP', false);\n }\n /** Disable all API caches. Does not disable bundler caches. */\n get EXPO_NO_CACHE() {\n return boolish('EXPO_NO_CACHE', false);\n }\n /** Disable the app select redirect page. */\n get EXPO_NO_REDIRECT_PAGE() {\n return boolish('EXPO_NO_REDIRECT_PAGE', false);\n }\n /** The React Metro port that's baked into react-native scripts and tools. */\n get RCT_METRO_PORT() {\n return int('RCT_METRO_PORT', 0);\n }\n /** Skip validating the manifest during `export`. */\n get EXPO_SKIP_MANIFEST_VALIDATION_TOKEN(): boolean {\n return !!string('EXPO_SKIP_MANIFEST_VALIDATION_TOKEN', '');\n }\n\n /** Public folder path relative to the project root. Default to `public` */\n get EXPO_PUBLIC_FOLDER(): string {\n return string('EXPO_PUBLIC_FOLDER', 'public');\n }\n\n /** Higher priority `$EDIOTR` variable for indicating which editor to use when pressing `o` in the Terminal UI. */\n get EXPO_EDITOR(): string {\n return string('EXPO_EDITOR', '');\n }\n\n /**\n * Overwrite the dev server URL, disregarding the `--port`, `--host`, `--tunnel`, `--lan`, `--localhost` arguments.\n * This is useful for browser editors that require custom proxy URLs.\n */\n get EXPO_PACKAGER_PROXY_URL(): string {\n return string('EXPO_PACKAGER_PROXY_URL', '');\n }\n\n /**\n * **Experimental** - Disable using `exp.direct` as the hostname for\n * `--tunnel` connections. This enables **https://** forwarding which\n * can be used to test universal links on iOS.\n *\n * This may cause issues with `expo-linking` and Expo Go.\n *\n * Select the exact subdomain by passing a string value that is not one of: `true`, `false`, `1`, `0`.\n */\n get EXPO_TUNNEL_SUBDOMAIN(): string | boolean {\n const subdomain = string('EXPO_TUNNEL_SUBDOMAIN', '');\n if (['0', 'false', ''].includes(subdomain)) {\n return false;\n } else if (['1', 'true'].includes(subdomain)) {\n return true;\n }\n return subdomain;\n }\n\n /**\n * 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.\n *\n * By default, Expo CLI will use `['browser', 'module', 'main']` (default for Webpack) for web and the user-defined main fields for other platforms.\n */\n get EXPO_METRO_NO_MAIN_FIELD_OVERRIDE(): boolean {\n return boolish('EXPO_METRO_NO_MAIN_FIELD_OVERRIDE', false);\n }\n\n /**\n * HTTP/HTTPS proxy to connect to for network requests. Configures [https-proxy-agent](https://www.npmjs.com/package/https-proxy-agent).\n */\n get HTTP_PROXY(): string {\n return process.env.HTTP_PROXY || process.env.http_proxy || '';\n }\n\n /**\n * Instructs a different Metro config to be loaded.\n * The path, according to metro-config, should be a path relative to the current working directory.\n * This flag is internal and was added for external tools.\n * @internal\n */\n get EXPO_OVERRIDE_METRO_CONFIG(): string | undefined {\n return process.env.EXPO_OVERRIDE_METRO_CONFIG?.trim() || undefined;\n }\n\n /**\n * Use the network inspector by overriding the metro inspector proxy with a custom version.\n * @deprecated This has been replaced by `@react-native/dev-middleware` and is now unused.\n */\n get EXPO_NO_INSPECTOR_PROXY(): boolean {\n return boolish('EXPO_NO_INSPECTOR_PROXY', false);\n }\n\n /** Disable lazy bundling in Metro bundler. */\n get EXPO_NO_METRO_LAZY() {\n return boolish('EXPO_NO_METRO_LAZY', false);\n }\n\n /**\n * Enable the unstable inverse dependency stack trace for Metro bundling errors.\n * @deprecated This will be removed in the future.\n */\n get EXPO_METRO_UNSTABLE_ERRORS() {\n return boolish('EXPO_METRO_UNSTABLE_ERRORS', true);\n }\n\n /** Enable the experimental sticky resolver for Metro (Uses Expo Autolinking results and applies them to Metro's resolution)\n * @deprecated Replaced by `exp.experiments.autolinkingModuleResolution`\n */\n get EXPO_USE_STICKY_RESOLVER() {\n return boolish('EXPO_USE_STICKY_RESOLVER', false);\n }\n\n /** Disable Environment Variable injection in client bundles. */\n get EXPO_NO_CLIENT_ENV_VARS(): boolean {\n return boolish('EXPO_NO_CLIENT_ENV_VARS', false);\n }\n\n /** Set the default `user` that should be passed to `--user` with ADB commands. Used for installing APKs on Android devices with multiple profiles. Defaults to `0`. */\n get EXPO_ADB_USER(): string {\n return string('EXPO_ADB_USER', '0');\n }\n\n /** Used internally to enable E2E utilities. This behavior is not stable to external users. */\n get __EXPO_E2E_TEST(): boolean {\n return boolish('__EXPO_E2E_TEST', false);\n }\n\n /** Unstable: Force single-bundle exports in production. */\n get EXPO_NO_BUNDLE_SPLITTING(): boolean {\n return boolish('EXPO_NO_BUNDLE_SPLITTING', false);\n }\n\n /**\n * Enable Atlas to gather bundle information during development or export.\n * Note, because this used to be an experimental feature, both `EXPO_ATLAS` and `EXPO_UNSTABLE_ATLAS` are supported.\n */\n get EXPO_ATLAS() {\n return boolish('EXPO_ATLAS', boolish('EXPO_UNSTABLE_ATLAS', false));\n }\n\n /** Unstable: Enable tree shaking for Metro. */\n get EXPO_UNSTABLE_TREE_SHAKING() {\n return boolish('EXPO_UNSTABLE_TREE_SHAKING', false);\n }\n\n /** Unstable: Enable eager bundling where transformation runs uncached after the entire bundle has been created. This is required for production tree shaking and less optimized for development bundling. */\n get EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH() {\n return boolish('EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH', false);\n }\n\n /** Enable the use of Expo's custom metro require implementation. The custom require supports better debugging, tree shaking, and React Server Components. */\n get EXPO_USE_METRO_REQUIRE() {\n return boolish('EXPO_USE_METRO_REQUIRE', false);\n }\n\n /** Internal key used to pass eager bundle data from the CLI to the native run scripts during `npx expo run` commands. */\n get __EXPO_EAGER_BUNDLE_OPTIONS() {\n return string('__EXPO_EAGER_BUNDLE_OPTIONS', '');\n }\n\n /** Disable server deployment during production builds (during `expo export:embed`). This is useful for testing API routes and server components against a local server. */\n get EXPO_NO_DEPLOY(): boolean {\n return boolish('EXPO_NO_DEPLOY', false);\n }\n\n /** Enable hydration during development when rendering Expo Web */\n get EXPO_WEB_DEV_HYDRATE(): boolean {\n return boolish('EXPO_WEB_DEV_HYDRATE', false);\n }\n\n /** Enable experimental React Server Functions support. */\n get EXPO_UNSTABLE_SERVER_FUNCTIONS(): boolean {\n return boolish('EXPO_UNSTABLE_SERVER_FUNCTIONS', false);\n }\n\n /** Enable unstable/experimental mode where React Native Web isn't required to run Expo apps on web. */\n get EXPO_NO_REACT_NATIVE_WEB(): boolean {\n return boolish('EXPO_NO_REACT_NATIVE_WEB', false);\n }\n\n /** Enable unstable/experimental support for deploying the native server in `npx expo run` commands. */\n get EXPO_UNSTABLE_DEPLOY_SERVER(): boolean {\n return boolish('EXPO_UNSTABLE_DEPLOY_SERVER', false);\n }\n\n /** Is running in EAS Build. This is set by EAS: https://docs.expo.dev/eas/environment-variables/ */\n get EAS_BUILD(): boolean {\n return boolish('EAS_BUILD', false);\n }\n\n /** Disable the React Native Directory compatibility check for new architecture when installing packages */\n get EXPO_NO_NEW_ARCH_COMPAT_CHECK(): boolean {\n return boolish('EXPO_NO_NEW_ARCH_COMPAT_CHECK', false);\n }\n\n /** Disable the dependency validation when installing other dependencies and starting the project */\n get EXPO_NO_DEPENDENCY_VALIDATION(): boolean {\n // Default to disabling when running in a web container (stackblitz, bolt, etc).\n const isWebContainer = process.versions.webcontainer != null;\n return boolish('EXPO_NO_DEPENDENCY_VALIDATION', isWebContainer);\n }\n\n /** Force Expo CLI to run in webcontainer mode, this has impact on which URL Expo is using by default */\n get EXPO_FORCE_WEBCONTAINER_ENV(): boolean {\n return boolish('EXPO_FORCE_WEBCONTAINER_ENV', false);\n }\n\n /** Force Expo CLI to run in webcontainer mode, this has impact on which URL Expo is using by default */\n get EXPO_UNSTABLE_WEB_MODAL(): boolean {\n return boolish('EXPO_UNSTABLE_WEB_MODAL', false);\n }\n\n /** Disable by falsy value live binding in experimental import export support. Enabled by default. */\n get EXPO_UNSTABLE_LIVE_BINDINGS(): boolean {\n return boolish('EXPO_UNSTABLE_LIVE_BINDINGS', true);\n }\n\n /**\n * Enable the experimental MCP integration or further specify the MCP server URL.\n */\n get EXPO_UNSTABLE_MCP_SERVER(): string {\n const value = string('EXPO_UNSTABLE_MCP_SERVER', '');\n if (value === '1' || value.toLowerCase() === 'true') {\n return this.EXPO_STAGING ? 'staging-mcp.expo.dev' : 'mcp.expo.dev';\n }\n return value;\n }\n\n /** Enable Expo Log Box for iOS and Android (Web is enabled by default) */\n get EXPO_UNSTABLE_LOG_BOX(): boolean {\n return boolish('EXPO_UNSTABLE_LOG_BOX', false);\n }\n\n /**\n * Enable Bonjour advertising of the Expo CLI on local networks\n */\n get EXPO_UNSTABLE_BONJOUR(): boolean {\n return boolish('EXPO_UNSTABLE_BONJOUR', false);\n }\n}\n\nexport const env = new Env();\n\nexport function envIsWebcontainer() {\n // See: https://github.com/unjs/std-env/blob/4b1e03c4efce58249858efc2cc5f5eac727d0adb/src/providers.ts#L134-L143\n return (\n env.EXPO_FORCE_WEBCONTAINER_ENV ||\n (process.env.SHELL === '/bin/jsh' && !!process.versions.webcontainer)\n );\n}\n"],"names":["env","envIsWebcontainer","Env","EXPO_PROFILE","boolish","EXPO_DEBUG","EXPO_OFFLINE","EXPO_BETA","EXPO_STAGING","EXPO_LOCAL","CI","EXPO_NO_TELEMETRY","EXPO_NO_TELEMETRY_DETACH","EXPO_UNIVERSE_DIR","string","WEB_HOST","EXPO_NO_GIT_STATUS","EXPO_NO_WEB_SETUP","EXPO_NO_TYPESCRIPT_SETUP","EXPO_NO_CACHE","EXPO_NO_REDIRECT_PAGE","RCT_METRO_PORT","int","EXPO_SKIP_MANIFEST_VALIDATION_TOKEN","EXPO_PUBLIC_FOLDER","EXPO_EDITOR","EXPO_PACKAGER_PROXY_URL","EXPO_TUNNEL_SUBDOMAIN","subdomain","includes","EXPO_METRO_NO_MAIN_FIELD_OVERRIDE","HTTP_PROXY","process","http_proxy","EXPO_OVERRIDE_METRO_CONFIG","trim","undefined","EXPO_NO_INSPECTOR_PROXY","EXPO_NO_METRO_LAZY","EXPO_METRO_UNSTABLE_ERRORS","EXPO_USE_STICKY_RESOLVER","EXPO_NO_CLIENT_ENV_VARS","EXPO_ADB_USER","__EXPO_E2E_TEST","EXPO_NO_BUNDLE_SPLITTING","EXPO_ATLAS","EXPO_UNSTABLE_TREE_SHAKING","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","EXPO_USE_METRO_REQUIRE","__EXPO_EAGER_BUNDLE_OPTIONS","EXPO_NO_DEPLOY","EXPO_WEB_DEV_HYDRATE","EXPO_UNSTABLE_SERVER_FUNCTIONS","EXPO_NO_REACT_NATIVE_WEB","EXPO_UNSTABLE_DEPLOY_SERVER","EAS_BUILD","EXPO_NO_NEW_ARCH_COMPAT_CHECK","EXPO_NO_DEPENDENCY_VALIDATION","isWebContainer","versions","webcontainer","EXPO_FORCE_WEBCONTAINER_ENV","EXPO_UNSTABLE_WEB_MODAL","EXPO_UNSTABLE_LIVE_BINDINGS","EXPO_UNSTABLE_MCP_SERVER","value","toLowerCase","EXPO_UNSTABLE_LOG_BOX","EXPO_UNSTABLE_BONJOUR","SHELL"],"mappings":";;;;;;;;;;;IAwTaA,GAAG;eAAHA;;IAEGC,iBAAiB;eAAjBA;;;;yBA1TqB;;;;;;;gEACjB;;;;;;;;;;;AAEpB,mFAAmF;AAEnF,6CAA6C;AAE7C,MAAMC;IACJ,6BAA6B,GAC7B,IAAIC,eAAe;QACjB,OAAOC,IAAAA,iBAAO,EAAC,gBAAgB;IACjC;IAEA,yBAAyB,GACzB,IAAIC,aAAa;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,OACED,IAAI6D,2BAA2B,IAC9B7B,sBAAO,CAAChC,GAAG,CAACqE,KAAK,KAAK,cAAc,CAAC,CAACrC,sBAAO,CAAC2B,QAAQ,CAACC,YAAY;AAExE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/env.ts"],"sourcesContent":["import { boolish, int, string } from 'getenv';\nimport process from 'node:process';\n\n// @expo/webpack-config -> expo-pwa -> @expo/image-utils: EXPO_IMAGE_UTILS_NO_SHARP\n\n// TODO: EXPO_CLI_USERNAME, EXPO_CLI_PASSWORD\n\nclass Env {\n /** Enable profiling metrics */\n get EXPO_PROFILE() {\n return boolish('EXPO_PROFILE', false);\n }\n\n /** Enable debug logging */\n get EXPO_DEBUG() {\n return boolish('EXPO_DEBUG', false);\n }\n\n /** Disable all network requests */\n get EXPO_OFFLINE() {\n return boolish('EXPO_OFFLINE', false);\n }\n\n /** Enable the beta version of Expo (TODO: Should this just be in the beta version of expo releases?) */\n get EXPO_BETA() {\n return boolish('EXPO_BETA', false);\n }\n\n /** Enable staging API environment */\n get EXPO_STAGING() {\n return boolish('EXPO_STAGING', false);\n }\n\n /** Enable local API environment */\n get EXPO_LOCAL() {\n return boolish('EXPO_LOCAL', false);\n }\n\n /** Is running in non-interactive CI mode */\n get CI() {\n return boolish('CI', false);\n }\n\n /** Disable telemetry (analytics) */\n get EXPO_NO_TELEMETRY() {\n return boolish('EXPO_NO_TELEMETRY', false);\n }\n\n /** Disable detaching telemetry to separate process */\n get EXPO_NO_TELEMETRY_DETACH() {\n return boolish('EXPO_NO_TELEMETRY_DETACH', false);\n }\n\n /** local directory to the universe repo for testing locally */\n get EXPO_UNIVERSE_DIR() {\n return string('EXPO_UNIVERSE_DIR', '');\n }\n\n /** @deprecated Default Webpack host string */\n get WEB_HOST() {\n return string('WEB_HOST', '0.0.0.0');\n }\n\n /** Skip warning users about a dirty git status */\n get EXPO_NO_GIT_STATUS() {\n return boolish('EXPO_NO_GIT_STATUS', true);\n }\n /** Disable auto web setup */\n get EXPO_NO_WEB_SETUP() {\n return boolish('EXPO_NO_WEB_SETUP', envIsHeadless());\n }\n /** Disable auto TypeScript setup */\n get EXPO_NO_TYPESCRIPT_SETUP() {\n return boolish('EXPO_NO_TYPESCRIPT_SETUP', false);\n }\n /** Disable all API caches. Does not disable bundler caches. */\n get EXPO_NO_CACHE() {\n return boolish('EXPO_NO_CACHE', false);\n }\n /** Disable the app select redirect page. */\n get EXPO_NO_REDIRECT_PAGE() {\n return boolish('EXPO_NO_REDIRECT_PAGE', false);\n }\n /** The React Metro port that's baked into react-native scripts and tools. */\n get RCT_METRO_PORT() {\n return int('RCT_METRO_PORT', 0);\n }\n /** Skip validating the manifest during `export`. */\n get EXPO_SKIP_MANIFEST_VALIDATION_TOKEN(): boolean {\n return !!string('EXPO_SKIP_MANIFEST_VALIDATION_TOKEN', '');\n }\n\n /** Public folder path relative to the project root. Default to `public` */\n get EXPO_PUBLIC_FOLDER(): string {\n return string('EXPO_PUBLIC_FOLDER', 'public');\n }\n\n /** Higher priority `$EDIOTR` variable for indicating which editor to use when pressing `o` in the Terminal UI. */\n get EXPO_EDITOR(): string {\n return string('EXPO_EDITOR', '');\n }\n\n /**\n * Overwrite the dev server URL, disregarding the `--port`, `--host`, `--tunnel`, `--lan`, `--localhost` arguments.\n * This is useful for browser editors that require custom proxy URLs.\n */\n get EXPO_PACKAGER_PROXY_URL(): string {\n return string('EXPO_PACKAGER_PROXY_URL', '');\n }\n\n /**\n * **Experimental** - Disable using `exp.direct` as the hostname for\n * `--tunnel` connections. This enables **https://** forwarding which\n * can be used to test universal links on iOS.\n *\n * This may cause issues with `expo-linking` and Expo Go.\n *\n * Select the exact subdomain by passing a string value that is not one of: `true`, `false`, `1`, `0`.\n */\n get EXPO_TUNNEL_SUBDOMAIN(): string | boolean {\n const subdomain = string('EXPO_TUNNEL_SUBDOMAIN', '');\n if (['0', 'false', ''].includes(subdomain)) {\n return false;\n } else if (['1', 'true'].includes(subdomain)) {\n return true;\n }\n return subdomain;\n }\n\n /**\n * 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.\n *\n * By default, Expo CLI will use `['browser', 'module', 'main']` (default for Webpack) for web and the user-defined main fields for other platforms.\n */\n get EXPO_METRO_NO_MAIN_FIELD_OVERRIDE(): boolean {\n return boolish('EXPO_METRO_NO_MAIN_FIELD_OVERRIDE', false);\n }\n\n /**\n * HTTP/HTTPS proxy to connect to for network requests. Configures [https-proxy-agent](https://www.npmjs.com/package/https-proxy-agent).\n */\n get HTTP_PROXY(): string {\n return process.env.HTTP_PROXY || process.env.http_proxy || '';\n }\n\n /**\n * Instructs a different Metro config to be loaded.\n * The path, according to metro-config, should be a path relative to the current working directory.\n * This flag is internal and was added for external tools.\n * @internal\n */\n get EXPO_OVERRIDE_METRO_CONFIG(): string | undefined {\n return process.env.EXPO_OVERRIDE_METRO_CONFIG?.trim() || undefined;\n }\n\n /**\n * Use the network inspector by overriding the metro inspector proxy with a custom version.\n * @deprecated This has been replaced by `@react-native/dev-middleware` and is now unused.\n */\n get EXPO_NO_INSPECTOR_PROXY(): boolean {\n return boolish('EXPO_NO_INSPECTOR_PROXY', false);\n }\n\n /** Disable lazy bundling in Metro bundler. */\n get EXPO_NO_METRO_LAZY() {\n return boolish('EXPO_NO_METRO_LAZY', false);\n }\n\n /**\n * Enable the unstable inverse dependency stack trace for Metro bundling errors.\n * @deprecated This will be removed in the future.\n */\n get EXPO_METRO_UNSTABLE_ERRORS() {\n return boolish('EXPO_METRO_UNSTABLE_ERRORS', true);\n }\n\n /** Disable Environment Variable injection in client bundles. */\n get EXPO_NO_CLIENT_ENV_VARS(): boolean {\n return boolish('EXPO_NO_CLIENT_ENV_VARS', false);\n }\n\n /** Set the default `user` that should be passed to `--user` with ADB commands. Used for installing APKs on Android devices with multiple profiles. Defaults to `0`. */\n get EXPO_ADB_USER(): string {\n return string('EXPO_ADB_USER', '0');\n }\n\n /** Used internally to enable E2E utilities. This behavior is not stable to external users. */\n get __EXPO_E2E_TEST(): boolean {\n return boolish('__EXPO_E2E_TEST', false);\n }\n\n /** Unstable: Force single-bundle exports in production. */\n get EXPO_NO_BUNDLE_SPLITTING(): boolean {\n return boolish('EXPO_NO_BUNDLE_SPLITTING', false);\n }\n\n /**\n * Enable Atlas to gather bundle information during development or export.\n * Note, because this used to be an experimental feature, both `EXPO_ATLAS` and `EXPO_UNSTABLE_ATLAS` are supported.\n */\n get EXPO_ATLAS() {\n return boolish('EXPO_ATLAS', boolish('EXPO_UNSTABLE_ATLAS', false));\n }\n\n /** Unstable: Enable tree shaking for Metro. */\n get EXPO_UNSTABLE_TREE_SHAKING() {\n return boolish('EXPO_UNSTABLE_TREE_SHAKING', false);\n }\n\n /** Unstable: Enable eager bundling where transformation runs uncached after the entire bundle has been created. This is required for production tree shaking and less optimized for development bundling. */\n get EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH() {\n return boolish('EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH', false);\n }\n\n /** Enable the use of Expo's custom metro require implementation. The custom require supports better debugging, tree shaking, and React Server Components. */\n get EXPO_USE_METRO_REQUIRE() {\n return boolish('EXPO_USE_METRO_REQUIRE', false);\n }\n\n /** Internal key used to pass eager bundle data from the CLI to the native run scripts during `npx expo run` commands. */\n get __EXPO_EAGER_BUNDLE_OPTIONS() {\n return string('__EXPO_EAGER_BUNDLE_OPTIONS', '');\n }\n\n /** Disable server deployment during production builds (during `expo export:embed`). This is useful for testing API routes and server components against a local server. */\n get EXPO_NO_DEPLOY(): boolean {\n return boolish('EXPO_NO_DEPLOY', false);\n }\n\n /** Enable hydration during development when rendering Expo Web */\n get EXPO_WEB_DEV_HYDRATE(): boolean {\n return boolish('EXPO_WEB_DEV_HYDRATE', false);\n }\n\n /** Enable experimental React Server Functions support. */\n get EXPO_UNSTABLE_SERVER_FUNCTIONS(): boolean {\n return boolish('EXPO_UNSTABLE_SERVER_FUNCTIONS', false);\n }\n\n /** Enable unstable/experimental mode where React Native Web isn't required to run Expo apps on web. */\n get EXPO_NO_REACT_NATIVE_WEB(): boolean {\n return boolish('EXPO_NO_REACT_NATIVE_WEB', false);\n }\n\n /** Enable unstable/experimental support for deploying the native server in `npx expo run` commands. */\n get EXPO_UNSTABLE_DEPLOY_SERVER(): boolean {\n return boolish('EXPO_UNSTABLE_DEPLOY_SERVER', false);\n }\n\n /** Is running in EAS Build. This is set by EAS: https://docs.expo.dev/eas/environment-variables/ */\n get EAS_BUILD(): boolean {\n return boolish('EAS_BUILD', false);\n }\n\n /** Disable the React Native Directory compatibility check for new architecture when installing packages */\n get EXPO_NO_NEW_ARCH_COMPAT_CHECK(): boolean {\n return boolish('EXPO_NO_NEW_ARCH_COMPAT_CHECK', envIsHeadless());\n }\n\n /** Disable the dependency validation when installing other dependencies and starting the project */\n get EXPO_NO_DEPENDENCY_VALIDATION(): boolean {\n return boolish('EXPO_NO_DEPENDENCY_VALIDATION', envIsHeadless());\n }\n\n /** Force Expo CLI to run in webcontainer mode, this has impact on which URL Expo is using by default */\n get EXPO_FORCE_WEBCONTAINER_ENV(): boolean {\n return boolish('EXPO_FORCE_WEBCONTAINER_ENV', false);\n }\n\n /** Force Expo CLI to run in webcontainer mode, this has impact on which URL Expo is using by default */\n get EXPO_UNSTABLE_WEB_MODAL(): boolean {\n return boolish('EXPO_UNSTABLE_WEB_MODAL', false);\n }\n\n /** Disable by falsy value live binding in experimental import export support. Enabled by default. */\n get EXPO_UNSTABLE_LIVE_BINDINGS(): boolean {\n return boolish('EXPO_UNSTABLE_LIVE_BINDINGS', true);\n }\n\n /**\n * Enable the experimental MCP integration or further specify the MCP server URL.\n */\n get EXPO_UNSTABLE_MCP_SERVER(): string {\n const value = string('EXPO_UNSTABLE_MCP_SERVER', '');\n if (value === '1' || value.toLowerCase() === 'true') {\n return this.EXPO_STAGING ? 'staging-mcp.expo.dev' : 'mcp.expo.dev';\n }\n return value;\n }\n\n /** Enable Expo Log Box for iOS and Android (Web is enabled by default) */\n get EXPO_UNSTABLE_LOG_BOX(): boolean {\n return boolish('EXPO_UNSTABLE_LOG_BOX', false);\n }\n\n /**\n * Enable Bonjour advertising of the Expo CLI on local networks\n */\n get EXPO_UNSTABLE_BONJOUR(): boolean {\n return boolish('EXPO_UNSTABLE_BONJOUR', !envIsHeadless());\n }\n\n /** @internal Configure other environment variables for headless operations */\n get EXPO_UNSTABLE_HEADLESS() {\n return boolish('EXPO_UNSTABLE_HEADLESS', envIsWebcontainer());\n }\n}\n\nexport const env = new Env();\n\nexport function envIsWebcontainer() {\n // See: https://github.com/unjs/std-env/blob/4b1e03c4efce58249858efc2cc5f5eac727d0adb/src/providers.ts#L134-L143\n return (\n env.EXPO_FORCE_WEBCONTAINER_ENV ||\n (process.env.SHELL === '/bin/jsh' && !!process.versions.webcontainer)\n );\n}\n\nexport function envIsHeadless() {\n return env.EXPO_UNSTABLE_HEADLESS;\n}\n"],"names":["env","envIsHeadless","envIsWebcontainer","Env","EXPO_PROFILE","boolish","EXPO_DEBUG","EXPO_OFFLINE","EXPO_BETA","EXPO_STAGING","EXPO_LOCAL","CI","EXPO_NO_TELEMETRY","EXPO_NO_TELEMETRY_DETACH","EXPO_UNIVERSE_DIR","string","WEB_HOST","EXPO_NO_GIT_STATUS","EXPO_NO_WEB_SETUP","EXPO_NO_TYPESCRIPT_SETUP","EXPO_NO_CACHE","EXPO_NO_REDIRECT_PAGE","RCT_METRO_PORT","int","EXPO_SKIP_MANIFEST_VALIDATION_TOKEN","EXPO_PUBLIC_FOLDER","EXPO_EDITOR","EXPO_PACKAGER_PROXY_URL","EXPO_TUNNEL_SUBDOMAIN","subdomain","includes","EXPO_METRO_NO_MAIN_FIELD_OVERRIDE","HTTP_PROXY","process","http_proxy","EXPO_OVERRIDE_METRO_CONFIG","trim","undefined","EXPO_NO_INSPECTOR_PROXY","EXPO_NO_METRO_LAZY","EXPO_METRO_UNSTABLE_ERRORS","EXPO_NO_CLIENT_ENV_VARS","EXPO_ADB_USER","__EXPO_E2E_TEST","EXPO_NO_BUNDLE_SPLITTING","EXPO_ATLAS","EXPO_UNSTABLE_TREE_SHAKING","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","EXPO_USE_METRO_REQUIRE","__EXPO_EAGER_BUNDLE_OPTIONS","EXPO_NO_DEPLOY","EXPO_WEB_DEV_HYDRATE","EXPO_UNSTABLE_SERVER_FUNCTIONS","EXPO_NO_REACT_NATIVE_WEB","EXPO_UNSTABLE_DEPLOY_SERVER","EAS_BUILD","EXPO_NO_NEW_ARCH_COMPAT_CHECK","EXPO_NO_DEPENDENCY_VALIDATION","EXPO_FORCE_WEBCONTAINER_ENV","EXPO_UNSTABLE_WEB_MODAL","EXPO_UNSTABLE_LIVE_BINDINGS","EXPO_UNSTABLE_MCP_SERVER","value","toLowerCase","EXPO_UNSTABLE_LOG_BOX","EXPO_UNSTABLE_BONJOUR","EXPO_UNSTABLE_HEADLESS","SHELL","versions","webcontainer"],"mappings":";;;;;;;;;;;IAoTaA,GAAG;eAAHA;;IAUGC,aAAa;eAAbA;;IARAC,iBAAiB;eAAjBA;;;;yBAtTqB;;;;;;;gEACjB;;;;;;;;;;;AAEpB,mFAAmF;AAEnF,6CAA6C;AAE7C,MAAMC;IACJ,6BAA6B,GAC7B,IAAIC,eAAe;QACjB,OAAOC,IAAAA,iBAAO,EAAC,gBAAgB;IACjC;IAEA,yBAAyB,GACzB,IAAIC,aAAa;QACf,OAAOD,IAAAA,iBAAO,EAAC,cAAc;IAC/B;IAEA,iCAAiC,GACjC,IAAIE,eAAe;QACjB,OAAOF,IAAAA,iBAAO,EAAC,gBAAgB;IACjC;IAEA,sGAAsG,GACtG,IAAIG,YAAY;QACd,OAAOH,IAAAA,iBAAO,EAAC,aAAa;IAC9B;IAEA,mCAAmC,GACnC,IAAII,eAAe;QACjB,OAAOJ,IAAAA,iBAAO,EAAC,gBAAgB;IACjC;IAEA,iCAAiC,GACjC,IAAIK,aAAa;QACf,OAAOL,IAAAA,iBAAO,EA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AiCJ;IAClD;IAEA,sGAAsG,GACtG,IAAIyD,8BAAuC;QACzC,OAAOrD,IAAAA,iBAAO,EAAC,+BAA+B;IAChD;IAEA,sGAAsG,GACtG,IAAIsD,0BAAmC;QACrC,OAAOtD,IAAAA,iBAAO,EAAC,2BAA2B;IAC5C;IAEA,mGAAmG,GACnG,IAAIuD,8BAAuC;QACzC,OAAOvD,IAAAA,iBAAO,EAAC,+BAA+B;IAChD;IAEA;;GAEC,GACD,IAAIwD,2BAAmC;QACrC,MAAMC,QAAQ/C,IAAAA,gBAAM,EAAC,4BAA4B;QACjD,IAAI+C,UAAU,OAAOA,MAAMC,WAAW,OAAO,QAAQ;YACnD,OAAO,IAAI,CAACtD,YAAY,GAAG,yBAAyB;QACtD;QACA,OAAOqD;IACT;IAEA,wEAAwE,GACxE,IAAIE,wBAAiC;QACnC,OAAO3D,IAAAA,iBAAO,EAAC,yBAAyB;IAC1C;IAEA;;GAEC,GACD,IAAI4D,wBAAiC;QACnC,OAAO5D,IAAAA,iBAAO,EAAC,yBAAyB,CAACJ;IAC3C;IAEA,4EAA4E,GAC5E,IAAIiE,yBAAyB;QAC3B,OAAO7D,IAAAA,iBAAO,EAAC,0BAA0BH;IAC3C;AACF;AAEO,MAAMF,MAAM,IAAIG;AAEhB,SAASD;IACd,gHAAgH;IAChH,OACEF,IAAI0D,2BAA2B,IAC9BzB,sBAAO,CAACjC,GAAG,CAACmE,KAAK,KAAK,cAAc,CAAC,CAAClC,sBAAO,CAACmC,QAAQ,CAACC,YAAY;AAExE;AAEO,SAASpE;IACd,OAAOD,IAAIkE,sBAAsB;AACnC"}
|
|
@@ -15,13 +15,16 @@ _export(exports, {
|
|
|
15
15
|
getPID: function() {
|
|
16
16
|
return getPID;
|
|
17
17
|
},
|
|
18
|
+
getProcessCommand: function() {
|
|
19
|
+
return getProcessCommand;
|
|
20
|
+
},
|
|
18
21
|
getRunningProcess: function() {
|
|
19
22
|
return getRunningProcess;
|
|
20
23
|
}
|
|
21
24
|
});
|
|
22
|
-
function
|
|
23
|
-
const data = require("
|
|
24
|
-
|
|
25
|
+
function _spawnasync() {
|
|
26
|
+
const data = /*#__PURE__*/ _interop_require_default(require("@expo/spawn-async"));
|
|
27
|
+
_spawnasync = function() {
|
|
25
28
|
return data;
|
|
26
29
|
};
|
|
27
30
|
return data;
|
|
@@ -33,6 +36,11 @@ function _path() {
|
|
|
33
36
|
};
|
|
34
37
|
return data;
|
|
35
38
|
}
|
|
39
|
+
function _interop_require_default(obj) {
|
|
40
|
+
return obj && obj.__esModule ? obj : {
|
|
41
|
+
default: obj
|
|
42
|
+
};
|
|
43
|
+
}
|
|
36
44
|
function _getRequireWildcardCache(nodeInterop) {
|
|
37
45
|
if (typeof WeakMap !== "function") return null;
|
|
38
46
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -75,68 +83,99 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
75
83
|
return newObj;
|
|
76
84
|
}
|
|
77
85
|
const debug = require('debug')('expo:utils:getRunningProcess');
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
stdio: [
|
|
81
|
-
'pipe',
|
|
82
|
-
'pipe',
|
|
83
|
-
'ignore'
|
|
84
|
-
]
|
|
85
|
-
};
|
|
86
|
-
function getPID(port) {
|
|
86
|
+
/** Timeout applied to shell commands */ const timeout = 350;
|
|
87
|
+
async function getPID(port) {
|
|
87
88
|
try {
|
|
88
|
-
const
|
|
89
|
+
const { stdout } = await (0, _spawnasync().default)('lsof', [
|
|
89
90
|
`-i:${port}`,
|
|
90
91
|
'-P',
|
|
91
92
|
'-t',
|
|
92
93
|
'-sTCP:LISTEN'
|
|
93
|
-
],
|
|
94
|
-
|
|
94
|
+
], {
|
|
95
|
+
timeout
|
|
96
|
+
});
|
|
97
|
+
const pid = Number(stdout.split('\n', 1)[0].trim());
|
|
95
98
|
debug(`pid: ${pid} for port: ${port}`);
|
|
96
|
-
return pid;
|
|
99
|
+
return Number.isSafeInteger(pid) ? pid : null;
|
|
97
100
|
} catch (error) {
|
|
98
101
|
debug(`No pid found for port: ${port}. Error: ${error}`);
|
|
99
102
|
return null;
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
/** Get `package.json` `name` field for a given directory. Returns `null` if none exist. */ function getPackageName(packageRoot) {
|
|
103
|
-
const packageJson = _path().join(packageRoot, 'package.json');
|
|
104
106
|
try {
|
|
107
|
+
const packageJson = _path().resolve(packageRoot, 'package.json');
|
|
105
108
|
return require(packageJson).name || null;
|
|
106
|
-
} catch
|
|
109
|
+
} catch (error) {
|
|
107
110
|
return null;
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (name) {
|
|
113
|
-
|
|
113
|
+
async function getProcessCommand(pid, procDirectory) {
|
|
114
|
+
let name = getPackageName(procDirectory);
|
|
115
|
+
if (!name) {
|
|
116
|
+
// ps
|
|
117
|
+
// -o args=: Output argv without header
|
|
118
|
+
// -p [pid]: For process of PID
|
|
119
|
+
const { stdout } = await (0, _spawnasync().default)('ps', [
|
|
120
|
+
'-o',
|
|
121
|
+
'args=',
|
|
122
|
+
'-p',
|
|
123
|
+
`${pid}`
|
|
124
|
+
], {
|
|
125
|
+
timeout
|
|
126
|
+
});
|
|
127
|
+
name = stdout.trim();
|
|
114
128
|
}
|
|
115
|
-
return
|
|
129
|
+
return name || null;
|
|
116
130
|
}
|
|
117
|
-
function getDirectoryOfProcessById(
|
|
118
|
-
|
|
131
|
+
async function getDirectoryOfProcessById(pid) {
|
|
132
|
+
try {
|
|
133
|
+
var _stdout_split_find;
|
|
134
|
+
// lsof
|
|
135
|
+
// -F n: ask for machine readable output
|
|
136
|
+
// -a: apply conditions as logical AND
|
|
137
|
+
// -d cwd: Filter by cwd fd
|
|
138
|
+
// -p [pid]: Filter by input process id
|
|
139
|
+
const { stdout } = await (0, _spawnasync().default)('lsof', [
|
|
140
|
+
'-F',
|
|
141
|
+
'n',
|
|
142
|
+
'-a',
|
|
143
|
+
'-d',
|
|
144
|
+
'cwd',
|
|
145
|
+
'-p',
|
|
146
|
+
`${pid}`
|
|
147
|
+
], {
|
|
148
|
+
timeout
|
|
149
|
+
});
|
|
150
|
+
const processCWD = (_stdout_split_find = stdout.split('\n').find((output)=>output.startsWith('n'))) == null ? void 0 : _stdout_split_find.slice(1);
|
|
151
|
+
return processCWD && _path().isAbsolute(processCWD) ? _path().normalize(processCWD) : null;
|
|
152
|
+
} catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
119
155
|
}
|
|
120
|
-
function getRunningProcess(port) {
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
if (!pid) {
|
|
156
|
+
async function getRunningProcess(port) {
|
|
157
|
+
// Don't even try on Windows, since `lsof` and `ps` are not available there
|
|
158
|
+
if (process.platform === 'win32') {
|
|
124
159
|
return null;
|
|
125
160
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const directory = getDirectoryOfProcessById(pid);
|
|
129
|
-
// /Users/evanbacon/Documents/GitHub/lab/myapp/package.json
|
|
130
|
-
const command = getProcessCommand(pid, directory);
|
|
131
|
-
// TODO: Have a better message for reusing another process.
|
|
132
|
-
return {
|
|
133
|
-
pid,
|
|
134
|
-
directory,
|
|
135
|
-
command
|
|
136
|
-
};
|
|
137
|
-
} catch {
|
|
161
|
+
const pid = await getPID(port);
|
|
162
|
+
if (!pid) {
|
|
138
163
|
return null;
|
|
139
164
|
}
|
|
165
|
+
try {
|
|
166
|
+
const directory = await getDirectoryOfProcessById(pid);
|
|
167
|
+
if (directory) {
|
|
168
|
+
const command = await getProcessCommand(pid, directory);
|
|
169
|
+
if (command) {
|
|
170
|
+
return {
|
|
171
|
+
pid,
|
|
172
|
+
directory,
|
|
173
|
+
command
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
} catch {}
|
|
178
|
+
return null;
|
|
140
179
|
}
|
|
141
180
|
|
|
142
181
|
//# sourceMappingURL=getRunningProcess.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/getRunningProcess.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/getRunningProcess.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport * as path from 'path';\n\nconst debug = require('debug')('expo:utils:getRunningProcess') as typeof console.log;\n\n/** Timeout applied to shell commands */\nconst timeout = 350;\n\n/** Returns a pid value for a running port like `63828` or null if nothing is running on the given port. */\nexport async function getPID(port: number): Promise<number | null> {\n try {\n const { stdout } = await spawnAsync('lsof', [`-i:${port}`, '-P', '-t', '-sTCP:LISTEN'], {\n timeout,\n });\n const pid = Number(stdout.split('\\n', 1)[0].trim());\n debug(`pid: ${pid} for port: ${port}`);\n return Number.isSafeInteger(pid) ? pid : null;\n } catch (error: any) {\n debug(`No pid found for port: ${port}. Error: ${error}`);\n return null;\n }\n}\n\n/** Get `package.json` `name` field for a given directory. Returns `null` if none exist. */\nfunction getPackageName(packageRoot: string): string | null {\n try {\n const packageJson = path.resolve(packageRoot, 'package.json');\n return require(packageJson).name || null;\n } catch (error) {\n return null;\n }\n}\n\n/** Returns a command like `node /Users/evanbacon/.../bin/expo start` or the package.json name. */\nexport async function getProcessCommand(\n pid: number,\n procDirectory: string\n): Promise<string | null> {\n let name = getPackageName(procDirectory);\n if (!name) {\n // ps\n // -o args=: Output argv without header\n // -p [pid]: For process of PID\n const { stdout } = await spawnAsync('ps', ['-o', 'args=', '-p', `${pid}`], {\n timeout,\n });\n name = stdout.trim();\n }\n return name || null;\n}\n\n/** Get directory for a given process ID. */\nexport async function getDirectoryOfProcessById(pid: number): Promise<string | null> {\n try {\n // lsof\n // -F n: ask for machine readable output\n // -a: apply conditions as logical AND\n // -d cwd: Filter by cwd fd\n // -p [pid]: Filter by input process id\n const { stdout } = await spawnAsync('lsof', ['-F', 'n', '-a', '-d', 'cwd', '-p', `${pid}`], {\n timeout,\n });\n const processCWD = stdout\n .split('\\n')\n .find((output) => output.startsWith('n'))\n ?.slice(1);\n return processCWD && path.isAbsolute(processCWD) ? path.normalize(processCWD) : null;\n } catch {\n return null;\n }\n}\n\ninterface RunningProcess {\n /** The PID value for the port. */\n pid: number;\n /** Get the directory for the running process. */\n directory: string;\n /** The command running the process like `node /Users/evanbacon/.../bin/expo start` or the `package.json` name like `my-app`. */\n command: string;\n}\n\n/** Get information about a running process given a port. Returns null if no process is running on the given port. */\nexport async function getRunningProcess(port: number): Promise<RunningProcess | null> {\n // Don't even try on Windows, since `lsof` and `ps` are not available there\n if (process.platform === 'win32') {\n return null;\n }\n\n const pid = await getPID(port);\n if (!pid) {\n return null;\n }\n try {\n const directory = await getDirectoryOfProcessById(pid);\n if (directory) {\n const command = await getProcessCommand(pid, directory);\n if (command) {\n return { pid, directory, command };\n }\n }\n } catch {}\n return null;\n}\n"],"names":["getDirectoryOfProcessById","getPID","getProcessCommand","getRunningProcess","debug","require","timeout","port","stdout","spawnAsync","pid","Number","split","trim","isSafeInteger","error","getPackageName","packageRoot","packageJson","path","resolve","name","procDirectory","processCWD","find","output","startsWith","slice","isAbsolute","normalize","process","platform","directory","command"],"mappings":";;;;;;;;;;;IAoDsBA,yBAAyB;eAAzBA;;IA3CAC,MAAM;eAANA;;IAyBAC,iBAAiB;eAAjBA;;IAgDAC,iBAAiB;eAAjBA;;;;gEAlFC;;;;;;;iEACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtB,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,sCAAsC,GACtC,MAAMC,UAAU;AAGT,eAAeL,OAAOM,IAAY;IACvC,IAAI;QACF,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMC,IAAAA,qBAAU,EAAC,QAAQ;YAAC,CAAC,GAAG,EAAEF,MAAM;YAAE;YAAM;YAAM;SAAe,EAAE;YACtFD;QACF;QACA,MAAMI,MAAMC,OAAOH,OAAOI,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,CAACC,IAAI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IACT;AACF;AAYO,eAAepB,kBAAkBI,IAAY;IAClD,2EAA2E;IAC3E,IAAIuB,QAAQC,QAAQ,KAAK,SAAS;QAChC,OAAO;IACT;IAEA,MAAMrB,MAAM,MAAMT,OAAOM;IACzB,IAAI,CAACG,KAAK;QACR,OAAO;IACT;IACA,IAAI;QACF,MAAMsB,YAAY,MAAMhC,0BAA0BU;QAClD,IAAIsB,WAAW;YACb,MAAMC,UAAU,MAAM/B,kBAAkBQ,KAAKsB;YAC7C,IAAIC,SAAS;gBACX,OAAO;oBAAEvB;oBAAKsB;oBAAWC;gBAAQ;YACnC;QACF;IACF,EAAE,OAAM,CAAC;IACT,OAAO;AACT"}
|
package/build/src/utils/ip.js
CHANGED
|
@@ -2,10 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
getGateway: function() {
|
|
13
|
+
return getGateway;
|
|
14
|
+
},
|
|
15
|
+
getGatewayAsync: function() {
|
|
16
|
+
return getGatewayAsync;
|
|
17
|
+
},
|
|
18
|
+
getIpAddressAsync: function() {
|
|
19
|
+
return getIpAddressAsync;
|
|
9
20
|
}
|
|
10
21
|
});
|
|
11
22
|
function _lannetwork() {
|
|
@@ -15,13 +26,38 @@ function _lannetwork() {
|
|
|
15
26
|
};
|
|
16
27
|
return data;
|
|
17
28
|
}
|
|
18
|
-
|
|
29
|
+
const _env = require("./env");
|
|
30
|
+
// NOTE(@kitten): In headless mode, there's no point in trying to run DHCP, since
|
|
31
|
+
// we assume we're online and probing is going to be enough
|
|
32
|
+
const options = {
|
|
33
|
+
noDhcp: (0, _env.envIsHeadless)()
|
|
34
|
+
};
|
|
35
|
+
function getGateway() {
|
|
36
|
+
try {
|
|
37
|
+
return (0, _lannetwork().lanNetworkSync)(options);
|
|
38
|
+
} catch {
|
|
39
|
+
return {
|
|
40
|
+
iname: null,
|
|
41
|
+
address: '127.0.0.1',
|
|
42
|
+
gateway: null,
|
|
43
|
+
internal: true
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function getGatewayAsync() {
|
|
19
48
|
try {
|
|
20
|
-
|
|
21
|
-
return lan.address;
|
|
49
|
+
return await (0, _lannetwork().lanNetwork)(options);
|
|
22
50
|
} catch {
|
|
23
|
-
return
|
|
51
|
+
return {
|
|
52
|
+
iname: null,
|
|
53
|
+
address: '127.0.0.1',
|
|
54
|
+
gateway: null,
|
|
55
|
+
internal: true
|
|
56
|
+
};
|
|
24
57
|
}
|
|
25
58
|
}
|
|
59
|
+
async function getIpAddressAsync() {
|
|
60
|
+
return (await getGatewayAsync()).address;
|
|
61
|
+
}
|
|
26
62
|
|
|
27
63
|
//# sourceMappingURL=ip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/ip.ts"],"sourcesContent":["import { lanNetworkSync } from 'lan-network';\n\nexport function
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/ip.ts"],"sourcesContent":["import { lanNetworkSync, lanNetwork } from 'lan-network';\n\nimport { envIsHeadless } from './env';\n\n// NOTE(@kitten): In headless mode, there's no point in trying to run DHCP, since\n// we assume we're online and probing is going to be enough\nconst options = {\n noDhcp: envIsHeadless(),\n};\n\nexport interface GatewayInfo {\n iname: string | null;\n address: string;\n gateway: string | null;\n internal: boolean;\n}\n\nexport function getGateway(): GatewayInfo {\n try {\n return lanNetworkSync(options);\n } catch {\n return {\n iname: null,\n address: '127.0.0.1',\n gateway: null,\n internal: true,\n };\n }\n}\n\nexport async function getGatewayAsync(): Promise<GatewayInfo> {\n try {\n return await lanNetwork(options);\n } catch {\n return {\n iname: null,\n address: '127.0.0.1',\n gateway: null,\n internal: true,\n };\n }\n}\n\nexport async function getIpAddressAsync(): Promise<string> {\n return (await getGatewayAsync()).address;\n}\n"],"names":["getGateway","getGatewayAsync","getIpAddressAsync","options","noDhcp","envIsHeadless","lanNetworkSync","iname","address","gateway","internal","lanNetwork"],"mappings":";;;;;;;;;;;IAiBgBA,UAAU;eAAVA;;IAaMC,eAAe;eAAfA;;IAaAC,iBAAiB;eAAjBA;;;;yBA3CqB;;;;;;qBAEb;AAE9B,iFAAiF;AACjF,2DAA2D;AAC3D,MAAMC,UAAU;IACdC,QAAQC,IAAAA,kBAAa;AACvB;AASO,SAASL;IACd,IAAI;QACF,OAAOM,IAAAA,4BAAc,EAACH;IACxB,EAAE,OAAM;QACN,OAAO;YACLI,OAAO;YACPC,SAAS;YACTC,SAAS;YACTC,UAAU;QACZ;IACF;AACF;AAEO,eAAeT;IACpB,IAAI;QACF,OAAO,MAAMU,IAAAA,wBAAU,EAACR;IAC1B,EAAE,OAAM;QACN,OAAO;YACLI,OAAO;YACPC,SAAS;YACTC,SAAS;YACTC,UAAU;QACZ;IACF;AACF;AAEO,eAAeR;IACpB,OAAO,AAAC,CAAA,MAAMD,iBAAgB,EAAGO,OAAO;AAC1C"}
|
|
@@ -9,9 +9,15 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
getEnvFiles: function() {
|
|
13
|
+
return getEnvFiles;
|
|
14
|
+
},
|
|
12
15
|
loadEnvFiles: function() {
|
|
13
16
|
return loadEnvFiles;
|
|
14
17
|
},
|
|
18
|
+
reloadEnvFiles: function() {
|
|
19
|
+
return reloadEnvFiles;
|
|
20
|
+
},
|
|
15
21
|
setNodeEnv: function() {
|
|
16
22
|
return setNodeEnv;
|
|
17
23
|
}
|
|
@@ -23,6 +29,18 @@ function _env() {
|
|
|
23
29
|
};
|
|
24
30
|
return data;
|
|
25
31
|
}
|
|
32
|
+
function _nodepath() {
|
|
33
|
+
const data = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
34
|
+
_nodepath = function() {
|
|
35
|
+
return data;
|
|
36
|
+
};
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
function _interop_require_default(obj) {
|
|
40
|
+
return obj && obj.__esModule ? obj : {
|
|
41
|
+
default: obj
|
|
42
|
+
};
|
|
43
|
+
}
|
|
26
44
|
function _getRequireWildcardCache(nodeInterop) {
|
|
27
45
|
if (typeof WeakMap !== "function") return null;
|
|
28
46
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -69,8 +87,55 @@ function setNodeEnv(mode) {
|
|
|
69
87
|
process.env.BABEL_ENV = process.env.BABEL_ENV || process.env.NODE_ENV;
|
|
70
88
|
globalThis.__DEV__ = process.env.NODE_ENV !== 'production';
|
|
71
89
|
}
|
|
90
|
+
let prevEnvKeys;
|
|
72
91
|
function loadEnvFiles(projectRoot, options) {
|
|
73
|
-
|
|
92
|
+
const params = {
|
|
93
|
+
...options,
|
|
94
|
+
force: !!(options == null ? void 0 : options.force),
|
|
95
|
+
silent: !!(options == null ? void 0 : options.silent),
|
|
96
|
+
mode: process.env.NODE_ENV,
|
|
97
|
+
systemEnv: process.env
|
|
98
|
+
};
|
|
99
|
+
const envInfo = _env().loadProjectEnv(projectRoot, params);
|
|
100
|
+
const envOutput = {};
|
|
101
|
+
if (envInfo.result === 'loaded') {
|
|
102
|
+
prevEnvKeys = new Set();
|
|
103
|
+
for (const key of envInfo.loaded){
|
|
104
|
+
envOutput[key] = envInfo.env[key] ?? undefined;
|
|
105
|
+
prevEnvKeys.add(key);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
_env().logLoadedEnv(envInfo, params);
|
|
109
|
+
return process.env;
|
|
110
|
+
}
|
|
111
|
+
function getEnvFiles(projectRoot) {
|
|
112
|
+
return _env().getEnvFiles({
|
|
113
|
+
mode: process.env.NODE_ENV
|
|
114
|
+
}).map((fileName)=>_nodepath().default.join(projectRoot, fileName));
|
|
115
|
+
}
|
|
116
|
+
function reloadEnvFiles(projectRoot) {
|
|
117
|
+
const isEnabled = _env().isEnabled();
|
|
118
|
+
if (isEnabled) {
|
|
119
|
+
const params = {
|
|
120
|
+
force: true,
|
|
121
|
+
silent: true,
|
|
122
|
+
mode: process.env.NODE_ENV,
|
|
123
|
+
systemEnv: process.env
|
|
124
|
+
};
|
|
125
|
+
// We use a global tracker to allow overwrites of env vars we set ourselves
|
|
126
|
+
const envInfo = _env().parseProjectEnv(projectRoot, params);
|
|
127
|
+
const envOutput = {};
|
|
128
|
+
for(const key in envInfo.env){
|
|
129
|
+
const value = envInfo.env[key];
|
|
130
|
+
if (process.env[key] !== value) {
|
|
131
|
+
if (typeof process.env[key] === 'undefined' || (!prevEnvKeys || prevEnvKeys.has(key)) && process.env[key] !== value) {
|
|
132
|
+
(prevEnvKeys ||= new Set()).add(key);
|
|
133
|
+
process.env[key] = envInfo.env[key];
|
|
134
|
+
envOutput[key] = value ?? undefined;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
74
139
|
}
|
|
75
140
|
|
|
76
141
|
//# sourceMappingURL=nodeEnv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/nodeEnv.ts"],"sourcesContent":["import * as env from '@expo/env';\n\n// TODO(@kitten): We assign this here to run server-side code bundled by metro\n// It's not isolated into a worker thread yet\ndeclare namespace globalThis {\n let __DEV__: boolean | undefined;\n}\n\n/**\n * Set the environment to production or development\n * lots of tools use this to determine if they should run in a dev mode.\n */\nexport function setNodeEnv(mode: 'development' | 'production') {\n process.env.NODE_ENV = process.env.NODE_ENV || mode;\n process.env.BABEL_ENV = process.env.BABEL_ENV || process.env.NODE_ENV;\n globalThis.__DEV__ = process.env.NODE_ENV !== 'production';\n}\n\n/**\n * Load the dotenv files into the current `process.env` scope.\n * Note, this requires `NODE_ENV` being set through `setNodeEnv`.\n */\nexport function loadEnvFiles(projectRoot: string, options?:
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/nodeEnv.ts"],"sourcesContent":["import * as env from '@expo/env';\nimport path from 'node:path';\n\ntype EnvOutput = Record<string, string | undefined>;\n\n// TODO(@kitten): We assign this here to run server-side code bundled by metro\n// It's not isolated into a worker thread yet\ndeclare namespace globalThis {\n let __DEV__: boolean | undefined;\n}\n\n/**\n * Set the environment to production or development\n * lots of tools use this to determine if they should run in a dev mode.\n */\nexport function setNodeEnv(mode: 'development' | 'production') {\n process.env.NODE_ENV = process.env.NODE_ENV || mode;\n process.env.BABEL_ENV = process.env.BABEL_ENV || process.env.NODE_ENV;\n globalThis.__DEV__ = process.env.NODE_ENV !== 'production';\n}\n\ninterface LoadEnvFilesOptions {\n force?: boolean;\n silent?: boolean;\n mode?: string;\n}\n\nlet prevEnvKeys: Set<string> | undefined;\n\n/**\n * Load the dotenv files into the current `process.env` scope.\n * Note, this requires `NODE_ENV` being set through `setNodeEnv`.\n */\nexport function loadEnvFiles(projectRoot: string, options?: LoadEnvFilesOptions) {\n const params = {\n ...options,\n force: !!options?.force,\n silent: !!options?.silent,\n mode: process.env.NODE_ENV,\n systemEnv: process.env,\n };\n\n const envInfo = env.loadProjectEnv(projectRoot, params);\n const envOutput: EnvOutput = {};\n if (envInfo.result === 'loaded') {\n prevEnvKeys = new Set();\n for (const key of envInfo.loaded) {\n envOutput[key] = envInfo.env[key] ?? undefined;\n prevEnvKeys.add(key);\n }\n }\n\n env.logLoadedEnv(envInfo, params);\n return process.env;\n}\n\nexport function getEnvFiles(projectRoot: string) {\n return env\n .getEnvFiles({ mode: process.env.NODE_ENV })\n .map((fileName) => path.join(projectRoot, fileName));\n}\n\nexport function reloadEnvFiles(projectRoot: string) {\n const isEnabled = env.isEnabled();\n if (isEnabled) {\n const params = {\n force: true,\n silent: true,\n mode: process.env.NODE_ENV,\n systemEnv: process.env,\n };\n\n // We use a global tracker to allow overwrites of env vars we set ourselves\n const envInfo = env.parseProjectEnv(projectRoot, params);\n const envOutput: EnvOutput = {};\n for (const key in envInfo.env) {\n const value = envInfo.env[key];\n if (process.env[key] !== value) {\n if (\n typeof process.env[key] === 'undefined' ||\n ((!prevEnvKeys || prevEnvKeys.has(key)) && process.env[key] !== value)\n ) {\n (prevEnvKeys ||= new Set()).add(key);\n process.env[key] = envInfo.env[key];\n envOutput[key] = value ?? undefined;\n }\n }\n }\n }\n}\n"],"names":["getEnvFiles","loadEnvFiles","reloadEnvFiles","setNodeEnv","mode","process","env","NODE_ENV","BABEL_ENV","globalThis","__DEV__","prevEnvKeys","projectRoot","options","params","force","silent","systemEnv","envInfo","loadProjectEnv","envOutput","result","Set","key","loaded","undefined","add","logLoadedEnv","map","fileName","path","join","isEnabled","parseProjectEnv","value","has"],"mappings":";;;;;;;;;;;IAwDgBA,WAAW;eAAXA;;IAvBAC,YAAY;eAAZA;;IA6BAC,cAAc;eAAdA;;IA/CAC,UAAU;eAAVA;;;;iEAfK;;;;;;;gEACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcV,SAASA,WAAWC,IAAkC;IAC3DC,QAAQC,GAAG,CAACC,QAAQ,GAAGF,QAAQC,GAAG,CAACC,QAAQ,IAAIH;IAC/CC,QAAQC,GAAG,CAACE,SAAS,GAAGH,QAAQC,GAAG,CAACE,SAAS,IAAIH,QAAQC,GAAG,CAACC,QAAQ;IACrEE,WAAWC,OAAO,GAAGL,QAAQC,GAAG,CAACC,QAAQ,KAAK;AAChD;AAQA,IAAII;AAMG,SAASV,aAAaW,WAAmB,EAAEC,OAA6B;IAC7E,MAAMC,SAAS;QACb,GAAGD,OAAO;QACVE,OAAO,CAAC,EAACF,2BAAAA,QAASE,KAAK;QACvBC,QAAQ,CAAC,EAACH,2BAAAA,QAASG,MAAM;QACzBZ,MAAMC,QAAQC,GAAG,CAACC,QAAQ;QAC1BU,WAAWZ,QAAQC,GAAG;IACxB;IAEA,MAAMY,UAAUZ,OAAIa,c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,GAAG,CAACiB,IAAI;oBACnCH,SAAS,CAACG,IAAI,GAAGW,SAAST;gBAC5B;YACF;QACF;IACF;AACF"}
|
package/build/src/utils/port.js
CHANGED
|
@@ -116,7 +116,7 @@ function isRestrictedPort(port) {
|
|
|
116
116
|
}
|
|
117
117
|
async function isBusyPortRunningSameProcessAsync(projectRoot, { port }) {
|
|
118
118
|
const { getRunningProcess } = require('./getRunningProcess');
|
|
119
|
-
const runningProcess = isRestrictedPort(port) ? null : getRunningProcess(port);
|
|
119
|
+
const runningProcess = isRestrictedPort(port) ? null : await getRunningProcess(port);
|
|
120
120
|
if (runningProcess) {
|
|
121
121
|
if (runningProcess.directory === projectRoot) {
|
|
122
122
|
return true;
|
|
@@ -137,7 +137,7 @@ async function choosePortAsync(projectRoot, { defaultPort, host, reuseExistingPo
|
|
|
137
137
|
const isRestricted = port && isRestrictedPort(port);
|
|
138
138
|
let message = isRestricted ? `Admin permissions are required to run a server on a port below 1024` : `Port ${_chalk().default.bold(defaultPort)} is`;
|
|
139
139
|
const { getRunningProcess } = require('./getRunningProcess');
|
|
140
|
-
const runningProcess = isRestricted ? null : getRunningProcess(defaultPort);
|
|
140
|
+
const runningProcess = isRestricted ? null : await getRunningProcess(defaultPort);
|
|
141
141
|
if (runningProcess) {
|
|
142
142
|
const pidTag = _chalk().default.gray(`(pid ${runningProcess.pid})`);
|
|
143
143
|
if (runningProcess.directory === projectRoot) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/port.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { env } from './env';\nimport { CommandError } from './errors';\nimport { testPortAsync, freePortAsync } from './freeport';\nimport * as Log from '../log';\n\n/** Get a free port or assert a CLI command error. */\nexport async function getFreePortAsync(rangeStart: number): Promise<number> {\n const port = await freePortAsync(rangeStart, [null, 'localhost']);\n if (!port) {\n throw new CommandError('NO_PORT_FOUND', 'No available port found');\n }\n\n return port;\n}\n\n/** @return `true` if the port can still be used to start the dev server, `false` if the dev server should be skipped, and asserts if the port is now taken. */\nexport async function ensurePortAvailabilityAsync(\n projectRoot: string,\n { port }: { port: number }\n): Promise<boolean> {\n const isFreePort = await testPortAsync(port, [null]);\n // Check if port has become busy during the build.\n if (isFreePort) {\n return true;\n }\n\n const isBusy = await isBusyPortRunningSameProcessAsync(projectRoot, { port });\n if (!isBusy) {\n throw new CommandError(\n `Port \"${port}\" became busy running another process while the app was compiling. Re-run command to use a new port.`\n );\n }\n\n // Log that the dev server will not be started and that the logs will appear in another window.\n Log.log(\n '› The dev server for this app is already running in another window. Logs will appear there.'\n );\n return false;\n}\n\nfunction isRestrictedPort(port: number) {\n if (process.platform !== 'win32' && port < 1024) {\n const isRoot = process.getuid && process.getuid() === 0;\n return !isRoot;\n }\n return false;\n}\n\nasync function isBusyPortRunningSameProcessAsync(projectRoot: string, { port }: { port: number }) {\n const { getRunningProcess } =\n require('./getRunningProcess') as typeof import('./getRunningProcess');\n
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/port.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { env } from './env';\nimport { CommandError } from './errors';\nimport { testPortAsync, freePortAsync } from './freeport';\nimport * as Log from '../log';\n\n/** Get a free port or assert a CLI command error. */\nexport async function getFreePortAsync(rangeStart: number): Promise<number> {\n const port = await freePortAsync(rangeStart, [null, 'localhost']);\n if (!port) {\n throw new CommandError('NO_PORT_FOUND', 'No available port found');\n }\n\n return port;\n}\n\n/** @return `true` if the port can still be used to start the dev server, `false` if the dev server should be skipped, and asserts if the port is now taken. */\nexport async function ensurePortAvailabilityAsync(\n projectRoot: string,\n { port }: { port: number }\n): Promise<boolean> {\n const isFreePort = await testPortAsync(port, [null]);\n // Check if port has become busy during the build.\n if (isFreePort) {\n return true;\n }\n\n const isBusy = await isBusyPortRunningSameProcessAsync(projectRoot, { port });\n if (!isBusy) {\n throw new CommandError(\n `Port \"${port}\" became busy running another process while the app was compiling. Re-run command to use a new port.`\n );\n }\n\n // Log that the dev server will not be started and that the logs will appear in another window.\n Log.log(\n '› The dev server for this app is already running in another window. Logs will appear there.'\n );\n return false;\n}\n\nfunction isRestrictedPort(port: number) {\n if (process.platform !== 'win32' && port < 1024) {\n const isRoot = process.getuid && process.getuid() === 0;\n return !isRoot;\n }\n return false;\n}\n\nasync function isBusyPortRunningSameProcessAsync(projectRoot: string, { port }: { port: number }) {\n const { getRunningProcess } =\n require('./getRunningProcess') as typeof import('./getRunningProcess');\n const runningProcess = isRestrictedPort(port) ? null : await getRunningProcess(port);\n if (runningProcess) {\n if (runningProcess.directory === projectRoot) {\n return true;\n } else {\n return false;\n }\n }\n\n return null;\n}\n\n// TODO(Bacon): Revisit after all start and run code is merged.\nexport async function choosePortAsync(\n projectRoot: string,\n {\n defaultPort,\n host,\n reuseExistingPort,\n }: {\n defaultPort: number;\n host?: string;\n reuseExistingPort?: boolean;\n }\n): Promise<number | null> {\n try {\n const port = await freePortAsync(defaultPort, [host ?? null]);\n if (port === defaultPort || defaultPort === 0) {\n return port;\n }\n\n const isRestricted = port && isRestrictedPort(port);\n\n let message = isRestricted\n ? `Admin permissions are required to run a server on a port below 1024`\n : `Port ${chalk.bold(defaultPort)} is`;\n\n const { getRunningProcess } =\n require('./getRunningProcess') as typeof import('./getRunningProcess');\n const runningProcess = isRestricted ? null : await getRunningProcess(defaultPort);\n\n if (runningProcess) {\n const pidTag = chalk.gray(`(pid ${runningProcess.pid})`);\n if (runningProcess.directory === projectRoot) {\n message += ` running this app in another window`;\n if (reuseExistingPort) {\n return null;\n }\n } else {\n message += ` running ${chalk.cyan(runningProcess.command)} in another window`;\n }\n message += '\\n' + chalk.gray(` ${runningProcess.directory} ${pidTag}`);\n } else {\n message += ' being used by another process';\n }\n\n Log.log(`\\u203A ${message}`);\n const { confirmAsync } = require('./prompts') as typeof import('./prompts');\n const change = await confirmAsync({\n message: `Use port ${port} instead?`,\n initial: true,\n });\n return change ? port : null;\n } catch (error: any) {\n if (error.code === 'ABORTED') {\n throw error;\n } else if (error.code === 'NON_INTERACTIVE') {\n Log.warn(chalk.yellow(error.message));\n return null;\n }\n throw error;\n }\n}\n\n// TODO(Bacon): Revisit after all start and run code is merged.\nexport async function resolvePortAsync(\n projectRoot: string,\n {\n /** Should opt to reuse a port that is running the same project in another window. */\n reuseExistingPort,\n /** Preferred port. */\n defaultPort,\n /** Backup port for when the default isn't available. */\n fallbackPort,\n }: {\n reuseExistingPort?: boolean;\n defaultPort?: string | number;\n fallbackPort?: number;\n } = {}\n): Promise<number | null> {\n let port: number;\n if (typeof defaultPort === 'string') {\n port = parseInt(defaultPort, 10);\n } else if (typeof defaultPort === 'number') {\n port = defaultPort;\n } else {\n port = env.RCT_METRO_PORT || fallbackPort || 8081;\n }\n\n // Only check the port when the bundler is running.\n const resolvedPort = await choosePortAsync(projectRoot, {\n defaultPort: port,\n reuseExistingPort,\n });\n if (resolvedPort == null) {\n Log.log('\\u203A Skipping dev server');\n // Skip bundling if the port is null\n } else {\n // Use the new or resolved port\n process.env.RCT_METRO_PORT = String(resolvedPort);\n }\n\n return resolvedPort;\n}\n"],"names":["choosePortAsync","ensurePortAvailabilityAsync","getFreePortAsync","resolvePortAsync","rangeStart","port","freePortAsync","CommandError","projectRoot","isFreePort","testPortAsync","isBusy","isBusyPortRunningSameProcessAsync","Log","log","isRestrictedPort","process","platform","isRoot","getuid","getRunningProcess","require","runningProcess","directory","defaultPort","host","reuseExistingPort","isRestricted","message","chalk","bold","pidTag","gray","pid","cyan","command","confirmAsync","change","initial","error","code","warn","yellow","fallbackPort","parseInt","env","RCT_METRO_PORT","resolvedPort","String"],"mappings":";;;;;;;;;;;IAkEsBA,eAAe;eAAfA;;IAhDAC,2BAA2B;eAA3BA;;IAVAC,gBAAgB;eAAhBA;;IAwHAC,gBAAgB;eAAhBA;;;;gEAhIJ;;;;;;qBAEE;wBACS;0BACgB;6DACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGd,eAAeD,iBAAiBE,UAAkB;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