@expo/cli 0.3.2 → 0.4.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 (69) hide show
  1. package/README.md +48 -10
  2. package/build/bin/cli +2 -2
  3. package/build/src/api/graphql/client.js +3 -1
  4. package/build/src/api/graphql/client.js.map +1 -1
  5. package/build/src/api/rest/client.js +5 -2
  6. package/build/src/api/rest/client.js.map +1 -1
  7. package/build/src/api/rest/wrapFetchWithProxy.js +25 -0
  8. package/build/src/api/rest/wrapFetchWithProxy.js.map +1 -0
  9. package/build/src/export/fork-bundleAsync.js +2 -1
  10. package/build/src/export/fork-bundleAsync.js.map +1 -1
  11. package/build/src/install/resolveOptions.js +6 -2
  12. package/build/src/install/resolveOptions.js.map +1 -1
  13. package/build/src/prebuild/copyTemplateFiles.js +6 -33
  14. package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
  15. package/build/src/prebuild/resolveTemplate.js +2 -2
  16. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  17. package/build/src/prebuild/updateFromTemplate.js +1 -3
  18. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  19. package/build/src/prebuild/updatePackageJson.js +3 -46
  20. package/build/src/prebuild/updatePackageJson.js.map +1 -1
  21. package/build/src/run/ios/XcodeBuild.js +2 -1
  22. package/build/src/run/ios/XcodeBuild.js.map +1 -1
  23. package/build/src/run/ios/codeSigning/simulatorCodeSigning.js +45 -0
  24. package/build/src/run/ios/codeSigning/simulatorCodeSigning.js.map +1 -0
  25. package/build/src/start/doctor/ngrok/NgrokResolver.js +5 -0
  26. package/build/src/start/doctor/ngrok/NgrokResolver.js.map +1 -1
  27. package/build/src/start/platforms/PlatformManager.js +6 -1
  28. package/build/src/start/platforms/PlatformManager.js.map +1 -1
  29. package/build/src/start/platforms/android/adbReverse.js +10 -0
  30. package/build/src/start/platforms/android/adbReverse.js.map +1 -1
  31. package/build/src/start/resolveOptions.js +1 -1
  32. package/build/src/start/resolveOptions.js.map +1 -1
  33. package/build/src/start/server/AsyncNgrok.js +58 -14
  34. package/build/src/start/server/AsyncNgrok.js.map +1 -1
  35. package/build/src/start/server/BundlerDevServer.js +4 -1
  36. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  37. package/build/src/start/server/metro/MetroBundlerDevServer.js +20 -5
  38. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  39. package/build/src/start/server/metro/instantiateMetro.js +1 -6
  40. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  41. package/build/src/start/server/metro/withMetroMultiPlatform.js +36 -5
  42. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  43. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +4 -2
  44. package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
  45. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +7 -3
  46. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
  47. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
  48. package/build/src/start/server/middleware/resolveEntryPoint.js +2 -1
  49. package/build/src/start/server/middleware/resolveEntryPoint.js.map +1 -1
  50. package/build/src/start/server/middleware/resolvePlatform.js +3 -2
  51. package/build/src/start/server/middleware/resolvePlatform.js.map +1 -1
  52. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +2 -8
  53. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  54. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  55. package/build/src/utils/codesigning.js +3 -0
  56. package/build/src/utils/codesigning.js.map +1 -1
  57. package/build/src/utils/downloadAppAsync.js +1 -2
  58. package/build/src/utils/downloadAppAsync.js.map +1 -1
  59. package/build/src/utils/env.js +37 -1
  60. package/build/src/utils/env.js.map +1 -1
  61. package/build/src/utils/npm.js +4 -11
  62. package/build/src/utils/npm.js.map +1 -1
  63. package/build/src/utils/url.js +2 -2
  64. package/build/src/utils/url.js.map +1 -1
  65. package/build/src/utils/validateApplicationId.js +3 -3
  66. package/build/src/utils/validateApplicationId.js.map +1 -1
  67. package/build/src/utils/variadic.js +18 -0
  68. package/build/src/utils/variadic.js.map +1 -1
  69. package/package.json +5 -4
package/README.md CHANGED
@@ -1,4 +1,40 @@
1
- # @expo/cli
1
+ <!-- Title -->
2
+
3
+ <p align="center">
4
+ <a href="https://expo.dev/">
5
+ <img alt="Expo CLI" src="../../../.github/resources/cli-banner.svg">
6
+ </a>
7
+ </p>
8
+
9
+ <p align="center">The fastest way to build and run universal React Native apps for iOS, Android, and the web</p>
10
+
11
+ <p align="center">
12
+
13
+ <a aria-label="Join the Expo Discord" href="https://discord.gg/4gtbPAdpaE" target="_blank">
14
+ <img alt="Discord" src="https://img.shields.io/discord/695411232856997968.svg?style=flat-square&labelColor=000000&color=000000&logo=discord&logoColor=FFFFFF&label=" />
15
+ </a>
16
+ <a aria-label="Browse the Expo forums" href="https://forums.expo.dev" target="_blank">
17
+ <img alt="" src="https://img.shields.io/badge/Ask%20Questions%20-000.svg?style=flat-square&logo=discourse&logoWidth=15&labelColor=000000&color=000000">
18
+ </a>
19
+
20
+ </p>
21
+
22
+ <p align="center">
23
+ <a aria-label="expo documentation" href="https://docs.expo.dev/workflow/expo-cli/">📚 Read the Documentation</a>
24
+ |
25
+ <a aria-label="Contribute to Expo CLI" href="#contributing"><b>Contribute to Expo CLI</b></a>
26
+ </p>
27
+
28
+ <p>
29
+ <a aria-label="Follow @expo on Twitter" href="https://twitter.com/intent/follow?screen_name=expo" target="_blank">
30
+ <img alt="Twitter: expo" src="https://img.shields.io/twitter/follow/expo.svg?style=flat-square&label=Follow%20%40expo&logo=TWITTER&logoColor=FFFFFF&labelColor=00aced&logoWidth=15&color=lightgray" target="_blank" />
31
+ </a>
32
+ <a aria-label="Follow Expo on Medium" href="https://blog.expo.dev">
33
+ <img align="right" alt="Medium: exposition" src="https://img.shields.io/badge/Learn%20more%20on%20our%20blog-lightgray.svg?style=flat-square" target="_blank" />
34
+ </a>
35
+ </p>
36
+
37
+ ---
2
38
 
3
39
  The `@expo/cli` package is a CLI binary that should be used via `expo` like `npx expo start`.
4
40
 
@@ -6,13 +42,15 @@ The `@expo/cli` package is a CLI binary that should be used via `expo` like `npx
6
42
  npx expo
7
43
  ```
8
44
 
45
+ > ⭐️ Be sure to star the Expo GitHub repo if you enjoy using the project!
46
+
9
47
  ## Design
10
48
 
11
49
  This CLI has the following purposes:
12
50
 
13
51
  - Be a minimal interface for starting a local development server that emulates a production EAS Updates server. The development server is the proxy between a native runtime (Expo Go, Dev Client) and a JS Bundler (Metro, Webpack).
14
- - To accomplish secure manifest signing (think https/TSL/SSL for web (required for sandboxing AsyncStorage, Permissions, etc.)) we need an authenticated Expo user account. This is the only reason we include the authentication commands `login`, `logout`, `whoami`, `register`. Standard web CLIs don't have authentication commands because they either don't setup https or they use emulation via packages like `devcert`.
15
- - Orchestrating various native tools like Xcode, Simulator.app, Android Studio, ADB, etc. to make native builds as painless as possible. `run:ios`, `run:android` commands.
52
+ - To accomplish secure manifest signing (think https/TSL/SSL for web (required for sandboxing AsyncStorage, Permissions, etc.)) we need an authenticated Expo user account. This is the only reason we include the authentication commands `login`, `logout`, `whoami`, `register`. Standard web CLIs don't have authentication commands because they either don't set up https or they use emulation via packages like `devcert`.
53
+ - Orchestrating various native tools like Xcode, `Simulator.app`, Android Studio, ADB, etc. to make native builds as painless as possible. `run:ios`, `run:android` commands.
16
54
  - Implementing a versioned `prebuild` command that can reliably work with a project for long periods of time. Prebuild is like a bundler for native code, it generates the `ios`, `android` folders based on the project Expo config (`app.json`).
17
55
  - `npx expo config` is auxiliary to `npx expo prebuild` and used for debugging/introspection.
18
56
  - Installing versioned libraries with `npx expo install` this is a minimal utility born out of pure necessity since versioning in React Native is hard to get right.
@@ -31,13 +69,13 @@ We highly recommend setting up an alias for the Expo CLI so you can try it in pr
31
69
  alias nexpo="/path/to/expo/packages/@expo/cli/build/bin/cli"
32
70
  ```
33
71
 
34
- Then use it with `nexpo` like `nexpo config`. You can also setup a debug version:
72
+ Then use it with `nexpo` like `nexpo config`. You can also set up a debug version:
35
73
 
36
74
  ```
37
75
  alias expo-inspect="node --inspect /path/to/expo/packages/@expo/cli/build/bin/cli"
38
76
  ```
39
77
 
40
- Then you can run it, and visit `chrome://inspect/#devices` in Chrome, and press "Open dedicated DevTools for Node" to get a debugger attached to your process. When debugging the CLI, you'll want to disable workers whenever possible, this will make all code run on the same thread, this is mostly applicable to the `start` command, i.e. `expo-inspect start --max-workers 0`.
78
+ Then you can run it and visit `chrome://inspect/#devices` in Chrome, and press "Open dedicated DevTools for Node" to get a debugger attached to your process. When debugging the CLI, you'll want to disable workers whenever possible, this will make all code run on the same thread, this is mostly applicable to the `start` command, i.e. `expo-inspect start --max-workers 0`.
41
79
 
42
80
  ## Format
43
81
 
@@ -67,19 +105,19 @@ Then you can run it, and visit `chrome://inspect/#devices` in Chrome, and press
67
105
  There are two testing scripts:
68
106
 
69
107
  - `yarn test`: Controlled unit and integration tests.
70
- - `yarn test:e2e`: End to end testing for CLI commands. This requires the files be built with `yarn build`
108
+ - `yarn test:e2e`: End to end testing for CLI commands. This requires the files to be built with `yarn build`
71
109
 
72
110
  ---
73
111
 
74
112
  - You can target a specific set of tests with the `--watch` flag. Example: `yarn test --watch config`.
75
- - We use back ticks for `it` blocks. Example <code>it(`works`)</code>.
76
- - If a pull request is fully self contained to the `packages/@expo/cli/` folder (i.e. no `yarn.lock` modifications, etc.) then most native CI tests will be skipped, making CI pass faster in PRs.
113
+ - We use backticks for `it` blocks. Example <code>it(`works`)</code>.
114
+ - If a pull request is fully self-contained to the `packages/@expo/cli/` folder (i.e. no `yarn.lock` modifications, etc.) then most native CI tests will be skipped, making CI pass faster in PRs.
77
115
 
78
116
  ### Unit Testing Guidelines
79
117
 
80
118
  - Use `nock` for network requests.
81
119
  - No top level `describe` blocks that wrap all the tests in a file.
82
- - When testing a function, pass the function to the describe instead of a stringified function name:
120
+ - When testing a function, pass the function to the `describe` block instead of a stringified function name:
83
121
  - `describe(foobar, () => {})` instead of `describe('foobar', () => {})`
84
122
  - Use virtual `fs` via `memfs` whenever possible.
85
123
  - We have a lot of global module [**mocks**](./e2e/setup.ts) already in place, consider them when writing tests.
@@ -97,7 +135,7 @@ There are two testing scripts:
97
135
 
98
136
  The legacy global `expo-cli` package was deprecated in favor of this versioned `@expo/cli` package for the following reasons:
99
137
 
100
- - `expo-cli` was too big and took way too long to install. This made CI frustrating to setup since you needed to also target global node modules for caching.
138
+ - `expo-cli` was too big and took way too long to install. This made CI frustrating to set up since you needed to also target global node modules for caching.
101
139
  - `expo-cli` worked for almost all versions of the `expo` package, meaning it was getting more complex with every release.
102
140
  - `expo-cli` combined service commands (like the legacy `build`, `submit`, `publish`) with project-level commands like `expo start`. We've since divided services into `eas-cli` and project commands into `npx expo` (`@expo/cli`). This structure is more optimal/faster for developers since they can install/update commands when they need them.
103
141
  - This CLI utilizes more Node.js standard features like `$EDITOR` instead of the custom `$EXPO_EDITOR` environment variable. Also transitioning away from `$EXPO_DEBUG` and more towards `$DEBUG=expo:*`. These types of changes make Expo CLI play nicer with existing tooling.
package/build/bin/cli CHANGED
@@ -121,7 +121,7 @@ const args = (0, _arg).default({
121
121
  });
122
122
  if (args["--version"]) {
123
123
  // Version is added in the build script.
124
- console.log("0.3.2");
124
+ console.log("0.4.0");
125
125
  process.exit(0);
126
126
  }
127
127
  if (args["--non-interactive"]) {
@@ -248,7 +248,7 @@ commands[command]().then((exec)=>{
248
248
  logEventAsync("action", {
249
249
  action: `expo ${command}`,
250
250
  source: "expo/cli",
251
- source_version: "0.3.2"
251
+ source_version: "0.4.0"
252
252
  });
253
253
  });
254
254
 
@@ -15,6 +15,8 @@ var _exchangeRetry = require("@urql/exchange-retry");
15
15
  var _nodeFetch = _interopRequireDefault(require("node-fetch"));
16
16
  var Log = _interopRequireWildcard(require("../../log"));
17
17
  var _endpoint = require("../endpoint");
18
+ var _wrapFetchWithOffline = require("../rest/wrapFetchWithOffline");
19
+ var _wrapFetchWithProxy = require("../rest/wrapFetchWithProxy");
18
20
  var _userSettings = _interopRequireDefault(require("../user/UserSettings"));
19
21
  function _interopRequireDefault(obj) {
20
22
  return obj && obj.__esModule ? obj : {
@@ -59,7 +61,7 @@ const graphqlClient = (0, _core).createClient({
59
61
  _core.fetchExchange,
60
62
  ],
61
63
  // @ts-ignore Type 'typeof fetch' is not assignable to type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>'.
62
- fetch: _nodeFetch.default,
64
+ fetch: (0, _wrapFetchWithOffline).wrapFetchWithOffline((0, _wrapFetchWithProxy).wrapFetchWithProxy(_nodeFetch.default)),
63
65
  fetchOptions: ()=>{
64
66
  var ref;
65
67
  const token = _userSettings.default.getAccessToken();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/api/graphql/client.ts"],"sourcesContent":["import {\n cacheExchange,\n Client,\n CombinedError as GraphqlError,\n createClient as createUrqlClient,\n dedupExchange,\n fetchExchange,\n OperationContext,\n OperationResult,\n PromisifiedSource,\n TypedDocumentNode,\n} from '@urql/core';\nimport { retryExchange } from '@urql/exchange-retry';\nimport { DocumentNode } from 'graphql';\nimport fetch from 'node-fetch';\n\nimport * as Log from '../../log';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport UserSettings from '../user/UserSettings';\n\ntype AccessTokenHeaders = {\n authorization: string;\n};\n\ntype SessionHeaders = {\n 'expo-session': string;\n};\n\nexport const graphqlClient = createUrqlClient({\n url: getExpoApiBaseUrl() + '/graphql',\n exchanges: [\n dedupExchange,\n cacheExchange,\n retryExchange({\n maxDelayMs: 4000,\n retryIf: (err) =>\n !!(err && (err.networkError || err.graphQLErrors.some((e) => e?.extensions?.isTransient))),\n }),\n fetchExchange,\n ],\n // @ts-ignore Type 'typeof fetch' is not assignable to type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>'.\n fetch,\n fetchOptions: (): { headers?: AccessTokenHeaders | SessionHeaders } => {\n const token = UserSettings.getAccessToken();\n if (token) {\n return {\n headers: {\n authorization: `Bearer ${token}`,\n },\n };\n }\n const sessionSecret = UserSettings.getSession()?.sessionSecret;\n if (sessionSecret) {\n return {\n headers: {\n 'expo-session': sessionSecret,\n },\n };\n }\n return {};\n },\n}) as StricterClient;\n\n/* Please specify additionalTypenames in your Graphql queries */\nexport interface StricterClient extends Client {\n // eslint-disable-next-line @typescript-eslint/ban-types\n query<Data = any, Variables extends object = {}>(\n query: DocumentNode | TypedDocumentNode<Data, Variables> | string,\n variables: Variables | undefined,\n context: Partial<OperationContext> & { additionalTypenames: string[] }\n ): PromisifiedSource<OperationResult<Data, Variables>>;\n}\n\nexport async function withErrorHandlingAsync<T>(promise: Promise<OperationResult<T>>): Promise<T> {\n const { data, error } = await promise;\n\n if (error) {\n if (error.graphQLErrors.some((e) => e?.extensions?.isTransient)) {\n Log.error(`We've encountered a transient error, please try again shortly.`);\n }\n throw error;\n }\n\n // Check for a malformed response. This only checks the root query's existence. It doesn't affect\n // returning responses with an empty result set.\n if (!data) {\n throw new Error('Returned query result data is null!');\n }\n\n return data;\n}\n\nexport { GraphqlError };\n"],"names":["GraphqlError","withErrorHandlingAsync","Log","graphqlClient","createUrqlClient","url","getExpoApiBaseUrl","exchanges","dedupExchange","cacheExchange","retryExchange","maxDelayMs","retryIf","err","networkError","graphQLErrors","some","e","extensions","isTransient","fetchExchange","fetch","fetchOptions","UserSettings","token","getAccessToken","headers","authorization","sessionSecret","getSession","promise","data","error","Error"],"mappings":"AAAA;;;;+BA4FSA,cAAY;;;eAAZA,KAAY,cAAA;;;QAnBCC,sBAAsB,GAAtBA,sBAAsB;;AA9DrC,IAAA,KAAY,WAAZ,YAAY,CAAA;AACW,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAElC,IAAA,UAAY,kCAAZ,YAAY,EAAA;AAElBC,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACmB,IAAA,SAAa,WAAb,aAAa,CAAA;AACtB,IAAA,aAAsB,kCAAtB,sB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E,aAAa;iBAC9B;aACF,CAAC;SACH;QACD,OAAO,EAAE,CAAC;KACX;CACF,CAAC,AAAkB,AAAC;QAjCRzB,aAAa,GAAbA,aAAa;AA6CnB,eAAeF,sBAAsB,CAAI6B,OAAoC,EAAc;IAChG,MAAM,EAAEC,IAAI,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAG,MAAMF,OAAO,AAAC;IAEtC,IAAIE,KAAK,EAAE;QACT,IAAIA,KAAK,CAACjB,aAAa,CAACC,IAAI,CAAC,CAACC,CAAC;gBAAKA,GAAa;YAAbA,OAAAA,CAAC,QAAY,GAAbA,KAAAA,CAAa,GAAbA,CAAAA,GAAa,GAAbA,CAAC,CAAEC,UAAU,SAAA,GAAbD,KAAAA,CAAa,GAAbA,GAAa,CAAEE,WAAW,AAAb,CAAa;SAAA,CAAC,EAAE;YAC/DjB,GAAG,CAAC8B,KAAK,CAAC,CAAC,8DAA8D,CAAC,CAAC,CAAC;SAC7E;QACD,MAAMA,KAAK,CAAC;KACb;IAED,iGAAiG;IACjG,gDAAgD;IAChD,IAAI,CAACD,IAAI,EAAE;QACT,MAAM,IAAIE,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAED,OAAOF,IAAI,CAAC;CACb"}
1
+ {"version":3,"sources":["../../../../src/api/graphql/client.ts"],"sourcesContent":["import {\n cacheExchange,\n Client,\n CombinedError as GraphqlError,\n createClient as createUrqlClient,\n dedupExchange,\n fetchExchange,\n OperationContext,\n OperationResult,\n PromisifiedSource,\n TypedDocumentNode,\n} from '@urql/core';\nimport { retryExchange } from '@urql/exchange-retry';\nimport { DocumentNode } from 'graphql';\nimport fetch from 'node-fetch';\n\nimport * as Log from '../../log';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { wrapFetchWithOffline } from '../rest/wrapFetchWithOffline';\nimport { wrapFetchWithProxy } from '../rest/wrapFetchWithProxy';\nimport UserSettings from '../user/UserSettings';\n\ntype AccessTokenHeaders = {\n authorization: string;\n};\n\ntype SessionHeaders = {\n 'expo-session': string;\n};\n\nexport const graphqlClient = createUrqlClient({\n url: getExpoApiBaseUrl() + '/graphql',\n exchanges: [\n dedupExchange,\n cacheExchange,\n retryExchange({\n maxDelayMs: 4000,\n retryIf: (err) =>\n !!(err && (err.networkError || err.graphQLErrors.some((e) => e?.extensions?.isTransient))),\n }),\n fetchExchange,\n ],\n // @ts-ignore Type 'typeof fetch' is not assignable to type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>'.\n fetch: wrapFetchWithOffline(wrapFetchWithProxy(fetch)),\n fetchOptions: (): { headers?: AccessTokenHeaders | SessionHeaders } => {\n const token = UserSettings.getAccessToken();\n if (token) {\n return {\n headers: {\n authorization: `Bearer ${token}`,\n },\n };\n }\n const sessionSecret = UserSettings.getSession()?.sessionSecret;\n if (sessionSecret) {\n return {\n headers: {\n 'expo-session': sessionSecret,\n },\n };\n }\n return {};\n },\n}) as StricterClient;\n\n/* Please specify additionalTypenames in your Graphql queries */\nexport interface StricterClient extends Client {\n // eslint-disable-next-line @typescript-eslint/ban-types\n query<Data = any, Variables extends object = {}>(\n query: DocumentNode | TypedDocumentNode<Data, Variables> | string,\n variables: Variables | undefined,\n context: Partial<OperationContext> & { additionalTypenames: string[] }\n ): PromisifiedSource<OperationResult<Data, Variables>>;\n}\n\nexport async function withErrorHandlingAsync<T>(promise: Promise<OperationResult<T>>): Promise<T> {\n const { data, error } = await promise;\n\n if (error) {\n if (error.graphQLErrors.some((e) => e?.extensions?.isTransient)) {\n Log.error(`We've encountered a transient error, please try again shortly.`);\n }\n throw error;\n }\n\n // Check for a malformed response. This only checks the root query's existence. It doesn't affect\n // returning responses with an empty result set.\n if (!data) {\n throw new Error('Returned query result data is null!');\n }\n\n return data;\n}\n\nexport { GraphqlError };\n"],"names":["GraphqlError","withErrorHandlingAsync","Log","graphqlClient","createUrqlClient","url","getExpoApiBaseUrl","exchanges","dedupExchange","cacheExchange","retryExchange","maxDelayMs","retryIf","err","networkError","graphQLErrors","some","e","extensions","isTransient","fetchExchange","fetch","wrapFetchWithOffline","wrapFetchWithProxy","fetchOptions","UserSettings","token","getAccessToken","headers","authorization","sessionSecret","getSession","promise","data","error","Error"],"mappings":"AAAA;;;;+BA8FSA,cAAY;;;eAAZA,KAAY,cAAA;;;QAnBCC,sBAAsB,GAAtBA,sBAAsB;;AAhErC,IAAA,KAAY,WAAZ,YAAY,CAAA;AACW,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAElC,IAAA,UAAY,kCAAZ,YAAY,EAAA;AAElBC,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACmB,IAAA,SAAa,WAAb,aAAa,CAAA;AACV,IAAA,qBAA8B,WAA9B,8BAA8B,CAAA;AAChC,IAAA,mBAA4B,WAA5B,4BAA4B,CAAA;AACtC,IAAA,aAAsB,kCAAtB,sBAAsB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUxC,MAAMC,aAAa,GAAGC,CAAAA,GAAAA,KAAgB,AAiC3C,CAAA,aAjC2C,CAAC;IAC5CC,GAAG,EAAEC,CAAAA,GAAAA,SAAiB,AAAE,CAAA,kBAAF,EAAE,GAAG,UAAU;IACrCC,SAAS,EAAE;QACTC,KAAa,cAAA;QACbC,KAAa,cAAA;QACbC,CAAAA,GAAAA,cAAa,AAIX,CAAA,cAJW,CAAC;YACZC,UAAU,EAAE,IAAI;YAChBC,OAAO,EAAE,CAACC,GAAG;gBACX,OAAA,CAAC,CAAC,CAACA,GAAG,IAAI,CAACA,GAAG,CAACC,YAAY,IAAID,GAAG,CAACE,aAAa,CAACC,IAAI,CAAC,CAACC,CAAC;wBAAKA,GAAa;oBAAbA,OAAAA,CAAC,QAAY,GAAbA,KAAAA,CAAa,GAAbA,CAAAA,GAAa,GAAbA,CAAC,CAAEC,UAAU,SAAA,GAAbD,KAAAA,CAAa,GAAbA,GAAa,CAAEE,WAAW,AAAb,CAAa;iBAAA,CAAC,CAAC,CAAC,CAAA;aAAA;SAC7F,CAAC;QACFC,KAAa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KAAK,CAAC;KACb;IAED,iGAAiG;IACjG,gDAAgD;IAChD,IAAI,CAACD,IAAI,EAAE;QACT,MAAM,IAAIE,KAAK,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAED,OAAOF,IAAI,CAAC;CACb"}
@@ -15,6 +15,7 @@ var _fileSystemCache = require("./cache/FileSystemCache");
15
15
  var _wrapFetchWithCache = require("./cache/wrapFetchWithCache");
16
16
  var _wrapFetchWithBaseUrl = require("./wrapFetchWithBaseUrl");
17
17
  var _wrapFetchWithOffline = require("./wrapFetchWithOffline");
18
+ var _wrapFetchWithProxy = require("./wrapFetchWithProxy");
18
19
  function _interopRequireDefault(obj) {
19
20
  return obj && obj.__esModule ? obj : {
20
21
  default: obj
@@ -24,6 +25,7 @@ class ApiV2Error extends Error {
24
25
  name = "ApiV2Error";
25
26
  constructor(response){
26
27
  super(response.message);
28
+ this.code = response.code;
27
29
  this.expoApiV2ErrorCode = response.code;
28
30
  this.expoApiV2ErrorDetails = response.details;
29
31
  this.expoApiV2ErrorServerStack = response.stack;
@@ -77,7 +79,8 @@ function wrapFetchWithCredentials(fetchFunction) {
77
79
  }
78
80
  const fetchWithOffline = (0, _wrapFetchWithOffline).wrapFetchWithOffline(_nodeFetch.default);
79
81
  const fetchWithBaseUrl = (0, _wrapFetchWithBaseUrl).wrapFetchWithBaseUrl(fetchWithOffline, (0, _endpoint).getExpoApiBaseUrl() + "/v2/");
80
- const fetchWithCredentials = wrapFetchWithCredentials(fetchWithBaseUrl);
82
+ const fetchWithProxy = (0, _wrapFetchWithProxy).wrapFetchWithProxy(fetchWithBaseUrl);
83
+ const fetchWithCredentials = wrapFetchWithCredentials(fetchWithProxy);
81
84
  function createCachedFetch({ fetch , cacheDirectory , ttl , skipCache }) {
82
85
  // Disable all caching in EXPO_BETA.
83
86
  if (skipCache || _env.env.EXPO_BETA || _env.env.EXPO_NO_CACHE) {
@@ -88,7 +91,7 @@ function createCachedFetch({ fetch , cacheDirectory , ttl , skipCache }) {
88
91
  ttl
89
92
  }));
90
93
  }
91
- const fetchAsync = wrapFetchWithCredentials(fetchWithBaseUrl);
94
+ const fetchAsync = wrapFetchWithCredentials(fetchWithProxy);
92
95
  exports.fetchAsync = fetchAsync;
93
96
 
94
97
  //# sourceMappingURL=client.js.map
@@ -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 { env } from '../../utils/env';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport UserSettings from '../user/UserSettings';\nimport { FileSystemCache } from './cache/FileSystemCache';\nimport { wrapFetchWithCache } from './cache/wrapFetchWithCache';\nimport { FetchLike } from './client.types';\nimport { wrapFetchWithBaseUrl } from './wrapFetchWithBaseUrl';\nimport { wrapFetchWithOffline } from './wrapFetchWithOffline';\n\nexport class ApiV2Error extends Error {\n readonly name = 'ApiV2Error';\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.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 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 };\n}\n\nconst fetchWithOffline = wrapFetchWithOffline(fetchInstance);\n\nconst fetchWithBaseUrl = wrapFetchWithBaseUrl(fetchWithOffline, getExpoApiBaseUrl() + '/v2/');\n\nconst fetchWithCredentials = wrapFetchWithCredentials(fetchWithBaseUrl);\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,\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 ?? fetchWithCredentials;\n }\n\n return wrapFetchWithCache(\n fetch ?? fetchWithCredentials,\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 = wrapFetchWithCredentials(fetchWithBaseUrl);\n"],"names":["wrapFetchWithCredentials","createCachedFetch","ApiV2Error","Error","name","constructor","response","message","expoApiV2ErrorCode","code","expoApiV2ErrorDetails","details","expoApiV2ErrorServerStack","stack","expoApiV2ErrorMetadata","metadata","UnexpectedServerError","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","fetchWithOffline","wrapFetchWithOffline","fetchInstance","fetchWithBaseUrl","wrapFetchWithBaseUrl","getExpoApiBaseUrl","fetch","cacheDirectory","ttl","skipCache","env","EXPO_BETA","EXPO_NO_CACHE","wrapFetchWithCache","FileSystemCache","path","join","getExpoHomeDirectory","fetchAsync"],"mappings":"AAAA;;;;QA+CgBA,wBAAwB,GAAxBA,wBAAwB;QAoDxBC,iBAAiB,GAAjBA,iBAAiB;;AAnGI,IAAA,aAAiC,WAAjC,iCAAiC,CAAA;AAE5C,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACrB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEH,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACH,IAAA,SAAa,WAAb,aAAa,CAAA;AACtB,IAAA,aAAsB,kCAAtB,sBAAsB,EAAA;AACf,IAAA,gBAAyB,WAAzB,yBAAyB,CAAA;AACtB,IAAA,mBAA4B,WAA5B,4BAA4B,CAAA;AAE1B,IAAA,qBAAwB,WAAxB,wBAAwB,CAAA;AACxB,IAAA,qBAAwB,WAAxB,wBAAwB,CAAA;;;;;;AAEtD,MAAMC,UAAU,SAASC,KAAK;IACnC,AAASC,IAAI,GAAG,YAAY,CAAC;IAM7BC,YAAYC,QAMX,CAAE;QACD,KAAK,CAACA,QAAQ,CAACC,OAAO,CAAC,CAAC;QACxB,IAAI,CAACC,kBAAkB,GAAGF,QAAQ,CAACG,IAAI,CAAC;QACxC,IAAI,CAACC,qBAAqB,GAAGJ,QAAQ,CAACK,OAAO,CAAC;QAC9C,IAAI,CAACC,yBAAyB,GAAGN,QAAQ,CAACO,KAAK,CAAC;QAChD,IAAI,CAACC,sBAAsB,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AED,OAAOqC,CAAAA,GAAAA,mBAAkB,AAMxB,CAAA,mBANwB,CACvBP,KAAK,WAALA,KAAK,GAAI9B,oBAAoB,EAC7B,IAAIsC,gBAAe,gBAAA,CAAC;QAClBP,cAAc,EAAEQ,KAAI,QAAA,CAACC,IAAI,CAACC,CAAAA,GAAAA,aAAoB,AAAE,CAAA,qBAAF,EAAE,EAAEV,cAAc,CAAC;QACjEC,GAAG;KACJ,CAAC,CACH,CAAC;CACH;AAGM,MAAMU,UAAU,GAAG5D,wBAAwB,CAAC6C,gBAAgB,CAAC,AAAC;QAAxDe,UAAU,GAAVA,UAAU"}
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 { env } from '../../utils/env';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport UserSettings from '../user/UserSettings';\nimport { FileSystemCache } from './cache/FileSystemCache';\nimport { wrapFetchWithCache } from './cache/wrapFetchWithCache';\nimport { FetchLike } from './client.types';\nimport { wrapFetchWithBaseUrl } from './wrapFetchWithBaseUrl';\nimport { wrapFetchWithOffline } from './wrapFetchWithOffline';\nimport { wrapFetchWithProxy } from './wrapFetchWithProxy';\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 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 };\n}\n\nconst fetchWithOffline = wrapFetchWithOffline(fetchInstance);\n\nconst fetchWithBaseUrl = wrapFetchWithBaseUrl(fetchWithOffline, getExpoApiBaseUrl() + '/v2/');\n\nconst fetchWithProxy = wrapFetchWithProxy(fetchWithBaseUrl);\n\nconst fetchWithCredentials = 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,\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 ?? fetchWithCredentials;\n }\n\n return wrapFetchWithCache(\n fetch ?? fetchWithCredentials,\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 = wrapFetchWithCredentials(fetchWithProxy);\n"],"names":["wrapFetchWithCredentials","createCachedFetch","ApiV2Error","Error","name","constructor","response","message","code","expoApiV2ErrorCode","expoApiV2ErrorDetails","details","expoApiV2ErrorServerStack","stack","expoApiV2ErrorMetadata","metadata","UnexpectedServerError","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","fetchWithOffline","wrapFetchWithOffline","fetchInstance","fetchWithBaseUrl","wrapFetchWithBaseUrl","getExpoApiBaseUrl","fetchWithProxy","wrapFetchWithProxy","fetch","cacheDirectory","ttl","skipCache","env","EXPO_BETA","EXPO_NO_CACHE","wrapFetchWithCache","FileSystemCache","path","join","getExpoHomeDirectory","fetchAsync"],"mappings":"AAAA;;;;QAkDgBA,wBAAwB,GAAxBA,wBAAwB;QAsDxBC,iBAAiB,GAAjBA,iBAAiB;;AAxGI,IAAA,aAAiC,WAAjC,iCAAiC,CAAA;AAE5C,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACrB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEH,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACH,IAAA,SAAa,WAAb,aAAa,CAAA;AACtB,IAAA,aAAsB,kCAAtB,sBAAsB,EAAA;AACf,IAAA,gBAAyB,WAAzB,yBAAyB,CAAA;AACtB,IAAA,mBAA4B,WAA5B,4BAA4B,CAAA;AAE1B,IAAA,qBAAwB,WAAxB,wBAAwB,CAAA;AACxB,IAAA,qBAAwB,WAAxB,wBAAwB,CAAA;AAC1B,IAAA,mBAAsB,WAAtB,s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,EAAEK,CAAAA,GAAAA,SAAiB,AAAE,CAAA,kBAAF,EAAE,GAAG,MAAM,CAAC,AAAC;AAE9F,MAAMC,cAAc,GAAGC,CAAAA,GAAAA,mBAAkB,AAAkB,CAAA,mBAAlB,CAACJ,gBAAgB,CAAC,AAAC;AAE5D,MAAM3B,oBAAoB,GAAGlB,wBAAwB,CAACgD,cAAc,CAAC,AAAC;AAM/D,SAAS/C,iBAAiB,CAAC,EAChCiD,KAAK,CAAA,EACLC,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,WAALA,KAAK,GAAIhC,oBAAoB,CAAC;KACtC;IAED,OAAOuC,CAAAA,GAAAA,mBAAkB,AAMxB,CAAA,mBANwB,CACvBP,KAAK,WAALA,KAAK,GAAIhC,oBAAoB,EAC7B,IAAIwC,gBAAe,gBAAA,CAAC;QAClBP,cAAc,EAAEQ,KAAI,QAAA,CAACC,IAAI,CAACC,CAAAA,GAAAA,aAAoB,AAAE,CAAA,qBAAF,EAAE,EAAEV,cAAc,CAAC;QACjEC,GAAG;KACJ,CAAC,CACH,CAAC;CACH;AAGM,MAAMU,UAAU,GAAG9D,wBAAwB,CAACgD,cAAc,CAAC,AAAC;QAAtDc,UAAU,GAAVA,UAAU"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.wrapFetchWithProxy = wrapFetchWithProxy;
6
+ var _httpsProxyAgent = _interopRequireDefault(require("https-proxy-agent"));
7
+ var _env = require("../../utils/env");
8
+ function _interopRequireDefault(obj) {
9
+ return obj && obj.__esModule ? obj : {
10
+ default: obj
11
+ };
12
+ }
13
+ const debug = require("debug")("expo:api:fetch:proxy");
14
+ function wrapFetchWithProxy(fetchFunction) {
15
+ return async function fetchWithProxy(url, options = {}) {
16
+ const proxy = _env.env.HTTP_PROXY;
17
+ if (!options.agent && proxy) {
18
+ debug("Using proxy:", proxy);
19
+ options.agent = (0, _httpsProxyAgent).default(proxy);
20
+ }
21
+ return fetchFunction(url, options);
22
+ };
23
+ }
24
+
25
+ //# sourceMappingURL=wrapFetchWithProxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/api/rest/wrapFetchWithProxy.ts"],"sourcesContent":["import createHttpsProxyAgent from 'https-proxy-agent';\n\nimport { env } from '../../utils/env';\nimport { FetchLike } from './client.types';\n\nconst debug = require('debug')('expo:api:fetch:proxy') as typeof console.log;\n\n/** Wrap fetch with support for proxies. */\nexport function wrapFetchWithProxy(fetchFunction: FetchLike): FetchLike {\n return async function fetchWithProxy(url, options = {}) {\n const proxy = env.HTTP_PROXY;\n if (!options.agent && proxy) {\n debug('Using proxy:', proxy);\n options.agent = createHttpsProxyAgent(proxy);\n }\n return fetchFunction(url, options);\n };\n}\n"],"names":["wrapFetchWithProxy","debug","require","fetchFunction","fetchWithProxy","url","options","proxy","env","HTTP_PROXY","agent","createHttpsProxyAgent"],"mappings":"AAAA;;;;QAQgBA,kBAAkB,GAAlBA,kBAAkB;AARA,IAAA,gBAAmB,kCAAnB,mBAAmB,EAAA;AAEjC,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;;;;;;AAGrC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sBAAsB,CAAC,AAAsB,AAAC;AAGtE,SAASF,kBAAkB,CAACG,aAAwB,EAAa;IACtE,OAAO,eAAeC,cAAc,CAACC,GAAG,EAAEC,OAAO,GAAG,EAAE,EAAE;QACtD,MAAMC,KAAK,GAAGC,IAAG,IAAA,CAACC,UAAU,AAAC;QAC7B,IAAI,CAACH,OAAO,CAACI,KAAK,IAAIH,KAAK,EAAE;YAC3BN,KAAK,CAAC,cAAc,EAAEM,KAAK,CAAC,CAAC;YAC7BD,OAAO,CAACI,KAAK,GAAGC,CAAAA,GAAAA,gBAAqB,AAAO,CAAA,QAAP,CAACJ,KAAK,CAAC,CAAC;SAC9C;QACD,OAAOJ,aAAa,CAACE,GAAG,EAAEC,OAAO,CAAC,CAAC;KACpC,CAAC;CACH"}
@@ -59,7 +59,8 @@ async function bundleAsync(projectRoot, expoConfig, options, bundles) {
59
59
  reporter,
60
60
  ...options
61
61
  });
62
- config = (0, _withMetroMultiPlatform).withMetroMultiPlatform(projectRoot, config, (0, _platformBundlers).getPlatformBundlers(exp));
62
+ const bundlerPlatforms = (0, _platformBundlers).getPlatformBundlers(exp);
63
+ config = await (0, _withMetroMultiPlatform).withMetroMultiPlatformAsync(projectRoot, config, bundlerPlatforms);
63
64
  const metroServer = await metro.runMetro(config, {
64
65
  watch: false
65
66
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/fork-bundleAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig, getConfigFilePaths, Platform } from '@expo/config';\nimport {\n buildHermesBundleAsync,\n isEnableHermesManaged,\n maybeThrowFromInconsistentEngineAsync,\n} from '@expo/dev-server/build/HermesBundler';\nimport {\n importExpoMetroConfigFromProject,\n importMetroFromProject,\n importMetroServerFromProject,\n} from '@expo/dev-server/build/metro/importMetroFromProject';\nimport { LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport Metro from 'metro';\nimport { Terminal } from 'metro-core';\n\nimport { MetroTerminalReporter } from '../start/server/metro/MetroTerminalReporter';\nimport { withMetroMultiPlatform } from '../start/server/metro/withMetroMultiPlatform';\nimport { getPlatformBundlers } from '../start/server/platformBundlers';\n\nexport type MetroDevServerOptions = LoadOptions & {\n logger: import('@expo/bunyan');\n quiet?: boolean;\n};\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n sourceMapUrl?: string;\n};\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\nexport type BundleOutput = {\n code: string;\n map: string;\n hermesBytecodeBundle?: Uint8Array;\n hermesSourcemap?: string;\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nfunction getExpoMetroConfig(\n projectRoot: string,\n { logger }: Pick<MetroDevServerOptions, 'logger'>\n): typeof import('@expo/metro-config') {\n try {\n return importExpoMetroConfigFromProject(projectRoot);\n } catch {\n // If expo isn't installed, use the unversioned config and warn about installing expo.\n }\n\n const unversionedVersion = require('@expo/metro-config/package.json').version;\n logger.info(\n { tag: 'expo' },\n chalk.gray(\n `\\u203A Unversioned ${chalk.bold`@expo/metro-config@${unversionedVersion}`} is being used. Bundling apps may not work as expected, and is subject to breaking changes. Install ${chalk.bold`expo`} or set the app.json sdkVersion to use a stable version of @expo/metro-config.`\n )\n );\n\n return require('@expo/metro-config');\n}\n\nlet nextBuildID = 0;\n\n// Fork of @expo/dev-server bundleAsync to add Metro logging back.\n\nasync function assertEngineMismatchAsync(projectRoot: string, exp: ExpoConfig, platform: Platform) {\n const isHermesManaged = isEnableHermesManaged(exp, platform);\n\n const paths = getConfigFilePaths(projectRoot);\n const configFilePath = paths.dynamicConfigPath ?? paths.staticConfigPath ?? 'app.json';\n await maybeThrowFromInconsistentEngineAsync(\n projectRoot,\n configFilePath,\n platform,\n isHermesManaged\n );\n}\n\nexport async function bundleAsync(\n projectRoot: string,\n expoConfig: ExpoConfig,\n options: MetroDevServerOptions,\n bundles: BundleOptions[]\n): Promise<BundleOutput[]> {\n // Assert early so the user doesn't have to wait until bundling is complete to find out that\n // Hermes won't be available.\n await Promise.all(\n bundles.map(({ platform }) => assertEngineMismatchAsync(projectRoot, expoConfig, platform))\n );\n\n const metro = importMetroFromProject(projectRoot);\n const Server = importMetroServerFromProject(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(projectRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n },\n };\n\n const ExpoMetroConfig = getExpoMetroConfig(projectRoot, options);\n\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n let config = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n config = withMetroMultiPlatform(projectRoot, config, getPlatformBundlers(exp));\n\n const metroServer = await metro.runMetro(config, {\n watch: false,\n });\n\n const buildAsync = async (bundle: BundleOptions): Promise<BundleOutput> => {\n const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;\n const bundleOptions: Metro.BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n bundleType: 'bundle',\n platform: bundle.platform,\n entryFile: bundle.entryPoint,\n dev: bundle.dev ?? false,\n minify: bundle.minify ?? !bundle.dev,\n inlineSourceMap: false,\n sourceMapUrl: bundle.sourceMapUrl,\n createModuleIdFactory: config.serializer.createModuleIdFactory,\n onProgress: (transformedFileCount: number, totalFileCount: number) => {\n if (!options.quiet) {\n terminalReporter.update({\n buildID,\n type: 'bundle_transform_progressed',\n transformedFileCount,\n totalFileCount,\n });\n }\n },\n };\n const bundleDetails = {\n ...bundleOptions,\n buildID,\n };\n terminalReporter.update({\n buildID,\n type: 'bundle_build_started',\n // @ts-expect-error: TODO\n bundleDetails,\n });\n try {\n const { code, map } = await metroServer.build(bundleOptions);\n const assets = (await metroServer.getAssets(\n bundleOptions\n )) as readonly BundleAssetWithFileHashes[];\n terminalReporter.update({\n buildID,\n type: 'bundle_build_done',\n });\n return { code, map, assets };\n } catch (error) {\n terminalReporter.update({\n buildID,\n type: 'bundle_build_failed',\n });\n\n throw error;\n }\n };\n\n const maybeAddHermesBundleAsync = async (\n bundle: BundleOptions,\n bundleOutput: BundleOutput\n ): Promise<BundleOutput> => {\n const { platform } = bundle;\n const isHermesManaged = isEnableHermesManaged(expoConfig, platform);\n if (isHermesManaged) {\n const platformTag = chalk.bold(\n { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform\n );\n\n terminalReporter.terminal.log(`${platformTag} Building Hermes bytecode for the bundle`);\n\n const hermesBundleOutput = await buildHermesBundleAsync(\n projectRoot,\n bundleOutput.code,\n bundleOutput.map,\n bundle.minify\n );\n bundleOutput.hermesBytecodeBundle = hermesBundleOutput.hbc;\n bundleOutput.hermesSourcemap = hermesBundleOutput.sourcemap;\n }\n return bundleOutput;\n };\n\n try {\n const intermediateOutputs = await Promise.all(bundles.map((bundle) => buildAsync(bundle)));\n const bundleOutputs: BundleOutput[] = [];\n for (let i = 0; i < bundles.length; ++i) {\n // hermesc does not support parallel building even we spawn processes.\n // we should build them sequentially.\n bundleOutputs.push(await maybeAddHermesBundleAsync(bundles[i], intermediateOutputs[i]));\n }\n return bundleOutputs;\n } catch (error) {\n // New line so errors don't show up inline with the progress bar\n console.log('');\n throw error;\n } finally {\n metroServer.end();\n }\n}\n"],"names":["bundleAsync","getExpoMetroConfig","projectRoot","logger","importExpoMetroConfigFromProject","unversionedVersion","require","version","info","tag","chalk","gray","bold","nextBuildID","assertEngineMismatchAsync","exp","platform","isHermesManaged","isEnableHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","maybeThrowFromInconsistentEngineAsync","expoConfig","options","bundles","Promise","all","map","metro","importMetroFromProject","Server","importMetroServerFromProject","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","ExpoMetroConfig","getConfig","skipSDKVersionRequirement","config","loadAsync","withMetroMultiPlatform","getPlatformBundlers","metroServer","runMetro","watch","buildAsync","bundle","buildID","bundleOptions","DEFAULT_BUNDLE_OPTIONS","bundleType","entryFile","entryPoint","dev","minify","inlineSourceMap","sourceMapUrl","createModuleIdFactory","serializer","onProgress","transformedFileCount","totalFileCount","quiet","type","bundleDetails","code","build","assets","getAssets","error","maybeAddHermesBundleAsync","bundleOutput","platformTag","ios","android","web","log","hermesBundleOutput","buildHermesBundleAsync","hermesBytecodeBundle","hbc","hermesSourcemap","sourcemap","intermediateOutputs","bundleOutputs","i","length","push","console","end"],"mappings":"AAAA;;;;QAgFsBA,WAAW,GAAXA,WAAW;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EmB,OAAO,CAACZ,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,MAAMP,KAAK,CAAC;KACb,QAAS;QACR3B,WAAW,CAAC+C,GAAG,EAAE,CAAC;KACnB;CACF"}
1
+ {"version":3,"sources":["../../../src/export/fork-bundleAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig, getConfigFilePaths, Platform } from '@expo/config';\nimport {\n buildHermesBundleAsync,\n isEnableHermesManaged,\n maybeThrowFromInconsistentEngineAsync,\n} from '@expo/dev-server/build/HermesBundler';\nimport {\n importExpoMetroConfigFromProject,\n importMetroFromProject,\n importMetroServerFromProject,\n} from '@expo/dev-server/build/metro/importMetroFromProject';\nimport { LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport Metro from 'metro';\nimport { Terminal } from 'metro-core';\n\nimport { MetroTerminalReporter } from '../start/server/metro/MetroTerminalReporter';\nimport { withMetroMultiPlatformAsync } from '../start/server/metro/withMetroMultiPlatform';\nimport { getPlatformBundlers } from '../start/server/platformBundlers';\n\nexport type MetroDevServerOptions = LoadOptions & {\n logger: import('@expo/bunyan');\n quiet?: boolean;\n};\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n sourceMapUrl?: string;\n};\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\nexport type BundleOutput = {\n code: string;\n map: string;\n hermesBytecodeBundle?: Uint8Array;\n hermesSourcemap?: string;\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nfunction getExpoMetroConfig(\n projectRoot: string,\n { logger }: Pick<MetroDevServerOptions, 'logger'>\n): typeof import('@expo/metro-config') {\n try {\n return importExpoMetroConfigFromProject(projectRoot);\n } catch {\n // If expo isn't installed, use the unversioned config and warn about installing expo.\n }\n\n const unversionedVersion = require('@expo/metro-config/package.json').version;\n logger.info(\n { tag: 'expo' },\n chalk.gray(\n `\\u203A Unversioned ${chalk.bold`@expo/metro-config@${unversionedVersion}`} is being used. Bundling apps may not work as expected, and is subject to breaking changes. Install ${chalk.bold`expo`} or set the app.json sdkVersion to use a stable version of @expo/metro-config.`\n )\n );\n\n return require('@expo/metro-config');\n}\n\nlet nextBuildID = 0;\n\n// Fork of @expo/dev-server bundleAsync to add Metro logging back.\n\nasync function assertEngineMismatchAsync(projectRoot: string, exp: ExpoConfig, platform: Platform) {\n const isHermesManaged = isEnableHermesManaged(exp, platform);\n\n const paths = getConfigFilePaths(projectRoot);\n const configFilePath = paths.dynamicConfigPath ?? paths.staticConfigPath ?? 'app.json';\n await maybeThrowFromInconsistentEngineAsync(\n projectRoot,\n configFilePath,\n platform,\n isHermesManaged\n );\n}\n\nexport async function bundleAsync(\n projectRoot: string,\n expoConfig: ExpoConfig,\n options: MetroDevServerOptions,\n bundles: BundleOptions[]\n): Promise<BundleOutput[]> {\n // Assert early so the user doesn't have to wait until bundling is complete to find out that\n // Hermes won't be available.\n await Promise.all(\n bundles.map(({ platform }) => assertEngineMismatchAsync(projectRoot, expoConfig, platform))\n );\n\n const metro = importMetroFromProject(projectRoot);\n const Server = importMetroServerFromProject(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(projectRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n },\n };\n\n const ExpoMetroConfig = getExpoMetroConfig(projectRoot, options);\n\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n let config = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n\n const bundlerPlatforms = getPlatformBundlers(exp);\n\n config = await withMetroMultiPlatformAsync(projectRoot, config, bundlerPlatforms);\n\n const metroServer = await metro.runMetro(config, {\n watch: false,\n });\n\n const buildAsync = async (bundle: BundleOptions): Promise<BundleOutput> => {\n const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;\n const bundleOptions: Metro.BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n bundleType: 'bundle',\n platform: bundle.platform,\n entryFile: bundle.entryPoint,\n dev: bundle.dev ?? false,\n minify: bundle.minify ?? !bundle.dev,\n inlineSourceMap: false,\n sourceMapUrl: bundle.sourceMapUrl,\n createModuleIdFactory: config.serializer.createModuleIdFactory,\n onProgress: (transformedFileCount: number, totalFileCount: number) => {\n if (!options.quiet) {\n terminalReporter.update({\n buildID,\n type: 'bundle_transform_progressed',\n transformedFileCount,\n totalFileCount,\n });\n }\n },\n };\n const bundleDetails = {\n ...bundleOptions,\n buildID,\n };\n terminalReporter.update({\n buildID,\n type: 'bundle_build_started',\n // @ts-expect-error: TODO\n bundleDetails,\n });\n try {\n const { code, map } = await metroServer.build(bundleOptions);\n const assets = (await metroServer.getAssets(\n bundleOptions\n )) as readonly BundleAssetWithFileHashes[];\n terminalReporter.update({\n buildID,\n type: 'bundle_build_done',\n });\n return { code, map, assets };\n } catch (error) {\n terminalReporter.update({\n buildID,\n type: 'bundle_build_failed',\n });\n\n throw error;\n }\n };\n\n const maybeAddHermesBundleAsync = async (\n bundle: BundleOptions,\n bundleOutput: BundleOutput\n ): Promise<BundleOutput> => {\n const { platform } = bundle;\n const isHermesManaged = isEnableHermesManaged(expoConfig, platform);\n if (isHermesManaged) {\n const platformTag = chalk.bold(\n { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform\n );\n\n terminalReporter.terminal.log(`${platformTag} Building Hermes bytecode for the bundle`);\n\n const hermesBundleOutput = await buildHermesBundleAsync(\n projectRoot,\n bundleOutput.code,\n bundleOutput.map,\n bundle.minify\n );\n bundleOutput.hermesBytecodeBundle = hermesBundleOutput.hbc;\n bundleOutput.hermesSourcemap = hermesBundleOutput.sourcemap;\n }\n return bundleOutput;\n };\n\n try {\n const intermediateOutputs = await Promise.all(bundles.map((bundle) => buildAsync(bundle)));\n const bundleOutputs: BundleOutput[] = [];\n for (let i = 0; i < bundles.length; ++i) {\n // hermesc does not support parallel building even we spawn processes.\n // we should build them sequentially.\n bundleOutputs.push(await maybeAddHermesBundleAsync(bundles[i], intermediateOutputs[i]));\n }\n return bundleOutputs;\n } catch (error) {\n // New line so errors don't show up inline with the progress bar\n console.log('');\n throw error;\n } finally {\n metroServer.end();\n }\n}\n"],"names":["bundleAsync","getExpoMetroConfig","projectRoot","logger","importExpoMetroConfigFromProject","unversionedVersion","require","version","info","tag","chalk","gray","bold","nextBuildID","assertEngineMismatchAsync","exp","platform","isHermesManaged","isEnableHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","maybeThrowFromInconsistentEngineAsync","expoConfig","options","bundles","Promise","all","map","metro","importMetroFromProject","Server","importMetroServerFromProject","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","ExpoMetroConfig","getConfig","skipSDKVersionRequirement","config","loadAsync","bundlerPlatforms","getPlatformBundlers","withMetroMultiPlatformAsync","metroServer","runMetro","watch","buildAsync","bundle","buildID","bundleOptions","DEFAULT_BUNDLE_OPTIONS","bundleType","entryFile","entryPoint","dev","minify","inlineSourceMap","sourceMapUrl","createModuleIdFactory","serializer","onProgress","transformedFileCount","totalFileCount","quiet","type","bundleDetails","code","build","assets","getAssets","error","maybeAddHermesBundleAsync","bundleOutput","platformTag","ios","android","web","log","hermesBundleOutput","buildHermesBundleAsync","hermesBytecodeBundle","hbc","hermesSourcemap","sourcemap","intermediateOutputs","bundleOutputs","i","length","push","console","end"],"mappings":"AAAA;;;;QAgFsBA,WAAW,GAAXA,WAAW;AAhFmC,IAAA,OAAc,WAAd,cAAc,CAAA;AAK3E,IAAA,cAAsC,WAAtC,sCAAsC,CAAA;AAKtC,IAAA,uBAAqD,WAArD,qDAAqD,CAAA;AAE1C,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEA,IAAA,UAAY,WAAZ,YAAY,CAAA;AAEC,IAAA,sBAA6C,WAA7C,6CAA6C,CAAA;AACvC,IAAA,uBAA8C,WAA9C,8CAA8C,CAAA;AACtD,IAAA,iBAAkC,WAAlC,kCAAkC,CAA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AAG,CAAC,CAAC,EAAEJ,WAAW,CAAC,wCAAwC,CAAC,CAAC,CAAC;YAExF,MAAMK,kBAAkB,GAAG,MAAMC,CAAAA,GAAAA,cAAsB,AAKtD,CAAA,uBALsD,CACrDtF,WAAW,EACX+E,YAAY,CAACN,IAAI,EACjBM,YAAY,CAACnD,GAAG,EAChB0B,MAAM,CAACQ,MAAM,CACd,AAAC;YACFiB,YAAY,CAACQ,oBAAoB,GAAGF,kBAAkB,CAACG,GAAG,CAAC;YAC3DT,YAAY,CAACU,eAAe,GAAGJ,kBAAkB,CAACK,SAAS,CAAC;SAC7D;QACD,OAAOX,YAAY,CAAC;KACrB,AAAC;IAEF,IAAI;QACF,MAAMY,mBAAmB,GAAG,MAAMjE,OAAO,CAACC,GAAG,CAACF,OAAO,CAACG,GAAG,CAAC,CAAC0B,MAAM,GAAKD,UAAU,CAACC,MAAM,CAAC;QAAA,CAAC,CAAC,AAAC;QAC3F,MAAMsC,aAAa,GAAmB,EAAE,AAAC;QACzC,IAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGpE,OAAO,CAACqE,MAAM,EAAE,EAAED,CAAC,CAAE;YACvC,sEAAsE;YACtE,qCAAqC;YACrCD,aAAa,CAACG,IAAI,CAAC,MAAMjB,yBAAyB,CAACrD,OAAO,CAACoE,CAAC,CAAC,EAAEF,mBAAmB,CAACE,CAAC,CAAC,CAAC,CAAC,CAAC;SACzF;QACD,OAAOD,aAAa,CAAC;KACtB,CAAC,OAAOf,KAAK,EAAE;QACd,gEAAgE;QAChEmB,OAAO,CAACZ,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,MAAMP,KAAK,CAAC;KACb,QAAS;QACR3B,WAAW,CAAC+C,GAAG,EAAE,CAAC;KACnB;CACF"}
@@ -22,13 +22,17 @@ function resolveOptions(options) {
22
22
  }
23
23
  async function resolveArgsAsync(argv) {
24
24
  const { variadic , extras , flags } = (0, _variadic).parseVariadicArguments(argv);
25
- (0, _variadic).assertUnexpectedObjectKeys([
25
+ (0, _variadic).assertUnexpectedVariadicFlags([
26
26
  "--check",
27
27
  "--fix",
28
28
  "--npm",
29
29
  "--pnpm",
30
30
  "--yarn"
31
- ], flags);
31
+ ], {
32
+ variadic,
33
+ extras,
34
+ flags
35
+ }, "npx expo install");
32
36
  return {
33
37
  // Variadic arguments like `npx expo install react react-dom` -> ['react', 'react-dom']
34
38
  variadic,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/install/resolveOptions.ts"],"sourcesContent":["import * as PackageManager from '@expo/package-manager';\n\nimport { CommandError } from '../utils/errors';\nimport { assertUnexpectedObjectKeys, parseVariadicArguments } from '../utils/variadic';\n\nexport type Options = Pick<PackageManager.CreateForProjectOptions, 'npm' | 'pnpm' | 'yarn'> & {\n /** Check which packages need to be updated, does not install any provided packages. */\n check?: boolean;\n /** Should the dependencies be fixed automatically. */\n fix?: boolean;\n /** Should disable install output, used for commands like `prebuild` that run install internally. */\n silent?: boolean;\n};\n\nfunction resolveOptions(options: Options): Options {\n if (options.fix && options.check) {\n throw new CommandError('BAD_ARGS', 'Specify at most one of: --check, --fix');\n }\n if ([options.npm, options.pnpm, options.yarn].filter(Boolean).length > 1) {\n throw new CommandError('BAD_ARGS', 'Specify at most one of: --npm, --pnpm, --yarn');\n }\n return {\n ...options,\n };\n}\n\nexport async function resolveArgsAsync(\n argv: string[]\n): Promise<{ variadic: string[]; options: Options; extras: string[] }> {\n const { variadic, extras, flags } = parseVariadicArguments(argv);\n\n assertUnexpectedObjectKeys(['--check', '--fix', '--npm', '--pnpm', '--yarn'], flags);\n\n return {\n // Variadic arguments like `npx expo install react react-dom` -> ['react', 'react-dom']\n variadic,\n options: resolveOptions({\n fix: !!flags['--fix'],\n check: !!flags['--check'],\n yarn: !!flags['--yarn'],\n npm: !!flags['--npm'],\n pnpm: !!flags['--pnpm'],\n }),\n extras,\n };\n}\n"],"names":["resolveArgsAsync","resolveOptions","options","fix","check","CommandError","npm","pnpm","yarn","filter","Boolean","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,CAAC,CAACS,KAAK,CAAC,OAAO,CAAC;YACrBR,IAAI,EAAE,CAAC,CAACQ,KAAK,CAAC,QAAQ,CAAC;SACxB,CAAC;QACFD,MAAM;KACP,CAAC;CACH"}
1
+ {"version":3,"sources":["../../../src/install/resolveOptions.ts"],"sourcesContent":["import * as PackageManager from '@expo/package-manager';\n\nimport { CommandError } from '../utils/errors';\nimport { assertUnexpectedVariadicFlags, parseVariadicArguments } from '../utils/variadic';\n\nexport type Options = Pick<PackageManager.CreateForProjectOptions, 'npm' | 'pnpm' | 'yarn'> & {\n /** Check which packages need to be updated, does not install any provided packages. */\n check?: boolean;\n /** Should the dependencies be fixed automatically. */\n fix?: boolean;\n /** Should disable install output, used for commands like `prebuild` that run install internally. */\n silent?: boolean;\n};\n\nfunction resolveOptions(options: Options): Options {\n if (options.fix && options.check) {\n throw new CommandError('BAD_ARGS', 'Specify at most one of: --check, --fix');\n }\n if ([options.npm, options.pnpm, options.yarn].filter(Boolean).length > 1) {\n throw new CommandError('BAD_ARGS', 'Specify at most one of: --npm, --pnpm, --yarn');\n }\n return {\n ...options,\n };\n}\n\nexport async function resolveArgsAsync(\n argv: string[]\n): Promise<{ variadic: string[]; options: Options; extras: string[] }> {\n const { variadic, extras, flags } = parseVariadicArguments(argv);\n\n assertUnexpectedVariadicFlags(\n ['--check', '--fix', '--npm', '--pnpm', '--yarn'],\n { variadic, extras, flags },\n 'npx expo install'\n );\n\n return {\n // Variadic arguments like `npx expo install react react-dom` -> ['react', 'react-dom']\n variadic,\n options: resolveOptions({\n fix: !!flags['--fix'],\n check: !!flags['--check'],\n yarn: !!flags['--yarn'],\n npm: !!flags['--npm'],\n pnpm: !!flags['--pnpm'],\n }),\n extras,\n };\n}\n"],"names":["resolveArgsAsync","resolveOptions","options","fix","check","CommandError","npm","pnpm","yarn","filter","Boolean","length","argv","variadic","extras","flags","parseVariadicArguments","assertUnexpectedVariadicFlags"],"mappings":"AAAA;;;;QA0BsBA,gBAAgB,GAAhBA,gB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;YACrBR,IAAI,EAAE,CAAC,CAACQ,KAAK,CAAC,QAAQ,CAAC;SACxB,CAAC;QACFD,MAAM;KACP,CAAC;CACH"}
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.createCopyFilesSuccessMessage = createCopyFilesSuccessMessage;
6
6
  exports.copyTemplateFilesAsync = copyTemplateFilesAsync;
7
- exports.resolveBareEntryFile = resolveBareEntryFile;
8
- var _paths = require("@expo/config/paths");
9
7
  var _chalk = _interopRequireDefault(require("chalk"));
10
8
  var _fs = _interopRequireDefault(require("fs"));
11
9
  var _path = _interopRequireDefault(require("path"));
12
10
  var _dir = require("../utils/dir");
13
11
  var _mergeGitIgnorePaths = require("../utils/mergeGitIgnorePaths");
14
- var _updatePackageJson = require("./updatePackageJson");
15
12
  function _interopRequireDefault(obj) {
16
13
  return obj && obj.__esModule ? obj : {
17
14
  default: obj
@@ -42,11 +39,14 @@ function createCopyFilesSuccessMessage(platforms, { skippedPaths , gitignore })
42
39
  }
43
40
  return message;
44
41
  }
45
- async function copyTemplateFilesAsync(projectRoot, { pkg , templateDirectory , platforms }) {
46
- const copyFilePaths = getFilePathsToCopy(projectRoot, pkg, platforms);
42
+ async function copyTemplateFilesAsync(projectRoot, { templateDirectory , platforms }) {
47
43
  const copyResults = await copyPathsFromTemplateAsync(projectRoot, {
48
44
  templateDirectory,
49
- copyFilePaths
45
+ copyFilePaths: [
46
+ // Just copy over the native folders from the template
47
+ // we copy the metro file in a different way.
48
+ ...platforms,
49
+ ]
50
50
  });
51
51
  const hasPlatformSpecificGitIgnores = hasAllPlatformSpecificGitIgnores(templateDirectory, platforms);
52
52
  debug(`All platforms have an internal gitignore: ${hasPlatformSpecificGitIgnores}`);
@@ -75,32 +75,5 @@ async function copyPathsFromTemplateAsync(/** File path to the project. */ proje
75
75
  skippedPaths
76
76
  };
77
77
  }
78
- /** Get a list of relative file paths to copy from the template folder. Example: `['ios', 'android', 'index.js']` */ function getFilePathsToCopy(projectRoot, pkg, platforms) {
79
- const targetPaths = [
80
- ...platforms
81
- ];
82
- const bareEntryFile = resolveBareEntryFile(projectRoot, pkg.main);
83
- // Only create index.js if we cannot resolve the existing entry point (after replacing the expo entry).
84
- if (!bareEntryFile) {
85
- targetPaths.push("index.js");
86
- }
87
- debug(`Files to copy:`, targetPaths);
88
- return targetPaths;
89
- }
90
- function resolveBareEntryFile(projectRoot, main) {
91
- // expo app entry is not needed for bare projects.
92
- if ((0, _updatePackageJson).isPkgMainExpoAppEntry(main)) {
93
- return null;
94
- }
95
- // Look at the `package.json`s `main` field for the main file.
96
- const resolvedMainField = main != null ? main : "./index";
97
- // Get a list of possible extensions for the main file.
98
- const extensions = (0, _paths).getBareExtensions([
99
- "ios",
100
- "android"
101
- ]);
102
- // Testing the main field against all of the provided extensions - for legacy reasons we can't use node module resolution as the package.json allows you to pass in a file without a relative path and expect it as a relative path.
103
- return (0, _paths).getFileWithExtensions(projectRoot, resolvedMainField, extensions);
104
- }
105
78
 
106
79
  //# sourceMappingURL=copyTemplateFiles.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/copyTemplateFiles.ts"],"sourcesContent":["import { PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport { MergeResults } from '@expo/config-plugins/build/utils/generateCode';\nimport { getBareExtensions, getFileWithExtensions } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { copySync, directoryExistsAsync } from '../utils/dir';\nimport { mergeGitIgnorePaths } from '../utils/mergeGitIgnorePaths';\nimport { isPkgMainExpoAppEntry } from './updatePackageJson';\n\nconst debug = require('debug')('expo:prebuild:copyTemplateFiles') as typeof console.log;\n\ntype CopyFilesResults = {\n /** Merge results for the root `.gitignore` file */\n gitignore: MergeResults | null;\n /** List of file paths that were copied from the template into the project. */\n copiedPaths: string[];\n /** List of file paths that were skipped due to a number of factors. */\n skippedPaths: string[];\n};\n\n/**\n * Return true if the given platforms all have an internal `.gitignore` file.\n *\n * @param projectRoot\n * @param platforms\n */\nfunction hasAllPlatformSpecificGitIgnores(projectRoot: string, platforms: ModPlatform[]): boolean {\n return platforms.reduce<boolean>(\n (p, platform) => p && fs.existsSync(path.join(projectRoot, platform, '.gitignore')),\n true\n );\n}\n\n/** Create a custom log message based on the copy file results. */\nexport function createCopyFilesSuccessMessage(\n platforms: ModPlatform[],\n { skippedPaths, gitignore }: CopyFilesResults\n): string {\n let message = `Created native project${platforms.length > 1 ? 's' : ''}`;\n\n if (skippedPaths.length) {\n message += chalk.dim(\n ` | ${skippedPaths.map((path) => chalk.bold(`/${path}`)).join(', ')} already created`\n );\n }\n if (!gitignore) {\n message += chalk.dim(` | gitignore skipped`);\n } else if (!gitignore.didMerge) {\n message += chalk.dim(` | gitignore already synced`);\n } else if (gitignore.didMerge && gitignore.didClear) {\n message += chalk.dim(` | synced gitignore`);\n }\n return message;\n}\n\n/** Copy template files into the project and possibly merge the `.gitignore` files. */\nexport async function copyTemplateFilesAsync(\n projectRoot: string,\n {\n pkg,\n templateDirectory,\n platforms,\n }: {\n /** Project `package.json` as JSON. */\n pkg: PackageJSONConfig;\n /** File path to the template directory. */\n templateDirectory: string;\n /** List of platforms to copy against. */\n platforms: ModPlatform[];\n }\n): Promise<CopyFilesResults> {\n const copyFilePaths = getFilePathsToCopy(projectRoot, pkg, platforms);\n\n const copyResults = await copyPathsFromTemplateAsync(projectRoot, {\n templateDirectory,\n copyFilePaths,\n });\n\n const hasPlatformSpecificGitIgnores = hasAllPlatformSpecificGitIgnores(\n templateDirectory,\n platforms\n );\n debug(`All platforms have an internal gitignore: ${hasPlatformSpecificGitIgnores}`);\n const gitignore = hasPlatformSpecificGitIgnores\n ? null\n : mergeGitIgnorePaths(\n path.join(projectRoot, '.gitignore'),\n path.join(templateDirectory, '.gitignore')\n );\n\n return { ...copyResults, gitignore };\n}\n\nasync function copyPathsFromTemplateAsync(\n /** File path to the project. */\n projectRoot: string,\n {\n templateDirectory,\n copyFilePaths,\n }: {\n /** File path to the template project. */\n templateDirectory: string;\n /** List of relative paths to copy from the template to the project. */\n copyFilePaths: string[];\n }\n): Promise<Pick<CopyFilesResults, 'copiedPaths' | 'skippedPaths'>> {\n const copiedPaths = [];\n const skippedPaths = [];\n for (const copyFilePath of copyFilePaths) {\n const projectPath = path.join(projectRoot, copyFilePath);\n if (!(await directoryExistsAsync(projectPath))) {\n copiedPaths.push(copyFilePath);\n copySync(path.join(templateDirectory, copyFilePath), projectPath);\n } else {\n skippedPaths.push(copyFilePath);\n }\n }\n debug(`Copied files:`, copiedPaths);\n debug(`Skipped files:`, copiedPaths);\n return { copiedPaths, skippedPaths };\n}\n\n/** Get a list of relative file paths to copy from the template folder. Example: `['ios', 'android', 'index.js']` */\nfunction getFilePathsToCopy(projectRoot: string, pkg: PackageJSONConfig, platforms: ModPlatform[]) {\n const targetPaths: string[] = [...platforms];\n\n const bareEntryFile = resolveBareEntryFile(projectRoot, pkg.main);\n // Only create index.js if we cannot resolve the existing entry point (after replacing the expo entry).\n if (!bareEntryFile) {\n targetPaths.push('index.js');\n }\n\n debug(`Files to copy:`, targetPaths);\n return targetPaths;\n}\n\nexport function resolveBareEntryFile(projectRoot: string, main: any) {\n // expo app entry is not needed for bare projects.\n if (isPkgMainExpoAppEntry(main)) {\n return null;\n }\n // Look at the `package.json`s `main` field for the main file.\n const resolvedMainField = main ?? './index';\n // Get a list of possible extensions for the main file.\n const extensions = getBareExtensions(['ios', 'android']);\n // Testing the main field against all of the provided extensions - for legacy reasons we can't use node module resolution as the package.json allows you to pass in a file without a relative path and expect it as a relative path.\n return getFileWithExtensions(projectRoot, resolvedMainField, extensions);\n}\n"],"names":["createCopyFilesSuccessMessage","copyTemplateFilesAsync","resolveBareEntryFile","debug","require","hasAllPlatformSpecificGitIgnores","projectRoot","platforms","reduce","p","platform","fs","existsSync","path","join","skippedPaths","gitignore","message","length","chalk","dim","map","bold","didMerge","didClear","pkg","templateDirectory","copyFilePaths","getFilePathsToCopy","copyResults","copyPathsFromTemplateAsync","hasPlatformSpecificGitIgnores","mergeGitIgnorePaths","copiedPaths","copyFilePath","projectPath","directoryExistsAsync","push","copySync","targetPaths","bareEntryFile","main","isPkgMainExpoAppEntry","resolvedMainField","extensions","getBareExtensions","getFileWithExtensions"],"mappings":"AAAA;;;;QAqCgBA,6BAA6B,GAA7BA,6BAA6B;QAsBvBC,sBAAsB,GAAtBA,sBAAsB;QAgF5BC,oBAAoB,GAApBA,oBAAoB;AAxIqB,IAAA,MAAoB,WAApB,oBAAoB,CAAA;AAC3D,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEwB,IAAA,IAAc,WAAd,cAAc,CAAA;AACzB,IAAA,oBAA8B,WAA9B,8BAA8B,CAAA;AAC5B,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;;;;;;AAE3D,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAWxF;;;;;GAKG,CACH,SAASC,gCAAgC,CAACC,WAAmB,EAAEC,SAAwB,EAAW;IAChG,OAAOA,SAAS,CAACC,MAAM,CACrB,CAACC,CAAC,EAAEC,QAAQ,GAAKD,CAAC,IAAIE,GAAE,QAAA,CAACC,UAAU,CAACC,KAAI,QAAA,CAACC,IAAI,CAACR,WAAW,EAAEI,QAAQ,EAAE,YAAY,CAAC,CAAC;IAAA,EACnF,IAAI,CACL,CAAC;CACH;AAGM,SAASV,6BAA6B,CAC3CO,SAAwB,EACxB,EAAEQ,YAAY,CAAA,EAAEC,SAAS,CAAA,EAAoB,EACrC;IACR,IAAIC,OAAO,GAAG,CAAC,sBAAsB,EAAEV,SAAS,CAACW,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC,AAAC;IAEzE,IAAIH,YAAY,CAACG,MAAM,EAAE;QACvBD,OAA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,AAAC;IAE7C,MAAMiC,aAAa,GAAGtC,oBAAoB,CAACI,WAAW,EAAEmB,GAAG,CAACgB,IAAI,CAAC,AAAC;IAClE,uGAAuG;IACvG,IAAI,CAACD,aAAa,EAAE;QAClBD,WAAW,CAACF,IAAI,CAAC,UAAU,CAAC,CAAC;KAC9B;IAEDlC,KAAK,CAAC,CAAC,cAAc,CAAC,EAAEoC,WAAW,CAAC,CAAC;IACrC,OAAOA,WAAW,CAAC;CACpB;AAEM,SAASrC,oBAAoB,CAACI,WAAmB,EAAEmC,IAAS,EAAE;IACnE,kDAAkD;IAClD,IAAIC,CAAAA,GAAAA,kBAAqB,AAAM,CAAA,sBAAN,CAACD,IAAI,CAAC,EAAE;QAC/B,OAAO,IAAI,CAAC;KACb;IACD,8DAA8D;IAC9D,MAAME,iBAAiB,GAAGF,IAAI,WAAJA,IAAI,GAAI,SAAS,AAAC;IAC5C,uDAAuD;IACvD,MAAMG,UAAU,GAAGC,CAAAA,GAAAA,MAAiB,AAAoB,CAAA,kBAApB,CAAC;QAAC,KAAK;QAAE,SAAS;KAAC,CAAC,AAAC;IACzD,oOAAoO;IACpO,OAAOC,CAAAA,GAAAA,MAAqB,AAA4C,CAAA,sBAA5C,CAACxC,WAAW,EAAEqC,iBAAiB,EAAEC,UAAU,CAAC,CAAC;CAC1E"}
1
+ {"version":3,"sources":["../../../src/prebuild/copyTemplateFiles.ts"],"sourcesContent":["import { ModPlatform } from '@expo/config-plugins';\nimport { MergeResults } from '@expo/config-plugins/build/utils/generateCode';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { copySync, directoryExistsAsync } from '../utils/dir';\nimport { mergeGitIgnorePaths } from '../utils/mergeGitIgnorePaths';\n\nconst debug = require('debug')('expo:prebuild:copyTemplateFiles') as typeof console.log;\n\ntype CopyFilesResults = {\n /** Merge results for the root `.gitignore` file */\n gitignore: MergeResults | null;\n /** List of file paths that were copied from the template into the project. */\n copiedPaths: string[];\n /** List of file paths that were skipped due to a number of factors. */\n skippedPaths: string[];\n};\n\n/**\n * Return true if the given platforms all have an internal `.gitignore` file.\n *\n * @param projectRoot\n * @param platforms\n */\nfunction hasAllPlatformSpecificGitIgnores(projectRoot: string, platforms: ModPlatform[]): boolean {\n return platforms.reduce<boolean>(\n (p, platform) => p && fs.existsSync(path.join(projectRoot, platform, '.gitignore')),\n true\n );\n}\n\n/** Create a custom log message based on the copy file results. */\nexport function createCopyFilesSuccessMessage(\n platforms: ModPlatform[],\n { skippedPaths, gitignore }: CopyFilesResults\n): string {\n let message = `Created native project${platforms.length > 1 ? 's' : ''}`;\n\n if (skippedPaths.length) {\n message += chalk.dim(\n ` | ${skippedPaths.map((path) => chalk.bold(`/${path}`)).join(', ')} already created`\n );\n }\n if (!gitignore) {\n message += chalk.dim(` | gitignore skipped`);\n } else if (!gitignore.didMerge) {\n message += chalk.dim(` | gitignore already synced`);\n } else if (gitignore.didMerge && gitignore.didClear) {\n message += chalk.dim(` | synced gitignore`);\n }\n return message;\n}\n\n/** Copy template files into the project and possibly merge the `.gitignore` files. */\nexport async function copyTemplateFilesAsync(\n projectRoot: string,\n {\n templateDirectory,\n platforms,\n }: {\n /** File path to the template directory. */\n templateDirectory: string;\n /** List of platforms to copy against. */\n platforms: ModPlatform[];\n }\n): Promise<CopyFilesResults> {\n const copyResults = await copyPathsFromTemplateAsync(projectRoot, {\n templateDirectory,\n copyFilePaths: [\n // Just copy over the native folders from the template\n // we copy the metro file in a different way.\n ...platforms,\n ],\n });\n\n const hasPlatformSpecificGitIgnores = hasAllPlatformSpecificGitIgnores(\n templateDirectory,\n platforms\n );\n debug(`All platforms have an internal gitignore: ${hasPlatformSpecificGitIgnores}`);\n const gitignore = hasPlatformSpecificGitIgnores\n ? null\n : mergeGitIgnorePaths(\n path.join(projectRoot, '.gitignore'),\n path.join(templateDirectory, '.gitignore')\n );\n\n return { ...copyResults, gitignore };\n}\n\nasync function copyPathsFromTemplateAsync(\n /** File path to the project. */\n projectRoot: string,\n {\n templateDirectory,\n copyFilePaths,\n }: {\n /** File path to the template project. */\n templateDirectory: string;\n /** List of relative paths to copy from the template to the project. */\n copyFilePaths: string[];\n }\n): Promise<Pick<CopyFilesResults, 'copiedPaths' | 'skippedPaths'>> {\n const copiedPaths = [];\n const skippedPaths = [];\n for (const copyFilePath of copyFilePaths) {\n const projectPath = path.join(projectRoot, copyFilePath);\n if (!(await directoryExistsAsync(projectPath))) {\n copiedPaths.push(copyFilePath);\n copySync(path.join(templateDirectory, copyFilePath), projectPath);\n } else {\n skippedPaths.push(copyFilePath);\n }\n }\n debug(`Copied files:`, copiedPaths);\n debug(`Skipped files:`, copiedPaths);\n return { copiedPaths, skippedPaths };\n}\n"],"names":["createCopyFilesSuccessMessage","copyTemplateFilesAsync","debug","require","hasAllPlatformSpecificGitIgnores","projectRoot","platforms","reduce","p","platform","fs","existsSync","path","join","skippedPaths","gitignore","message","length","chalk","dim","map","bold","didMerge","didClear","templateDirectory","copyResults","copyPathsFromTemplateAsync","copyFilePaths","hasPlatformSpecificGitIgnores","mergeGitIgnorePaths","copiedPaths","copyFilePath","projectPath","directoryExistsAsync","push","copySync"],"mappings":"AAAA;;;;QAkCgBA,6BAA6B,GAA7BA,6BAA6B;QAsBvBC,sBAAsB,GAAtBA,sBAAsB;AAtD1B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEwB,IAAA,IAAc,WAAd,cAAc,CAAA;AACzB,IAAA,oBAA8B,WAA9B,8BAA8B,CAAA;;;;;;AAElE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAWxF;;;;;GAKG,CACH,SAASC,gCAAgC,CAACC,WAAmB,EAAEC,SAAwB,EAAW;IAChG,OAAOA,SAAS,CAACC,MAAM,CACrB,CAACC,CAAC,EAAEC,QAAQ,GAAKD,CAAC,IAAIE,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H,YAAY,CAAC,CAAC;SACjC;KACF;IACD7B,KAAK,CAAC,CAAC,aAAa,CAAC,EAAE4B,WAAW,CAAC,CAAC;IACpC5B,KAAK,CAAC,CAAC,cAAc,CAAC,EAAE4B,WAAW,CAAC,CAAC;IACrC,OAAO;QAAEA,WAAW;QAAEhB,YAAY;KAAE,CAAC;CACtC"}
@@ -6,9 +6,9 @@ exports.cloneTemplateAsync = cloneTemplateAsync;
6
6
  exports.resolveTemplateArgAsync = resolveTemplateArgAsync;
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _fs = _interopRequireDefault(require("fs"));
9
- var _nodeFetch = _interopRequireDefault(require("node-fetch"));
10
9
  var _path = _interopRequireDefault(require("path"));
11
10
  var _semver = _interopRequireDefault(require("semver"));
11
+ var _client = require("../api/rest/client");
12
12
  var Log = _interopRequireWildcard(require("../log"));
13
13
  var _errors = require("../utils/errors");
14
14
  var _npm = require("../utils/npm");
@@ -65,7 +65,7 @@ async function getRepoInfo(url, examplePath) {
65
65
  // Support repos whose entire purpose is to be an example, e.g.
66
66
  // https://github.com/:username/:my-cool-example-repo-name.
67
67
  if (t === undefined) {
68
- const infoResponse = await (0, _nodeFetch).default(`https://api.github.com/repos/${username}/${name}`);
68
+ const infoResponse = await (0, _client).fetchAsync(`https://api.github.com/repos/${username}/${name}`);
69
69
  if (infoResponse.status !== 200) {
70
70
  return;
71
71
  }