@expo/cli 0.18.18 → 0.19.0-canary-20240625-2333e70

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.
Files changed (224) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/api/rest/client.js +1 -2
  3. package/build/src/api/rest/client.js.map +1 -1
  4. package/build/src/api/user/UserSettings.js +2 -4
  5. package/build/src/api/user/UserSettings.js.map +1 -1
  6. package/build/src/api/user/actions.js +2 -2
  7. package/build/src/api/user/actions.js.map +1 -1
  8. package/build/src/api/user/user.js +1 -1
  9. package/build/src/api/user/user.js.map +1 -1
  10. package/build/src/customize/customizeAsync.js +1 -2
  11. package/build/src/customize/customizeAsync.js.map +1 -1
  12. package/build/src/customize/generate.js +4 -42
  13. package/build/src/customize/generate.js.map +1 -1
  14. package/build/src/customize/templates.js +30 -18
  15. package/build/src/customize/templates.js.map +1 -1
  16. package/build/src/export/embed/exportEmbedAsync.js +1 -1
  17. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  18. package/build/src/export/embed/index.js +1 -1
  19. package/build/src/export/embed/index.js.map +1 -1
  20. package/build/src/export/embed/resolveOptions.js +5 -8
  21. package/build/src/export/embed/resolveOptions.js.map +1 -1
  22. package/build/src/export/exportApp.js +10 -8
  23. package/build/src/export/exportApp.js.map +1 -1
  24. package/build/src/export/exportAssets.js +3 -4
  25. package/build/src/export/exportAssets.js.map +1 -1
  26. package/build/src/export/exportHermes.js +4 -7
  27. package/build/src/export/exportHermes.js.map +1 -1
  28. package/build/src/export/exportStaticAsync.js +8 -8
  29. package/build/src/export/exportStaticAsync.js.map +1 -1
  30. package/build/src/export/favicon.js +6 -6
  31. package/build/src/export/favicon.js.map +1 -1
  32. package/build/src/export/persistMetroAssets.js +18 -14
  33. package/build/src/export/persistMetroAssets.js.map +1 -1
  34. package/build/src/export/publicFolder.js.map +1 -1
  35. package/build/src/export/resolveOptions.js +1 -2
  36. package/build/src/export/resolveOptions.js.map +1 -1
  37. package/build/src/export/saveAssets.js +40 -18
  38. package/build/src/export/saveAssets.js.map +1 -1
  39. package/build/src/install/installAsync.js +1 -2
  40. package/build/src/install/installAsync.js.map +1 -1
  41. package/build/src/lint/ESlintPrerequisite.js +11 -12
  42. package/build/src/lint/ESlintPrerequisite.js.map +1 -1
  43. package/build/src/prebuild/configureProjectAsync.js +1 -2
  44. package/build/src/prebuild/configureProjectAsync.js.map +1 -1
  45. package/build/src/prebuild/renameTemplateAppName.js +1 -1
  46. package/build/src/prebuild/renameTemplateAppName.js.map +1 -1
  47. package/build/src/prebuild/updatePackageJson.js +2 -4
  48. package/build/src/prebuild/updatePackageJson.js.map +1 -1
  49. package/build/src/run/android/index.js +1 -1
  50. package/build/src/run/android/index.js.map +1 -1
  51. package/build/src/run/android/resolveGradlePropsAsync.js +1 -1
  52. package/build/src/run/android/resolveGradlePropsAsync.js.map +1 -1
  53. package/build/src/run/android/resolveOptions.js +1 -2
  54. package/build/src/run/android/resolveOptions.js.map +1 -1
  55. package/build/src/run/android/runAndroidAsync.js +2 -3
  56. package/build/src/run/android/runAndroidAsync.js.map +1 -1
  57. package/build/src/run/index.js +1 -2
  58. package/build/src/run/index.js.map +1 -1
  59. package/build/src/run/ios/appleDevice/AppleDevice.js +1 -2
  60. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
  61. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +1 -2
  62. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -1
  63. package/build/src/run/ios/codeSigning/Security.js +2 -4
  64. package/build/src/run/ios/codeSigning/Security.js.map +1 -1
  65. package/build/src/run/ios/codeSigning/settings.js +1 -1
  66. package/build/src/run/ios/codeSigning/settings.js.map +1 -1
  67. package/build/src/run/ios/index.js +1 -1
  68. package/build/src/run/ios/index.js.map +1 -1
  69. package/build/src/run/ios/options/resolveNativeScheme.js +3 -6
  70. package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -1
  71. package/build/src/run/resolveBundlerProps.js +1 -2
  72. package/build/src/run/resolveBundlerProps.js.map +1 -1
  73. package/build/src/run/startBundler.js +1 -2
  74. package/build/src/run/startBundler.js.map +1 -1
  75. package/build/src/start/doctor/apple/XcodePrerequisite.js +1 -1
  76. package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
  77. package/build/src/start/doctor/dependencies/resolvePackages.js +1 -2
  78. package/build/src/start/doctor/dependencies/resolvePackages.js.map +1 -1
  79. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +1 -1
  80. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  81. package/build/src/start/doctor/ngrok/ExternalModule.js +3 -6
  82. package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
  83. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +1 -2
  84. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
  85. package/build/src/start/doctor/typescript/updateTSConfig.js +1 -3
  86. package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
  87. package/build/src/start/interface/commandsTable.js +4 -0
  88. package/build/src/start/interface/commandsTable.js.map +1 -1
  89. package/build/src/start/interface/interactiveActions.js +2 -3
  90. package/build/src/start/interface/interactiveActions.js.map +1 -1
  91. package/build/src/start/platforms/ExpoGoInstaller.js +1 -2
  92. package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
  93. package/build/src/start/platforms/PlatformManager.js +1 -2
  94. package/build/src/start/platforms/PlatformManager.js.map +1 -1
  95. package/build/src/start/platforms/android/ADBServer.js +1 -2
  96. package/build/src/start/platforms/android/ADBServer.js.map +1 -1
  97. package/build/src/start/platforms/android/AndroidDeviceManager.js +2 -4
  98. package/build/src/start/platforms/android/AndroidDeviceManager.js.map +1 -1
  99. package/build/src/start/platforms/android/AndroidPlatformManager.js +1 -2
  100. package/build/src/start/platforms/android/AndroidPlatformManager.js.map +1 -1
  101. package/build/src/start/platforms/android/adb.js +6 -10
  102. package/build/src/start/platforms/android/adb.js.map +1 -1
  103. package/build/src/start/platforms/ios/AppleDeviceManager.js +2 -3
  104. package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
  105. package/build/src/start/platforms/ios/devicectl.js +2 -3
  106. package/build/src/start/platforms/ios/devicectl.js.map +1 -1
  107. package/build/src/start/platforms/ios/getBestSimulator.js +1 -2
  108. package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
  109. package/build/src/start/platforms/ios/simctl.js +4 -7
  110. package/build/src/start/platforms/ios/simctl.js.map +1 -1
  111. package/build/src/start/platforms/ios/simctlLogging.js +2 -4
  112. package/build/src/start/platforms/ios/simctlLogging.js.map +1 -1
  113. package/build/src/start/resolveOptions.js +2 -4
  114. package/build/src/start/resolveOptions.js.map +1 -1
  115. package/build/src/start/server/AsyncNgrok.js +1 -2
  116. package/build/src/start/server/AsyncNgrok.js.map +1 -1
  117. package/build/src/start/server/BundlerDevServer.js +15 -15
  118. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  119. package/build/src/start/server/DevServerManager.js +6 -10
  120. package/build/src/start/server/DevServerManager.js.map +1 -1
  121. package/build/src/start/server/DevToolsPluginManager.js +1 -2
  122. package/build/src/start/server/DevToolsPluginManager.js.map +1 -1
  123. package/build/src/start/server/ReactDevToolsProxy.js +1 -2
  124. package/build/src/start/server/ReactDevToolsProxy.js.map +1 -1
  125. package/build/src/start/server/UrlCreator.js +3 -6
  126. package/build/src/start/server/UrlCreator.js.map +1 -1
  127. package/build/src/start/server/metro/MetroBundlerDevServer.js +139 -124
  128. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  129. package/build/src/start/server/metro/MetroTerminalReporter.js +17 -6
  130. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  131. package/build/src/start/server/metro/TerminalReporter.js +15 -4
  132. package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
  133. package/build/src/start/server/metro/createExpoMetroResolver.js +5 -9
  134. package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
  135. package/build/src/start/server/metro/createServerRouteMiddleware.js +1 -1
  136. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  137. package/build/src/start/server/metro/debugging/messageHandlers/VscodeRuntimeGetProperties.js +2 -4
  138. package/build/src/start/server/metro/debugging/messageHandlers/VscodeRuntimeGetProperties.js.map +1 -1
  139. package/build/src/start/server/metro/debugging/pageIsSupported.js +1 -2
  140. package/build/src/start/server/metro/debugging/pageIsSupported.js.map +1 -1
  141. package/build/src/start/server/metro/getCssModulesFromBundler.js +1 -2
  142. package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -1
  143. package/build/src/start/server/metro/instantiateMetro.js +33 -35
  144. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  145. package/build/src/start/server/metro/metroErrorInterface.js +28 -10
  146. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  147. package/build/src/start/server/metro/router.js +2 -4
  148. package/build/src/start/server/metro/router.js.map +1 -1
  149. package/build/src/start/server/metro/runServer-fork.js +3 -1
  150. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  151. package/build/src/start/server/metro/withMetroMultiPlatform.js +134 -58
  152. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  153. package/build/src/start/server/metro/withMetroResolvers.js +13 -18
  154. package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
  155. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +1 -2
  156. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -1
  157. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +2 -3
  158. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
  159. package/build/src/start/server/middleware/InterstitialPageMiddleware.js +7 -12
  160. package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
  161. package/build/src/start/server/middleware/ManifestMiddleware.js +8 -13
  162. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  163. package/build/src/start/server/middleware/ReactDevToolsPageMiddleware.js +3 -5
  164. package/build/src/start/server/middleware/ReactDevToolsPageMiddleware.js.map +1 -1
  165. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +1 -2
  166. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
  167. package/build/src/start/server/middleware/inspector/JsInspector.js +4 -8
  168. package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
  169. package/build/src/start/server/middleware/inspector/LaunchBrowser.js +2 -2
  170. package/build/src/start/server/middleware/inspector/LaunchBrowser.js.map +1 -1
  171. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js +1 -2
  172. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js.map +1 -1
  173. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js +2 -4
  174. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js.map +1 -1
  175. package/build/src/start/server/middleware/metroOptions.js +26 -15
  176. package/build/src/start/server/middleware/metroOptions.js.map +1 -1
  177. package/build/src/start/server/middleware/resolvePlatform.js +1 -2
  178. package/build/src/start/server/middleware/resolvePlatform.js.map +1 -1
  179. package/build/src/start/server/platformBundlers.js +2 -3
  180. package/build/src/start/server/platformBundlers.js.map +1 -1
  181. package/build/src/start/server/serverLogLikeMetro.js +2 -4
  182. package/build/src/start/server/serverLogLikeMetro.js.map +1 -1
  183. package/build/src/start/server/webTemplate.js +2 -3
  184. package/build/src/start/server/webTemplate.js.map +1 -1
  185. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +13 -19
  186. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  187. package/build/src/start/server/webpack/resolveFromProject.js.map +1 -1
  188. package/build/src/start/startAsync.js +2 -4
  189. package/build/src/start/startAsync.js.map +1 -1
  190. package/build/src/utils/FileNotifier.js +1 -1
  191. package/build/src/utils/FileNotifier.js.map +1 -1
  192. package/build/src/utils/dir.js +2 -4
  193. package/build/src/utils/dir.js.map +1 -1
  194. package/build/src/utils/errors.js +3 -6
  195. package/build/src/utils/errors.js.map +1 -1
  196. package/build/src/utils/exit.js +1 -2
  197. package/build/src/utils/exit.js.map +1 -1
  198. package/build/src/utils/getOrPromptApplicationId.js +2 -4
  199. package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
  200. package/build/src/utils/link.js +1 -1
  201. package/build/src/utils/link.js.map +1 -1
  202. package/build/src/utils/mergeGitIgnorePaths.js +1 -1
  203. package/build/src/utils/mergeGitIgnorePaths.js.map +1 -1
  204. package/build/src/utils/npm.js +2 -3
  205. package/build/src/utils/npm.js.map +1 -1
  206. package/build/src/utils/open.js +1 -2
  207. package/build/src/utils/open.js.map +1 -1
  208. package/build/src/utils/port.js +1 -1
  209. package/build/src/utils/port.js.map +1 -1
  210. package/build/src/utils/profile.js +1 -1
  211. package/build/src/utils/profile.js.map +1 -1
  212. package/build/src/utils/prompts.js +2 -2
  213. package/build/src/utils/prompts.js.map +1 -1
  214. package/build/src/utils/telemetry/getContext.js +2 -3
  215. package/build/src/utils/telemetry/getContext.js.map +1 -1
  216. package/build/src/utils/tsconfig/evaluateTsConfig.js +1 -2
  217. package/build/src/utils/tsconfig/evaluateTsConfig.js.map +1 -1
  218. package/build/src/utils/tsconfig/loadTsConfigPaths.js +4 -5
  219. package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -1
  220. package/build/src/utils/url.js +1 -2
  221. package/build/src/utils/url.js.map +1 -1
  222. package/package.json +38 -43
  223. package/static/template/.eslintrc.js +4 -0
  224. package/static/template/serve.json +0 -13
package/build/bin/cli CHANGED
@@ -120,7 +120,7 @@ const args = (0, _arg().default)({
120
120
  });
121
121
  if (args["--version"]) {
122
122
  // Version is added in the build script.
123
- console.log("0.18.18");
123
+ console.log("0.19.0-canary-20240625-2333e70");
124
124
  process.exit(0);
125
125
  }
126
126
  if (args["--non-interactive"]) {
@@ -70,8 +70,7 @@ function wrapFetchWithCredentials(fetchFunction) {
70
70
  if (Array.isArray(options.headers)) {
71
71
  throw new Error("request headers must be in object form");
72
72
  }
73
- var _headers;
74
- const resolvedHeaders = (_headers = options.headers) != null ? _headers : {};
73
+ const resolvedHeaders = options.headers ?? {};
75
74
  const token = _userSettings.default.getAccessToken();
76
75
  if (token) {
77
76
  resolvedHeaders.authorization = `Bearer ${token}`;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/api/rest/client.ts"],"sourcesContent":["import { getExpoHomeDirectory } from '@expo/config/build/getUserState';\nimport { JSONValue } from '@expo/json-file';\nimport fetchInstance from 'node-fetch';\nimport path from 'path';\n\nimport { wrapFetchWithCache } from './cache/wrapFetchWithCache';\nimport { FetchLike } from './client.types';\nimport { wrapFetchWithBaseUrl } from './wrapFetchWithBaseUrl';\nimport { wrapFetchWithOffline } from './wrapFetchWithOffline';\nimport { wrapFetchWithProgress } from './wrapFetchWithProgress';\nimport { wrapFetchWithProxy } from './wrapFetchWithProxy';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { disableNetwork } from '../settings';\nimport UserSettings from '../user/UserSettings';\n\nexport class ApiV2Error extends Error {\n readonly name = 'ApiV2Error';\n readonly code: string;\n readonly expoApiV2ErrorCode: string;\n readonly expoApiV2ErrorDetails?: JSONValue;\n readonly expoApiV2ErrorServerStack?: string;\n readonly expoApiV2ErrorMetadata?: object;\n\n constructor(response: {\n message: string;\n code: string;\n stack?: string;\n details?: JSONValue;\n metadata?: object;\n }) {\n super(response.message);\n this.code = response.code;\n this.expoApiV2ErrorCode = response.code;\n this.expoApiV2ErrorDetails = response.details;\n this.expoApiV2ErrorServerStack = response.stack;\n this.expoApiV2ErrorMetadata = response.metadata;\n }\n}\n\n/**\n * An Expo server error that didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the server.\n */\nexport class UnexpectedServerError extends Error {\n readonly name = 'UnexpectedServerError';\n}\n\n/**\n * @returns a `fetch` function that will inject user authentication information and handle errors from the Expo API.\n */\nexport function wrapFetchWithCredentials(fetchFunction: FetchLike): FetchLike {\n return async function fetchWithCredentials(url, options = {}) {\n if (Array.isArray(options.headers)) {\n throw new Error('request headers must be in object form');\n }\n\n const resolvedHeaders = options.headers ?? ({} as any);\n\n const token = UserSettings.getAccessToken();\n if (token) {\n resolvedHeaders.authorization = `Bearer ${token}`;\n } else {\n const sessionSecret = UserSettings.getSession()?.sessionSecret;\n if (sessionSecret) {\n resolvedHeaders['expo-session'] = sessionSecret;\n }\n }\n\n try {\n const results = await fetchFunction(url, {\n ...options,\n headers: resolvedHeaders,\n });\n\n if (results.status >= 400 && results.status < 500) {\n const body = await results.text();\n try {\n const data = JSON.parse(body);\n if (data?.errors?.length) {\n throw new ApiV2Error(data.errors[0]);\n }\n } catch (error: any) {\n // Server returned non-json response.\n if (error.message.includes('in JSON at position')) {\n throw new UnexpectedServerError(body);\n }\n throw error;\n }\n }\n return results;\n } catch (error: any) {\n // Specifically, when running `npx expo start` and the wifi is connected but not really (public wifi, airplanes, etc).\n if ('code' in error && error.code === 'ENOTFOUND') {\n disableNetwork();\n\n throw new CommandError(\n 'OFFLINE',\n 'Network connection is unreliable. Try again with the environment variable `EXPO_OFFLINE=1` to skip network requests.'\n );\n }\n\n throw error;\n }\n };\n}\n\nconst fetchWithOffline = wrapFetchWithOffline(fetchInstance);\n\nconst fetchWithBaseUrl = wrapFetchWithBaseUrl(fetchWithOffline, getExpoApiBaseUrl() + '/v2/');\n\nconst fetchWithProxy = wrapFetchWithProxy(fetchWithBaseUrl);\n\nconst fetchWithCredentials = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n\n/**\n * Create an instance of the fully qualified fetch command (auto authentication and api) but with caching in the '~/.expo' directory.\n * Caching is disabled automatically if the EXPO_NO_CACHE or EXPO_BETA environment variables are enabled.\n */\nexport function createCachedFetch({\n fetch = fetchWithCredentials,\n cacheDirectory,\n ttl,\n skipCache,\n}: {\n fetch?: FetchLike;\n cacheDirectory: string;\n ttl?: number;\n skipCache?: boolean;\n}): FetchLike {\n // Disable all caching in EXPO_BETA.\n if (skipCache || env.EXPO_BETA || env.EXPO_NO_CACHE) {\n return fetch;\n }\n\n const { FileSystemCache } =\n require('./cache/FileSystemCache') as typeof import('./cache/FileSystemCache');\n\n return wrapFetchWithCache(\n fetch,\n new FileSystemCache({\n cacheDirectory: path.join(getExpoHomeDirectory(), cacheDirectory),\n ttl,\n })\n );\n}\n\n/** Instance of fetch with automatic base URL pointing to the Expo API, user credential injection, and API error handling. Caching not included. */\nexport const fetchAsync = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n"],"names":["ApiV2Error","UnexpectedServerError","wrapFetchWithCredentials","createCachedFetch","fetchAsync","Error","name","constructor","response","message","code","expoApiV2ErrorCode","expoApiV2ErrorDetails","details","expoApiV2ErrorServerStack","stack","expoApiV2ErrorMetadata","metadata","fetchFunction","fetchWithCredentials","url","options","Array","isArray","headers","resolvedHeaders","token","UserSettings","getAccessToken","authorization","sessionSecret","getSession","results","status","body","text","data","JSON","parse","errors","length","error","includes","disableNetwork","CommandError","fetchWithOffline","wrapFetchWithOffline","fetchInstance","fetchWithBaseUrl","wrapFetchWithBaseUrl","getExpoApiBaseUrl","fetchWithProxy","wrapFetchWithProxy","wrapFetchWithProgress","fetch","cacheDirectory","ttl","skipCache","env","EXPO_BETA","EXPO_NO_CACHE","FileSystemCache","require","wrapFetchWithCache","path","join","getExpoHomeDirectory"],"mappings":"AAAA;;;;;;;;;;;IAiBaA,UAAU,MAAVA,UAAU;IA4BVC,qBAAqB,MAArBA,qBAAqB;IAOlBC,wBAAwB,MAAxBA,wBAAwB;IAoExBC,iBAAiB,MAAjBA,iBAAiB;IA6BpBC,UAAU,MAAVA,UAAU;;;yBArJc,iCAAiC;;;;;;;8DAE5C,YAAY;;;;;;;8DACrB,MAAM;;;;;;oCAEY,4BAA4B;sCAE1B,wBAAwB;sCACxB,wBAAwB;uCACvB,yBAAyB;oCAC5B,sBA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,CAAC,AAAC"}
1
+ {"version":3,"sources":["../../../../src/api/rest/client.ts"],"sourcesContent":["import { getExpoHomeDirectory } from '@expo/config/build/getUserState';\nimport { JSONValue } from '@expo/json-file';\nimport fetchInstance from 'node-fetch';\nimport path from 'path';\n\nimport { wrapFetchWithCache } from './cache/wrapFetchWithCache';\nimport { FetchLike } from './client.types';\nimport { wrapFetchWithBaseUrl } from './wrapFetchWithBaseUrl';\nimport { wrapFetchWithOffline } from './wrapFetchWithOffline';\nimport { wrapFetchWithProgress } from './wrapFetchWithProgress';\nimport { wrapFetchWithProxy } from './wrapFetchWithProxy';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { disableNetwork } from '../settings';\nimport UserSettings from '../user/UserSettings';\n\nexport class ApiV2Error extends Error {\n readonly name = 'ApiV2Error';\n readonly code: string;\n readonly expoApiV2ErrorCode: string;\n readonly expoApiV2ErrorDetails?: JSONValue;\n readonly expoApiV2ErrorServerStack?: string;\n readonly expoApiV2ErrorMetadata?: object;\n\n constructor(response: {\n message: string;\n code: string;\n stack?: string;\n details?: JSONValue;\n metadata?: object;\n }) {\n super(response.message);\n this.code = response.code;\n this.expoApiV2ErrorCode = response.code;\n this.expoApiV2ErrorDetails = response.details;\n this.expoApiV2ErrorServerStack = response.stack;\n this.expoApiV2ErrorMetadata = response.metadata;\n }\n}\n\n/**\n * An Expo server error that didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the server.\n */\nexport class UnexpectedServerError extends Error {\n readonly name = 'UnexpectedServerError';\n}\n\n/**\n * @returns a `fetch` function that will inject user authentication information and handle errors from the Expo API.\n */\nexport function wrapFetchWithCredentials(fetchFunction: FetchLike): FetchLike {\n return async function fetchWithCredentials(url, options = {}) {\n if (Array.isArray(options.headers)) {\n throw new Error('request headers must be in object form');\n }\n\n const resolvedHeaders = options.headers ?? ({} as any);\n\n const token = UserSettings.getAccessToken();\n if (token) {\n resolvedHeaders.authorization = `Bearer ${token}`;\n } else {\n const sessionSecret = UserSettings.getSession()?.sessionSecret;\n if (sessionSecret) {\n resolvedHeaders['expo-session'] = sessionSecret;\n }\n }\n\n try {\n const results = await fetchFunction(url, {\n ...options,\n headers: resolvedHeaders,\n });\n\n if (results.status >= 400 && results.status < 500) {\n const body = await results.text();\n try {\n const data = JSON.parse(body);\n if (data?.errors?.length) {\n throw new ApiV2Error(data.errors[0]);\n }\n } catch (error: any) {\n // Server returned non-json response.\n if (error.message.includes('in JSON at position')) {\n throw new UnexpectedServerError(body);\n }\n throw error;\n }\n }\n return results;\n } catch (error: any) {\n // Specifically, when running `npx expo start` and the wifi is connected but not really (public wifi, airplanes, etc).\n if ('code' in error && error.code === 'ENOTFOUND') {\n disableNetwork();\n\n throw new CommandError(\n 'OFFLINE',\n 'Network connection is unreliable. Try again with the environment variable `EXPO_OFFLINE=1` to skip network requests.'\n );\n }\n\n throw error;\n }\n };\n}\n\nconst fetchWithOffline = wrapFetchWithOffline(fetchInstance);\n\nconst fetchWithBaseUrl = wrapFetchWithBaseUrl(fetchWithOffline, getExpoApiBaseUrl() + '/v2/');\n\nconst fetchWithProxy = wrapFetchWithProxy(fetchWithBaseUrl);\n\nconst fetchWithCredentials = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n\n/**\n * Create an instance of the fully qualified fetch command (auto authentication and api) but with caching in the '~/.expo' directory.\n * Caching is disabled automatically if the EXPO_NO_CACHE or EXPO_BETA environment variables are enabled.\n */\nexport function createCachedFetch({\n fetch = fetchWithCredentials,\n cacheDirectory,\n ttl,\n skipCache,\n}: {\n fetch?: FetchLike;\n cacheDirectory: string;\n ttl?: number;\n skipCache?: boolean;\n}): FetchLike {\n // Disable all caching in EXPO_BETA.\n if (skipCache || env.EXPO_BETA || env.EXPO_NO_CACHE) {\n return fetch;\n }\n\n const { FileSystemCache } =\n require('./cache/FileSystemCache') as typeof import('./cache/FileSystemCache');\n\n return wrapFetchWithCache(\n fetch,\n new FileSystemCache({\n cacheDirectory: path.join(getExpoHomeDirectory(), cacheDirectory),\n ttl,\n })\n );\n}\n\n/** Instance of fetch with automatic base URL pointing to the Expo API, user credential injection, and API error handling. Caching not included. */\nexport const fetchAsync = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n"],"names":["ApiV2Error","UnexpectedServerError","wrapFetchWithCredentials","createCachedFetch","fetchAsync","Error","name","constructor","response","message","code","expoApiV2ErrorCode","expoApiV2ErrorDetails","details","expoApiV2ErrorServerStack","stack","expoApiV2ErrorMetadata","metadata","fetchFunction","fetchWithCredentials","url","options","Array","isArray","headers","resolvedHeaders","token","UserSettings","getAccessToken","authorization","sessionSecret","getSession","results","status","body","text","data","JSON","parse","errors","length","error","includes","disableNetwork","CommandError","fetchWithOffline","wrapFetchWithOffline","fetchInstance","fetchWithBaseUrl","wrapFetchWithBaseUrl","getExpoApiBaseUrl","fetchWithProxy","wrapFetchWithProxy","wrapFetchWithProgress","fetch","cacheDirectory","ttl","skipCache","env","EXPO_BETA","EXPO_NO_CACHE","FileSystemCache","require","wrapFetchWithCache","path","join","getExpoHomeDirectory"],"mappings":"AAAA;;;;;;;;;;;IAiBaA,UAAU,MAAVA,UAAU;IA4BVC,qBAAqB,MAArBA,qBAAqB;IAOlBC,wBAAwB,MAAxBA,wBAAwB;IAoExBC,iBAAiB,MAAjBA,iBAAiB;IA6BpBC,UAAU,MAAVA,UAAU;;;yBArJc,iCAAiC;;;;;;;8DAE5C,YAAY;;;;;;;8DACrB,MAAM;;;;;;oCAEY,4BAA4B;sCAE1B,wBAAwB;sCACxB,wBAAwB;uCACvB,yBAAyB;oCAC5B,sBAAsB;qBACrC,iBAAiB;wBACR,oBAAoB;0BACf,aAAa;0BAChB,aAAa;mEACnB,sBAAsB;;;;;;AAExC,MAAMJ,UAAU,SAASK,KAAK;IACnC,AAASC,IAAI,GAAG,YAAY,CAAC;IAO7BC,YAAYC,QAMX,CAAE;QACD,KAAK,CAACA,QAAQ,C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E7D,MAAMC,gBAAgB,GAAGC,IAAAA,qBAAoB,qBAAA,EAACJ,gBAAgB,EAAEK,IAAAA,SAAiB,kBAAA,GAAE,GAAG,MAAM,CAAC,AAAC;AAE9F,MAAMC,cAAc,GAAGC,IAAAA,mBAAkB,mBAAA,EAACJ,gBAAgB,CAAC,AAAC;AAE5D,MAAM7B,oBAAoB,GAAGkC,IAAAA,sBAAqB,sBAAA,EAACnD,wBAAwB,CAACiD,cAAc,CAAC,CAAC,AAAC;AAMtF,SAAShD,iBAAiB,CAAC,EAChCmD,KAAK,EAAGnC,oBAAoB,CAAA,EAC5BoC,cAAc,CAAA,EACdC,GAAG,CAAA,EACHC,SAAS,CAAA,EAMV,EAAa;IACZ,oCAAoC;IACpC,IAAIA,SAAS,IAAIC,IAAG,IAAA,CAACC,SAAS,IAAID,IAAG,IAAA,CAACE,aAAa,EAAE;QACnD,OAAON,KAAK,CAAC;IACf,CAAC;IAED,MAAM,EAAEO,eAAe,CAAA,EAAE,GACvBC,OAAO,CAAC,yBAAyB,CAAC,AAA4C,AAAC;IAEjF,OAAOC,IAAAA,mBAAkB,mBAAA,EACvBT,KAAK,EACL,IAAIO,eAAe,CAAC;QAClBN,cAAc,EAAES,KAAI,EAAA,QAAA,CAACC,IAAI,CAACC,IAAAA,aAAoB,EAAA,qBAAA,GAAE,EAAEX,cAAc,CAAC;QACjEC,GAAG;KACJ,CAAC,CACH,CAAC;AACJ,CAAC;AAGM,MAAMpD,UAAU,GAAGiD,IAAAA,sBAAqB,sBAAA,EAACnD,wBAAwB,CAACiD,cAAc,CAAC,CAAC,AAAC"}
@@ -54,8 +54,7 @@ async function setSessionAsync(sessionData) {
54
54
  function getSession() {
55
55
  try {
56
56
  var ref;
57
- var ref1;
58
- return (ref1 = (ref = _jsonFile().default.read((0, _getUserState().getUserStatePath)())) == null ? void 0 : ref.auth) != null ? ref1 : null;
57
+ return ((ref = _jsonFile().default.read((0, _getUserState().getUserStatePath)())) == null ? void 0 : ref.auth) ?? null;
59
58
  } catch (error) {
60
59
  if (error.code === "ENOENT") {
61
60
  return null;
@@ -64,8 +63,7 @@ function getSession() {
64
63
  }
65
64
  }
66
65
  function getAccessToken() {
67
- var _EXPO_TOKEN;
68
- return (_EXPO_TOKEN = process.env.EXPO_TOKEN) != null ? _EXPO_TOKEN : null;
66
+ return process.env.EXPO_TOKEN ?? null;
69
67
  }
70
68
  // returns an anonymous, unique identifier for a user on the current computer
71
69
  async function getAnonymousIdentifierAsync() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/api/user/UserSettings.ts"],"sourcesContent":["import { getExpoHomeDirectory, getUserStatePath } from '@expo/config/build/getUserState';\nimport JsonFile from '@expo/json-file';\nimport crypto from 'crypto';\n\ntype SessionData = {\n sessionSecret: string;\n // These fields are potentially used by Expo CLI.\n userId: string;\n username: string;\n currentConnection: 'Username-Password-Authentication' | 'Browser-Flow-Authentication';\n};\n\nexport type UserSettingsData = {\n auth?: SessionData | null;\n ignoreBundledBinaries?: string[];\n PATH?: string;\n /** Last development code signing ID used for `npx expo run:ios`. */\n developmentCodeSigningId?: string;\n /** Unique user ID which is generated anonymously and can be cleared locally. */\n uuid?: string;\n};\n\n/** Return the user cache directory. */\nfunction getDirectory() {\n return getExpoHomeDirectory();\n}\n\nfunction getFilePath(): string {\n return getUserStatePath();\n}\n\nfunction userSettingsJsonFile(): JsonFile<UserSettingsData> {\n return new JsonFile<UserSettingsData>(getFilePath(), {\n ensureDir: true,\n jsonParseErrorDefault: {},\n cantReadFileDefault: {},\n });\n}\n\nasync function setSessionAsync(sessionData?: SessionData): Promise<void> {\n await UserSettings.setAsync('auth', sessionData, {\n default: {},\n ensureDir: true,\n });\n}\n\nfunction getSession(): SessionData | null {\n try {\n return JsonFile.read<UserSettingsData>(getUserStatePath())?.auth ?? null;\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n return null;\n }\n throw error;\n }\n}\n\nfunction getAccessToken(): string | null {\n return process.env.EXPO_TOKEN ?? null;\n}\n\n// returns an anonymous, unique identifier for a user on the current computer\nasync function getAnonymousIdentifierAsync(): Promise<string> {\n const settings = await userSettingsJsonFile();\n let id = await settings.getAsync('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n await settings.setAsync('uuid', id);\n }\n\n return id;\n}\n\nconst UserSettings = Object.assign(userSettingsJsonFile(), {\n getSession,\n setSessionAsync,\n getAccessToken,\n getDirectory,\n getFilePath,\n userSettingsJsonFile,\n getAnonymousIdentifierAsync,\n});\n\nexport default UserSettings;\n"],"names":["getDirectory","getExpoHomeDirectory","getFilePath","getUserStatePath","userSettingsJsonFile","JsonFile","ensureDir","jsonParseErrorDefault","cantReadFileDefault","setSessionAsync","sessionData","UserSettings","setAsync","default","getSession","read","auth","error","code","getAccessToken","process","env","EXPO_TOKEN","getAnonymousIdentifierAsync","settings","id","getAsync","crypto","randomUUID","Object","assign"],"mappings":"AAAA;;;;+BAoFA,SAA4B;;aAA5B,QAA4B;;;yBApF2B,iCAAiC;;;;;;;8DACnE,iBAAiB;;;;;;;8DACnB,QAAQ;;;;;;;;;;;AAoB3B,qCAAqC,GACrC,SAASA,YAAY,GAAG;IACtB,OAAOC,IAAAA,aAAoB,EAAA,qBAAA,GAAE,CAAC;AAChC,CAAC;AAED,SAASC,WAAW,GAAW;IAC7B,OAAOC,IAAAA,aAAgB,EAAA,iBAAA,GAAE,CAAC;AAC5B,CAAC;AAED,SAASC,oBAAoB,GAA+B;IAC1D,OAAO,IAAIC,CAAAA,SAAQ,EAAA,CAAA,QAAA,CAAmBH,WAAW,EAAE,EAAE;QACnDI,SAAS,EAAE,IAAI;QACfC,qBAAqB,EAAE,EAAE;QACzBC,mBAAmB,EAAE,EAAE;KACxB,CAAC,CAAC;AACL,CAAC;AAED,eAAeC,eAAe,CAACC,WAAyB,EAAiB;IACvE,MAAMC,YAAY,CAACC,QAAQ,CAAC,MAAM,EAAEF,WAAW,EAAE;QAC/CG,OAAO,EAAE,EAAE;QACXP,SAAS,EAAE,IAAI;KAChB,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EH,QAA4B,GAAbZ,YAAY"}
1
+ {"version":3,"sources":["../../../../src/api/user/UserSettings.ts"],"sourcesContent":["import { getExpoHomeDirectory, getUserStatePath } from '@expo/config/build/getUserState';\nimport JsonFile from '@expo/json-file';\nimport crypto from 'crypto';\n\ntype SessionData = {\n sessionSecret: string;\n // These fields are potentially used by Expo CLI.\n userId: string;\n username: string;\n currentConnection: 'Username-Password-Authentication' | 'Browser-Flow-Authentication';\n};\n\nexport type UserSettingsData = {\n auth?: SessionData | null;\n ignoreBundledBinaries?: string[];\n PATH?: string;\n /** Last development code signing ID used for `npx expo run:ios`. */\n developmentCodeSigningId?: string;\n /** Unique user ID which is generated anonymously and can be cleared locally. */\n uuid?: string;\n};\n\n/** Return the user cache directory. */\nfunction getDirectory() {\n return getExpoHomeDirectory();\n}\n\nfunction getFilePath(): string {\n return getUserStatePath();\n}\n\nfunction userSettingsJsonFile(): JsonFile<UserSettingsData> {\n return new JsonFile<UserSettingsData>(getFilePath(), {\n ensureDir: true,\n jsonParseErrorDefault: {},\n cantReadFileDefault: {},\n });\n}\n\nasync function setSessionAsync(sessionData?: SessionData): Promise<void> {\n await UserSettings.setAsync('auth', sessionData, {\n default: {},\n ensureDir: true,\n });\n}\n\nfunction getSession(): SessionData | null {\n try {\n return JsonFile.read<UserSettingsData>(getUserStatePath())?.auth ?? null;\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n return null;\n }\n throw error;\n }\n}\n\nfunction getAccessToken(): string | null {\n return process.env.EXPO_TOKEN ?? null;\n}\n\n// returns an anonymous, unique identifier for a user on the current computer\nasync function getAnonymousIdentifierAsync(): Promise<string> {\n const settings = await userSettingsJsonFile();\n let id = await settings.getAsync('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n await settings.setAsync('uuid', id);\n }\n\n return id;\n}\n\nconst UserSettings = Object.assign(userSettingsJsonFile(), {\n getSession,\n setSessionAsync,\n getAccessToken,\n getDirectory,\n getFilePath,\n userSettingsJsonFile,\n getAnonymousIdentifierAsync,\n});\n\nexport default UserSettings;\n"],"names":["getDirectory","getExpoHomeDirectory","getFilePath","getUserStatePath","userSettingsJsonFile","JsonFile","ensureDir","jsonParseErrorDefault","cantReadFileDefault","setSessionAsync","sessionData","UserSettings","setAsync","default","getSession","read","auth","error","code","getAccessToken","process","env","EXPO_TOKEN","getAnonymousIdentifierAsync","settings","id","getAsync","crypto","randomUUID","Object","assign"],"mappings":"AAAA;;;;+BAoFA,SAA4B;;aAA5B,QAA4B;;;yBApF2B,iCAAiC;;;;;;;8DACnE,iBAAiB;;;;;;;8DACnB,QAAQ;;;;;;;;;;;AAoB3B,qCAAqC,GACrC,SAASA,YAAY,GAAG;IACtB,OAAOC,IAAAA,aAAoB,EAAA,qBAAA,GAAE,CAAC;AAChC,CAAC;AAED,SAASC,WAAW,GAAW;IAC7B,OAAOC,IAAAA,aAAgB,EAAA,iBAAA,GAAE,CAAC;AAC5B,CAAC;AAED,SAASC,oBAAoB,GAA+B;IAC1D,OAAO,IAAIC,CAAAA,SAAQ,EAAA,CAAA,QAAA,CAAmBH,WAAW,EAAE,EAAE;QACnDI,SAAS,EAAE,IAAI;QACfC,qBAAqB,EAAE,EAAE;QACzBC,mBAAmB,EAAE,EAAE;KACxB,CAAC,CAAC;AACL,CAAC;AAED,eAAeC,eAAe,CAACC,WAAyB,EAAiB;IACvE,MAAMC,YAAY,CAACC,QAAQ,CAAC,MAAM,EAAEF,WAAW,EAAE;QAC/CG,OAAO,EAAE,EAAE;QACXP,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC;AAED,SAASQ,UAAU,GAAuB;IACxC,IAAI;YACKT,GAAmD;QAA1D,OAAOA,CAAAA,CAAAA,GAAmD,GAAnDA,SAAQ,EAAA,QAAA,CAACU,IAAI,CAAmBZ,IAAAA,aAAgB,EAAA,iBAAA,GAAE,CAAC,SAAM,GAAzDE,KAAAA,CAAyD,GAAzDA,GAAmD,CAAEW,IAAI,CAAA,IAAI,IAAI,CAAC;IAC3E,EAAE,OAAOC,KAAK,EAAO;QACnB,IAAIA,KAAK,CAACC,IAAI,KAAK,QAAQ,EAAE;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAMD,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAASE,cAAc,GAAkB;IACvC,OAAOC,OAAO,CAACC,GAAG,CAACC,UAAU,IAAI,IAAI,CAAC;AACxC,CAAC;AAED,6EAA6E;AAC7E,eAAeC,2BAA2B,GAAoB;IAC5D,MAAMC,QAAQ,GAAG,MAAMpB,oBAAoB,EAAE,AAAC;IAC9C,IAAIqB,EAAE,GAAG,MAAMD,QAAQ,CAACE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,AAAC;IAE/C,IAAI,CAACD,EAAE,EAAE;QACPA,EAAE,GAAGE,OAAM,EAAA,QAAA,CAACC,UAAU,EAAE,CAAC;QACzB,MAAMJ,QAAQ,CAACZ,QAAQ,CAAC,MAAM,EAAEa,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,OAAOA,EAAE,CAAC;AACZ,CAAC;AAED,MAAMd,YAAY,GAAGkB,MAAM,CAACC,MAAM,CAAC1B,oBAAoB,EAAE,EAAE;IACzDU,UAAU;IACVL,eAAe;IACfU,cAAc;IACdnB,YAAY;IACZE,WAAW;IACXE,oBAAoB;IACpBmB,2BAA2B;CAC5B,CAAC,AAAC;MAEH,QAA4B,GAAbZ,YAAY"}
@@ -109,8 +109,8 @@ async function showLoginPromptAsync({ printNewLine =false , otp , ...options } =
109
109
  ].filter(Boolean), {
110
110
  nonInteractiveHelp: `Use the EXPO_TOKEN environment variable to authenticate in CI (${(0, _link.learnMore)("https://docs.expo.dev/accounts/programmatic-access/")})`
111
111
  });
112
- username != null ? username : username = resolved.username;
113
- password != null ? password : password = resolved.password;
112
+ username ??= resolved.username;
113
+ password ??= resolved.password;
114
114
  }
115
115
  // This is just for the types.
116
116
  (0, _assert().default)(username && password);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/api/user/actions.ts"],"sourcesContent":["import assert from 'assert';\nimport chalk from 'chalk';\n\nimport { retryUsernamePasswordAuthWithOTPAsync } from './otp';\nimport { Actor, getUserAsync, loginAsync, ssoLoginAsync } from './user';\nimport * as Log from '../../log';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\nimport promptAsync, { Question } from '../../utils/prompts';\nimport { ApiV2Error } from '../rest/client';\n\n/** Show login prompt while prompting for missing credentials. */\nexport async function showLoginPromptAsync({\n printNewLine = false,\n otp,\n ...options\n}: {\n printNewLine?: boolean;\n username?: string;\n password?: string;\n otp?: string;\n sso?: boolean | undefined;\n} = {}): Promise<void> {\n if (env.EXPO_OFFLINE) {\n throw new CommandError('OFFLINE', 'Cannot authenticate in offline-mode');\n }\n const hasCredentials = options.username && options.password;\n const sso = options.sso;\n\n if (printNewLine) {\n Log.log();\n }\n\n if (sso) {\n await ssoLoginAsync();\n return;\n }\n\n Log.log(\n hasCredentials\n ? `Logging in to EAS with email or username (exit and run 'npx expo login --help' for other login options)`\n : `Log in to EAS with email or username (exit and run 'npx expo login --help' for other login options)`\n );\n\n let username = options.username;\n let password = options.password;\n\n if (!hasCredentials) {\n const resolved = await promptAsync(\n [\n !options.username && {\n type: 'text',\n name: 'username',\n message: 'Email or username',\n },\n !options.password && {\n type: 'password',\n name: 'password',\n message: 'Password',\n },\n ].filter(Boolean) as Question<string>[],\n {\n nonInteractiveHelp: `Use the EXPO_TOKEN environment variable to authenticate in CI (${learnMore(\n 'https://docs.expo.dev/accounts/programmatic-access/'\n )})`,\n }\n );\n username ??= resolved.username;\n password ??= resolved.password;\n }\n // This is just for the types.\n assert(username && password);\n\n try {\n await loginAsync({\n username,\n password,\n otp,\n });\n } catch (e) {\n if (e instanceof ApiV2Error && e.expoApiV2ErrorCode === 'ONE_TIME_PASSWORD_REQUIRED') {\n await retryUsernamePasswordAuthWithOTPAsync(\n username,\n password,\n e.expoApiV2ErrorMetadata as any\n );\n } else {\n throw e;\n }\n }\n}\n\n/** Ensure the user is logged in, if not, prompt to login. */\nexport async function ensureLoggedInAsync(): Promise<Actor> {\n let user = await getUserAsync().catch(() => null);\n\n if (!user) {\n Log.warn(chalk.yellow`An Expo user account is required to proceed.`);\n await showLoginPromptAsync({ printNewLine: true });\n user = await getUserAsync();\n }\n\n assert(user, 'User should be logged in');\n return user;\n}\n"],"names":["showLoginPromptAsync","ensureLoggedInAsync","printNewLine","otp","options","env","EXPO_OFFLINE","CommandError","hasCredentials","username","password","sso","Log","log","ssoLoginAsync","resolved","promptAsync","type","name","message","filter","Boolean","nonInteractiveHelp","learnMore","assert","loginAsync","e","ApiV2Error","expoApiV2ErrorCode","retryUsernamePasswordAuthWithOTPAsync","expoApiV2ErrorMetadata","user","getUserAsync","catch","warn","chalk","yellow"],"mappings":"AAAA;;;;;;;;;;;IAasBA,oBAAoB,MAApBA,oBAAoB;IAiFpBC,mBAAmB,MAAnBA,mBAAmB;;;8DA9FtB,QAAQ;;;;;;;8DACT,OAAO;;;;;;qBAE6B,OAAO;sBACE,QAAQ;2DAClD,WAAW;qBACZ,iBAAiB;wBACR,oBAAoB;sBACvB,kBAAkB;8DACN,qBAAqB;wBAChC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGpC,eAAeD,oBAAoB,CAAC,EACzCE,YAAY,EAAG,KAAK,CAAA,EACpBC,GAAG,CAAA,EACH,GAAGC,OAAO,EAOX,GAAG,EAAE,EAAiB;IACrB,IAAIC,IAAG,IAAA,CAACC,YAAY,EAAE;QACpB,MAAM,IAAIC,OAAY,aAAA,CAAC,SAAS,EAAE,qCAAqC,CAAC,CAAC;IAC3E,CAAC;IACD,MAAMC,cAAc,GAAGJ,OAAO,CAACK,QAAQ,IAAIL,OAAO,CAACM,QAAQ,AAAC;IAC5D,MAAMC,GAAG,GAAGP,OAAO,CAACO,GAAG,AAAC;IAExB,IAAIT,YAAY,EAAE;QAChBU,IAAG,C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AC,YAAYC,OAAU,WAAA,IAAID,CAAC,CAACE,kBAAkB,KAAK,4BAA4B,EAAE;YACpF,MAAMC,IAAAA,IAAqC,sCAAA,EACzCpB,QAAQ,EACRC,QAAQ,EACRgB,CAAC,CAACI,sBAAsB,CACzB,CAAC;QACJ,OAAO;YACL,MAAMJ,CAAC,CAAC;QACV,CAAC;IACH,CAAC;AACH,CAAC;AAGM,eAAezB,mBAAmB,GAAmB;IAC1D,IAAI8B,IAAI,GAAG,MAAMC,IAAAA,KAAY,aAAA,GAAE,CAACC,KAAK,CAAC,IAAM,IAAI,CAAC,AAAC;IAElD,IAAI,CAACF,IAAI,EAAE;QACTnB,IAAG,CAACsB,IAAI,CAACC,MAAK,EAAA,QAAA,CAACC,MAAM,CAAC,4CAA4C,CAAC,CAAC,CAAC;QACrE,MAAMpC,oBAAoB,CAAC;YAAEE,YAAY,EAAE,IAAI;SAAE,CAAC,CAAC;QACnD6B,IAAI,GAAG,MAAMC,IAAAA,KAAY,aAAA,GAAE,CAAC;IAC9B,CAAC;IAEDR,IAAAA,OAAM,EAAA,QAAA,EAACO,IAAI,EAAE,0BAA0B,CAAC,CAAC;IACzC,OAAOA,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"sources":["../../../../src/api/user/actions.ts"],"sourcesContent":["import assert from 'assert';\nimport chalk from 'chalk';\n\nimport { retryUsernamePasswordAuthWithOTPAsync } from './otp';\nimport { Actor, getUserAsync, loginAsync, ssoLoginAsync } from './user';\nimport * as Log from '../../log';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\nimport promptAsync, { Question } from '../../utils/prompts';\nimport { ApiV2Error } from '../rest/client';\n\n/** Show login prompt while prompting for missing credentials. */\nexport async function showLoginPromptAsync({\n printNewLine = false,\n otp,\n ...options\n}: {\n printNewLine?: boolean;\n username?: string;\n password?: string;\n otp?: string;\n sso?: boolean | undefined;\n} = {}): Promise<void> {\n if (env.EXPO_OFFLINE) {\n throw new CommandError('OFFLINE', 'Cannot authenticate in offline-mode');\n }\n const hasCredentials = options.username && options.password;\n const sso = options.sso;\n\n if (printNewLine) {\n Log.log();\n }\n\n if (sso) {\n await ssoLoginAsync();\n return;\n }\n\n Log.log(\n hasCredentials\n ? `Logging in to EAS with email or username (exit and run 'npx expo login --help' for other login options)`\n : `Log in to EAS with email or username (exit and run 'npx expo login --help' for other login options)`\n );\n\n let username = options.username;\n let password = options.password;\n\n if (!hasCredentials) {\n const resolved = await promptAsync(\n [\n !options.username && {\n type: 'text',\n name: 'username',\n message: 'Email or username',\n },\n !options.password && {\n type: 'password',\n name: 'password',\n message: 'Password',\n },\n ].filter(Boolean) as Question<string>[],\n {\n nonInteractiveHelp: `Use the EXPO_TOKEN environment variable to authenticate in CI (${learnMore(\n 'https://docs.expo.dev/accounts/programmatic-access/'\n )})`,\n }\n );\n username ??= resolved.username;\n password ??= resolved.password;\n }\n // This is just for the types.\n assert(username && password);\n\n try {\n await loginAsync({\n username,\n password,\n otp,\n });\n } catch (e) {\n if (e instanceof ApiV2Error && e.expoApiV2ErrorCode === 'ONE_TIME_PASSWORD_REQUIRED') {\n await retryUsernamePasswordAuthWithOTPAsync(\n username,\n password,\n e.expoApiV2ErrorMetadata as any\n );\n } else {\n throw e;\n }\n }\n}\n\n/** Ensure the user is logged in, if not, prompt to login. */\nexport async function ensureLoggedInAsync(): Promise<Actor> {\n let user = await getUserAsync().catch(() => null);\n\n if (!user) {\n Log.warn(chalk.yellow`An Expo user account is required to proceed.`);\n await showLoginPromptAsync({ printNewLine: true });\n user = await getUserAsync();\n }\n\n assert(user, 'User should be logged in');\n return user;\n}\n"],"names":["showLoginPromptAsync","ensureLoggedInAsync","printNewLine","otp","options","env","EXPO_OFFLINE","CommandError","hasCredentials","username","password","sso","Log","log","ssoLoginAsync","resolved","promptAsync","type","name","message","filter","Boolean","nonInteractiveHelp","learnMore","assert","loginAsync","e","ApiV2Error","expoApiV2ErrorCode","retryUsernamePasswordAuthWithOT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AMpC,oBAAoB,CAAC;YAAEE,YAAY,EAAE,IAAI;SAAE,CAAC,CAAC;QACnD6B,IAAI,GAAG,MAAMC,IAAAA,KAAY,aAAA,GAAE,CAAC;IAC9B,CAAC;IAEDR,IAAAA,OAAM,EAAA,QAAA,EAACO,IAAI,EAAE,0BAA0B,CAAC,CAAC;IACzC,OAAOA,IAAI,CAAC;AACd,CAAC"}
@@ -104,7 +104,7 @@ async function getUserAsync() {
104
104
  if (!_env.env.EXPO_OFFLINE && !currentUser && hasCredentials) {
105
105
  var ref1;
106
106
  const user = await _userQuery.UserQuery.currentUserAsync();
107
- currentUser = user != null ? user : undefined;
107
+ currentUser = user ?? undefined;
108
108
  (ref1 = (0, _telemetry.getTelemetry)()) == null ? void 0 : ref1.identify(currentUser);
109
109
  }
110
110
  return currentUser;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/api/user/user.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport gql from 'graphql-tag';\n\nimport UserSettings from './UserSettings';\nimport { getSessionUsingBrowserAuthFlowAsync } from './expoSsoLauncher';\nimport { CurrentUserQuery } from '../../graphql/generated';\nimport * as Log from '../../log';\nimport { getDevelopmentCodeSigningDirectory } from '../../utils/codesigning';\nimport { env } from '../../utils/env';\nimport { getTelemetry } from '../../utils/telemetry';\nimport { getExpoWebsiteBaseUrl } from '../endpoint';\nimport { graphqlClient } from '../graphql/client';\nimport { UserQuery } from '../graphql/queries/UserQuery';\nimport { fetchAsync } from '../rest/client';\n\nexport type Actor = NonNullable<CurrentUserQuery['meActor']>;\n\nlet currentUser: Actor | undefined;\n\nexport const ANONYMOUS_USERNAME = 'anonymous';\n\n/**\n * Resolve the name of the actor, either normal user or robot user.\n * This should be used whenever the \"current user\" needs to be displayed.\n * The display name CANNOT be used as project owner.\n */\nexport function getActorDisplayName(user?: Actor): string {\n switch (user?.__typename) {\n case 'User':\n return user.username;\n case 'SSOUser':\n return user.username;\n case 'Robot':\n return user.firstName ? `${user.firstName} (robot)` : 'robot';\n default:\n return ANONYMOUS_USERNAME;\n }\n}\n\nexport async function getUserAsync(): Promise<Actor | undefined> {\n const hasCredentials = UserSettings.getAccessToken() || UserSettings.getSession()?.sessionSecret;\n if (!env.EXPO_OFFLINE && !currentUser && hasCredentials) {\n const user = await UserQuery.currentUserAsync();\n currentUser = user ?? undefined;\n getTelemetry()?.identify(currentUser);\n }\n return currentUser;\n}\n\nexport async function loginAsync(json: {\n username: string;\n password: string;\n otp?: string;\n}): Promise<void> {\n const res = await fetchAsync('auth/loginAsync', {\n method: 'POST',\n body: JSON.stringify(json),\n });\n const {\n data: { sessionSecret },\n } = await res.json();\n\n const userData = await fetchUserAsync({ sessionSecret });\n\n await UserSettings.setSessionAsync({\n sessionSecret,\n userId: userData.id,\n username: userData.username,\n currentConnection: 'Username-Password-Authentication',\n });\n}\n\nexport async function ssoLoginAsync(): Promise<void> {\n const sessionSecret = await getSessionUsingBrowserAuthFlowAsync({\n expoWebsiteUrl: getExpoWebsiteBaseUrl(),\n });\n const userData = await fetchUserAsync({ sessionSecret });\n\n await UserSettings.setSessionAsync({\n sessionSecret,\n userId: userData.id,\n username: userData.username,\n currentConnection: 'Browser-Flow-Authentication',\n });\n}\n\nexport async function logoutAsync(): Promise<void> {\n currentUser = undefined;\n await Promise.all([\n fs.rm(getDevelopmentCodeSigningDirectory(), { recursive: true, force: true }),\n UserSettings.setSessionAsync(undefined),\n ]);\n Log.log('Logged out');\n}\n\nasync function fetchUserAsync({\n sessionSecret,\n}: {\n sessionSecret: string;\n}): Promise<{ id: string; username: string }> {\n const result = await graphqlClient\n .query(\n gql`\n query UserQuery {\n meUserActor {\n id\n username\n }\n }\n `,\n {},\n {\n fetchOptions: {\n headers: {\n 'expo-session': sessionSecret,\n },\n },\n additionalTypenames: [] /* UserQuery has immutable fields */,\n }\n )\n .toPromise();\n const { data } = result;\n return {\n id: data.meUserActor.id,\n username: data.meUserActor.username,\n };\n}\n"],"names":["ANONYMOUS_USERNAME","getActorDisplayName","getUserAsync","loginAsync","ssoLoginAsync","logoutAsync","currentUser","user","__typename","username","firstName","UserSettings","hasCredentials","getAccessToken","getSession","sessionSecret","env","EXPO_OFFLINE","getTelemetry","UserQuery","currentUserAsync","undefined","identify","json","res","fetchAsync","method","body","JSON","stringify","data","userData","fetchUserAsync","setSessionAsync","userId","id","currentConnection","getSessionUsingBrowserAuthFlowAsync","expoWebsiteUrl","getExpoWebsiteBaseUrl","Promise","all","fs","rm","getDevelopmentCodeSigningDirectory","recursive","force","Log","log","result","graphqlClient","query","gql","fetchOptions","headers","additionalTypenames","toPromise","meUserActor"],"mappings":"AAAA;;;;;;;;;;;IAmBaA,kBAAkB,MAAlBA,kBAAkB;IAOfC,mBAAmB,MAAnBA,mBAAmB;IAabC,YAAY,MAAZA,YAAY;IAUZC,UAAU,MAAVA,UAAU;IAuBVC,aAAa,MAAbA,aAAa;IAcbC,WAAW,MAAXA,WAAW;;;yBAtFF,IAAI;;;;;;;8DACnB,aAAa;;;;;;mEAEJ,gBAAgB;iCACW,mBAAmB;2DAElD,WAAW;6BACmB,yBAAyB;qBACxD,iBAAiB;2BACR,uBAAuB;0BACd,aAAa;wBACrB,mBAAmB;2BACvB,8BAA8B;yBAC7B,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAI3C,IAAIC,WAAW,AAAmB,AAAC;AAE5B,MAAMN,kBAAkB,GAAG,WAAW,AAAC;AAOvC,SAASC,mBAAmB,CAACM,IAAY,EAAU;IACxD,OAAQA,IAAI,QAAY,GAAhBA,KAAAA,CAAgB,GAAhBA,IAAI,CAAEC,UAAU;QACtB,KAAK,MAAM;YACT,OAAOD,IAAI,CAACE,QAAQ,CAAC;QACvB,KAAK,SAAS;YACZ,OAAOF,IAAI,CAACE,QAAQ,CAAC;QACvB,KAAK,OAAO;YACV,OAAOF,IAAI,CAACG,SAAS,GAAG,CAAC,EAAEH,IAAI,CAACG,SAAS,CAAC,QAAQ,CAAC,GAAG,OA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f,MAAM,EAAE1B,IAAI,CAAA,EAAE,GAAGmB,MAAM,AAAC;IACxB,OAAO;QACLd,EAAE,EAAEL,IAAI,CAAC2B,WAAW,CAACtB,EAAE;QACvB1B,QAAQ,EAAEqB,IAAI,CAAC2B,WAAW,CAAChD,QAAQ;KACpC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../../src/api/user/user.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport gql from 'graphql-tag';\n\nimport UserSettings from './UserSettings';\nimport { getSessionUsingBrowserAuthFlowAsync } from './expoSsoLauncher';\nimport { CurrentUserQuery } from '../../graphql/generated';\nimport * as Log from '../../log';\nimport { getDevelopmentCodeSigningDirectory } from '../../utils/codesigning';\nimport { env } from '../../utils/env';\nimport { getTelemetry } from '../../utils/telemetry';\nimport { getExpoWebsiteBaseUrl } from '../endpoint';\nimport { graphqlClient } from '../graphql/client';\nimport { UserQuery } from '../graphql/queries/UserQuery';\nimport { fetchAsync } from '../rest/client';\n\nexport type Actor = NonNullable<CurrentUserQuery['meActor']>;\n\nlet currentUser: Actor | undefined;\n\nexport const ANONYMOUS_USERNAME = 'anonymous';\n\n/**\n * Resolve the name of the actor, either normal user or robot user.\n * This should be used whenever the \"current user\" needs to be displayed.\n * The display name CANNOT be used as project owner.\n */\nexport function getActorDisplayName(user?: Actor): string {\n switch (user?.__typename) {\n case 'User':\n return user.username;\n case 'SSOUser':\n return user.username;\n case 'Robot':\n return user.firstName ? `${user.firstName} (robot)` : 'robot';\n default:\n return ANONYMOUS_USERNAME;\n }\n}\n\nexport async function getUserAsync(): Promise<Actor | undefined> {\n const hasCredentials = UserSettings.getAccessToken() || UserSettings.getSession()?.sessionSecret;\n if (!env.EXPO_OFFLINE && !currentUser && hasCredentials) {\n const user = await UserQuery.currentUserAsync();\n currentUser = user ?? undefined;\n getTelemetry()?.identify(currentUser);\n }\n return currentUser;\n}\n\nexport async function loginAsync(json: {\n username: string;\n password: string;\n otp?: string;\n}): Promise<void> {\n const res = await fetchAsync('auth/loginAsync', {\n method: 'POST',\n body: JSON.stringify(json),\n });\n const {\n data: { sessionSecret },\n } = await res.json();\n\n const userData = await fetchUserAsync({ sessionSecret });\n\n await UserSettings.setSessionAsync({\n sessionSecret,\n userId: userData.id,\n username: userData.username,\n currentConnection: 'Username-Password-Authentication',\n });\n}\n\nexport async function ssoLoginAsync(): Promise<void> {\n const sessionSecret = await getSessionUsingBrowserAuthFlowAsync({\n expoWebsiteUrl: getExpoWebsiteBaseUrl(),\n });\n const userData = await fetchUserAsync({ sessionSecret });\n\n await UserSettings.setSessionAsync({\n sessionSecret,\n userId: userData.id,\n username: userData.username,\n currentConnection: 'Browser-Flow-Authentication',\n });\n}\n\nexport async function logoutAsync(): Promise<void> {\n currentUser = undefined;\n await Promise.all([\n fs.rm(getDevelopmentCodeSigningDirectory(), { recursive: true, force: true }),\n UserSettings.setSessionAsync(undefined),\n ]);\n Log.log('Logged out');\n}\n\nasync function fetchUserAsync({\n sessionSecret,\n}: {\n sessionSecret: string;\n}): Promise<{ id: string; username: string }> {\n const result = await graphqlClient\n .query(\n gql`\n query UserQuery {\n meUserActor {\n id\n username\n }\n }\n `,\n {},\n {\n fetchOptions: {\n headers: {\n 'expo-session': sessionSecret,\n },\n },\n additionalTypenames: [] /* UserQuery has immutable fields */,\n }\n )\n .toPromise();\n const { data } = result;\n return {\n id: data.meUserActor.id,\n username: data.meUserActor.username,\n };\n}\n"],"names":["ANONYMOUS_USERNAME","getActorDisplayName","getUserAsync","loginAsync","ssoLoginAsync","logoutAsync","currentUser","user","__typename","username","firstName","UserSettings","hasCredentials","getAccessToken","getSession","sessionSecret","env","EXPO_OFFLINE","getTelemetry","UserQuery","currentUserAsync","undefined","identify","json","res","fetchAsync","method","body","JSON","stringify","data","userData","fetchUserAsync","setSessionAsync","userId","id","currentConnection","getSessionUsingBrowserAuthFlowAsync","expoWebsiteUrl","getExpoWebsiteBaseUrl","Promise","all","fs","rm","getDevelopmentCodeSigningDirectory","recursive","force","Log","log","result","graphqlClient","query","gql","fetchOptions","headers","additionalTypenames","toPromise","meUserActor"],"mappings":"AAAA;;;;;;;;;;;IAmBaA,kBAAkB,MAAlBA,kBAAkB;IAOfC,mBAAmB,MAAnBA,mBAAmB;IAabC,YAAY,MAAZA,YAAY;IAUZC,UAAU,MAAVA,UAAU;IAuBVC,aAAa,MAAbA,aAAa;IAcbC,WAAW,MAAXA,WAAW;;;yBAtFF,IAAI;;;;;;;8DACnB,aAAa;;;;;;mEAEJ,gBAAgB;iCACW,mBAAmB;2DAElD,WAAW;6BACmB,yBAAyB;qBACxD,iBAAiB;2BACR,uBAAuB;0BACd,aAAa;wBACrB,mBAAmB;2BACvB,8BAA8B;yBAC7B,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAI3C,IAAIC,WAAW,AAAmB,AAAC;AAE5B,MAAMN,kBAAkB,GAAG,WAAW,AAAC;AAOvC,SAASC,mBAAmB,CAACM,IAAY,EAAU;IACxD,OAAQA,IAAI,QAAY,GAAhBA,KAAAA,CAAgB,GAAhBA,IAAI,CAAEC,UAAU;QACtB,KAAK,MAAM;YACT,OAAOD,IAAI,CAACE,QAAQ,CAAC;QACvB,KAAK,SAAS;YACZ,OAAOF,IAAI,CAACE,QAAQ,CAAC;QACvB,KAAK,OAAO;YACV,OAAOF,IAAI,CAACG,SAAS,GAAG,CAAC,EAAEH,IAAI,CAACG,SAAS,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;QAChE;YACE,OAAOV,kBAAkB,CAAC;KAC7B;AACH,CAAC;AAEM,eAAeE,YAAY,GAA+B;QACPS,GAAyB;IAAjF,MAAMC,cAAc,GAAGD,aAAY,QAAA,CAACE,cAAc,EAAE,IAAIF,CAAAA,CAAAA,GAAyB,GAAzBA,aAAY,QAAA,CAACG,UAAU,EAAE,SAAe,GAAxCH,KAAAA,CAAwC,GAAxCA,GAAyB,CAAEI,aAAa,CAAA,AAAC;IACjG,IAAI,CAACC,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J,aAAY,QAAA,CAACsB,eAAe,CAAC;QACjClB,aAAa;QACbmB,MAAM,EAAEH,QAAQ,CAACI,EAAE;QACnB1B,QAAQ,EAAEsB,QAAQ,CAACtB,QAAQ;QAC3B2B,iBAAiB,EAAE,6BAA6B;KACjD,CAAC,CAAC;AACL,CAAC;AAEM,eAAe/B,WAAW,GAAkB;IACjDC,WAAW,GAAGe,SAAS,CAAC;IACxB,MAAMmB,OAAO,CAACC,GAAG,CAAC;QAChBC,GAAE,EAAA,SAAA,CAACC,EAAE,CAACC,IAAAA,YAAkC,mCAAA,GAAE,EAAE;YAAEC,SAAS,EAAE,IAAI;YAAEC,KAAK,EAAE,IAAI;SAAE,CAAC;QAC7EnC,aAAY,QAAA,CAACsB,eAAe,CAACZ,SAAS,CAAC;KACxC,CAAC,CAAC;IACH0B,IAAG,CAACC,GAAG,CAAC,YAAY,CAAC,CAAC;AACxB,CAAC;AAED,eAAehB,cAAc,CAAC,EAC5BjB,aAAa,CAAA,EAGd,EAA6C;IAC5C,MAAMkC,MAAM,GAAG,MAAMC,OAAa,cAAA,CAC/BC,KAAK,CACJC,IAAAA,WAAG,EAAA,QAAA,CAAA,CAAC;;;;;;;MAOJ,CAAC,EACD,EAAE,EACF;QACEC,YAAY,EAAE;YACZC,OAAO,EAAE;gBACP,cAAc,EAAEvC,aAAa;aAC9B;SACF;QACDwC,mBAAmB,EAAE,EAAE;KACxB,CACF,CACAC,SAAS,EAAE,AAAC;IACf,MAAM,EAAE1B,IAAI,CAAA,EAAE,GAAGmB,MAAM,AAAC;IACxB,OAAO;QACLd,EAAE,EAAEL,IAAI,CAAC2B,WAAW,CAACtB,EAAE;QACvB1B,QAAQ,EAAEqB,IAAI,CAAC2B,WAAW,CAAChD,QAAQ;KACpC,CAAC;AACJ,CAAC"}
@@ -29,11 +29,10 @@ async function customizeAsync(files, options, extras) {
29
29
  const { exp } = (0, _config().getConfig)(projectRoot, {
30
30
  skipSDKVersionRequirement: true
31
31
  });
32
- var ref1;
33
32
  // Create the destination resolution props which are used in both
34
33
  // the query and select functions.
35
34
  const props = {
36
- webStaticPath: ((ref1 = (ref = exp.web) == null ? void 0 : ref.staticPath) != null ? ref1 : (0, _platformBundlers.getPlatformBundlers)(projectRoot, exp).web === "webpack") ? "web" : "public"
35
+ webStaticPath: ((ref = exp.web) == null ? void 0 : ref.staticPath) ?? (0, _platformBundlers.getPlatformBundlers)(projectRoot, exp).web === "webpack" ? "web" : "public"
37
36
  };
38
37
  // If the user provided files, we'll generate them without prompting.
39
38
  if (files.length) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/customize/customizeAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\n\nimport { queryAndGenerateAsync, selectAndGenerateAsync } from './generate';\nimport { Options } from './resolveOptions';\nimport { DestinationResolutionProps } from './templates';\nimport { getPlatformBundlers } from '../start/server/platformBundlers';\nimport { findUpProjectRootOrAssert } from '../utils/findUp';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\nexport async function customizeAsync(files: string[], options: Options, extras: any[]) {\n setNodeEnv('development');\n // Locate the project root based on the process current working directory.\n // This enables users to run `npx expo customize` from a subdirectory of the project.\n const projectRoot = findUpProjectRootOrAssert(process.cwd());\n\n require('@expo/env').load(projectRoot);\n\n // Get the static path (defaults to 'web/')\n // Doesn't matter if expo is installed or which mode is used.\n const { exp } = getConfig(projectRoot, {\n skipSDKVersionRequirement: true,\n });\n\n // Create the destination resolution props which are used in both\n // the query and select functions.\n const props: DestinationResolutionProps = {\n webStaticPath:\n exp.web?.staticPath ?? getPlatformBundlers(projectRoot, exp).web === 'webpack'\n ? 'web'\n : 'public',\n };\n\n // If the user provided files, we'll generate them without prompting.\n if (files.length) {\n return queryAndGenerateAsync(projectRoot, {\n files,\n props,\n extras,\n });\n }\n\n // Otherwise, we'll prompt the user to select which files to generate.\n await selectAndGenerateAsync(projectRoot, {\n props,\n extras,\n });\n}\n"],"names":["customizeAsync","files","options","extras","exp","setNodeEnv","projectRoot","findUpProjectRootOrAssert","process","cwd","require","load","getConfig","skipSDKVersionRequirement","props","webStaticPath","web","staticPath","getPlatformBundlers","length","queryAndGenerateAsync","selectAndGenerateAsync"],"mappings":"AAAA;;;;+BASsBA,gBAAc;;aAAdA,cAAc;;;yBATV,cAAc;;;;;;0BAEsB,YAAY;kCAGtC,kCAAkC;wBAC5B,iBAAiB;yBAChC,kBAAkB;AAEtC,eAAeA,cAAc,CAACC,KAAe,EAAEC,OAAgB,EAAEC,MAAa,EAAE;QAkBjFC,GAAO;IAjBXC,IAAAA,QAAU,WAAA,EAAC,aAAa,CAAC,CAAC;IAC1B,0EAA0E;IAC1E,qFAAqF;IACrF,MAAMC,WAAW,GAAGC,IAAAA,OAAyB,0BAAA,EAACC,OAAO,CAACC,GAAG,EAAE,CAAC,AAAC;IAE7DC,OAAO,CAAC,WAAW,CAAC,CAACC,IAAI,CAACL,WAAW,CAAC,CAAC;IAEvC,2CAA2C;IAC3C,6DAA6D;IAC7D,MAAM,EAAEF,GAAG,CAAA,EAAE,GAAGQ,IAAAA,OAAS,EAAA,UAAA,EAACN,WAAW,EAAE;QACrCO,yBAAyB,EAAE,IAAI;KAChC,CAAC,AAAC;QAMCT,IAAmB;IAJvB,iEAAiE;IACjE,kCAAkC;IAClC,MAAMU,KAAK,GAA+B;QACxCC,aAAa,EACXX,CAAAA,CAAAA,IAAmB,GAAnBA,CAAAA,GAAO,GAAPA,GAAG,CAACY,GAAG,SAAY,GAAnBZ,KAAAA,CAAmB,GAAnBA,GAAO,CAAEa,UAAU,YAAnBb,IAAmB,GAAIc,IAAAA,iBAAmB,oBAAA,EAACZ,WAAW,EAAEF,GAAG,CAAC,CAACY,GAAG,KAAK,SAAS,CAAA,GAC1E,KAAK,GACL,QAAQ;KACf,AAAC;IAEF,qEAAqE;IACrE,IAAIf,KAAK,CAACkB,MAAM,EAAE;QAChB,OAAOC,IAAAA,SAAqB,sBAAA,EAACd,WAAW,EAAE;YACxCL,KAAK;YACLa,KAAK;YACLX,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,sEAAsE;IACtE,MAAMkB,IAAAA,SAAsB,uBAAA,EAACf,WAAW,EAAE;QACxCQ,KAAK;QACLX,MAAM;KACP,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"sources":["../../../src/customize/customizeAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\n\nimport { queryAndGenerateAsync, selectAndGenerateAsync } from './generate';\nimport { Options } from './resolveOptions';\nimport { DestinationResolutionProps } from './templates';\nimport { getPlatformBundlers } from '../start/server/platformBundlers';\nimport { findUpProjectRootOrAssert } from '../utils/findUp';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\nexport async function customizeAsync(files: string[], options: Options, extras: any[]) {\n setNodeEnv('development');\n // Locate the project root based on the process current working directory.\n // This enables users to run `npx expo customize` from a subdirectory of the project.\n const projectRoot = findUpProjectRootOrAssert(process.cwd());\n\n require('@expo/env').load(projectRoot);\n\n // Get the static path (defaults to 'web/')\n // Doesn't matter if expo is installed or which mode is used.\n const { exp } = getConfig(projectRoot, {\n skipSDKVersionRequirement: true,\n });\n\n // Create the destination resolution props which are used in both\n // the query and select functions.\n const props: DestinationResolutionProps = {\n webStaticPath:\n exp.web?.staticPath ?? getPlatformBundlers(projectRoot, exp).web === 'webpack'\n ? 'web'\n : 'public',\n };\n\n // If the user provided files, we'll generate them without prompting.\n if (files.length) {\n return queryAndGenerateAsync(projectRoot, {\n files,\n props,\n extras,\n });\n }\n\n // Otherwise, we'll prompt the user to select which files to generate.\n await selectAndGenerateAsync(projectRoot, {\n props,\n extras,\n });\n}\n"],"names":["customizeAsync","files","options","extras","exp","setNodeEnv","projectRoot","findUpProjectRootOrAssert","process","cwd","require","load","getConfig","skipSDKVersionRequirement","props","webStaticPath","web","staticPath","getPlatformBundlers","length","queryAndGenerateAsync","selectAndGenerateAsync"],"mappings":"AAAA;;;;+BASsBA,gBAAc;;aAAdA,cAAc;;;yBATV,cAAc;;;;;;0BAEsB,YAAY;k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terop) {
40
- if (typeof WeakMap !== "function") return null;
41
- var cacheBabelInterop = new WeakMap();
42
- var cacheNodeInterop = new WeakMap();
43
- return (_getRequireWildcardCache = function(nodeInterop) {
44
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
45
- })(nodeInterop);
46
- }
47
- function _interopRequireWildcard(obj, nodeInterop) {
48
- if (!nodeInterop && obj && obj.__esModule) {
49
- return obj;
50
- }
51
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
52
- return {
53
- default: obj
54
- };
55
- }
56
- var cache = _getRequireWildcardCache(nodeInterop);
57
- if (cache && cache.has(obj)) {
58
- return cache.get(obj);
59
- }
60
- var newObj = {};
61
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
62
- for(var key in obj){
63
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
64
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
65
- if (desc && (desc.get || desc.set)) {
66
- Object.defineProperty(newObj, key, desc);
67
- } else {
68
- newObj[key] = obj[key];
69
- }
70
- }
71
- }
72
- newObj.default = obj;
73
- if (cache) {
74
- cache.set(obj, newObj);
75
- }
76
- return newObj;
77
- }
78
39
  async function queryAndGenerateAsync(projectRoot, { files , props , extras }) {
79
40
  const valid = files.filter((file)=>!!_templates.TEMPLATES.find((template)=>template.destination(props) === file));
80
41
  if (valid.length !== files.length) {
@@ -106,9 +67,10 @@ async function generateAsync(projectRoot, { answer , props , extras }) {
106
67
  // Copy files
107
68
  await Promise.all(answer.map(async (file)=>{
108
69
  const template = _templates.TEMPLATES[file];
109
- if (template.id === "tsconfig.json") {
110
- const { typescript } = await Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("./typescript.js")));
111
- return typescript(projectRoot);
70
+ if (template.configureAsync) {
71
+ if (await template.configureAsync(projectRoot)) {
72
+ return;
73
+ }
112
74
  }
113
75
  const projectFilePath = _path().default.resolve(projectRoot, template.destination(props));
114
76
  // copy the file from template
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/customize/generate.ts"],"sourcesContent":["import path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { DestinationResolutionProps, selectTemplatesAsync, TEMPLATES } from './templates';\nimport { installAsync } from '../install/installAsync';\nimport { Log } from '../log';\nimport { copyAsync } from '../utils/dir';\nimport { CommandError } from '../utils/errors';\n\nexport async function queryAndGenerateAsync(\n projectRoot: string,\n {\n files,\n props,\n extras,\n }: {\n files: string[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const valid = files.filter(\n (file) => !!TEMPLATES.find((template) => template.destination(props) === file)\n );\n\n if (valid.length !== files.length) {\n const diff = files.filter(\n (file) => !TEMPLATES.find((template) => template.destination(props) === file)\n );\n throw new CommandError(\n `Invalid files: ${diff.join(', ')}. Allowed: ${TEMPLATES.map((template) =>\n template.destination(props)\n ).join(', ')}`\n );\n }\n\n if (!valid.length) {\n return;\n }\n Log.log(`Generating: ${valid.join(', ')}`);\n return generateAsync(projectRoot, {\n answer: files.map((file) =>\n TEMPLATES.findIndex((template) => template.destination(props) === file)\n ),\n props,\n extras,\n });\n}\n\n/** Select templates to generate then generate and install. */\nexport async function selectAndGenerateAsync(\n projectRoot: string,\n {\n props,\n extras,\n }: {\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const answer = await selectTemplatesAsync(projectRoot, props);\n\n if (!answer?.length) {\n Log.exit('\\n\\u203A Exiting with no change...', 0);\n }\n\n await generateAsync(projectRoot, {\n answer,\n props,\n extras,\n });\n}\n\nasync function generateAsync(\n projectRoot: string,\n {\n answer,\n props,\n extras,\n }: {\n answer: number[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n // Copy files\n await Promise.all(\n answer.map(async (file) => {\n const template = TEMPLATES[file];\n\n if (template.id === 'tsconfig.json') {\n const { typescript } = await import('./typescript.js');\n return typescript(projectRoot);\n }\n\n const projectFilePath = path.resolve(projectRoot, template.destination(props));\n // copy the file from template\n return copyAsync(template.file(projectRoot), projectFilePath, {\n overwrite: true,\n recursive: true,\n });\n })\n );\n\n // Install dependencies\n const packages = answer\n .map((file) => TEMPLATES[file].dependencies)\n .flat()\n .filter((pkg) => !resolveFrom.silent(projectRoot, pkg));\n if (packages.length) {\n Log.debug('Installing ' + packages.join(', '));\n await installAsync(packages, {}, ['--dev', ...extras]);\n }\n}\n"],"names":["queryAndGenerateAsync","selectAndGenerateAsync","projectRoot","files","props","extras","valid","filter","file","TEMPLATES","find","template","destination","length","diff","CommandError","join","map","Log","log","generateAsync","answer","findIndex","selectTemplatesAsync","exit","Promise","all","id","typescript","projectFilePath","path","resolve","copyAsync","overwrite","recursive","packages","dependencies","flat","pkg","resolveFrom","silent","debug","installAsync"],"mappings":"AAAA;;;;;;;;;;;IASsBA,qBAAqB,MAArBA,qBAAqB;IA0CrBC,sBAAsB,MAAtBA,sBAAsB;;;8DAnD3B,MAAM;;;;;;;8DACC,cAAc;;;;;;2BAEsC,aAAa;8BAC5D,yBAAyB;qBAClC,QAAQ;qBACF,cAAc;wBACX,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvC,eAAeD,qBAAqB,CACzCE,WAAmB,EACnB,EACEC,KAAK,CAAA,EACLC,KAAK,CAAA,EACLC,MAAM,CAAA,EAMP,EACD;IACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CACxB,CAACC,IAAI,GAAK,CAAC,CAACC,UAAS,UAAA,CAACC,IAAI,CAAC,CAACC,QAAQ,GAAKA,QAAQ,CAACC,WAAW,CAACR,KAAK,CAAC,KAAKI,IAAI,CAAC,CAC/E,AAAC;IAEF,IAAIF,KAAK,CAACO,MAAM,KAAKV,KAAK,CAACU,MAAM,EAAE;QACjC,MAAMC,IAAI,GAAGX,KAAK,CAACI,MAAM,CACvB,CAACC,IAAI,GAAK,CAACC,UAA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AAC,aAAa,GAAGN,QAAQ,CAACnB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,MAAM0B,IAAAA,aAAY,aAAA,EAACP,QAAQ,EAAE,EAAE,EAAE;YAAC,OAAO;eAAK9B,MAAM;SAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
1
+ {"version":3,"sources":["../../../src/customize/generate.ts"],"sourcesContent":["import path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { DestinationResolutionProps, selectTemplatesAsync, TEMPLATES } from './templates';\nimport { installAsync } from '../install/installAsync';\nimport { Log } from '../log';\nimport { copyAsync } from '../utils/dir';\nimport { CommandError } from '../utils/errors';\n\nexport async function queryAndGenerateAsync(\n projectRoot: string,\n {\n files,\n props,\n extras,\n }: {\n files: string[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const valid = files.filter(\n (file) => !!TEMPLATES.find((template) => template.destination(props) === file)\n );\n\n if (valid.length !== files.length) {\n const diff = files.filter(\n (file) => !TEMPLATES.find((template) => template.destination(props) === file)\n );\n throw new CommandError(\n `Invalid files: ${diff.join(', ')}. Allowed: ${TEMPLATES.map((template) =>\n template.destination(props)\n ).join(', ')}`\n );\n }\n\n if (!valid.length) {\n return;\n }\n Log.log(`Generating: ${valid.join(', ')}`);\n return generateAsync(projectRoot, {\n answer: files.map((file) =>\n TEMPLATES.findIndex((template) => template.destination(props) === file)\n ),\n props,\n extras,\n });\n}\n\n/** Select templates to generate then generate and install. */\nexport async function selectAndGenerateAsync(\n projectRoot: string,\n {\n props,\n extras,\n }: {\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const answer = await selectTemplatesAsync(projectRoot, props);\n\n if (!answer?.length) {\n Log.exit('\\n\\u203A Exiting with no change...', 0);\n }\n\n await generateAsync(projectRoot, {\n answer,\n props,\n extras,\n });\n}\n\nasync function generateAsync(\n projectRoot: string,\n {\n answer,\n props,\n extras,\n }: {\n answer: number[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n // Copy files\n await Promise.all(\n answer.map(async (file) => {\n const template = TEMPLATES[file];\n\n if (template.configureAsync) {\n if (await template.configureAsync(projectRoot)) {\n return;\n }\n }\n\n const projectFilePath = path.resolve(projectRoot, template.destination(props));\n // copy the file from template\n return copyAsync(template.file(projectRoot), projectFilePath, {\n overwrite: true,\n recursive: true,\n });\n })\n );\n\n // Install dependencies\n const packages = answer\n .map((file) => TEMPLATES[file].dependencies)\n .flat()\n .filter((pkg) => !resolveFrom.silent(projectRoot, pkg));\n if (packages.length) {\n Log.debug('Installing ' + packages.join(', '));\n await installAsync(packages, {}, ['--dev', ...extras]);\n }\n}\n"],"names":["queryAndGenerateAsync","selectAndGenerateAsync","projectRoot","files","props","extras","valid","filter","file","TEMPLATES","find","template","destination","length","diff","CommandError","join","map","Log","log","generateAsync","answer","findIndex","selectTemplatesAsync","exit","Promise","all","configureAsync","projectFilePath","path","resolve","copyAsync","overwrite","recursive","packages","dependencies","flat","pkg","resolveFrom","silent","debug","installAsync"],"mappings":"AAAA;;;;;;;;;;;IASsBA,qBAAqB,MAArBA,qBAAqB;IA0CrBC,sBAAsB,MAAtBA,sBAAsB;;;8DAnD3B,MAAM;;;;;;;8DACC,cAAc;;;;;;2BAEsC,aAAa;8BAC5D,yBAAyB;qBAClC,QAAQ;qBACF,cAAc;wBACX,iBAAiB;;;;;;AAEvC,eAAeD,qBAAqB,CACzCE,WAAmB,EACnB,EACEC,KAAK,CAAA,EACLC,KAAK,CAAA,EACLC,MAAM,CAAA,EAMP,EACD;IACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CACxB,CAACC,IAAI,GAAK,CAAC,CAACC,UAAS,UAAA,CAACC,IAAI,CAAC,CAACC,QAAQ,GAAKA,QAAQ,CAACC,WAAW,CAACR,KAAK,CAAC,KAAKI,IAAI,CAAC,CAC/E,AAAC;IAEF,IAAIF,KAAK,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AAIH,QAAQ,CAACrB,MAAM,EAAE;QACnBK,IAAG,IAAA,CAACsB,KAAK,CAAC,aAAa,GAAGN,QAAQ,CAAClB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,MAAMyB,IAAAA,aAAY,aAAA,EAACP,QAAQ,EAAE,EAAE,EAAE;YAAC,OAAO;eAAK7B,MAAM;SAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
@@ -79,14 +79,6 @@ const TEMPLATES = [
79
79
  "babel-preset-expo",
80
80
  ]
81
81
  },
82
- {
83
- id: "webpack.config.js",
84
- file: (projectRoot)=>importFromExpoWebpackConfig(projectRoot, "template", "webpack.config.js"),
85
- destination: ()=>"webpack.config.js",
86
- dependencies: [
87
- "@expo/webpack-config"
88
- ]
89
- },
90
82
  {
91
83
  id: "metro.config.js",
92
84
  dependencies: [
@@ -96,11 +88,30 @@ const TEMPLATES = [
96
88
  file: (projectRoot)=>importFromVendor(projectRoot, "metro.config.js")
97
89
  },
98
90
  {
99
- id: "serve.json",
100
- file: (projectRoot)=>importFromExpoWebpackConfig(projectRoot, "web-default", "serve.json"),
101
- // web/serve.json
102
- destination: ({ webStaticPath })=>webStaticPath + "/serve.json",
103
- dependencies: []
91
+ // `tsconfig.json` is special-cased and doesn't follow the template.
92
+ id: "tsconfig.json",
93
+ dependencies: [],
94
+ destination: ()=>"tsconfig.json",
95
+ file: ()=>"",
96
+ configureAsync: async (projectRoot)=>{
97
+ const { typescript } = require("./typescript");
98
+ await typescript(projectRoot);
99
+ return true;
100
+ }
101
+ },
102
+ {
103
+ id: ".eslintrc.js",
104
+ dependencies: [],
105
+ destination: ()=>".eslintrc.js",
106
+ file: (projectRoot)=>importFromVendor(projectRoot, ".eslintrc.js"),
107
+ configureAsync: async (projectRoot)=>{
108
+ const { ESLintProjectPrerequisite } = require("../lint/ESlintPrerequisite");
109
+ const prerequisite = new ESLintProjectPrerequisite(projectRoot);
110
+ if (!await prerequisite.assertAsync()) {
111
+ await prerequisite.bootstrapAsync();
112
+ }
113
+ return false;
114
+ }
104
115
  },
105
116
  {
106
117
  id: "index.html",
@@ -110,11 +121,12 @@ const TEMPLATES = [
110
121
  dependencies: []
111
122
  },
112
123
  {
113
- // `tsconfig.json` is special cased and don't not follow the template
114
- id: "tsconfig.json",
115
- dependencies: [],
116
- destination: ()=>"tsconfig.json",
117
- file: ()=>""
124
+ id: "webpack.config.js",
125
+ file: (projectRoot)=>importFromExpoWebpackConfig(projectRoot, "template", "webpack.config.js"),
126
+ destination: ()=>"webpack.config.js",
127
+ dependencies: [
128
+ "@expo/webpack-config"
129
+ ]
118
130
  },
119
131
  ];
120
132
  /** Generate the prompt choices. */ function createChoices(projectRoot, props) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/customize/templates.ts"],"sourcesContent":["import chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport prompt, { ExpoChoice } from '../utils/prompts';\n\nconst debug = require('debug')('expo:customize:templates');\n\nexport type DestinationResolutionProps = {\n /** Web 'public' folder path (defaults to `/web`). This technically can be changed but shouldn't be. */\n webStaticPath: string;\n};\n\nfunction importFromExpoWebpackConfig(projectRoot: string, folder: string, moduleId: string) {\n try {\n const filePath = resolveFrom(projectRoot, `@expo/webpack-config/${folder}/${moduleId}`);\n debug(`Using @expo/webpack-config template for \"${moduleId}\": ${filePath}`);\n return filePath;\n } catch {\n debug(`@expo/webpack-config template for \"${moduleId}\" not found, falling back on @expo/cli`);\n }\n return importFromVendor(projectRoot, moduleId);\n}\n\nfunction importFromVendor(projectRoot: string, moduleId: string) {\n try {\n const filePath = resolveFrom(projectRoot, '@expo/cli/static/template/' + moduleId);\n debug(`Using @expo/cli template for \"${moduleId}\": ${filePath}`);\n return filePath;\n } catch {\n // For dev mode, testing and other cases where @expo/cli is not installed\n const filePath = require.resolve(`@expo/cli/static/template/${moduleId}`);\n debug(\n `Local @expo/cli template for \"${moduleId}\" not found, falling back on template relative to @expo/cli: ${filePath}`\n );\n\n return filePath;\n }\n}\n\nexport const TEMPLATES: {\n /** Unique ID for easily indexing. */\n id: string;\n /** Template file path to copy into the project. */\n file: (projectRoot: string) => string;\n /** Output location for the file in the user project. */\n destination: (props: DestinationResolutionProps) => string;\n /** List of dependencies to install in the project. These are used inside of the template file. */\n dependencies: string[];\n}[] = [\n {\n id: 'babel.config.js',\n file: (projectRoot) => importFromVendor(projectRoot, 'babel.config.js'),\n destination: () => 'babel.config.js',\n dependencies: [\n // Even though this is installed in `expo`, we should add it for now.\n 'babel-preset-expo',\n ],\n },\n {\n id: 'webpack.config.js',\n file: (projectRoot) =>\n importFromExpoWebpackConfig(projectRoot, 'template', 'webpack.config.js'),\n destination: () => 'webpack.config.js',\n dependencies: ['@expo/webpack-config'],\n },\n {\n id: 'metro.config.js',\n dependencies: ['@expo/metro-config'],\n destination: () => 'metro.config.js',\n file: (projectRoot) => importFromVendor(projectRoot, 'metro.config.js'),\n },\n {\n id: 'serve.json',\n file: (projectRoot) => importFromExpoWebpackConfig(projectRoot, 'web-default', 'serve.json'),\n // web/serve.json\n destination: ({ webStaticPath }) => webStaticPath + '/serve.json',\n dependencies: [],\n },\n {\n id: 'index.html',\n file: (projectRoot) => importFromExpoWebpackConfig(projectRoot, 'web-default', 'index.html'),\n // web/index.html\n destination: ({ webStaticPath }) => webStaticPath + '/index.html',\n dependencies: [],\n },\n {\n // `tsconfig.json` is special cased and don't not follow the template\n id: 'tsconfig.json',\n dependencies: [],\n destination: () => 'tsconfig.json',\n file: () => '',\n },\n];\n\n/** Generate the prompt choices. */\nfunction createChoices(\n projectRoot: string,\n props: DestinationResolutionProps\n): ExpoChoice<number>[] {\n return TEMPLATES.map((template, index) => {\n const destination = template.destination(props);\n const localProjectFile = path.resolve(projectRoot, destination);\n const exists = fs.existsSync(localProjectFile);\n\n return {\n title: destination,\n value: index,\n description: exists ? chalk.red('This will overwrite the existing file') : undefined,\n };\n });\n}\n\n/** Prompt to select templates to add. */\nexport async function selectTemplatesAsync(projectRoot: string, props: DestinationResolutionProps) {\n const options = createChoices(projectRoot, props);\n\n const { answer } = await prompt({\n type: 'multiselect',\n name: 'answer',\n message: 'Which files would you like to generate?',\n hint: '- Space to select. Return to submit',\n warn: 'File already exists.',\n limit: options.length,\n instructions: '',\n choices: options,\n });\n return answer;\n}\n"],"names":["TEMPLATES","selectTemplatesAsync","debug","require","importFromExpoWebpackConfig","projectRoot","folder","moduleId","filePath","resolveFrom","importFromVendor","resolve","id","file","destination","dependencies","webStaticPath","createChoices","props","map","template","index","localProjectFile","path","exists","fs","existsSync","title","value","description","chalk","red","undefined","options","answer","prompt","type","name","message","hint","warn","limit","length","instructions","choices"],"mappings":"AAAA;;;;;;;;;;;IAyCaA,SAAS,MAATA,SAAS;IA0EAC,oBAAoB,MAApBA,oBAAoB;;;8DAnHxB,OAAO;;;;;;;8DACV,IAAI;;;;;;;8DACF,MAAM;;;;;;;8DACC,cAAc;;;;;;8DAEH,kBAAkB;;;;;;AAErD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,0BAA0B,CAAC,AAAC;AAO3D,SAASC,2BAA2B,CAACC,WAAmB,EAAEC,MAAc,EAAEC,QAAgB,EAAE;IAC1F,IAAI;QACF,MAAMC,QAAQ,GAAGC,IAAAA,YAAW,EAAA,QAAA,EAACJ,WAAW,EAAE,CAAC,qBAAqB,EAAEC,MAAM,CAAC,CAAC,EAAEC,QAAQ,CAAC,CAAC,CAAC,AAAC;QACxFL,KAAK,CAAC,CAAC,yCAAyC,EAAEK,QAAQ,CAAC,GAAG,EAAEC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC5E,OAAOA,QAAQ,CAAC;IAClB,EAAE,OAAM;QACNN,KAAK,CAAC,CAAC,mCAAmC,EAAEK,QAAQ,CAAC,sCAAsC,CAAC,CAAC,CAAC;IAChG,CAAC;IACD,OAAOG,gBAAgB,CAACL,WAAW,EAAEE,QAAQ,CAAC,CAAC;AACjD,CAAC;AAED,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EAAEa,KAAiC,EAAE;IACjG,MAAMe,OAAO,GAAGhB,aAAa,CAACZ,WAAW,EAAEa,KAAK,CAAC,AAAC;IAElD,MAAM,EAAEgB,MAAM,CAAA,EAAE,GAAG,MAAMC,IAAAA,QAAM,QAAA,EAAC;QAC9BC,IAAI,EAAE,aAAa;QACnBC,IAAI,EAAE,QAAQ;QACdC,OAAO,EAAE,yCAAyC;QAClDC,IAAI,EAAE,qCAAqC;QAC3CC,IAAI,EAAE,sBAAsB;QAC5BC,KAAK,EAAER,OAAO,CAACS,MAAM;QACrBC,YAAY,EAAE,EAAE;QAChBC,OAAO,EAAEX,OAAO;KACjB,CAAC,AAAC;IACH,OAAOC,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"sources":["../../../src/customize/templates.ts"],"sourcesContent":["import chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport prompt, { ExpoChoice } from '../utils/prompts';\n\nconst debug = require('debug')('expo:customize:templates');\n\nexport type DestinationResolutionProps = {\n /** Web 'public' folder path (defaults to `/web`). This technically can be changed but shouldn't be. */\n webStaticPath: string;\n};\n\nfunction importFromExpoWebpackConfig(projectRoot: string, folder: string, moduleId: string) {\n try {\n const filePath = resolveFrom(projectRoot, `@expo/webpack-config/${folder}/${moduleId}`);\n debug(`Using @expo/webpack-config template for \"${moduleId}\": ${filePath}`);\n return filePath;\n } catch {\n debug(`@expo/webpack-config template for \"${moduleId}\" not found, falling back on @expo/cli`);\n }\n return importFromVendor(projectRoot, moduleId);\n}\n\nfunction importFromVendor(projectRoot: string, moduleId: string) {\n try {\n const filePath = resolveFrom(projectRoot, '@expo/cli/static/template/' + moduleId);\n debug(`Using @expo/cli template for \"${moduleId}\": ${filePath}`);\n return filePath;\n } catch {\n // For dev mode, testing and other cases where @expo/cli is not installed\n const filePath = require.resolve(`@expo/cli/static/template/${moduleId}`);\n debug(\n `Local @expo/cli template for \"${moduleId}\" not found, falling back on template relative to @expo/cli: ${filePath}`\n );\n\n return filePath;\n }\n}\n\nexport const TEMPLATES: {\n /** Unique ID for easily indexing. */\n id: string;\n /** Template file path to copy into the project. */\n file: (projectRoot: string) => string;\n /** Output location for the file in the user project. */\n destination: (props: DestinationResolutionProps) => string;\n /** List of dependencies to install in the project. These are used inside of the template file. */\n dependencies: string[];\n\n /** Custom step for configuring the file. Return true to exit early. */\n configureAsync?: (projectRoot: string) => Promise<boolean>;\n}[] = [\n {\n id: 'babel.config.js',\n file: (projectRoot) => importFromVendor(projectRoot, 'babel.config.js'),\n destination: () => 'babel.config.js',\n dependencies: [\n // Even though this is installed in `expo`, we should add it for now.\n 'babel-preset-expo',\n ],\n },\n {\n id: 'metro.config.js',\n dependencies: ['@expo/metro-config'],\n destination: () => 'metro.config.js',\n file: (projectRoot) => importFromVendor(projectRoot, 'metro.config.js'),\n },\n {\n // `tsconfig.json` is special-cased and doesn't follow the template.\n id: 'tsconfig.json',\n dependencies: [],\n destination: () => 'tsconfig.json',\n file: () => '',\n configureAsync: async (projectRoot) => {\n const { typescript } = require('./typescript') as typeof import('./typescript');\n await typescript(projectRoot);\n return true;\n },\n },\n {\n id: '.eslintrc.js',\n dependencies: [],\n destination: () => '.eslintrc.js',\n file: (projectRoot) => importFromVendor(projectRoot, '.eslintrc.js'),\n configureAsync: async (projectRoot) => {\n const { ESLintProjectPrerequisite } =\n require('../lint/ESlintPrerequisite') as typeof import('../lint/ESlintPrerequisite.js');\n const prerequisite = new ESLintProjectPrerequisite(projectRoot);\n if (!(await prerequisite.assertAsync())) {\n await prerequisite.bootstrapAsync();\n }\n return false;\n },\n },\n {\n id: 'index.html',\n file: (projectRoot) => importFromExpoWebpackConfig(projectRoot, 'web-default', 'index.html'),\n // web/index.html\n destination: ({ webStaticPath }) => webStaticPath + '/index.html',\n dependencies: [],\n },\n {\n id: 'webpack.config.js',\n file: (projectRoot) =>\n importFromExpoWebpackConfig(projectRoot, 'template', 'webpack.config.js'),\n destination: () => 'webpack.config.js',\n dependencies: ['@expo/webpack-config'],\n },\n];\n\n/** Generate the prompt choices. */\nfunction createChoices(\n projectRoot: string,\n props: DestinationResolutionProps\n): ExpoChoice<number>[] {\n return TEMPLATES.map((template, index) => {\n const destination = template.destination(props);\n const localProjectFile = path.resolve(projectRoot, destination);\n const exists = fs.existsSync(localProjectFile);\n\n return {\n title: destination,\n value: index,\n description: exists ? chalk.red('This will overwrite the existing file') : undefined,\n };\n });\n}\n\n/** Prompt to select templates to add. */\nexport async function selectTemplatesAsync(projectRoot: string, props: DestinationResolutionProps) {\n const options = createChoices(projectRoot, props);\n\n const { answer } = await prompt({\n type: 'multiselect',\n name: 'answer',\n message: 'Which files would you like to generate?',\n hint: '- Space to select. Return to submit',\n warn: 'File already exists.',\n limit: options.length,\n instructions: '',\n choices: options,\n });\n return answer;\n}\n"],"names":["TEMPLATES","selectTemplatesAsync","debug","require","importFromExpoWebpackConfig","projectRoot","folder","moduleId","filePath","resolveFrom","importFromVendor","resolve","id","file","destination","dependencies","configureAsync","typescript","ESLintProjectPrerequisite","prerequisite","assertAsync","bootstrapAsync","webStaticPath","createChoices","props","map","template","index","localProjectFile","path","exists","fs","existsSync","title","value","description","chalk","red","undefined","options","answer","prompt","type","name","message","hint","warn","limit","length","instructions","choices"],"mappings":"AAAA;;;;;;;;;;;IAyCaA,SAAS,MAATA,SAAS;IA0FAC,oBAAoB,MAApBA,oBAAoB;;;8DAnIxB,OAAO;;;;;;;8DACV,IAAI;;;;;;;8DACF,MAAM;;;;;;;8DACC,cAAc;;;;;;8DAEH,kBAAkB;;;;;;AAErD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,0BAA0B,CAAC,AAAC;AAO3D,SAASC,2BAA2B,CAACC,WAAmB,EAAEC,MAAc,EAAEC,QAAgB,EAAE;IAC1F,IAAI;QACF,MAAMC,QAAQ,GAAGC,IAAAA,YAAW,EAAA,QAAA,EAACJ,WAAW,EAAE,CAAC,qBAAqB,EAAEC,MAAM,CAAC,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;KACjB,CAAC,AAAC;IACH,OAAOC,MAAM,CAAC;AAChB,CAAC"}
@@ -139,7 +139,7 @@ async function exportEmbedAsync(projectRoot, options) {
139
139
  _bundle().default.save(bundle, options, _log.Log.log),
140
140
  // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native
141
141
  // platforms when doing production embeds (unlikely).
142
- options.assetsDest ? (0, _persistMetroAssets.persistMetroAssetsAsync)(assets, {
142
+ options.assetsDest ? (0, _persistMetroAssets.persistMetroAssetsAsync)(projectRoot, assets, {
143
143
  platform: options.platform,
144
144
  outputDirectory: options.assetsDest,
145
145
  iosAssetCatalogDirectory: options.assetCatalogDest
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getConfig } from '@expo/config';\nimport getMetroAssets from '@expo/metro-config/build/transform-worker/getAssets';\nimport assert from 'assert';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport Server from 'metro/src/Server';\nimport splitBundleOptions from 'metro/src/lib/splitBundleOptions';\nimport output from 'metro/src/shared/output/bundle';\nimport type { BundleOptions } from 'metro/src/shared/types';\nimport path from 'path';\n\nimport { Options } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { DevServerManager } from '../../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { assertMetroPrivateServer } from '../../start/server/metro/metroPrivateServer';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { removeAsync } from '../../utils/dir';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\nimport { BundleAssetWithFileHashes } from '../saveAssets';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (!bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//)) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(path.join(bundleParent, `*.app/${bundleName}`), {\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function exportEmbedBundleAndAssetsAsync(\n projectRoot: string,\n options: Options\n): Promise<{\n bundle: Awaited<ReturnType<Server['build']>>;\n assets: readonly BundleAssetWithFileHashes[];\n}> {\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: options.resetCache,\n maxWorkers: options.maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n try {\n const bundles = await devServer.legacySinglePageExportBundleAsync(\n {\n splitChunks: false,\n mainModuleName: options.entryFile,\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: !!sourceMapUrl,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n // source map inline\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n {\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n }\n );\n\n return {\n bundle: {\n code: bundles.artifacts.filter((a: any) => a.type === 'js')[0].source.toString(),\n // Can be optional when source maps aren't enabled.\n map: bundles.artifacts.filter((a: any) => a.type === 'map')[0]?.source.toString(),\n },\n assets: bundles.assets,\n };\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n } finally {\n devServerManager.stopAsync();\n }\n}\n\n// Exports for expo-updates\nexport async function createMetroServerAndBundleRequestAsync(\n projectRoot: string,\n options: Pick<\n Options,\n | 'maxWorkers'\n | 'config'\n | 'platform'\n | 'sourcemapOutput'\n | 'sourcemapUseAbsolutePath'\n | 'entryFile'\n | 'minify'\n | 'dev'\n | 'resetCache'\n | 'unstableTransformProfile'\n >\n): Promise<{ server: Server; bundleRequest: BundleOptions }> {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n // TODO: This is always enabled in the native script and there's no way to disable it.\n resetCache: options.resetCache,\n\n maxWorkers: options.maxWorkers,\n config: options.config,\n },\n {\n exp,\n isExporting: true,\n getMetroBundler() {\n return server.getBundler().getBundler();\n },\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const bundleRequest = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n splitChunks: false,\n mainModuleName: resolveRealEntryFilePath(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n isExporting: true,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n }),\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const server = new Server(config, {\n watch: false,\n });\n\n return { server, bundleRequest };\n}\n\nexport async function exportEmbedAssetsAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions({\n ...bundleRequest,\n bundleType: 'todo',\n });\n\n assertMetroPrivateServer(server);\n\n const dependencies = await server._bundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n const config = server._config;\n\n return getMetroAssets(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n // Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n // behavior.\n projectRoot: config.projectRoot, // this._getServerRootDir(),\n publicPath: config.transformer.publicPath,\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n\n/**\n * This is a workaround for Metro not resolving entry file paths to their real location.\n * When running exports through `eas build --local` on macOS, the `/var/folders` path is used instead of `/private/var/folders`.\n *\n * See: https://github.com/expo/expo/issues/28890\n */\nfunction resolveRealEntryFilePath(projectRoot: string, entryFile: string): string {\n if (projectRoot.startsWith('/private/var') && entryFile.startsWith('/var')) {\n return fs.realpathSync(entryFile);\n }\n\n return entryFile;\n}\n"],"names":["exportEmbedAsync","exportEmbedBundleAndAssetsAsync","createMetroServerAndBundleRequestAsync","exportEmbedAssetsAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","join","dot","projectRoot","options","setNodeEnv","dev","load","removeAsync","platform","previousPath","fs","existsSync","bundle","assets","mkdirSync","recursive","mode","Promise","all","output","save","Log","log","assetsDest","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","devServerManager","DevServerManager","startMetroAsync","minify","port","isExporting","location","resetDevServer","resetCache","maxWorkers","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","exp","getConfig","skipSDKVersionRequirement","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","bundles","legacySinglePageExportBundleAsync","splitChunks","mainModuleName","entryFile","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","unstable_transformProfile","unstableTransformProfile","code","artifacts","filter","a","type","source","toString","map","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","stopAsync","config","loadMetroConfigAsync","getMetroBundler","server","getBundler","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","getMetroDirectBundleOptionsForExpoConfig","resolveRealEntryFilePath","watch","onProgress","resolverOptions","transformOptions","splitBundleOptions","bundleType","assertMetroPrivateServer","dependencies","_bundler","getDependencies","shallow","lazy","_config","getMetroAssets","processModuleFilter","serializer","assetPlugins","transformer","publicPath","Error","startsWith","realpathSync"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IA4CsBA,gBAAgB,MAAhBA,gBAAgB;IAoChBC,+BAA+B,MAA/BA,+BAA+B;IA6E/BC,sCAAsC,MAAtCA,sCAAsC;IAqEtCC,sBAAsB,MAAtBA,sBAAsB;;;yBAlOlB,cAAc;;;;;;;8DACb,qDAAqD;;;;;;;8DAC7D,QAAQ;;;;;;;8DACZ,IAAI;;;;;;;yBACc,MAAM;;;;;;;8DACpB,kBAAkB;;;;;;;8DACN,kCAAkC;;;;;;;8DAC9C,gCAAgC;;;;;;;8DAElC,MAAM;;;;;;qCAGyC,uBAAuB;qBACnE,WAAW;kCACE,qCAAqC;uCAChC,gDAAgD;kCACjD,2CAA2C;oCACvC,6CAA6C;8BAC7B,4CAA4C;sBAC3E,kBAAkB;qBAChB,iBAAiB;yBAClB,qBAAqB;8BACV,iBAAiB;oCACf,uBAAuB;;;;;;AAG/D,M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"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getConfig } from '@expo/config';\nimport getMetroAssets from '@expo/metro-config/build/transform-worker/getAssets';\nimport assert from 'assert';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport Server from 'metro/src/Server';\nimport splitBundleOptions from 'metro/src/lib/splitBundleOptions';\nimport output from 'metro/src/shared/output/bundle';\nimport type { BundleOptions } from 'metro/src/shared/types';\nimport path from 'path';\n\nimport { Options } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { DevServerManager } from '../../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { assertMetroPrivateServer } from '../../start/server/metro/metroPrivateServer';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { removeAsync } from '../../utils/dir';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\nimport { BundleAssetWithFileHashes } from '../saveAssets';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (!bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//)) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(path.join(bundleParent, `*.app/${bundleName}`), {\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(projectRoot, assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function exportEmbedBundleAndAssetsAsync(\n projectRoot: string,\n options: Options\n): Promise<{\n bundle: Awaited<ReturnType<Server['build']>>;\n assets: readonly BundleAssetWithFileHashes[];\n}> {\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: options.resetCache,\n maxWorkers: options.maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n try {\n const bundles = await devServer.legacySinglePageExportBundleAsync(\n {\n splitChunks: false,\n mainModuleName: options.entryFile,\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: !!sourceMapUrl,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n // source map inline\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n {\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n }\n );\n\n return {\n bundle: {\n code: bundles.artifacts.filter((a: any) => a.type === 'js')[0].source.toString(),\n // Can be optional when source maps aren't enabled.\n map: bundles.artifacts.filter((a: any) => a.type === 'map')[0]?.source.toString(),\n },\n assets: bundles.assets,\n };\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n } finally {\n devServerManager.stopAsync();\n }\n}\n\n// Exports for expo-updates\nexport async function createMetroServerAndBundleRequestAsync(\n projectRoot: string,\n options: Pick<\n Options,\n | 'maxWorkers'\n | 'config'\n | 'platform'\n | 'sourcemapOutput'\n | 'sourcemapUseAbsolutePath'\n | 'entryFile'\n | 'minify'\n | 'dev'\n | 'resetCache'\n | 'unstableTransformProfile'\n >\n): Promise<{ server: Server; bundleRequest: BundleOptions }> {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n // TODO: This is always enabled in the native script and there's no way to disable it.\n resetCache: options.resetCache,\n\n maxWorkers: options.maxWorkers,\n config: options.config,\n },\n {\n exp,\n isExporting: true,\n getMetroBundler() {\n return server.getBundler().getBundler();\n },\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const bundleRequest = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n splitChunks: false,\n mainModuleName: resolveRealEntryFilePath(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n isExporting: true,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n }),\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const server = new Server(config, {\n watch: false,\n });\n\n return { server, bundleRequest };\n}\n\nexport async function exportEmbedAssetsAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions({\n ...bundleRequest,\n bundleType: 'todo',\n });\n\n assertMetroPrivateServer(server);\n\n const dependencies = await server._bundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n const config = server._config;\n\n return getMetroAssets(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n // Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n // behavior.\n projectRoot: config.projectRoot, // this._getServerRootDir(),\n publicPath: config.transformer.publicPath,\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n\n/**\n * This is a workaround for Metro not resolving entry file paths to their real location.\n * When running exports through `eas build --local` on macOS, the `/var/folders` path is used instead of `/private/var/folders`.\n *\n * See: https://github.com/expo/expo/issues/28890\n */\nfunction resolveRealEntryFilePath(projectRoot: string, entryFile: string): string {\n if (projectRoot.startsWith('/private/var') && entryFile.startsWith('/var')) {\n return fs.realpathSync(entryFile);\n }\n\n return entryFile;\n}\n"],"names":["exportEmbedAsync","exportEmbedBundleAndAssetsAsync","createMetroServerAndBundleRequestAsync","exportEmbedAssetsAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","join","dot","projectRoot","options","setNodeEnv","dev","load","removeAsync","platform","previousPath","fs","existsSync","bundle","assets","mkdirSync","recursive","mode","Promise","all","output","save","Log","log","assetsDest","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","devServerManager","DevServerManager","startMetroAsync","minify","port","isExporting","location","resetDevServer","resetCache","maxWorkers","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","exp","getConfig","skipSDKVersionRequirement","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","bundles","legacySinglePageExportBundleAsync","splitChunks","mainModuleName","entryFile","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","unstable_transformProfile","unstableTransformProfile","code","artifacts","filter","a","type","source","toString","map","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","stopAsync","config","loadMetroConfigAsync","getMetroBundler","server","getBundler","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","getMetroDirectBundleOptionsForExpoConfig","resolveRealEntryFilePath","watch","onProgress","resolverOptions","transformOptions","splitBundleOptions","bundleType","assertMetroPrivateServer","dependencies","_bundler","getDependencies","shallow","lazy","_config","getMetroAssets","processModuleFilter","serializer","assetPlugins","transformer","publicPath","Error","startsWith","realpathSync"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IA4CsBA,gBAAgB,MAAhBA,gBAAgB;IAoChBC,+BAA+B,MAA/BA,+BAA+B;IA6E/BC,sCAAsC,MAAtCA,sCAAsC;IAqEtCC,sBAAsB,MAAtBA,sBAAsB;;;yBAlOlB,cAAc;;;;;;;8DACb,qDAAqD;;;;;;;8DAC7D,QAAQ;;;;;;;8DACZ,IAAI;;;;;;;yBACc,MAAM;;;;;;;8DACpB,kBAAkB;;;;;;;8DACN,kCAAkC;;;;;;;8DAC9C,gCAAgC;;;;;;;8DAElC,MAAM;;;;;;qCAGyC,uBAAuB;qBACnE,WAAW;kCACE,qCAAqC;uCAChC,gDAAgD;kCACjD,2CAA2C;oCACvC,6CAA6C;8BAC7B,4CAA4C;sBAC3E,kBAAkB;qBAChB,iBAAiB;yBAClB,qBAAqB;8BACV,iBAAiB;oCACf,uBAAuB;;;;;;AAG/D,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,AAAC;AAEpD,SAASC,0BAA0B,CAACC,YAAoB,EAAE;IACxD,+CAA+C;IAC/C,IAAI,CAACA,YAAY,CAACC,KAAK,+CAA+C,EAAE;QACtEJ,KAAK,CAAC,oCAAoC,EAAEG,YAAY,CAAC,CAAC;QAC1D,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAME,UAAU,GAAGC,KAAI,EAAA,QAAA,CAACC,QAAQ,CAACJ,YAAY,CAAC,AAAC;IAC/C,MAAMK,YAAY,GAAGF,KAAI,EAAA,QAAA,CAACG,OAAO,CAACN,YAAY,CAAC,AAA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