@expo/cli 0.13.2 → 0.15.0

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 (203) hide show
  1. package/build/bin/cli +30 -27
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/api/getVersions.js.map +1 -1
  4. package/build/src/api/rest/cache/response.js.map +1 -1
  5. package/build/src/api/rest/client.js +2 -2
  6. package/build/src/api/rest/client.js.map +1 -1
  7. package/build/src/config/configAsync.js +1 -1
  8. package/build/src/config/configAsync.js.map +1 -1
  9. package/build/src/config/index.js +2 -2
  10. package/build/src/config/index.js.map +1 -1
  11. package/build/src/customize/generate.js +1 -1
  12. package/build/src/customize/generate.js.map +1 -1
  13. package/build/src/customize/typescript.js +6 -4
  14. package/build/src/customize/typescript.js.map +1 -1
  15. package/build/src/export/createMetadataJson.js +3 -2
  16. package/build/src/export/createMetadataJson.js.map +1 -1
  17. package/build/src/export/embed/exportEmbedAsync.js +44 -17
  18. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  19. package/build/src/export/embed/index.js +4 -4
  20. package/build/src/export/embed/index.js.map +1 -1
  21. package/build/src/export/embed/resolveOptions.js +3 -3
  22. package/build/src/export/embed/resolveOptions.js.map +1 -1
  23. package/build/src/export/exportApp.js +74 -83
  24. package/build/src/export/exportApp.js.map +1 -1
  25. package/build/src/export/exportAssets.js +81 -21
  26. package/build/src/export/exportAssets.js.map +1 -1
  27. package/build/src/export/exportHermes.js +24 -14
  28. package/build/src/export/exportHermes.js.map +1 -1
  29. package/build/src/export/exportStaticAsync.js +109 -58
  30. package/build/src/export/exportStaticAsync.js.map +1 -1
  31. package/build/src/export/favicon.js +2 -2
  32. package/build/src/export/favicon.js.map +1 -1
  33. package/build/src/export/fork-bundleAsync.js +56 -23
  34. package/build/src/export/fork-bundleAsync.js.map +1 -1
  35. package/build/src/export/index.js +11 -9
  36. package/build/src/export/index.js.map +1 -1
  37. package/build/src/export/metroAssetLocalPath.js +101 -0
  38. package/build/src/export/metroAssetLocalPath.js.map +1 -0
  39. package/build/src/export/persistMetroAssets.js +94 -21
  40. package/build/src/export/persistMetroAssets.js.map +1 -1
  41. package/build/src/export/resolveOptions.js +1 -1
  42. package/build/src/export/resolveOptions.js.map +1 -1
  43. package/build/src/export/saveAssets.js +9 -48
  44. package/build/src/export/saveAssets.js.map +1 -1
  45. package/build/src/export/web/exportWebAsync.js +1 -1
  46. package/build/src/export/web/exportWebAsync.js.map +1 -1
  47. package/build/src/export/web/index.js +2 -2
  48. package/build/src/export/web/index.js.map +1 -1
  49. package/build/src/export/writeContents.js +6 -3
  50. package/build/src/export/writeContents.js.map +1 -1
  51. package/build/src/install/applyPlugins.js +52 -0
  52. package/build/src/install/applyPlugins.js.map +1 -0
  53. package/build/src/install/checkPackages.js +2 -2
  54. package/build/src/install/checkPackages.js.map +1 -1
  55. package/build/src/install/fixPackages.js +84 -0
  56. package/build/src/install/fixPackages.js.map +1 -0
  57. package/build/src/install/installAsync.js +32 -61
  58. package/build/src/install/installAsync.js.map +1 -1
  59. package/build/src/install/installExpoPackage.js +79 -0
  60. package/build/src/install/installExpoPackage.js.map +1 -0
  61. package/build/src/login/index.js +1 -1
  62. package/build/src/login/index.js.map +1 -1
  63. package/build/src/logout/index.js +1 -1
  64. package/build/src/logout/index.js.map +1 -1
  65. package/build/src/prebuild/clearNativeFolder.js +1 -1
  66. package/build/src/prebuild/clearNativeFolder.js.map +1 -1
  67. package/build/src/prebuild/configureProjectAsync.js +3 -3
  68. package/build/src/prebuild/configureProjectAsync.js.map +1 -1
  69. package/build/src/prebuild/copyTemplateFiles.js +21 -30
  70. package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
  71. package/build/src/prebuild/index.js +3 -3
  72. package/build/src/prebuild/index.js.map +1 -1
  73. package/build/src/prebuild/prebuildAsync.js +39 -17
  74. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  75. package/build/src/prebuild/resolveOptions.js +2 -2
  76. package/build/src/prebuild/resolveOptions.js.map +1 -1
  77. package/build/src/prebuild/updateFromTemplate.js +6 -6
  78. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  79. package/build/src/prebuild/updatePackageJson.js +49 -36
  80. package/build/src/prebuild/updatePackageJson.js.map +1 -1
  81. package/build/src/prebuild/validateTemplatePlatforms.js +2 -2
  82. package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -1
  83. package/build/src/register/index.js +1 -1
  84. package/build/src/register/index.js.map +1 -1
  85. package/build/src/run/android/index.js +2 -2
  86. package/build/src/run/android/index.js.map +1 -1
  87. package/build/src/run/ios/appleDevice/AppleDevice.js +35 -2
  88. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
  89. package/build/src/run/ios/index.js +2 -2
  90. package/build/src/run/ios/index.js.map +1 -1
  91. package/build/src/start/doctor/dependencies/getVersionedPackages.js +12 -4
  92. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  93. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +20 -3
  94. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  95. package/build/src/start/index.js +3 -3
  96. package/build/src/start/index.js.map +1 -1
  97. package/build/src/start/interface/interactiveActions.js +30 -11
  98. package/build/src/start/interface/interactiveActions.js.map +1 -1
  99. package/build/src/start/server/BundlerDevServer.js +14 -10
  100. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  101. package/build/src/start/server/DevServerManager.js +6 -1
  102. package/build/src/start/server/DevServerManager.js.map +1 -1
  103. package/build/src/start/server/DevToolsPluginManager.js +63 -0
  104. package/build/src/start/server/DevToolsPluginManager.js.map +1 -0
  105. package/build/src/start/server/getStaticRenderFunctions.js +21 -20
  106. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  107. package/build/src/start/server/metro/MetroBundlerDevServer.js +67 -64
  108. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  109. package/build/src/start/server/metro/bundleApiRoutes.js +4 -19
  110. package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
  111. package/build/src/start/server/metro/createExpoMetroResolver.js +187 -0
  112. package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -0
  113. package/build/src/start/server/metro/createJResolver.js +149 -0
  114. package/build/src/start/server/metro/createJResolver.js.map +1 -0
  115. package/build/src/start/server/metro/createServerRouteMiddleware.js +13 -1
  116. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  117. package/build/src/start/server/metro/externals.js +25 -3
  118. package/build/src/start/server/metro/externals.js.map +1 -1
  119. package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
  120. package/build/src/start/server/metro/formatFileCandidates.js +72 -0
  121. package/build/src/start/server/metro/formatFileCandidates.js.map +1 -0
  122. package/build/src/start/server/metro/inspector-proxy/device.js +3 -1
  123. package/build/src/start/server/metro/inspector-proxy/device.js.map +1 -1
  124. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js +3 -4
  125. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -1
  126. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js +24 -0
  127. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js.map +1 -0
  128. package/build/src/start/server/metro/inspector-proxy/handlers/utils.js +11 -0
  129. package/build/src/start/server/metro/inspector-proxy/handlers/utils.js.map +1 -0
  130. package/build/src/start/server/metro/inspector-proxy/index.js +10 -7
  131. package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
  132. package/build/src/start/server/metro/instantiateMetro.js +37 -16
  133. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  134. package/build/src/start/server/metro/metroErrorInterface.js +3 -2
  135. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  136. package/build/src/start/server/metro/router.js +6 -3
  137. package/build/src/start/server/metro/router.js.map +1 -1
  138. package/build/src/start/server/metro/runServer-fork.js +19 -10
  139. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  140. package/build/src/start/server/metro/serializeHtml.js +43 -0
  141. package/build/src/start/server/metro/serializeHtml.js.map +1 -0
  142. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +1 -2
  143. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
  144. package/build/src/start/server/metro/withMetroMultiPlatform.js +268 -191
  145. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  146. package/build/src/start/server/metro/withMetroResolvers.js +114 -40
  147. package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
  148. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +61 -0
  149. package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -0
  150. package/build/src/start/server/middleware/ExpoMiddleware.js +2 -2
  151. package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
  152. package/build/src/start/server/middleware/ManifestMiddleware.js +45 -68
  153. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  154. package/build/src/start/server/middleware/inspector/JsInspector.js +1 -1
  155. package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
  156. package/build/src/start/server/middleware/inspector/LaunchBrowser.js +30 -26
  157. package/build/src/start/server/middleware/inspector/LaunchBrowser.js.map +1 -1
  158. package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js +7 -7
  159. package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js.map +1 -1
  160. package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js +5 -2
  161. package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js.map +1 -1
  162. package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js +3 -2
  163. package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js.map +1 -1
  164. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js +8 -7
  165. package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js.map +1 -1
  166. package/build/src/start/server/middleware/metroOptions.js +123 -0
  167. package/build/src/start/server/middleware/metroOptions.js.map +1 -0
  168. package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
  169. package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
  170. package/build/src/start/server/type-generation/expo-env.js +1 -1
  171. package/build/src/start/server/type-generation/expo-env.js.map +1 -1
  172. package/build/src/start/server/type-generation/routes.js +1 -0
  173. package/build/src/start/server/type-generation/routes.js.map +1 -1
  174. package/build/src/utils/analytics/getMetroDebugProperties.js +1 -2
  175. package/build/src/utils/analytics/getMetroDebugProperties.js.map +1 -1
  176. package/build/src/utils/analytics/getMetroProperties.js +1 -2
  177. package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
  178. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  179. package/build/src/utils/args.js +4 -2
  180. package/build/src/utils/args.js.map +1 -1
  181. package/build/src/utils/cocoapods.js +2 -1
  182. package/build/src/utils/cocoapods.js.map +1 -1
  183. package/build/src/utils/dir.js +18 -8
  184. package/build/src/utils/dir.js.map +1 -1
  185. package/build/src/utils/env.js +6 -0
  186. package/build/src/utils/env.js.map +1 -1
  187. package/build/src/utils/getOrPromptApplicationId.js +2 -4
  188. package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
  189. package/build/src/utils/prompts.js +1 -28
  190. package/build/src/utils/prompts.js.map +1 -1
  191. package/build/src/whoami/index.js +1 -1
  192. package/build/src/whoami/index.js.map +1 -1
  193. package/package.json +16 -16
  194. package/static/shims/react-native-web/dist/cjs/exports/AppRegistry/AppContainer.js +13 -0
  195. package/static/shims/react-native-web/dist/cjs/exports/BackHandler/index.js +10 -0
  196. package/static/shims/react-native-web/dist/exports/AppRegistry/AppContainer.js +12 -0
  197. package/static/shims/react-native-web/dist/exports/BackHandler/index.js +7 -0
  198. package/build/src/export/createBundles.js +0 -37
  199. package/build/src/export/createBundles.js.map +0 -1
  200. package/build/src/start/server/metro/resolveFromProject.js +0 -90
  201. package/build/src/start/server/metro/resolveFromProject.js.map +0 -1
  202. package/build/src/start/server/middleware/resolveEntryPoint.js +0 -42
  203. package/build/src/start/server/middleware/resolveEntryPoint.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/resolveOptions.ts"],"sourcesContent":["import { ModPlatform } from '@expo/config-plugins';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { CommandError } from '../utils/errors';\nimport { validateUrl } from '../utils/url';\n\nexport function resolvePackageManagerOptions(args: any) {\n const managers: Record<string, boolean> = {\n npm: args['--npm'],\n yarn: args['--yarn'],\n pnpm: args['--pnpm'],\n bun: args['--bun'],\n };\n\n if (\n [managers.npm, managers.pnpm, managers.yarn, managers.bun, !!args['--no-install']].filter(\n Boolean\n ).length > 1\n ) {\n throw new CommandError(\n 'BAD_ARGS',\n 'Specify at most one of: --no-install, --npm, --pnpm, --yarn, --bun'\n );\n }\n\n return managers;\n}\n\n/** Resolves a template option as a URL or file path pointing to a tar file. */\nexport function resolveTemplateOption(template: string) {\n if (validateUrl(template)) {\n return template;\n }\n const templatePath = path.resolve(template);\n assert(fs.existsSync(templatePath), 'template file does not exist: ' + templatePath);\n assert(\n fs.statSync(templatePath).isFile(),\n 'template must be a tar file created by running `npm pack` in a project: ' + templatePath\n );\n\n return templatePath;\n}\n\n/** Resolves dependencies to skip from a string joined by `,`. Example: `react-native,expo,lodash` */\nexport function resolveSkipDependencyUpdate(value: any) {\n if (!value || typeof value !== 'string') {\n return [];\n }\n return value.split(',');\n}\n\n/** Returns an array of platforms based on the input platform identifier and runtime constraints. */\nexport function resolvePlatformOption(\n platform: string = 'all',\n { loose }: { loose?: boolean } = {}\n): ModPlatform[] {\n switch (platform) {\n case 'ios':\n return ['ios'];\n case 'android':\n return ['android'];\n case 'all':\n return loose || process.platform !== 'win32' ? ['android', 'ios'] : ['android'];\n default:\n return [platform as ModPlatform];\n }\n}\n\n/** Warns and filters out unsupported platforms based on the runtime constraints. Essentially this means no iOS on Windows devices. */\nexport function ensureValidPlatforms(platforms: ModPlatform[]): ModPlatform[] {\n // Skip ejecting for iOS on Windows\n if (process.platform === 'win32' && platforms.includes('ios')) {\n Log.warn(\n chalk`⚠️ Skipping generating the iOS native project files. Run {bold expo eject} again from macOS or Linux to generate the iOS project.\\n`\n );\n return platforms.filter((platform) => platform !== 'ios');\n }\n return platforms;\n}\n\n/** Asserts platform length must be greater than zero. */\nexport function assertPlatforms(platforms: ModPlatform[]) {\n if (!platforms?.length) {\n throw new CommandError('At least one platform must be enabled when syncing');\n }\n}\n"],"names":["resolvePackageManagerOptions","resolveTemplateOption","resolveSkipDependencyUpdate","resolvePlatformOption","ensureValidPlatforms","assertPlatforms","Log","args","managers","npm","yarn","pnpm","bun","filter","Boolean","length","CommandError","template","validateUrl","templatePath","path","resolve","assert","fs","existsSync","statSync","isFile","value","split","platform","loose","process","platforms","includes","warn","chalk"],"mappings":"AAAA;;;;QAUgBA,4BAA4B,GAA5BA,4BAA4B;QAuB5BC,qBAAqB,GAArBA,qBAAqB;QAerBC,2BAA2B,GAA3BA,2BAA2B;QAQ3BC,qBAAqB,GAArBA,qBAAqB;QAiBrBC,oBAAoB,GAApBA,oBAAoB;QAYpBC,eAAe,GAAfA,eAAe;AApFZ,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACc,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAClB,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnC,SAASN,4BAA4B,CAACO,IAAS,EAAE;IACtD,MAAMC,QAAQ,GAA4B;QACxCC,GAAG,EAAEF,IAAI,CAAC,OAAO,CAAC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AAqB,CACnC0B,QAAgB,GAAG,KAAK,EACxB,EAAEC,KAAK,CAAA,EAAuB,GAAG,EAAE,EACpB;IACf,OAAQD,QAAQ;QACd,KAAK,KAAK;YACR,OAAO;gBAAC,KAAK;aAAC,CAAC;QACjB,KAAK,SAAS;YACZ,OAAO;gBAAC,SAAS;aAAC,CAAC;QACrB,KAAK,KAAK;YACR,OAAOC,KAAK,IAAIC,OAAO,CAACF,QAAQ,KAAK,OAAO,GAAG;gBAAC,SAAS;gBAAE,KAAK;aAAC,GAAG;gBAAC,SAAS;aAAC,CAAC;QAClF;YACE,OAAO;gBAACA,QAAQ;aAAgB,CAAC;KACpC;CACF;AAGM,SAASzB,oBAAoB,CAAC4B,SAAwB,EAAiB;IAC5E,mCAAmC;IACnC,IAAID,OAAO,CAACF,QAAQ,KAAK,OAAO,IAAIG,SAAS,CAACC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC7D3B,GAAG,CAAC4B,IAAI,CACNC,MAAK,QAAA,CAAC,wIAAoI,CAAC,CAC5I,CAAC;QACF,OAAOH,SAAS,CAACnB,MAAM,CAAC,CAACgB,QAAQ,GAAKA,QAAQ,KAAK,KAAK;QAAA,CAAC,CAAC;KAC3D;IACD,OAAOG,SAAS,CAAC;CAClB;AAGM,SAAS3B,eAAe,CAAC2B,SAAwB,EAAE;IACxD,IAAI,CAACA,CAAAA,SAAS,QAAQ,GAAjBA,KAAAA,CAAiB,GAAjBA,SAAS,CAAEjB,MAAM,CAAA,EAAE;QACtB,MAAM,IAAIC,OAAY,aAAA,CAAC,oDAAoD,CAAC,CAAC;KAC9E;CACF"}
1
+ {"version":3,"sources":["../../../src/prebuild/resolveOptions.ts"],"sourcesContent":["import { ModPlatform } from '@expo/config-plugins';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { CommandError } from '../utils/errors';\nimport { validateUrl } from '../utils/url';\n\nexport function resolvePackageManagerOptions(args: any) {\n const managers: Record<string, boolean> = {\n npm: args['--npm'],\n yarn: args['--yarn'],\n pnpm: args['--pnpm'],\n bun: args['--bun'],\n };\n\n if (\n [managers.npm, managers.pnpm, managers.yarn, managers.bun, !!args['--no-install']].filter(\n Boolean\n ).length > 1\n ) {\n throw new CommandError(\n 'BAD_ARGS',\n 'Specify at most one of: --no-install, --npm, --pnpm, --yarn, --bun'\n );\n }\n\n return managers;\n}\n\n/** Resolves a template option as a URL or file path pointing to a tar file. */\nexport function resolveTemplateOption(template: string) {\n if (validateUrl(template)) {\n return template;\n }\n const templatePath = path.resolve(template);\n assert(fs.existsSync(templatePath), 'template file does not exist: ' + templatePath);\n assert(\n fs.statSync(templatePath).isFile(),\n 'template must be a tar file created by running `npm pack` in a project: ' + templatePath\n );\n\n return templatePath;\n}\n\n/** Resolves dependencies to skip from a string joined by `,`. Example: `react-native,expo,lodash` */\nexport function resolveSkipDependencyUpdate(value: any) {\n if (!value || typeof value !== 'string') {\n return [];\n }\n return value.split(',');\n}\n\n/** Returns an array of platforms based on the input platform identifier and runtime constraints. */\nexport function resolvePlatformOption(\n platform: string = 'all',\n { loose }: { loose?: boolean } = {}\n): ModPlatform[] {\n switch (platform) {\n case 'ios':\n return ['ios'];\n case 'android':\n return ['android'];\n case 'all':\n return loose || process.platform !== 'win32' ? ['android', 'ios'] : ['android'];\n default:\n return [platform as ModPlatform];\n }\n}\n\n/** Warns and filters out unsupported platforms based on the runtime constraints. Essentially this means no iOS on Windows devices. */\nexport function ensureValidPlatforms(platforms: ModPlatform[]): ModPlatform[] {\n // Skip prebuild for iOS on Windows\n if (process.platform === 'win32' && platforms.includes('ios')) {\n Log.warn(\n chalk`⚠️ Skipping generating the iOS native project files. Run {bold npx expo prebuild} again from macOS or Linux to generate the iOS project.\\n`\n );\n return platforms.filter((platform) => platform !== 'ios');\n }\n return platforms;\n}\n\n/** Asserts platform length must be greater than zero. */\nexport function assertPlatforms(platforms: ModPlatform[]) {\n if (!platforms?.length) {\n throw new CommandError('At least one platform must be enabled when syncing');\n }\n}\n"],"names":["resolvePackageManagerOptions","resolveTemplateOption","resolveSkipDependencyUpdate","resolvePlatformOption","ensureValidPlatforms","assertPlatforms","Log","args","managers","npm","yarn","pnpm","bun","filter","Boolean","length","CommandError","template","validateUrl","templatePath","path","resolve","assert","fs","existsSync","statSync","isFile","value","split","platform","loose","process","platforms","includes","warn","chalk"],"mappings":"AAAA;;;;QAUgBA,4BAA4B,GAA5BA,4BAA4B;QAuB5BC,qBAAqB,GAArBA,qBAAqB;QAerBC,2BAA2B,GAA3BA,2BAA2B;QAQ3BC,qBAAqB,GAArBA,qBAAqB;QAiBrBC,oBAAoB,GAApBA,oBAAoB;QAYpBC,eAAe,GAAfA,eAAe;AApFZ,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACc,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAClB,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnC,SAASN,4BAA4B,CAACO,IAAS,EAAE;IACtD,MAAMC,QAAQ,GAA4B;QACxCC,GAAG,EAAEF,IAAI,CAAC,OAAO,CAAC;QAClBG,IAAI,EAAEH,IAAI,CAAC,QAAQ,CAAC;QACpBI,IAAI,EAAEJ,IAAI,CAAC,QAAQ,CAAC;QACpBK,GAAG,EAAEL,IAAI,CAAC,OAAO,CAAC;KACnB,AAAC;IAEF,IACE;QAACC,QAAQ,CAACC,GAAG;QAAED,QAAQ,CAACG,IAAI;QAAEH,QAAQ,CAACE,IAAI;QAAEF,QAAQ,CAACI,GAAG;QAAE,CAAC,CAACL,IAAI,CAAC,cAAc,CAAC;KAAC,CAACM,MAAM,CACvFC,OAAO,CACR,CAACC,MAAM,GAAG,CAAC,EACZ;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gBAACA,QAAQ;aAAgB,CAAC;KACpC;CACF;AAGM,SAASzB,oBAAoB,CAAC4B,SAAwB,EAAiB;IAC5E,mCAAmC;IACnC,IAAID,OAAO,CAACF,QAAQ,KAAK,OAAO,IAAIG,SAAS,CAACC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC7D3B,GAAG,CAAC4B,IAAI,CACNC,MAAK,QAAA,CAAC,+IAA2I,CAAC,CACnJ,CAAC;QACF,OAAOH,SAAS,CAACnB,MAAM,CAAC,CAACgB,QAAQ,GAAKA,QAAQ,KAAK,KAAK;QAAA,CAAC,CAAC;KAC3D;IACD,OAAOG,SAAS,CAAC;CAClB;AAGM,SAAS3B,eAAe,CAAC2B,SAAwB,EAAE;IACxD,IAAI,CAACA,CAAAA,SAAS,QAAQ,GAAjBA,KAAAA,CAAiB,GAAjBA,SAAS,CAAEjB,MAAM,CAAA,EAAE;QACtB,MAAM,IAAIC,OAAY,aAAA,CAAC,oDAAoD,CAAC,CAAC;KAC9E;CACF"}
@@ -60,7 +60,7 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
60
60
  return {
61
61
  hasNewProjectFiles: !!copiedPaths.length,
62
62
  // If the iOS folder changes or new packages are added, we should rerun pod install.
63
- needsPodInstall: copiedPaths.includes("ios") || depsResults.hasNewDependencies || depsResults.hasNewDevDependencies,
63
+ needsPodInstall: copiedPaths.includes("ios") || !!depsResults.changedDependencies.length,
64
64
  ...depsResults
65
65
  };
66
66
  }
@@ -72,7 +72,7 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
72
72
  const platformDirectories = unknownPlatforms.map((platform)=>`./${platform}`
73
73
  ).reverse().join(" and ");
74
74
  const pluralized = unknownPlatforms.length > 1 ? "directories" : "directory";
75
- const ora = (0, _ora).logNewSection(`Creating native project ${pluralized} (${platformDirectories}) and updating .gitignore`);
75
+ const ora = (0, _ora).logNewSection(`Creating native ${pluralized} (${platformDirectories})`);
76
76
  try {
77
77
  await (0, _resolveTemplate).cloneTemplateAsync({
78
78
  templateDirectory,
@@ -80,11 +80,11 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
80
80
  exp,
81
81
  ora
82
82
  });
83
- const platforms = await (0, _validateTemplatePlatforms).validateTemplatePlatforms({
83
+ const platforms = (0, _validateTemplatePlatforms).validateTemplatePlatforms({
84
84
  templateDirectory,
85
85
  platforms: unknownPlatforms
86
86
  });
87
- const results = await (0, _copyTemplateFiles).copyTemplateFilesAsync(projectRoot, {
87
+ const results = (0, _copyTemplateFiles).copyTemplateFiles(projectRoot, {
88
88
  templateDirectory,
89
89
  platforms
90
90
  });
@@ -94,8 +94,8 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
94
94
  if (!(e instanceof _errors.AbortCommandError)) {
95
95
  Log.error(e.message);
96
96
  }
97
- ora.fail("Failed to create the native project.");
98
- Log.log(_chalk.default.yellow("You may want to delete the `./ios` and/or `./android` directories before trying again."));
97
+ ora.fail(`Failed to create the native ${pluralized}`);
98
+ Log.log(_chalk.default.yellow(_chalk.default`You may want to delete the {bold ./ios} and/or {bold ./android} directories before trying again.`));
99
99
  throw new _errors.SilentError(e);
100
100
  }
101
101
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/updateFromTemplate.ts"],"sourcesContent":["import { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\n\nimport { copyTemplateFilesAsync, createCopyFilesSuccessMessage } from './copyTemplateFiles';\nimport { cloneTemplateAsync } from './resolveTemplate';\nimport { DependenciesModificationResults, updatePackageJSONAsync } from './updatePackageJson';\nimport { validateTemplatePlatforms } from './validateTemplatePlatforms';\nimport * as Log from '../log';\nimport { AbortCommandError, SilentError } from '../utils/errors';\nimport { logNewSection } from '../utils/ora';\nimport { profile } from '../utils/profile';\n\n/**\n * Creates local native files from an input template file path.\n *\n * @return `true` if the project is ejecting, and `false` if it's syncing.\n */\nexport async function updateFromTemplateAsync(\n projectRoot: string,\n {\n exp,\n pkg,\n template,\n templateDirectory,\n platforms,\n skipDependencyUpdate,\n }: {\n /** Expo Config */\n exp: ExpoConfig;\n /** package.json as JSON */\n pkg: PackageJSONConfig;\n /** Template reference ID. */\n template?: string;\n /** Directory to write the template to before copying into the project. */\n templateDirectory?: string;\n /** List of platforms to clone. */\n platforms: ModPlatform[];\n /** List of dependencies to skip updating. */\n skipDependencyUpdate?: string[];\n }\n): Promise<\n {\n /** Indicates if new files were created in the project. */\n hasNewProjectFiles: boolean;\n /** Indicates that the project needs to run `pod install` */\n needsPodInstall: boolean;\n } & DependenciesModificationResults\n> {\n if (!templateDirectory) {\n const temporary = await import('tempy');\n templateDirectory = temporary.directory();\n }\n\n const copiedPaths = await profile(cloneTemplateAndCopyToProjectAsync)({\n projectRoot,\n template,\n templateDirectory,\n exp,\n platforms,\n });\n\n const depsResults = await profile(updatePackageJSONAsync)(projectRoot, {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n });\n\n return {\n hasNewProjectFiles: !!copiedPaths.length,\n // If the iOS folder changes or new packages are added, we should rerun pod install.\n needsPodInstall:\n copiedPaths.includes('ios') ||\n depsResults.hasNewDependencies ||\n depsResults.hasNewDevDependencies,\n ...depsResults,\n };\n}\n\n/**\n * Extract the template and copy the ios and android directories over to the project directory.\n *\n * @return `true` if any project files were created.\n */\nasync function cloneTemplateAndCopyToProjectAsync({\n projectRoot,\n templateDirectory,\n template,\n exp,\n platforms: unknownPlatforms,\n}: {\n projectRoot: string;\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n platforms: ModPlatform[];\n}): Promise<string[]> {\n const platformDirectories = unknownPlatforms\n .map((platform) => `./${platform}`)\n .reverse()\n .join(' and ');\n\n const pluralized = unknownPlatforms.length > 1 ? 'directories' : 'directory';\n const ora = logNewSection(\n `Creating native project ${pluralized} (${platformDirectories}) and updating .gitignore`\n );\n\n try {\n await cloneTemplateAsync({ templateDirectory, template, exp, ora });\n\n const platforms = await validateTemplatePlatforms({\n templateDirectory,\n platforms: unknownPlatforms,\n });\n\n const results = await copyTemplateFilesAsync(projectRoot, {\n templateDirectory,\n platforms,\n });\n\n ora.succeed(createCopyFilesSuccessMessage(platforms, results));\n\n return results.copiedPaths;\n } catch (e: any) {\n if (!(e instanceof AbortCommandError)) {\n Log.error(e.message);\n }\n ora.fail('Failed to create the native project.');\n Log.log(\n chalk.yellow(\n 'You may want to delete the `./ios` and/or `./android` directories before trying again.'\n )\n );\n throw new SilentError(e);\n }\n}\n"],"names":["updateFromTemplateAsync","Log","projectRoot","exp","pkg","template","templateDirectory","platforms","skipDependencyUpdate","temporary","directory","copiedPaths","profile","cloneTemplateAndCopyToProjectAsync","depsResults","updatePackageJSONAsync","hasNewProjectFiles","length","needsPodInstall","includes","hasNewDependencies","hasNewDevDependencies","unknownPlatforms","platformDirectories","map","platform","reverse","join","pluralized","ora","logNewSection","cloneTemplateAsync","validateTemplatePlatforms","results","copyTemplateFilesAsync","succeed","createCopyFilesSuccessMessage","e","AbortCommandError","error","message","fail","log","chalk","yellow","SilentError"],"mappings":"AAAA;;;;QAkBsBA,uBAAuB,GAAvBA,uBAAuB;AAhB3B,IAAA,MAAO,kCAAP,OAAO,EAAA;AAE6C,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACxD,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AACkB,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACnD,IAAA,0BAA6B,WAA7B,6BAA6B,CAAA;AAC3DC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACgC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAClC,IAAA,IAAc,WAAd,cAAc,CAAA;AACpB,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOnC,eAAeD,uBAAuB,CAC3CE,WAAmB,EACnB,EACEC,GAAG,CAAA,EACHC,GAAG,CAAA,EACHC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{ ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\n\nimport { copyTemplateFiles, createCopyFilesSuccessMessage } from './copyTemplateFiles';\nimport { cloneTemplateAsync } from './resolveTemplate';\nimport { DependenciesModificationResults, updatePackageJSONAsync } from './updatePackageJson';\nimport { validateTemplatePlatforms } from './validateTemplatePlatforms';\nimport * as Log from '../log';\nimport { AbortCommandError, SilentError } from '../utils/errors';\nimport { logNewSection } from '../utils/ora';\nimport { profile } from '../utils/profile';\n\n/**\n * Creates local native files from an input template file path.\n *\n * @return `true` if the project is prebuilding, and `false` if it's syncing.\n */\nexport async function updateFromTemplateAsync(\n projectRoot: string,\n {\n exp,\n pkg,\n template,\n templateDirectory,\n platforms,\n skipDependencyUpdate,\n }: {\n /** Expo Config */\n exp: ExpoConfig;\n /** package.json as JSON */\n pkg: PackageJSONConfig;\n /** Template reference ID. */\n template?: string;\n /** Directory to write the template to before copying into the project. */\n templateDirectory?: string;\n /** List of platforms to clone. */\n platforms: ModPlatform[];\n /** List of dependencies to skip updating. */\n skipDependencyUpdate?: string[];\n }\n): Promise<\n {\n /** Indicates if new files were created in the project. */\n hasNewProjectFiles: boolean;\n /** Indicates that the project needs to run `pod install` */\n needsPodInstall: boolean;\n } & DependenciesModificationResults\n> {\n if (!templateDirectory) {\n const temporary = await import('tempy');\n templateDirectory = temporary.directory();\n }\n\n const copiedPaths = await profile(cloneTemplateAndCopyToProjectAsync)({\n projectRoot,\n template,\n templateDirectory,\n exp,\n platforms,\n });\n\n const depsResults = await profile(updatePackageJSONAsync)(projectRoot, {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n });\n\n return {\n hasNewProjectFiles: !!copiedPaths.length,\n // If the iOS folder changes or new packages are added, we should rerun pod install.\n needsPodInstall: copiedPaths.includes('ios') || !!depsResults.changedDependencies.length,\n ...depsResults,\n };\n}\n\n/**\n * Extract the template and copy the ios and android directories over to the project directory.\n *\n * @return `true` if any project files were created.\n */\nasync function cloneTemplateAndCopyToProjectAsync({\n projectRoot,\n templateDirectory,\n template,\n exp,\n platforms: unknownPlatforms,\n}: {\n projectRoot: string;\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n platforms: ModPlatform[];\n}): Promise<string[]> {\n const platformDirectories = unknownPlatforms\n .map((platform) => `./${platform}`)\n .reverse()\n .join(' and ');\n\n const pluralized = unknownPlatforms.length > 1 ? 'directories' : 'directory';\n const ora = logNewSection(`Creating native ${pluralized} (${platformDirectories})`);\n\n try {\n await cloneTemplateAsync({ templateDirectory, template, exp, ora });\n\n const platforms = validateTemplatePlatforms({\n templateDirectory,\n platforms: unknownPlatforms,\n });\n\n const results = copyTemplateFiles(projectRoot, {\n templateDirectory,\n platforms,\n });\n\n ora.succeed(createCopyFilesSuccessMessage(platforms, results));\n\n return results.copiedPaths;\n } catch (e: any) {\n if (!(e instanceof AbortCommandError)) {\n Log.error(e.message);\n }\n ora.fail(`Failed to create the native ${pluralized}`);\n Log.log(\n chalk.yellow(\n chalk`You may want to delete the {bold ./ios} and/or {bold ./android} directories before trying again.`\n )\n );\n throw new SilentError(e);\n }\n}\n"],"names":["updateFromTemplateAsync","Log","projectRoot","exp","pkg","template","templateDirectory","platforms","skipDependencyUpdate","temporary","directory","copiedPaths","profile","cloneTemplateAndCopyToProjectAsync","depsResults","updatePackageJSONAsync","hasNewProjectFiles","length","needsPodInstall","includes","changedDependencies","unknownPlatforms","platformDirectories","map","platform","reverse","join","pluralized","ora","logNewSection","cloneTemplateAsync","validateTemplatePlatforms","results","copyTemplateFiles","succeed","createCopyFilesSuccessMessage","e","AbortCommandError","error","message","fail","log","chalk","yellow","SilentError"],"mappings":"AAAA;;;;QAkBsBA,uBAAuB,GAAvBA,uBAAuB;AAhB3B,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEwC,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACnD,IAAA,gBAAmB,WAAnB,mBAAmB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BAAA,CAAC,EAAE;YACrCpC,GAAG,CAACqC,KAAK,CAACF,CAAC,CAACG,OAAO,CAAC,CAAC;SACtB;QACDX,GAAG,CAACY,IAAI,CAAC,CAAC,4BAA4B,EAAEb,UAAU,CAAC,CAAC,CAAC,CAAC;QACtD1B,GAAG,CAACwC,GAAG,CACLC,MAAK,QAAA,CAACC,MAAM,CACVD,MAAK,QAAA,CAAC,gGAAgG,CAAC,CACxG,CACF,CAAC;QACF,MAAM,IAAIE,OAAW,YAAA,CAACR,CAAC,CAAC,CAAC;KAC1B;CACF"}
@@ -42,25 +42,28 @@ function _interopRequireWildcard(obj) {
42
42
  return newObj;
43
43
  }
44
44
  }
45
- async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , skipDependencyUpdate }) {
46
- const updatingPackageJsonStep = (0, _ora).logNewSection("Updating your package.json scripts, dependencies, and main file");
47
- const templatePkg = (0, _config).getPackageJson(templateDirectory);
45
+ async function updatePackageJSONAsync(projectRoot, { templateDirectory , templatePkg =(0, _config).getPackageJson(templateDirectory) , pkg , skipDependencyUpdate }) {
46
+ const updatingPackageJsonStep = (0, _ora).logNewSection("Updating package.json");
48
47
  const results = modifyPackageJson(projectRoot, {
49
48
  templatePkg,
50
49
  pkg,
51
50
  skipDependencyUpdate
52
51
  });
53
- await _fs.default.promises.writeFile(_path.default.resolve(projectRoot, "package.json"), // Add new line to match the format of running yarn.
54
- // This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.
55
- JSON.stringify(pkg, null, 2) + "\n");
56
- updatingPackageJsonStep.succeed("Updated package.json and added index.js entry point for iOS and Android");
52
+ const hasChanges = results.changedDependencies.length || results.scriptsChanged;
53
+ // NOTE: This is effectively bundler caching and subject to breakage if the inputs don't match the mutations.
54
+ if (hasChanges) {
55
+ await _fs.default.promises.writeFile(_path.default.resolve(projectRoot, "package.json"), // Add new line to match the format of running yarn.
56
+ // This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.
57
+ JSON.stringify(pkg, null, 2) + "\n");
58
+ }
59
+ updatingPackageJsonStep.succeed("Updated package.json" + (hasChanges ? "" : _chalk.default.dim(` | no changes`)));
57
60
  return results;
58
61
  }
59
62
  /**
60
63
  * Make required modifications to the `package.json` file as a JSON object.
61
64
  *
62
65
  * 1. Update `package.json` `scripts`.
63
- * 2. Update `package.json` `dependencies` and `devDependencies`.
66
+ * 2. Update `package.json` `dependencies` (not `devDependencies`).
64
67
  * 3. Update `package.json` `main`.
65
68
  *
66
69
  * @param projectRoot The root directory of the project.
@@ -69,33 +72,43 @@ async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , s
69
72
  * @param props.skipDependencyUpdate Array of dependencies to skip updating.
70
73
  * @returns
71
74
  */ function modifyPackageJson(projectRoot, { templatePkg , pkg , skipDependencyUpdate }) {
72
- updatePkgScripts({
75
+ const scriptsChanged = updatePkgScripts({
73
76
  pkg
74
77
  });
75
78
  // TODO: Move to `npx expo-doctor`
76
- return updatePkgDependencies(projectRoot, {
77
- pkg,
78
- templatePkg,
79
- skipDependencyUpdate
80
- });
79
+ return {
80
+ scriptsChanged,
81
+ ...updatePkgDependencies(projectRoot, {
82
+ pkg,
83
+ templatePkg,
84
+ skipDependencyUpdate
85
+ })
86
+ };
81
87
  }
82
88
  function updatePkgDependencies(projectRoot, { pkg: pkg1 , templatePkg , skipDependencyUpdate =[] }) {
83
- if (!pkg1.devDependencies) {
84
- pkg1.devDependencies = {};
85
- }
86
- const { dependencies , devDependencies } = templatePkg;
89
+ const { dependencies } = templatePkg;
90
+ // The default values come from the bare-minimum template's package.json.
91
+ // Users can change this by using different templates with the `--template` flag.
92
+ // The main reason for allowing the changing of dependencies would be to include
93
+ // dependencies that are required for the native project to build. For example,
94
+ // it does not need to include dependencies that are used in the JS-code only.
87
95
  const defaultDependencies = createDependenciesMap(dependencies);
88
- const defaultDevDependencies = createDependenciesMap(devDependencies);
96
+ // NOTE: This is a hack to ensure this doesn't trigger an extraneous change in the `package.json`
97
+ // it isn't required for anything in the `ios` and `android` folders.
98
+ delete defaultDependencies["expo-status-bar"];
99
+ // NOTE: Expo splash screen is installed by default in the template but the config plugin also lives in prebuild-config
100
+ // so we can delete it to prevent an extraneous change in the `package.json`.
101
+ delete defaultDependencies["expo-splash-screen"];
89
102
  const combinedDependencies = createDependenciesMap({
90
103
  ...defaultDependencies,
91
104
  ...pkg1.dependencies
92
105
  });
93
106
  // These dependencies are only added, not overwritten from the project
94
107
  const requiredDependencies = [
108
+ // TODO: This is no longer required because it's this same package.
95
109
  "expo",
96
- "expo-splash-screen",
97
- "react",
98
- "react-native"
110
+ // TODO: Drop this somehow.
111
+ "react-native",
99
112
  ].filter((depKey)=>!!defaultDependencies[depKey]
100
113
  );
101
114
  const symlinkedPackages = [];
@@ -132,29 +145,25 @@ function updatePkgDependencies(projectRoot, { pkg: pkg1 , templatePkg , skipDepe
132
145
  Log.warn(`\u203A Using current versions instead of recommended ${nonRecommendedPackages.map((pkg)=>_chalk.default.bold(pkg)
133
146
  ).join(", ")}.`);
134
147
  }
135
- const combinedDevDependencies = createDependenciesMap({
136
- ...defaultDevDependencies,
137
- ...pkg1.devDependencies
138
- });
139
148
  // Only change the dependencies if the normalized hash changes, this helps to reduce meaningless changes.
140
149
  const hasNewDependencies = hashForDependencyMap(pkg1.dependencies) !== hashForDependencyMap(combinedDependencies);
141
- const hasNewDevDependencies = hashForDependencyMap(pkg1.devDependencies) !== hashForDependencyMap(combinedDevDependencies);
142
150
  // Save the dependencies
151
+ let changedDependencies = [];
143
152
  if (hasNewDependencies) {
144
153
  var _dependencies;
154
+ changedDependencies = diffKeys(combinedDependencies, (_dependencies = pkg1.dependencies) != null ? _dependencies : {}).sort();
155
+ var _dependencies1;
145
156
  // Use Object.assign to preserve the original order of dependencies, this makes it easier to see what changed in the git diff.
146
- pkg1.dependencies = Object.assign((_dependencies = pkg1.dependencies) != null ? _dependencies : {}, combinedDependencies);
147
- }
148
- if (hasNewDevDependencies) {
149
- var _devDependencies;
150
- // Same as with dependencies
151
- pkg1.devDependencies = Object.assign((_devDependencies = pkg1.devDependencies) != null ? _devDependencies : {}, combinedDevDependencies);
157
+ pkg1.dependencies = Object.assign((_dependencies1 = pkg1.dependencies) != null ? _dependencies1 : {}, combinedDependencies);
152
158
  }
153
159
  return {
154
- hasNewDependencies,
155
- hasNewDevDependencies
160
+ changedDependencies
156
161
  };
157
162
  }
163
+ function diffKeys(a, b) {
164
+ return Object.keys(a).filter((key)=>a[key] !== b[key]
165
+ );
166
+ }
158
167
  function createDependenciesMap(dependencies) {
159
168
  if (typeof dependencies !== "object") {
160
169
  throw new Error(`Dependency map is invalid, expected object but got ${typeof dependencies}`);
@@ -174,18 +183,22 @@ function createDependenciesMap(dependencies) {
174
183
  }
175
184
  /**
176
185
  * Update package.json scripts - `npm start` should default to `expo
177
- * start --dev-client` rather than `expo start` after ejecting, for example.
186
+ * start --dev-client` rather than `expo start` after prebuilding, for example.
178
187
  */ function updatePkgScripts({ pkg }) {
179
188
  var ref, ref1;
189
+ let hasChanged = false;
180
190
  if (!pkg.scripts) {
181
191
  pkg.scripts = {};
182
192
  }
183
193
  if (!((ref = pkg.scripts.android) == null ? void 0 : ref.includes("run"))) {
184
194
  pkg.scripts.android = "expo run:android";
195
+ hasChanged = true;
185
196
  }
186
197
  if (!((ref1 = pkg.scripts.ios) == null ? void 0 : ref1.includes("run"))) {
187
198
  pkg.scripts.ios = "expo run:ios";
199
+ hasChanged = true;
188
200
  }
201
+ return hasChanged;
189
202
  }
190
203
  function normalizeDependencyMap(deps) {
191
204
  return Object.keys(deps).map((dependency)=>`${dependency}@${deps[dependency]}`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/updatePackageJson.ts"],"sourcesContent":["import { getPackageJson, PackageJSONConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport crypto from 'crypto';\nimport fs from 'fs';\nimport path from 'path';\nimport { intersects as semverIntersects, Range as SemverRange } from 'semver';\n\nimport * as Log from '../log';\nimport { isModuleSymlinked } from '../utils/isModuleSymlinked';\nimport { logNewSection } from '../utils/ora';\n\nexport type DependenciesMap = { [key: string]: string | number };\n\nexport type DependenciesModificationResults = {\n /** Indicates that new values were added to the `dependencies` object in the `package.json`. */\n hasNewDependencies: boolean;\n /** Indicates that new values were added to the `devDependencies` object in the `package.json`. */\n hasNewDevDependencies: boolean;\n};\n\n/** Modifies the `package.json` with `modifyPackageJson` and format/displays the results. */\nexport async function updatePackageJSONAsync(\n projectRoot: string,\n {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n }: {\n templateDirectory: string;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): Promise<DependenciesModificationResults> {\n const updatingPackageJsonStep = logNewSection(\n 'Updating your package.json scripts, dependencies, and main file'\n );\n\n const templatePkg = getPackageJson(templateDirectory);\n\n const results = modifyPackageJson(projectRoot, {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n });\n\n await fs.promises.writeFile(\n path.resolve(projectRoot, 'package.json'),\n // Add new line to match the format of running yarn.\n // This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.\n JSON.stringify(pkg, null, 2) + '\\n'\n );\n\n updatingPackageJsonStep.succeed(\n 'Updated package.json and added index.js entry point for iOS and Android'\n );\n\n return results;\n}\n\n/**\n * Make required modifications to the `package.json` file as a JSON object.\n *\n * 1. Update `package.json` `scripts`.\n * 2. Update `package.json` `dependencies` and `devDependencies`.\n * 3. Update `package.json` `main`.\n *\n * @param projectRoot The root directory of the project.\n * @param props.templatePkg Template project package.json as JSON.\n * @param props.pkg Current package.json as JSON.\n * @param props.skipDependencyUpdate Array of dependencies to skip updating.\n * @returns\n */\nfunction modifyPackageJson(\n projectRoot: string,\n {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n }: {\n templatePkg: PackageJSONConfig;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n) {\n updatePkgScripts({ pkg });\n\n // TODO: Move to `npx expo-doctor`\n return updatePkgDependencies(projectRoot, {\n pkg,\n templatePkg,\n skipDependencyUpdate,\n });\n}\n\n/**\n * Update package.json dependencies by combining the dependencies in the project we are ejecting\n * with the dependencies in the template project. Does the same for devDependencies.\n *\n * - The template may have some dependencies beyond react/react-native/react-native-unimodules,\n * for example RNGH and Reanimated. We should prefer the version that is already being used\n * in the project for those, but swap the react/react-native/react-native-unimodules versions\n * with the ones in the template.\n * - The same applies to expo-updates -- since some native project configuration may depend on the\n * version, we should always use the version of expo-updates in the template.\n *\n * > Exposed for testing.\n */\nexport function updatePkgDependencies(\n projectRoot: string,\n {\n pkg,\n templatePkg,\n skipDependencyUpdate = [],\n }: {\n pkg: PackageJSONConfig;\n templatePkg: PackageJSONConfig;\n /** @deprecated Required packages are not overwritten, only added when missing */\n skipDependencyUpdate?: string[];\n }\n): DependenciesModificationResults {\n if (!pkg.devDependencies) {\n pkg.devDependencies = {};\n }\n const { dependencies, devDependencies } = templatePkg;\n const defaultDependencies = createDependenciesMap(dependencies);\n const defaultDevDependencies = createDependenciesMap(devDependencies);\n\n const combinedDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDependencies,\n ...pkg.dependencies,\n });\n\n // These dependencies are only added, not overwritten from the project\n const requiredDependencies = ['expo', 'expo-splash-screen', 'react', 'react-native'].filter(\n (depKey) => !!defaultDependencies[depKey]\n );\n\n const symlinkedPackages: string[] = [];\n const nonRecommendedPackages: string[] = [];\n\n for (const dependenciesKey of requiredDependencies) {\n // If the local package.json defined the dependency that we want to overwrite...\n if (pkg.dependencies?.[dependenciesKey]) {\n // Then ensure it isn't symlinked (i.e. the user has a custom version in their yarn workspace).\n if (isModuleSymlinked(projectRoot, { moduleId: dependenciesKey, isSilent: true })) {\n // If the package is in the project's package.json and it's symlinked, then skip overwriting it.\n symlinkedPackages.push(dependenciesKey);\n continue;\n }\n\n // Do not modify manually skipped dependencies\n if (skipDependencyUpdate.includes(dependenciesKey)) {\n continue;\n }\n\n // Warn users for outdated dependencies when prebuilding\n const hasRecommendedVersion = versionRangesIntersect(\n pkg.dependencies[dependenciesKey],\n String(defaultDependencies[dependenciesKey])\n );\n if (!hasRecommendedVersion) {\n nonRecommendedPackages.push(`${dependenciesKey}@${defaultDependencies[dependenciesKey]}`);\n }\n }\n }\n\n if (symlinkedPackages.length) {\n Log.log(\n `\\u203A Using symlinked ${symlinkedPackages\n .map((pkg) => chalk.bold(pkg))\n .join(', ')} instead of recommended version(s).`\n );\n }\n\n if (nonRecommendedPackages.length) {\n Log.warn(\n `\\u203A Using current versions instead of recommended ${nonRecommendedPackages\n .map((pkg) => chalk.bold(pkg))\n .join(', ')}.`\n );\n }\n\n const combinedDevDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDevDependencies,\n ...pkg.devDependencies,\n });\n\n // Only change the dependencies if the normalized hash changes, this helps to reduce meaningless changes.\n const hasNewDependencies =\n hashForDependencyMap(pkg.dependencies) !== hashForDependencyMap(combinedDependencies);\n const hasNewDevDependencies =\n hashForDependencyMap(pkg.devDependencies) !== hashForDependencyMap(combinedDevDependencies);\n // Save the dependencies\n if (hasNewDependencies) {\n // Use Object.assign to preserve the original order of dependencies, this makes it easier to see what changed in the git diff.\n pkg.dependencies = Object.assign(pkg.dependencies ?? {}, combinedDependencies);\n }\n if (hasNewDevDependencies) {\n // Same as with dependencies\n pkg.devDependencies = Object.assign(pkg.devDependencies ?? {}, combinedDevDependencies);\n }\n\n return {\n hasNewDependencies,\n hasNewDevDependencies,\n };\n}\n\n/**\n * Create an object of type DependenciesMap a dependencies object or throw if not valid.\n *\n * @param dependencies - ideally an object of type {[key]: string} - if not then this will error.\n */\nexport function createDependenciesMap(dependencies: any): DependenciesMap {\n if (typeof dependencies !== 'object') {\n throw new Error(`Dependency map is invalid, expected object but got ${typeof dependencies}`);\n } else if (!dependencies) {\n return {};\n }\n\n const outputMap: DependenciesMap = {};\n\n for (const key of Object.keys(dependencies)) {\n const value = dependencies[key];\n if (typeof value === 'string') {\n outputMap[key] = value;\n } else {\n throw new Error(\n `Dependency for key \\`${key}\\` should be a \\`string\\`, instead got: \\`{ ${key}: ${JSON.stringify(\n value\n )} }\\``\n );\n }\n }\n return outputMap;\n}\n\n/**\n * Update package.json scripts - `npm start` should default to `expo\n * start --dev-client` rather than `expo start` after ejecting, for example.\n */\nfunction updatePkgScripts({ pkg }: { pkg: PackageJSONConfig }) {\n if (!pkg.scripts) {\n pkg.scripts = {};\n }\n if (!pkg.scripts.android?.includes('run')) {\n pkg.scripts.android = 'expo run:android';\n }\n if (!pkg.scripts.ios?.includes('run')) {\n pkg.scripts.ios = 'expo run:ios';\n }\n}\n\nfunction normalizeDependencyMap(deps: DependenciesMap): string[] {\n return Object.keys(deps)\n .map((dependency) => `${dependency}@${deps[dependency]}`)\n .sort();\n}\n\nexport function hashForDependencyMap(deps: DependenciesMap = {}): string {\n const depsList = normalizeDependencyMap(deps);\n const depsString = depsList.join('\\n');\n return createFileHash(depsString);\n}\n\nexport function createFileHash(contents: string): string {\n // this doesn't need to be secure, the shorter the better.\n return crypto.createHash('sha1').update(contents).digest('hex');\n}\n\n/**\n * Determine if two semver ranges are overlapping or intersecting.\n * This is a safe version of `semver.intersects` that does not throw.\n */\nfunction versionRangesIntersect(rangeA: string | SemverRange, rangeB: string | SemverRange) {\n try {\n return semverIntersects(rangeA, rangeB);\n } catch {\n return false;\n }\n}\n"],"names":["updatePackageJSONAsync","updatePkgDependencies","createDependenciesMap","hashForDependencyMap","createFileHash","Log","projectRoot","templateDirectory","pkg","skipDependencyUpdate","updatingPackageJsonStep","logNewSection","templatePkg","getPackageJson","results","modifyPackageJson","fs","promises","writeFile","path","resolve","JSON","stringify","succeed","updatePkgScripts","devDependencies","dependencies","defaultDependencies","defaultDevDependencies","combinedDependencies","requiredDependencies","filter","depKey","symlinkedPackages","nonRecommendedPackages","dependenciesKey","isModuleSymlinked","moduleId","isSilent","push","includes","hasRecommendedVersion","versionRangesIntersect","String","length","log","map","chalk","bold","join","warn","combinedDevDependencies","hasNewDependencies","hasNewDevDependencies","Object","assign","Error","outputMap","key","keys","value","scripts","android","ios","normalizeDependencyMap","deps","dependency","sort","depsList","depsString","contents","crypto","createHash","update","digest","rangeA","rangeB","semverIntersects"],"mappings":"AAAA;;;;QAqBsBA,sBAAsB,GAAtBA,sBAAsB;QAsF5BC,qBAAqB,GAArBA,qBAAqB;QA0GrBC,qBAAqB,GAArBA,qBAAqB;QA8CrBC,oBAAoB,GAApBA,oBAAoB;QAMpBC,cAAc,GAAdA,cAAc;AAzQoB,IAAA,OAAc,WAAd,cAAc,CAAA;AAC9C,IAAA,MAAO,kCAAP,OAAO,EAAA;AACN,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACZ,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAC8C,IAAA,OAAQ,WAAR,QAAQ,CAAA;AAEjEC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACmB,IAAA,kBAA4B,WAA5B,4BAA4B,CAAA;AAChC,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYrC,eAAeL,sBAAsB,CAC1CM,WAAmB,EACnB,EACEC,iBAAiB,CAAA,EACjBC,GAAG,CAAA,EACHC,oBAAoB,CAAA,EAKrB,EACyC;IAC1C,MAAMC,uBAAuB,GAAGC,CAAAA,GAAAA,IAAa,AAE5C,CAAA,cAF4C,CAC3C,iEAAiE,CAClE,AAAC;IAEF,MAAMC,WAAW,GAAGC,CAAAA,GAAAA,OAAc,AAAmB,CAAA,eAAnB,CAACN,iBAAiB,CAAC,AAAC;IAEtD,MAAMO,OAAO,GAAGC,iBAAiB,CAACT,WAAW,EAAE;QAC7CM,WAAW;QACXJ,GAAG;QACHC,oBAAoB;KACrB,CAAC,AAAC;IAEH,MAAMO,GAAE,QAAA,CAACC,QAAQ,CAACC,SAAS,CACzBC,KAAI,QAAA,CAACC,OAAO,CAACd,WAAW,EAAE,cAAc,CAAC,EACzC,oDAAoD;IACpD,sGAAsG;IACtGe,IAAI,CAACC,SAAS,C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C,KAAK,CAAC,CAAA,EAAE;QACrChC,GAAG,CAACqD,OAAO,CAACE,GAAG,GAAG,cAAc,CAAC;KAClC;CACF;AAED,SAASC,sBAAsB,CAACC,IAAqB,EAAY;IAC/D,OAAOX,MAAM,CAACK,IAAI,CAACM,IAAI,CAAC,CACrBnB,GAAG,CAAC,CAACoB,UAAU,GAAK,CAAC,EAAEA,UAAU,CAAC,CAAC,EAAED,IAAI,CAACC,UAAU,CAAC,CAAC,CAAC;IAAA,CAAC,CACxDC,IAAI,EAAE,CAAC;CACX;AAEM,SAAShE,oBAAoB,CAAC8D,IAAqB,GAAG,EAAE,EAAU;IACvE,MAAMG,QAAQ,GAAGJ,sBAAsB,CAACC,IAAI,CAAC,AAAC;IAC9C,MAAMI,UAAU,GAAGD,QAAQ,CAACnB,IAAI,CAAC,IAAI,CAAC,AAAC;IACvC,OAAO7C,cAAc,CAACiE,UAAU,CAAC,CAAC;CACnC;AAEM,SAASjE,cAAc,CAACkE,QAAgB,EAAU;IACvD,0DAA0D;IAC1D,OAAOC,OAAM,QAAA,CAACC,UAAU,CAAC,MAAM,CAAC,CAACC,MAAM,CAACH,QAAQ,CAAC,CAACI,MAAM,CAAC,KAAK,CAAC,CAAC;CACjE;AAED;;;GAGG,CACH,SAAShC,sBAAsB,CAACiC,MAA4B,EAAEC,MAA4B,EAAE;IAC1F,IAAI;QACF,OAAOC,CAAAA,GAAAA,OAAgB,AAAgB,CAAA,WAAhB,CAACF,MAAM,EAAEC,MAAM,CAAC,CAAC;KACzC,CAAC,OAAM;QACN,OAAO,KAAK,CAAC;KACd;CACF"}
1
+ {"version":3,"sources":["../../../src/prebuild/updatePackageJson.ts"],"sourcesContent":["import { getPackageJson, PackageJSONConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport crypto from 'crypto';\nimport fs from 'fs';\nimport path from 'path';\nimport { intersects as semverIntersects, Range as SemverRange } from 'semver';\n\nimport * as Log from '../log';\nimport { isModuleSymlinked } from '../utils/isModuleSymlinked';\nimport { logNewSection } from '../utils/ora';\n\nexport type DependenciesMap = { [key: string]: string | number };\n\nexport type DependenciesModificationResults = {\n /** A list of new values were added to the `dependencies` object in the `package.json`. */\n changedDependencies: string[];\n};\n\n/** Modifies the `package.json` with `modifyPackageJson` and format/displays the results. */\nexport async function updatePackageJSONAsync(\n projectRoot: string,\n {\n templateDirectory,\n templatePkg = getPackageJson(templateDirectory),\n pkg,\n skipDependencyUpdate,\n }: {\n templateDirectory: string;\n templatePkg?: PackageJSONConfig;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): Promise<DependenciesModificationResults> {\n const updatingPackageJsonStep = logNewSection('Updating package.json');\n\n const results = modifyPackageJson(projectRoot, {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n });\n\n const hasChanges = results.changedDependencies.length || results.scriptsChanged;\n\n // NOTE: This is effectively bundler caching and subject to breakage if the inputs don't match the mutations.\n if (hasChanges) {\n await fs.promises.writeFile(\n path.resolve(projectRoot, 'package.json'),\n // Add new line to match the format of running yarn.\n // This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.\n JSON.stringify(pkg, null, 2) + '\\n'\n );\n }\n\n updatingPackageJsonStep.succeed(\n 'Updated package.json' + (hasChanges ? '' : chalk.dim(` | no changes`))\n );\n\n return results;\n}\n\n/**\n * Make required modifications to the `package.json` file as a JSON object.\n *\n * 1. Update `package.json` `scripts`.\n * 2. Update `package.json` `dependencies` (not `devDependencies`).\n * 3. Update `package.json` `main`.\n *\n * @param projectRoot The root directory of the project.\n * @param props.templatePkg Template project package.json as JSON.\n * @param props.pkg Current package.json as JSON.\n * @param props.skipDependencyUpdate Array of dependencies to skip updating.\n * @returns\n */\nfunction modifyPackageJson(\n projectRoot: string,\n {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n }: {\n templatePkg: PackageJSONConfig;\n pkg: PackageJSONConfig;\n /** @deprecated Required packages are not overwritten, only added when missing */\n skipDependencyUpdate?: string[];\n }\n) {\n const scriptsChanged = updatePkgScripts({ pkg });\n\n // TODO: Move to `npx expo-doctor`\n return {\n scriptsChanged,\n ...updatePkgDependencies(projectRoot, {\n pkg,\n templatePkg,\n skipDependencyUpdate,\n }),\n };\n}\n\n/**\n * Update `package.json` dependencies by combining the `dependencies` in the\n * project we are creating with the dependencies in the template project.\n *\n * > Exposed for testing.\n */\nexport function updatePkgDependencies(\n projectRoot: string,\n {\n pkg,\n templatePkg,\n skipDependencyUpdate = [],\n }: {\n pkg: PackageJSONConfig;\n templatePkg: PackageJSONConfig;\n /** @deprecated Required packages are not overwritten, only added when missing */\n skipDependencyUpdate?: string[];\n }\n): DependenciesModificationResults {\n const { dependencies } = templatePkg;\n // The default values come from the bare-minimum template's package.json.\n // Users can change this by using different templates with the `--template` flag.\n // The main reason for allowing the changing of dependencies would be to include\n // dependencies that are required for the native project to build. For example,\n // it does not need to include dependencies that are used in the JS-code only.\n const defaultDependencies = createDependenciesMap(dependencies);\n\n // NOTE: This is a hack to ensure this doesn't trigger an extraneous change in the `package.json`\n // it isn't required for anything in the `ios` and `android` folders.\n delete defaultDependencies['expo-status-bar'];\n // NOTE: Expo splash screen is installed by default in the template but the config plugin also lives in prebuild-config\n // so we can delete it to prevent an extraneous change in the `package.json`.\n delete defaultDependencies['expo-splash-screen'];\n\n const combinedDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDependencies,\n ...pkg.dependencies,\n });\n\n // These dependencies are only added, not overwritten from the project\n const requiredDependencies = [\n // TODO: This is no longer required because it's this same package.\n 'expo',\n // TODO: Drop this somehow.\n 'react-native',\n ].filter((depKey) => !!defaultDependencies[depKey]);\n\n const symlinkedPackages: string[] = [];\n const nonRecommendedPackages: string[] = [];\n\n for (const dependenciesKey of requiredDependencies) {\n // If the local package.json defined the dependency that we want to overwrite...\n if (pkg.dependencies?.[dependenciesKey]) {\n // Then ensure it isn't symlinked (i.e. the user has a custom version in their yarn workspace).\n if (isModuleSymlinked(projectRoot, { moduleId: dependenciesKey, isSilent: true })) {\n // If the package is in the project's package.json and it's symlinked, then skip overwriting it.\n symlinkedPackages.push(dependenciesKey);\n continue;\n }\n\n // Do not modify manually skipped dependencies\n if (skipDependencyUpdate.includes(dependenciesKey)) {\n continue;\n }\n\n // Warn users for outdated dependencies when prebuilding\n const hasRecommendedVersion = versionRangesIntersect(\n pkg.dependencies[dependenciesKey],\n String(defaultDependencies[dependenciesKey])\n );\n if (!hasRecommendedVersion) {\n nonRecommendedPackages.push(`${dependenciesKey}@${defaultDependencies[dependenciesKey]}`);\n }\n }\n }\n\n if (symlinkedPackages.length) {\n Log.log(\n `\\u203A Using symlinked ${symlinkedPackages\n .map((pkg) => chalk.bold(pkg))\n .join(', ')} instead of recommended version(s).`\n );\n }\n\n if (nonRecommendedPackages.length) {\n Log.warn(\n `\\u203A Using current versions instead of recommended ${nonRecommendedPackages\n .map((pkg) => chalk.bold(pkg))\n .join(', ')}.`\n );\n }\n\n // Only change the dependencies if the normalized hash changes, this helps to reduce meaningless changes.\n const hasNewDependencies =\n hashForDependencyMap(pkg.dependencies) !== hashForDependencyMap(combinedDependencies);\n // Save the dependencies\n let changedDependencies: string[] = [];\n if (hasNewDependencies) {\n changedDependencies = diffKeys(combinedDependencies, pkg.dependencies ?? {}).sort();\n // Use Object.assign to preserve the original order of dependencies, this makes it easier to see what changed in the git diff.\n pkg.dependencies = Object.assign(pkg.dependencies ?? {}, combinedDependencies);\n }\n\n return {\n changedDependencies,\n };\n}\n\nfunction diffKeys(a: Record<string, any>, b: Record<string, any>): string[] {\n return Object.keys(a).filter((key) => a[key] !== b[key]);\n}\n\n/**\n * Create an object of type DependenciesMap a dependencies object or throw if not valid.\n *\n * @param dependencies - ideally an object of type {[key]: string} - if not then this will error.\n */\nexport function createDependenciesMap(dependencies: any): DependenciesMap {\n if (typeof dependencies !== 'object') {\n throw new Error(`Dependency map is invalid, expected object but got ${typeof dependencies}`);\n } else if (!dependencies) {\n return {};\n }\n\n const outputMap: DependenciesMap = {};\n\n for (const key of Object.keys(dependencies)) {\n const value = dependencies[key];\n if (typeof value === 'string') {\n outputMap[key] = value;\n } else {\n throw new Error(\n `Dependency for key \\`${key}\\` should be a \\`string\\`, instead got: \\`{ ${key}: ${JSON.stringify(\n value\n )} }\\``\n );\n }\n }\n return outputMap;\n}\n\n/**\n * Update package.json scripts - `npm start` should default to `expo\n * start --dev-client` rather than `expo start` after prebuilding, for example.\n */\nfunction updatePkgScripts({ pkg }: { pkg: PackageJSONConfig }) {\n let hasChanged = false;\n if (!pkg.scripts) {\n pkg.scripts = {};\n }\n if (!pkg.scripts.android?.includes('run')) {\n pkg.scripts.android = 'expo run:android';\n hasChanged = true;\n }\n if (!pkg.scripts.ios?.includes('run')) {\n pkg.scripts.ios = 'expo run:ios';\n hasChanged = true;\n }\n return hasChanged;\n}\n\nfunction normalizeDependencyMap(deps: DependenciesMap): string[] {\n return Object.keys(deps)\n .map((dependency) => `${dependency}@${deps[dependency]}`)\n .sort();\n}\n\nexport function hashForDependencyMap(deps: DependenciesMap = {}): string {\n const depsList = normalizeDependencyMap(deps);\n const depsString = depsList.join('\\n');\n return createFileHash(depsString);\n}\n\nexport function createFileHash(contents: string): string {\n // this doesn't need to be secure, the shorter the better.\n return crypto.createHash('sha1').update(contents).digest('hex');\n}\n\n/**\n * Determine if two semver ranges are overlapping or intersecting.\n * This is a safe version of `semver.intersects` that does not throw.\n */\nfunction versionRangesIntersect(rangeA: string | SemverRange, rangeB: string | SemverRange) {\n try {\n return semverIntersects(rangeA, rangeB);\n } catch {\n return false;\n }\n}\n"],"names":["updatePackageJSONAsync","updatePkgDependencies","createDependenciesMap","hashForDependencyMap","createFileHash","Log","projectRoot","templateDirectory","templatePkg","getPackageJson","pkg","skipDependencyUpdate","updatingPackageJsonStep","logNewSection","results","modifyPackageJson","hasChanges","changedDependencies","length","scriptsChanged","fs","promises","writeFile","path","resolve","JSON","stringify","succeed","chalk","dim","updatePkgScripts","dependencies","defaultDependencies","combinedDependencies","requiredDependencies","filter","depKey","symlinkedPackages","nonRecommendedPackages","dependenciesKey","isModuleSymlinked","moduleId","isSilent","push","includes","hasRecommendedVersion","versionRangesIntersect","String","log","map","bold","join","warn","hasNewDependencies","diffKeys","sort","Object","assign","a","b","keys","key","Error","outputMap","value","hasChanged","scripts","android","ios","normalizeDependencyMap","deps","dependency","depsList","depsString","contents","crypto","createHash","update","digest","rangeA","rangeB","semverIntersects"],"mappings":"AAAA;;;;QAmBsBA,sBAAsB,GAAtBA,sBAAsB;QAsF5BC,qBAAqB,GAArBA,qBAAqB;QA+GrBC,qBAAqB,GAArBA,qBAAqB;QAkDrBC,oBAAoB,GAApBA,oBAAoB;QAMpBC,cAAc,GAAdA,cAAc;AAhRoB,IAAA,OAAc,WAAd,cAAc,CAAA;AAC9C,IAAA,MAAO,kCAAP,OAAO,EAAA;AACN,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACZ,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAC8C,IAAA,OAAQ,WAAR,QAAQ,CAAA;AAEjEC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACmB,IAAA,kBAA4B,WAA5B,4BAA4B,CAAA;AAChC,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUrC,eAAeL,sBAAsB,CAC1CM,WAAmB,EACnB,EACEC,iBAAiB,CAAA,EACjBC,WAAW,EAAGC,CAAAA,GAAAA,OAAc,AAAmB,CAAA,eAAnB,CAACF,iBAAiB,CAAC,CAAA,EAC/CG,GAAG,CAAA,EACHC,oBAAoB,CAAA,EAMrB,EACyC;IAC1C,MAAMC,uBAAuB,GAAGC,CAAAA,GAAAA,IAAa,AAAyB,CAAA,cAAzB,CAAC,uBAAuB,CAAC,AAAC;IAEvE,MAAMC,OAAO,GAAGC,iBAAiB,CAACT,WAAW,EAAE;QAC7CE,WAAW;QACXE,GAAG;QACHC,oBAAoB;KACrB,CAAC,AAAC;IAEH,MAAMK,UAAU,GAAGF,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AA,CAACC,UAAU,CAAC,MAAM,CAAC,CAACC,MAAM,CAACH,QAAQ,CAAC,CAACI,MAAM,CAAC,KAAK,CAAC,CAAC;CACjE;AAED;;;GAGG,CACH,SAAShC,sBAAsB,CAACiC,MAA4B,EAAEC,MAA4B,EAAE;IAC1F,IAAI;QACF,OAAOC,CAAAA,GAAAA,OAAgB,AAAgB,CAAA,WAAhB,CAACF,MAAM,EAAEC,MAAM,CAAC,CAAC;KACzC,CAAC,OAAM;QACN,OAAO,KAAK,CAAC;KACd;CACF"}
@@ -33,10 +33,10 @@ function _interopRequireWildcard(obj) {
33
33
  return newObj;
34
34
  }
35
35
  }
36
- async function validateTemplatePlatforms({ templateDirectory , platforms }) {
36
+ function validateTemplatePlatforms({ templateDirectory , platforms }) {
37
37
  const existingPlatforms = [];
38
38
  for (const platform of platforms){
39
- if (await (0, _dir).directoryExistsAsync(_path.default.join(templateDirectory, platform))) {
39
+ if ((0, _dir).directoryExistsSync(_path.default.join(templateDirectory, platform))) {
40
40
  existingPlatforms.push(platform);
41
41
  } else {
42
42
  Log.warn(_chalk.default`⚠️ Skipping platform ${platform}. Use a template that contains native files for ${platform} (./${platform}).`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/validateTemplatePlatforms.ts"],"sourcesContent":["import { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { directoryExistsAsync } from '../utils/dir';\n\nexport async function validateTemplatePlatforms({\n templateDirectory,\n platforms,\n}: {\n templateDirectory: string;\n platforms: ModPlatform[];\n}) {\n const existingPlatforms: ModPlatform[] = [];\n\n for (const platform of platforms) {\n if (await directoryExistsAsync(path.join(templateDirectory, platform))) {\n existingPlatforms.push(platform);\n } else {\n Log.warn(\n chalk`⚠️ Skipping platform ${platform}. Use a template that contains native files for ${platform} (./${platform}).`\n );\n }\n }\n\n return existingPlatforms;\n}\n"],"names":["validateTemplatePlatforms","Log","templateDirectory","platforms","existingPlatforms","platform","directoryExistsAsync","path","join","push","warn","chalk"],"mappings":"AAAA;;;;QAOsBA,yBAAyB,GAAzBA,yBAAyB;AAN7B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACsB,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5C,eAAeD,yBAAyB,CAAC,EAC9CE,iBAAiB,CAAA,EACjBC,SAAS,CAAA,EAIV,EAAE;IACD,MAAMC,iBAAiB,GAAkB,EAAE,AAAC;IAE5C,KAAK,MAAMC,QAAQ,IAAIF,SAAS,CAAE;QAChC,IAAI,MAAMG,CAAAA,GAAAA,IAAoB,AAAwC,CAAA,qBAAxC,CAACC,KAAI,QAAA,CAACC,IAAI,CAACN,iBAAiB,EAAEG,QAAQ,CAAC,CAAC,EAAE;YACtED,iBAAiB,CAACK,IAAI,CAACJ,QAAQ,CAAC,CAAC;SAClC,MAAM;YACLJ,GAAG,CAACS,IAAI,CACNC,MAAK,QAAA,CAAC,0BAAsB,EAAEN,QAAQ,CAAC,gDAAgD,EAAEA,QAAQ,CAAC,IAAI,EAAEA,QAAQ,CAAC,EAAE,CAAC,CACrH,CAAC;SACH;KACF;IAED,OAAOD,iBAAiB,CAAC;CAC1B"}
1
+ {"version":3,"sources":["../../../src/prebuild/validateTemplatePlatforms.ts"],"sourcesContent":["import { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { directoryExistsSync } from '../utils/dir';\n\nexport function validateTemplatePlatforms({\n templateDirectory,\n platforms,\n}: {\n templateDirectory: string;\n platforms: ModPlatform[];\n}) {\n const existingPlatforms: ModPlatform[] = [];\n\n for (const platform of platforms) {\n if (directoryExistsSync(path.join(templateDirectory, platform))) {\n existingPlatforms.push(platform);\n } else {\n Log.warn(\n chalk`⚠️ Skipping platform ${platform}. Use a template that contains native files for ${platform} (./${platform}).`\n );\n }\n }\n\n return existingPlatforms;\n}\n"],"names":["validateTemplatePlatforms","Log","templateDirectory","platforms","existingPlatforms","platform","directoryExistsSync","path","join","push","warn","chalk"],"mappings":"AAAA;;;;QAOgBA,yBAAyB,GAAzBA,yBAAyB;AANvB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACqB,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3C,SAASD,yBAAyB,CAAC,EACxCE,iBAAiB,CAAA,EACjBC,SAAS,CAAA,EAIV,EAAE;IACD,MAAMC,iBAAiB,GAAkB,EAAE,AAAC;IAE5C,KAAK,MAAMC,QAAQ,IAAIF,SAAS,CAAE;QAChC,IAAIG,CAAAA,GAAAA,IAAmB,AAAwC,CAAA,oBAAxC,CAACC,KAAI,QAAA,CAACC,IAAI,CAACN,iBAAiB,EAAEG,QAAQ,CAAC,CAAC,EAAE;YAC/DD,iBAAiB,CAACK,IAAI,CAACJ,QAAQ,CAAC,CAAC;SAClC,MAAM;YACLJ,GAAG,CAACS,IAAI,CACNC,MAAK,QAAA,CAAC,0BAAsB,EAAEN,QAAQ,CAAC,gDAAgD,EAAEA,QAAQ,CAAC,IAAI,EAAEA,QAAQ,CAAC,EAAE,CAAC,CACrH,CAAC;SACH;KACF;IAED,OAAOD,iBAAiB,CAAC;CAC1B"}
@@ -39,7 +39,7 @@ const expoRegister = async (argv)=>{
39
39
  `-h, --help Usage info`);
40
40
  }
41
41
  const { registerAsync } = await Promise.resolve().then(function() {
42
- return _interopRequireWildcard(require("./registerAsync"));
42
+ return _interopRequireWildcard(require("./registerAsync.js"));
43
43
  });
44
44
  return registerAsync().catch(_errors.logCmdError);
45
45
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/register/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from '../../bin/cli';\nimport { assertArgs, printHelp } from '../utils/args';\nimport { logCmdError } from '../utils/errors';\n\nexport const expoRegister: Command = async (argv) => {\n const args = assertArgs(\n {\n // Types\n '--help': Boolean,\n // Aliases\n '-h': '--help',\n },\n argv\n );\n\n if (args['--help']) {\n printHelp(\n `Sign up for a new Expo account`,\n `npx expo register`,\n // Options\n `-h, --help Usage info`\n );\n }\n\n const { registerAsync } = await import('./registerAsync');\n return registerAsync().catch(logCmdError);\n};\n"],"names":["expoRegister","argv","args","assertArgs","Boolean","printHelp","registerAsync","catch","logCmdError"],"mappings":"AAAA;;;;;;AAEsC,IAAA,KAAe,WAAf,eAAe,CAAA;AACzB,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;AAEtC,MAAMA,YAAY,GAAY,OAAOC,IAAI,GAAK;IACnD,MAAMC,IAAI,GAAGC,CAAAA,GAAAA,KAAU,AAQtB,CAAA,WARsB,CACrB;QACE,QAAQ;QACR,QAAQ,EAAEC,OAAO;QACjB,UAAU;QACV,IAAI,EAAE,QAAQ;KACf,EACDH,IAAI,CACL,AAAC;IAEF,IAAIC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAClBG,CAAAA,GAAAA,KAAS,AAKR,CAAA,UALQ,CACP,CAAC,8BAA8B,CAAC,EAChC,CAAC,iBAAiB,CAAC,EACnB,UAAU;QACV,CAAC,wBAAwB,CAAC,CAC3B,CAAC;KACH;IAED,MAAM,EAAEC,aAAa,CAAA,EAAE,GAAG,MAAM;+CAAO,iBAAiB;MAAC,AAAC;IAC1D,OAAOA,aAAa,EAAE,CAACC,KAAK,CAACC,OAAW,YAAA,CAAC,CAAC;CAC3C,AAAC;QAtBWR,YAAY,GAAZA,YAAY"}
1
+ {"version":3,"sources":["../../../src/register/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from '../../bin/cli';\nimport { assertArgs, printHelp } from '../utils/args';\nimport { logCmdError } from '../utils/errors';\n\nexport const expoRegister: Command = async (argv) => {\n const args = assertArgs(\n {\n // Types\n '--help': Boolean,\n // Aliases\n '-h': '--help',\n },\n argv\n );\n\n if (args['--help']) {\n printHelp(\n `Sign up for a new Expo account`,\n `npx expo register`,\n // Options\n `-h, --help Usage info`\n );\n }\n\n const { registerAsync } = await import('./registerAsync.js');\n return registerAsync().catch(logCmdError);\n};\n"],"names":["expoRegister","argv","args","assertArgs","Boolean","printHelp","registerAsync","catch","logCmdError"],"mappings":"AAAA;;;;;;AAEsC,IAAA,KAAe,WAAf,eAAe,CAAA;AACzB,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;AAEtC,MAAMA,YAAY,GAAY,OAAOC,IAAI,GAAK;IACnD,MAAMC,IAAI,GAAGC,CAAAA,GAAAA,KAAU,AAQtB,CAAA,WARsB,CACrB;QACE,QAAQ;QACR,QAAQ,EAAEC,OAAO;QACjB,UAAU;QACV,IAAI,EAAE,QAAQ;KACf,EACDH,IAAI,CACL,AAAC;IAEF,IAAIC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAClBG,CAAAA,GAAAA,KAAS,AAKR,CAAA,UALQ,CACP,CAAC,8BAA8B,CAAC,EAChC,CAAC,iBAAiB,CAAC,EACnB,UAAU;QACV,CAAC,wBAAwB,CAAC,CAC3B,CAAC;KACH;IAED,MAAM,EAAEC,aAAa,CAAA,EAAE,GAAG,MAAM;+CAAO,oBAAoB;MAAC,AAAC;IAC7D,OAAOA,aAAa,EAAE,CAACC,KAAK,CAACC,OAAW,YAAA,CAAC,CAAC;CAC3C,AAAC;QAtBWR,YAAY,GAAZA,YAAY"}
@@ -72,14 +72,14 @@ const expoRunAndroid = async (argv)=>{
72
72
  `, 0);
73
73
  }
74
74
  const { resolveStringOrBooleanArgsAsync } = await Promise.resolve().then(function() {
75
- return _interopRequireWildcard(require("../../utils/resolveArgs"));
75
+ return _interopRequireWildcard(require("../../utils/resolveArgs.js"));
76
76
  });
77
77
  const parsed = await resolveStringOrBooleanArgsAsync(argv != null ? argv : [], rawArgsMap, {
78
78
  "--device": Boolean,
79
79
  "-d": "--device"
80
80
  }).catch(_errors.logCmdError);
81
81
  const { runAndroidAsync } = await Promise.resolve().then(function() {
82
- return _interopRequireWildcard(require("./runAndroidAsync"));
82
+ return _interopRequireWildcard(require("./runAndroidAsync.js"));
83
83
  });
84
84
  return runAndroidAsync(_path.default.resolve(parsed.projectRoot), {
85
85
  // Parsed options
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/run/android/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport arg from 'arg';\nimport chalk from 'chalk';\nimport path from 'path';\n\nimport { Command } from '../../../bin/cli';\nimport * as Log from '../../log';\nimport { assertWithOptionsArgs } from '../../utils/args';\nimport { logCmdError } from '../../utils/errors';\n\nexport const expoRunAndroid: Command = async (argv) => {\n const rawArgsMap: arg.Spec = {\n // Types\n '--help': Boolean,\n '--no-build-cache': Boolean,\n '--no-install': Boolean,\n '--no-bundler': Boolean,\n '--variant': String,\n\n '--port': Number,\n // Aliases\n '-p': '--port',\n\n '-h': '--help',\n };\n const args = assertWithOptionsArgs(rawArgsMap, {\n argv,\n\n permissive: true,\n });\n\n // '-d' -> '--device': Boolean,\n\n if (args['--help']) {\n Log.exit(\n chalk`\n {bold Description}\n Run the native Android app locally\n\n {bold Usage}\n $ npx expo run:android <dir>\n\n {bold Options} \n --no-build-cache Clear the native build cache\n --no-install Skip installing dependencies\n --no-bundler Skip starting the bundler\n --variant <name> Build variant. {dim Default: debug}\n -d, --device [device] Device name to run the app on\n -p, --port <port> Port to start the dev server on. {dim Default: 8081}\n -h, --help Output usage information\n`,\n 0\n );\n }\n\n const { resolveStringOrBooleanArgsAsync } = await import('../../utils/resolveArgs');\n const parsed = await resolveStringOrBooleanArgsAsync(argv ?? [], rawArgsMap, {\n '--device': Boolean,\n '-d': '--device',\n }).catch(logCmdError);\n\n const { runAndroidAsync } = await import('./runAndroidAsync');\n\n return runAndroidAsync(path.resolve(parsed.projectRoot), {\n // Parsed options\n buildCache: !args['--no-build-cache'],\n install: !args['--no-install'],\n bundler: !args['--no-bundler'],\n port: args['--port'],\n variant: args['--variant'],\n\n // Custom parsed args\n device: parsed.args['--device'],\n }).catch(logCmdError);\n};\n"],"names":["Log","expoRunAndroid","argv","rawArgsMap","Boolean","String","Number","args","assertWithOptionsArgs","permissive","exit","chalk","resolveStringOrBooleanArgsAsync","parsed","catch","logCmdError","runAndroidAsync","path","resolve","projectRoot","buildCache","install","bundler","port","variant","device"],"mappings":"AAAA;;;;;;AAEkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AAGXA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACuB,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AAC5B,IAAA,OAAoB,WAApB,oBAAoB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzC,MAAMC,cAAc,GAAY,OAAOC,IAAI,GAAK;IACrD,MAAMC,UAAU,GAAa;QAC3B,QAAQ;QACR,QAAQ,EAAEC,OAAO;QACjB,kBAAkB,EAAEA,OAAO;QAC3B,cAAc,EAAEA,OAAO;QACvB,cAAc,EAAEA,OAAO;QACvB,WAAW,EAAEC,MAAM;QAEnB,QAAQ,EAAEC,MAAM;QAChB,UAAU;QACV,IAAI,EAAE,QAAQ;QAEd,IAAI,EAAE,QAAQ;KACf,AAAC;IACF,MAAMC,IAAI,GAAGC,CAAAA,GAAAA,KAAqB,AAIhC,CAAA,sBAJgC,CAACL,UAAU,EAAE;QAC7CD,IAAI;QAEJO,UAAU,EAAE,IAAI;KACjB,CAAC,AAAC;IAEH,+BAA+B;IAE/B,IAAIF,IAAI,CAAC,QAAQ,CAAC,EAAE;QAClBP,GAAG,CAACU,IAAI,CACNC,MAAK,QAAA,CAAC;;;;;;;;;;;;;;;AAeZ,CAAC,EACK,CAAC,CACF,CAAC;KACH;IAED,MAAM,EAAEC,+BAA+B,CAAA,EAAE,GAAG,MAAM;+CAAO,yBAAyB;MAAC,AAAC;IACpF,MAAMC,MAAM,GAAG,MAAMD,+BAA+B,CAACV,IAAI,WAAJA,IAAI,GAAI,EAAE,EAAEC,UAAU,EAAE;QAC3E,UAAU,EAAEC,OAAO;QACnB,IAAI,EAAE,UAAU;KACjB,CAAC,CAACU,KAAK,CAACC,OAAW,YAAA,CAAC,AAAC;IAEtB,MAAM,EAAEC,eAAe,CAAA,EAAE,GAAG,MAAM;+CAAO,mBAAmB;MAAC,AAAC;IAE9D,OAAOA,eAAe,CAACC,KAAI,QAAA,CAACC,OAAO,CAACL,MAAM,CAACM,WAAW,CAAC,EAAE;QACvD,iBAAiB;QACjBC,UAAU,EAAE,CAACb,IAAI,CAAC,kBAAkB,CAAC;QACrCc,OAAO,EAAE,CAACd,IAAI,CAAC,cAAc,CAAC;QAC9Be,OAAO,EAAE,CAACf,IAAI,CAAC,cAAc,CAAC;QAC9BgB,IAAI,EAAEhB,IAAI,CAAC,QAAQ,CAAC;QACpBiB,OAAO,EAAEjB,IAAI,CAAC,WAAW,CAAC;QAE1B,qBAAqB;QACrBkB,MAAM,EAAEZ,MAAM,CAACN,IAAI,CAAC,UAAU,CAAC;KAChC,CAAC,CAACO,KAAK,CAACC,OAAW,YAAA,CAAC,CAAC;CACvB,AAAC;QAhEWd,cAAc,GAAdA,cAAc"}
1
+ {"version":3,"sources":["../../../../src/run/android/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport arg from 'arg';\nimport chalk from 'chalk';\nimport path from 'path';\n\nimport { Command } from '../../../bin/cli';\nimport * as Log from '../../log';\nimport { assertWithOptionsArgs } from '../../utils/args';\nimport { logCmdError } from '../../utils/errors';\n\nexport const expoRunAndroid: Command = async (argv) => {\n const rawArgsMap: arg.Spec = {\n // Types\n '--help': Boolean,\n '--no-build-cache': Boolean,\n '--no-install': Boolean,\n '--no-bundler': Boolean,\n '--variant': String,\n\n '--port': Number,\n // Aliases\n '-p': '--port',\n\n '-h': '--help',\n };\n const args = assertWithOptionsArgs(rawArgsMap, {\n argv,\n\n permissive: true,\n });\n\n // '-d' -> '--device': Boolean,\n\n if (args['--help']) {\n Log.exit(\n chalk`\n {bold Description}\n Run the native Android app locally\n\n {bold Usage}\n $ npx expo run:android <dir>\n\n {bold Options} \n --no-build-cache Clear the native build cache\n --no-install Skip installing dependencies\n --no-bundler Skip starting the bundler\n --variant <name> Build variant. {dim Default: debug}\n -d, --device [device] Device name to run the app on\n -p, --port <port> Port to start the dev server on. {dim Default: 8081}\n -h, --help Output usage information\n`,\n 0\n );\n }\n\n const { resolveStringOrBooleanArgsAsync } = await import('../../utils/resolveArgs.js');\n const parsed = await resolveStringOrBooleanArgsAsync(argv ?? [], rawArgsMap, {\n '--device': Boolean,\n '-d': '--device',\n }).catch(logCmdError);\n\n const { runAndroidAsync } = await import('./runAndroidAsync.js');\n\n return runAndroidAsync(path.resolve(parsed.projectRoot), {\n // Parsed options\n buildCache: !args['--no-build-cache'],\n install: !args['--no-install'],\n bundler: !args['--no-bundler'],\n port: args['--port'],\n variant: args['--variant'],\n\n // Custom parsed args\n device: parsed.args['--device'],\n }).catch(logCmdError);\n};\n"],"names":["Log","expoRunAndroid","argv","rawArgsMap","Boolean","String","Number","args","assertWithOptionsArgs","permissive","exit","chalk","resolveStringOrBooleanArgsAsync","parsed","catch","logCmdError","runAndroidAsync","path","resolve","projectRoot","buildCache","install","bundler","port","variant","device"],"mappings":"AAAA;;;;;;AAEkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AAGXA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACuB,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AAC5B,IAAA,OAAoB,WAApB,oBAAoB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzC,MAAMC,cAAc,GAAY,OAAOC,IAAI,GAAK;IACrD,MAAMC,UAAU,GAAa;QAC3B,QAAQ;QACR,QAA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,CAAC;QAE1B,qBAAqB;QACrBkB,MAAM,EAAEZ,MAAM,CAACN,IAAI,CAAC,UAAU,CAAC;KAChC,CAAC,CAACO,KAAK,CAACC,OAAW,YAAA,CAAC,CAAC;CACvB,AAAC;QAhEWd,cAAc,GAAdA,cAAc"}
@@ -13,6 +13,7 @@ var _usbmuxdClient = require("./client/UsbmuxdClient");
13
13
  var _afcprotocol = require("./protocol/AFCProtocol");
14
14
  var _log = require("../../../log");
15
15
  var _xcodeDeveloperDiskImagePrerequisite = require("../../../start/doctor/apple/XcodeDeveloperDiskImagePrerequisite");
16
+ var _xcrun = require("../../../start/platforms/ios/xcrun");
16
17
  var _delay = require("../../../utils/delay");
17
18
  var _errors = require("../../../utils/errors");
18
19
  var _exit = require("../../../utils/exit");
@@ -76,10 +77,11 @@ async function runOnDevice({ udid , appPath , bundleId , waitForApp , deltaPath
76
77
  // launch fails with EBusy or ENotFound if you try to launch immediately after install
77
78
  await (0, _delay).delayAsync(200);
78
79
  const debugServerClient = await launchApp(clientManager, {
80
+ bundleId,
79
81
  appInfo,
80
82
  detach: !waitForApp
81
83
  });
82
- if (waitForApp) {
84
+ if (waitForApp && debugServerClient) {
83
85
  (0, _exit).installExitHooks(async ()=>{
84
86
  // causes continue() to return
85
87
  debugServerClient.halt();
@@ -129,7 +131,7 @@ async function uploadApp(clientManager, { appBinaryPath , destinationPath }) {
129
131
  }
130
132
  await afcClient.uploadDirectory(appBinaryPath, destinationPath);
131
133
  }
132
- async function launchApp(clientManager, { appInfo , detach }) {
134
+ async function launchAppWithUsbmux(clientManager, { appInfo , detach }) {
133
135
  let tries = 0;
134
136
  while(tries < 3){
135
137
  const debugServerClient = await clientManager.getDebugserverClient();
@@ -158,5 +160,36 @@ async function launchApp(clientManager, { appInfo , detach }) {
158
160
  }
159
161
  throw new _errors.CommandError("Unable to launch app, number of tries exceeded");
160
162
  }
163
+ async function launchAppWithDeviceCtl(deviceId, bundleId) {
164
+ await (0, _xcrun).xcrunAsync([
165
+ "devicectl",
166
+ "device",
167
+ "process",
168
+ "launch",
169
+ "--device",
170
+ deviceId,
171
+ bundleId
172
+ ]);
173
+ }
174
+ /**
175
+ * iOS 17 introduces a new protocol called RemoteXPC.
176
+ * This is not yet implemented, so we fallback to devicectl.
177
+ *
178
+ * @see https://github.com/doronz88/pymobiledevice3/blob/master/misc/RemoteXPC.md#process-remoted
179
+ */ async function launchApp(clientManager, { bundleId , appInfo , detach }) {
180
+ try {
181
+ return await launchAppWithUsbmux(clientManager, {
182
+ appInfo,
183
+ detach
184
+ });
185
+ } catch (error) {
186
+ debug("Failed to launch app with Usbmuxd, falling back to xcrun...", error);
187
+ // Get the device UDID and close the connection, to allow `xcrun devicectl` to connect
188
+ const deviceId = clientManager.device.Properties.SerialNumber;
189
+ clientManager.end();
190
+ // Fallback to devicectl for iOS 17 support
191
+ return await launchAppWithDeviceCtl(deviceId, bundleId);
192
+ }
193
+ }
161
194
 
162
195
  //# sourceMappingURL=AppleDevice.js.map