eas-cli 24.8.0 → 24.9.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 (38) hide show
  1. package/README.md +222 -204
  2. package/build/commandUtils/workflow/validation.js +11 -2
  3. package/build/commands/simulator/events.js +4 -2
  4. package/build/commands/simulator/get.js +1 -0
  5. package/build/commands/simulator/index.js +11 -10
  6. package/build/commands/simulator/list.js +4 -2
  7. package/build/commands/submit/internal.d.ts +4 -1
  8. package/build/commands/submit/internal.js +20 -2
  9. package/build/commands/update/index.d.ts +2 -0
  10. package/build/commands/update/index.js +45 -4
  11. package/build/commands/update/republish.d.ts +1 -0
  12. package/build/commands/update/republish.js +6 -0
  13. package/build/commands/update/roll-back-to-embedded.d.ts +1 -0
  14. package/build/commands/update/roll-back-to-embedded.js +7 -1
  15. package/build/commands/update/rollback.d.ts +1 -0
  16. package/build/commands/update/rollback.js +11 -3
  17. package/build/commands/workflow/validate.js +1 -0
  18. package/build/graphql/generated.d.ts +181 -19
  19. package/build/graphql/generated.js +30 -3
  20. package/build/ora.js +12 -2
  21. package/build/project/maybeUploadSourceMapsAsync.d.ts +34 -0
  22. package/build/project/maybeUploadSourceMapsAsync.js +156 -0
  23. package/build/simulator/egress.d.ts +11 -4
  24. package/build/simulator/egress.js +72 -10
  25. package/build/simulator/env.d.ts +1 -0
  26. package/build/simulator/env.js +4 -1
  27. package/build/simulator/utils.d.ts +15 -5
  28. package/build/simulator/utils.js +33 -11
  29. package/build/update/active-rollout.d.ts +8 -0
  30. package/build/update/active-rollout.js +82 -0
  31. package/build/update/republish.d.ts +4 -1
  32. package/build/update/republish.js +13 -3
  33. package/build/update/roll-back-to-embedded.d.ts +4 -1
  34. package/build/update/roll-back-to-embedded.js +14 -3
  35. package/build/uploads.js +5 -1
  36. package/build/user/expoBrowserAuthFlowLauncher.js +0 -1
  37. package/oclif.manifest.json +205 -149
  38. package/package.json +5 -5
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_SOURCE_MAP_SIZE_BYTES = exports.SOURCE_MAP_PLATFORMS = void 0;
4
+ exports.isSourceMapPlatform = isSourceMapPlatform;
5
+ exports.maybeUploadSourceMapsAsync = maybeUploadSourceMapsAsync;
6
+ exports.resolveSourceMapPathsAsync = resolveSourceMapPathsAsync;
7
+ exports.stripSourcesContentAsync = stripSourcesContentAsync;
8
+ const tslib_1 = require("tslib");
9
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
10
+ const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
+ const path_1 = tslib_1.__importDefault(require("path"));
13
+ const uuid_1 = require("uuid");
14
+ const publish_1 = require("./publish");
15
+ const generated_1 = require("../graphql/generated");
16
+ const log_1 = tslib_1.__importDefault(require("../log"));
17
+ const uploads_1 = require("../uploads");
18
+ const files_1 = require("../utils/files");
19
+ const paths_1 = require("../utils/paths");
20
+ const progress_1 = require("../utils/progress");
21
+ /** Platforms for which EAS stores a source map. The GraphQL SourceMapGroup input has no `web`. */
22
+ exports.SOURCE_MAP_PLATFORMS = ['android', 'ios'];
23
+ /**
24
+ * Maximum size the EAS upload session accepts for a source map. Mirrors `maxSizeBytes` for
25
+ * `GCS_EAS_UPDATE_SOURCE_MAPS` in the server's upload configuration.
26
+ */
27
+ exports.MAX_SOURCE_MAP_SIZE_BYTES = 5 * 1024 * 1024;
28
+ function isSourceMapPlatform(platform) {
29
+ return exports.SOURCE_MAP_PLATFORMS.includes(platform);
30
+ }
31
+ /**
32
+ * Upload the source map that `expo export` emitted for each native platform.
33
+ *
34
+ * Publishing must never fail because of a source map, so every failure path warns and yields no
35
+ * entry for that platform.
36
+ */
37
+ async function maybeUploadSourceMapsAsync(distRoot, graphqlClient) {
38
+ let sourceMapPathByPlatform;
39
+ try {
40
+ sourceMapPathByPlatform = await resolveSourceMapPathsAsync(distRoot);
41
+ }
42
+ catch (err) {
43
+ log_1.default.warn(`Failed to locate source maps in ${distRoot}.\n\nReason: ${err.message}`);
44
+ return null;
45
+ }
46
+ const sources = {};
47
+ for (const platform of exports.SOURCE_MAP_PLATFORMS) {
48
+ const sourceMapPath = sourceMapPathByPlatform[platform];
49
+ if (!sourceMapPath) {
50
+ continue;
51
+ }
52
+ const source = await uploadSourceMapForPlatformAsync(graphqlClient, sourceMapPath, platform);
53
+ if (source) {
54
+ sources[platform] = source;
55
+ }
56
+ }
57
+ return Object.keys(sources).length > 0 ? sources : null;
58
+ }
59
+ async function uploadSourceMapForPlatformAsync(graphqlClient, sourceMapPath, platform) {
60
+ try {
61
+ // Always strip, so application source text never reaches EAS storage and the map has a chance
62
+ // of fitting under the upload limit.
63
+ const strippedPath = await stripSourcesContentAsync(sourceMapPath, platform);
64
+ const { size } = await fs_extra_1.default.promises.stat(strippedPath);
65
+ if (size > exports.MAX_SOURCE_MAP_SIZE_BYTES) {
66
+ log_1.default.warn(`Skipping the ${platform} source map because it is ${(0, files_1.formatBytes)(size)}, above the ${(0, files_1.formatBytes)(exports.MAX_SOURCE_MAP_SIZE_BYTES)} limit for source map uploads.`);
67
+ return null;
68
+ }
69
+ const bucketKey = await (0, uploads_1.uploadFileAtPathToGCSAsync)(graphqlClient, generated_1.UploadSessionType.EasUpdateSourceMaps, strippedPath, (0, progress_1.createProgressTracker)({
70
+ total: size,
71
+ message: ratio => `Uploading ${platform} source map (${(0, files_1.formatBytes)(size * ratio)} / ${(0, files_1.formatBytes)(size)})`,
72
+ completedMessage: (duration) => `Uploaded ${platform} source map ${chalk_1.default.dim(duration)}`,
73
+ }));
74
+ return { type: generated_1.SourceMapSourceType.Gcs, bucketKey };
75
+ }
76
+ catch (err) {
77
+ let errMessage = `Failed to upload the ${platform} source map to EAS`;
78
+ if (err.message) {
79
+ errMessage += `\n\nReason: ${err.message}`;
80
+ }
81
+ log_1.default.warn(errMessage);
82
+ return null;
83
+ }
84
+ }
85
+ /**
86
+ * Find the source map for each native platform in the export directory.
87
+ *
88
+ * The maps are not listed in metadata.json, so they are located relative to the bundle that
89
+ * metadata.json does name. That ties each map to the bundle actually being published.
90
+ */
91
+ async function resolveSourceMapPathsAsync(distRoot) {
92
+ const metadata = (0, publish_1.loadMetadata)(distRoot);
93
+ const paths = {};
94
+ for (const platform of exports.SOURCE_MAP_PLATFORMS) {
95
+ const bundle = metadata.fileMetadata[platform]?.bundle;
96
+ if (!bundle) {
97
+ continue;
98
+ }
99
+ const bundlePath = path_1.default.resolve(distRoot, bundle);
100
+ const sourceMapPath = `${bundlePath}.map`;
101
+ if (await fs_extra_1.default.pathExists(sourceMapPath)) {
102
+ paths[platform] = sourceMapPath;
103
+ continue;
104
+ }
105
+ // Older Expo CLI versions name the map after the bundle without its extension.
106
+ const siblingMaps = await (0, fast_glob_1.default)('*.map', { cwd: path_1.default.dirname(bundlePath), absolute: true });
107
+ if (siblingMaps.length === 1) {
108
+ paths[platform] = siblingMaps[0];
109
+ continue;
110
+ }
111
+ if (siblingMaps.length > 1) {
112
+ log_1.default.warn(`Found ${siblingMaps.length} source maps next to the ${platform} bundle and cannot tell which one belongs to it. Skipping the ${platform} source map.`);
113
+ }
114
+ else {
115
+ log_1.default.warn(`No source map was found for the ${platform} bundle. Skipping the ${platform} source map.`);
116
+ }
117
+ }
118
+ return paths;
119
+ }
120
+ /**
121
+ * Write a copy of the source map with every `sourcesContent` removed.
122
+ *
123
+ * Symbolication needs `mappings`, `sources` and `names`; `sourcesContent` only supplies the source
124
+ * text shown around a frame, and it is the bulk of a Hermes source map. The copy goes to a temporary
125
+ * directory so the export directory is left untouched.
126
+ */
127
+ async function stripSourcesContentAsync(sourceMapPath, platform) {
128
+ const sourceMap = JSON.parse(await fs_extra_1.default.readFile(sourceMapPath, 'utf8'));
129
+ if (!isRecord(sourceMap) || sourceMap.version !== 3) {
130
+ throw new Error(`Invalid source map at ${sourceMapPath}. Expected a version 3 source map.`);
131
+ }
132
+ removeSourcesContent(sourceMap);
133
+ const uploadDirectory = path_1.default.join((0, paths_1.getTmpDirectory)(), (0, uuid_1.v4)());
134
+ const uploadPath = path_1.default.join(uploadDirectory, `${platform}.map`);
135
+ await fs_extra_1.default.ensureDir(uploadDirectory);
136
+ await fs_extra_1.default.writeFile(uploadPath, JSON.stringify(sourceMap), 'utf8');
137
+ return uploadPath;
138
+ }
139
+ function removeSourcesContent(value) {
140
+ if (Array.isArray(value)) {
141
+ for (const child of value) {
142
+ removeSourcesContent(child);
143
+ }
144
+ return;
145
+ }
146
+ if (!isRecord(value)) {
147
+ return;
148
+ }
149
+ delete value.sourcesContent;
150
+ for (const child of Object.values(value)) {
151
+ removeSourcesContent(child);
152
+ }
153
+ }
154
+ function isRecord(value) {
155
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
156
+ }
@@ -1,4 +1,5 @@
1
1
  import { LocalEgressConfig } from './utils';
2
+ import { AppPlatform } from '../graphql/generated';
2
3
  /**
3
4
  * Local egress client. Two pieces run on the developer's machine for the life of
4
5
  * a simulator session started with `--egress local`:
@@ -56,11 +57,14 @@ export declare function parseEgressAllowList(entries: readonly string[]): string
56
57
  * Wrap the default destination policy with the `--egress-allow` list. A listed
57
58
  * destination connects to this machine's loopback or network exactly as named;
58
59
  * every other destination keeps the default refusals. `localhost` maps to the
59
- * loopback addresses directly and never goes through DNS.
60
+ * loopback addresses directly and never goes through DNS. For an Android
61
+ * emulator, every name for this machine's loopback matches an entry for any
62
+ * of them on the same port.
60
63
  */
61
- export declare function createEgressTargetResolver({ allow, onAllowed, }: {
64
+ export declare function createEgressTargetResolver({ allow, onAllowed, platform, }: {
62
65
  allow: readonly string[];
63
66
  onAllowed?: (destination: string) => void;
67
+ platform?: AppPlatform;
64
68
  }): EgressTargetResolver;
65
69
  export type LocalEgressProxyStats = {
66
70
  active: number;
@@ -72,10 +76,12 @@ export type LocalEgressProxyServer = {
72
76
  getStats: () => LocalEgressProxyStats;
73
77
  closeAsync: () => Promise<void>;
74
78
  };
75
- export declare function startLocalEgressProxyServerAsync({ host, port, resolveTargetAsync, }: {
79
+ export declare function startLocalEgressProxyServerAsync({ host, port, resolveTargetAsync, onPolicyRefusal, }: {
76
80
  host?: string;
77
81
  port: number;
78
82
  resolveTargetAsync?: EgressTargetResolver;
83
+ /** Called with the requested `host:port` when the destination policy refuses it. */
84
+ onPolicyRefusal?: (destination: string, error: EgressPolicyError) => void;
79
85
  }): Promise<LocalEgressProxyServer>;
80
86
  export declare function getChiselAssetName({ platform, arch, }: {
81
87
  platform: NodeJS.Platform;
@@ -110,7 +116,8 @@ export declare function classifyChiselClientLogLine(line: string): 'connected' |
110
116
  * Run the egress client until `signal` aborts. Rejects if the tunnel client exits
111
117
  * on its own, which means proxied HTTP(S) requests have lost their tunnel.
112
118
  */
113
- export declare function runLocalEgressAsync({ url, token, fingerprint, port, allow, localPort, signal, onConnected, onDisconnected, }: Omit<LocalEgressConfig, 'allow'> & {
119
+ export declare function runLocalEgressAsync({ url, token, fingerprint, port, allow, platform, localPort, signal, onConnected, onDisconnected, }: Omit<LocalEgressConfig, 'allow' | 'platform'> & {
120
+ platform?: AppPlatform;
114
121
  /** Normalized `--egress-allow` destinations; see createEgressTargetResolver. */
115
122
  allow?: readonly string[];
116
123
  /** Defaults to an available ephemeral port; the remote worker port stays fixed. */
@@ -26,6 +26,7 @@ const node_readline_1 = tslib_1.__importDefault(require("node:readline"));
26
26
  const node_zlib_1 = tslib_1.__importDefault(require("node:zlib"));
27
27
  const env_1 = require("./env");
28
28
  const utils_1 = require("./utils");
29
+ const generated_1 = require("../graphql/generated");
29
30
  const fetch_1 = tslib_1.__importDefault(require("../fetch"));
30
31
  const log_1 = tslib_1.__importDefault(require("../log"));
31
32
  const paths_1 = require("../utils/paths");
@@ -84,10 +85,17 @@ function readLocalEgressConfigFromEnv(env) {
84
85
  if (!url || !token || !fingerprint || !Number.isInteger(port) || port <= 0) {
85
86
  throw new Error('The current simulator session was not started with local egress, so there is no egress ' +
86
87
  `client to run (${env_1.EAS_SIMULATOR_EGRESS_URL} is not set). Start one with ` +
87
- '`eas simulator:start --platform ios --egress local`.');
88
+ '`eas simulator:start --egress local`.');
88
89
  }
89
90
  const allow = parseEgressAllowList((env[env_1.EAS_SIMULATOR_EGRESS_ALLOW] ?? '').split(',').filter(entry => entry.trim().length > 0));
90
- return { url, token, fingerprint, port, allow };
91
+ return {
92
+ url,
93
+ token,
94
+ fingerprint,
95
+ port,
96
+ allow,
97
+ platform: env[env_1.EAS_SIMULATOR_EGRESS_PLATFORM] === 'android' ? generated_1.AppPlatform.Android : generated_1.AppPlatform.Ios,
98
+ };
91
99
  }
92
100
  // ---------------------------------------------------------------------------
93
101
  // Destination policy
@@ -260,25 +268,44 @@ function parseEgressAllowEntry(entry) {
260
268
  function parseEgressAllowList(entries) {
261
269
  return [...new Set(entries.map(parseEgressAllowEntry))];
262
270
  }
271
+ /**
272
+ * How this machine's loopback appears to an Android emulator guest: 10.0.2.2
273
+ * from proxy-aware clients, 127.0.0.1 after the emulator's own proxy rewrites
274
+ * 10.0.2.2, and localhost.
275
+ */
276
+ const ANDROID_EMULATOR_LOOPBACK_HOSTS = ['localhost', '127.0.0.1', '10.0.2.2'];
263
277
  /**
264
278
  * Wrap the default destination policy with the `--egress-allow` list. A listed
265
279
  * destination connects to this machine's loopback or network exactly as named;
266
280
  * every other destination keeps the default refusals. `localhost` maps to the
267
- * loopback addresses directly and never goes through DNS.
281
+ * loopback addresses directly and never goes through DNS. For an Android
282
+ * emulator, every name for this machine's loopback matches an entry for any
283
+ * of them on the same port.
268
284
  */
269
- function createEgressTargetResolver({ allow, onAllowed, }) {
285
+ function createEgressTargetResolver({ allow, onAllowed, platform = generated_1.AppPlatform.Ios, }) {
270
286
  const allowed = new Set(allow);
287
+ const isAndroidLoopbackHost = (host) => platform === generated_1.AppPlatform.Android && ANDROID_EMULATOR_LOOPBACK_HOSTS.includes(host);
271
288
  if (allowed.size === 0) {
272
289
  return exports.resolveEgressTargetAsync;
273
290
  }
291
+ const findAllowedDestination = (host, port) => {
292
+ const destination = formatEgressDestination(host, port);
293
+ if (allowed.has(destination)) {
294
+ return destination;
295
+ }
296
+ if (isAndroidLoopbackHost(host)) {
297
+ return ANDROID_EMULATOR_LOOPBACK_HOSTS.map(alias => formatEgressDestination(alias, port)).find(alias => allowed.has(alias));
298
+ }
299
+ return undefined;
300
+ };
274
301
  return async (hostname, port) => {
275
302
  const host = normalizeEgressHostname(hostname);
276
- const destination = formatEgressDestination(host, port);
277
- if (!allowed.has(destination)) {
303
+ const destination = findAllowedDestination(host, port);
304
+ if (!destination) {
278
305
  return await (0, exports.resolveEgressTargetAsync)(hostname, port);
279
306
  }
280
307
  onAllowed?.(destination);
281
- if (host === 'localhost') {
308
+ if (host === 'localhost' || isAndroidLoopbackHost(host)) {
282
309
  return ['127.0.0.1', '::1'];
283
310
  }
284
311
  if (node_net_1.default.isIP(host)) {
@@ -357,6 +384,22 @@ function pipeBothWays(a, b, onClose) {
357
384
  a.pipe(b);
358
385
  b.pipe(a);
359
386
  }
387
+ function getRequestDestination(url) {
388
+ try {
389
+ const parsed = new URL(url ?? '');
390
+ return `${parsed.hostname}:${parsed.port || 80}`;
391
+ }
392
+ catch {
393
+ return url ?? '';
394
+ }
395
+ }
396
+ /**
397
+ * Android's Private DNS probe (DNS over TLS to the emulator's resolver) is
398
+ * refused in every session and falls back on its own; it is not worth a warning.
399
+ */
400
+ function isAndroidPrivateDnsProbe(destination) {
401
+ return /^(10\.0\.2\.3|127\.0\.0\.\d+):853$/.test(destination);
402
+ }
360
403
  function statusForError(err) {
361
404
  return err instanceof EgressPolicyError ? 403 : 502;
362
405
  }
@@ -381,7 +424,7 @@ function filteredRawHeaders(rawHeaders, upgrade = false) {
381
424
  }
382
425
  return result;
383
426
  }
384
- async function startLocalEgressProxyServerAsync({ host = exports.LOCAL_EGRESS_PROXY_HOST, port, resolveTargetAsync = exports.resolveEgressTargetAsync, }) {
427
+ async function startLocalEgressProxyServerAsync({ host = exports.LOCAL_EGRESS_PROXY_HOST, port, resolveTargetAsync = exports.resolveEgressTargetAsync, onPolicyRefusal, }) {
385
428
  const stats = { active: 0, total: 0, refused: 0 };
386
429
  const sockets = new Set();
387
430
  const operations = new Set();
@@ -464,6 +507,9 @@ async function startLocalEgressProxyServerAsync({ host = exports.LOCAL_EGRESS_PR
464
507
  catch (err) {
465
508
  finish();
466
509
  log_1.default.debug(`[egress] CONNECT ${req.url} refused: ${err instanceof Error ? err.message : err}`);
510
+ if (err instanceof EgressPolicyError) {
511
+ onPolicyRefusal?.(req.url ?? '', err);
512
+ }
467
513
  if (!clientSocket.destroyed) {
468
514
  clientSocket.end(`HTTP/1.1 ${statusForError(err)} ${node_http_1.default.STATUS_CODES[statusForError(err)]}\r\nConnection: close\r\n\r\n`);
469
515
  }
@@ -621,6 +667,9 @@ async function startLocalEgressProxyServerAsync({ host = exports.LOCAL_EGRESS_PR
621
667
  }
622
668
  finish();
623
669
  log_1.default.debug(`[egress] ${req.method} ${req.url} refused: ${err instanceof Error ? err.message : err}`);
670
+ if (err instanceof EgressPolicyError) {
671
+ onPolicyRefusal?.(getRequestDestination(req.url), err);
672
+ }
624
673
  }
625
674
  })();
626
675
  };
@@ -749,7 +798,7 @@ function classifyChiselClientLogLine(line) {
749
798
  * Run the egress client until `signal` aborts. Rejects if the tunnel client exits
750
799
  * on its own, which means proxied HTTP(S) requests have lost their tunnel.
751
800
  */
752
- async function runLocalEgressAsync({ url, token, fingerprint, port, allow = [], localPort = 0, signal, onConnected, onDisconnected, }) {
801
+ async function runLocalEgressAsync({ url, token, fingerprint, port, allow = [], platform = generated_1.AppPlatform.Ios, localPort = 0, signal, onConnected, onDisconnected, }) {
753
802
  let proxy;
754
803
  let child;
755
804
  let killTimer;
@@ -777,6 +826,7 @@ async function runLocalEgressAsync({ url, token, fingerprint, port, allow = [],
777
826
  const reportedAllowed = new Set();
778
827
  const resolveAllowedTarget = createEgressTargetResolver({
779
828
  allow,
829
+ platform,
780
830
  onAllowed: destination => {
781
831
  if (reportedAllowed.has(destination)) {
782
832
  log_1.default.debug(`[egress] ${destination} allowed by --egress-allow`);
@@ -786,13 +836,25 @@ async function runLocalEgressAsync({ url, token, fingerprint, port, allow = [],
786
836
  log_1.default.log(`The simulator reached ${destination} on this machine's network.`);
787
837
  },
788
838
  });
839
+ const reportedRefusals = new Set();
789
840
  proxy = await startLocalEgressProxyServerAsync({
790
841
  port: localPort,
791
842
  resolveTargetAsync: async (hostname, targetPort) => await resolveAllowedTarget(hostname, targetPort),
843
+ ...(platform === generated_1.AppPlatform.Android
844
+ ? {
845
+ onPolicyRefusal: (destination, error) => {
846
+ if (reportedRefusals.has(destination) || isAndroidPrivateDnsProbe(destination)) {
847
+ return;
848
+ }
849
+ reportedRefusals.add(destination);
850
+ log_1.default.warn(`${error.message} To let the emulator reach ${destination}, pass --egress-allow ${destination}.`);
851
+ },
852
+ }
853
+ : {}),
792
854
  });
793
855
  signal.throwIfAborted();
794
856
  log_1.default.debug(`[egress] proxy listening on ${exports.LOCAL_EGRESS_PROXY_HOST}:${proxy.port}`);
795
- const forwards = (0, utils_1.getLoopbackForwardPlan)(allow, port);
857
+ const forwards = (0, utils_1.getLoopbackForwardPlan)(allow, port, platform);
796
858
  for (const forwardPort of forwards.ports) {
797
859
  log_1.default.debug(`[egress] forwarding ${exports.LOCAL_EGRESS_PROXY_HOST}:${forwardPort} on the device host to this machine`);
798
860
  }
@@ -5,6 +5,7 @@ export declare const EAS_SIMULATOR_EGRESS_TOKEN = "EAS_SIMULATOR_EGRESS_TOKEN";
5
5
  export declare const EAS_SIMULATOR_EGRESS_FINGERPRINT = "EAS_SIMULATOR_EGRESS_FINGERPRINT";
6
6
  export declare const EAS_SIMULATOR_EGRESS_PORT = "EAS_SIMULATOR_EGRESS_PORT";
7
7
  export declare const EAS_SIMULATOR_EGRESS_ALLOW = "EAS_SIMULATOR_EGRESS_ALLOW";
8
+ export declare const EAS_SIMULATOR_EGRESS_PLATFORM = "EAS_SIMULATOR_EGRESS_PLATFORM";
8
9
  export declare const SIMULATOR_DOTENV_FILE_HEADER = "# Do not commit this file.\n# Do not modify these values manually. They are managed by eas-cli.\n# It holds configuration only for the current simulator session.\n\n";
9
10
  export declare function getSimulatorEnvFilePath(projectDir: string): string;
10
11
  export declare function loadSimulatorEnvAsync(projectDir: string): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SIMULATOR_DOTENV_FILE_HEADER = exports.EAS_SIMULATOR_EGRESS_ALLOW = exports.EAS_SIMULATOR_EGRESS_PORT = exports.EAS_SIMULATOR_EGRESS_FINGERPRINT = exports.EAS_SIMULATOR_EGRESS_TOKEN = exports.EAS_SIMULATOR_EGRESS_URL = exports.EAS_SIMULATOR_SESSION_ID = exports.SIMULATOR_DOTENV_FILE_NAME = void 0;
3
+ exports.SIMULATOR_DOTENV_FILE_HEADER = exports.EAS_SIMULATOR_EGRESS_PLATFORM = exports.EAS_SIMULATOR_EGRESS_ALLOW = exports.EAS_SIMULATOR_EGRESS_PORT = exports.EAS_SIMULATOR_EGRESS_FINGERPRINT = exports.EAS_SIMULATOR_EGRESS_TOKEN = exports.EAS_SIMULATOR_EGRESS_URL = exports.EAS_SIMULATOR_SESSION_ID = exports.SIMULATOR_DOTENV_FILE_NAME = void 0;
4
4
  exports.getSimulatorEnvFilePath = getSimulatorEnvFilePath;
5
5
  exports.loadSimulatorEnvAsync = loadSimulatorEnvAsync;
6
6
  exports.writeSimulatorEnvAsync = writeSimulatorEnvAsync;
@@ -20,6 +20,8 @@ exports.EAS_SIMULATOR_EGRESS_FINGERPRINT = 'EAS_SIMULATOR_EGRESS_FINGERPRINT';
20
20
  exports.EAS_SIMULATOR_EGRESS_PORT = 'EAS_SIMULATOR_EGRESS_PORT';
21
21
  // Comma-separated host:port destinations from `--egress-allow`.
22
22
  exports.EAS_SIMULATOR_EGRESS_ALLOW = 'EAS_SIMULATOR_EGRESS_ALLOW';
23
+ // "android" or "ios"; older sessions without it are iOS.
24
+ exports.EAS_SIMULATOR_EGRESS_PLATFORM = 'EAS_SIMULATOR_EGRESS_PLATFORM';
23
25
  exports.SIMULATOR_DOTENV_FILE_HEADER = '# Do not commit this file.\n# Do not modify these values manually. They are managed by eas-cli.\n# It holds configuration only for the current simulator session.\n\n';
24
26
  function getSimulatorEnvFilePath(projectDir) {
25
27
  return path_1.default.join(projectDir, exports.SIMULATOR_DOTENV_FILE_NAME);
@@ -45,6 +47,7 @@ async function loadSimulatorEnvAsync(projectDir) {
45
47
  exports.EAS_SIMULATOR_EGRESS_TOKEN,
46
48
  exports.EAS_SIMULATOR_EGRESS_FINGERPRINT,
47
49
  exports.EAS_SIMULATOR_EGRESS_PORT,
50
+ exports.EAS_SIMULATOR_EGRESS_PLATFORM,
48
51
  ]) {
49
52
  if (simulatorEnv[key] === undefined) {
50
53
  delete process.env[key];
@@ -1,4 +1,4 @@
1
- import { DeviceRunSessionByIdQuery, DeviceRunSessionResourceClass, DeviceRunSessionType } from '../graphql/generated';
1
+ import { AppPlatform, DeviceRunSessionByIdQuery, DeviceRunSessionResourceClass, DeviceRunSessionType } from '../graphql/generated';
2
2
  type DeviceRunSessionByIdResult = DeviceRunSessionByIdQuery['deviceRunSessions']['byId'];
3
3
  export type DeviceRunSessionRemoteConfig = NonNullable<DeviceRunSessionByIdResult['remoteConfig']>;
4
4
  /** Landing page where accounts without access can request it. */
@@ -10,6 +10,8 @@ export declare const EAS_SIMULATOR_WAITLIST_URL = "https://expo.dev/services/sim
10
10
  export declare function formatSimulatorUnavailableMessage(accountName: string): string;
11
11
  export declare const DEVICE_RUN_SESSION_TYPE_FLAG_VALUES: Record<DeviceRunSessionType, string>;
12
12
  export declare const DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE: Record<string, DeviceRunSessionType>;
13
+ export declare const DEVICE_RUN_SESSION_TYPE_FLAG_OPTIONS: string[];
14
+ export declare function deviceRunSessionTypesForFlagValue(value: string): DeviceRunSessionType[];
13
15
  export declare function deviceRunSessionTypeToFlagValue(type: DeviceRunSessionType): string;
14
16
  export declare const DEVICE_RUN_SESSION_RESOURCE_CLASS_FLAG_VALUES: Record<DeviceRunSessionResourceClass, string>;
15
17
  export declare const DEVICE_RUN_SESSION_RESOURCE_CLASS_BY_FLAG_VALUE: Record<string, DeviceRunSessionResourceClass>;
@@ -24,9 +26,15 @@ export type LocalEgressConfig = {
24
26
  * that the simulator may reach through the proxy (`--egress-allow`).
25
27
  */
26
28
  allow: string[];
29
+ /**
30
+ * An Android emulator guest reaches this machine's loopback as 10.0.2.2 (and,
31
+ * through the emulator's proxy, as 127.0.0.1); an iOS Simulator does not.
32
+ */
33
+ platform: AppPlatform;
27
34
  };
28
35
  export type LocalEgressOptions = {
29
36
  egressAllow?: readonly string[];
37
+ platform?: AppPlatform;
30
38
  /**
31
39
  * Link to the session on expo.dev. Its Logs section lists every connection
32
40
  * the local egress guard refused inside the simulator, with the process and
@@ -45,7 +53,9 @@ export type LocalEgressOptions = {
45
53
  * started with `--egress local`. `allow` comes from the developer's flags, not
46
54
  * from the worker.
47
55
  */
48
- export declare function getLocalEgressConfig(remoteConfig: DeviceRunSessionRemoteConfig, allow?: readonly string[]): LocalEgressConfig | null;
56
+ export declare function getLocalEgressConfig(remoteConfig: DeviceRunSessionRemoteConfig, allow?: readonly string[], platform?: AppPlatform): LocalEgressConfig | null;
57
+ /** The worker relay that the Android emulator's proxy points at; see build-tools androidLocalEgress.ts. */
58
+ export declare const ANDROID_EMULATOR_EGRESS_RELAY_PORT = 8898;
49
59
  export type LoopbackForwardPlan = {
50
60
  /** Ports the tunnel client forwards on the device host's loopback interface. */
51
61
  ports: number[];
@@ -62,14 +72,14 @@ export type LoopbackForwardPlan = {
62
72
  * `adb reverse`. The device host only permits unprivileged ports, and the proxy
63
73
  * port is already taken by the tunnel server, so those entries are skipped.
64
74
  */
65
- export declare function getLoopbackForwardPlan(allow: readonly string[], proxyPort: number): LoopbackForwardPlan;
75
+ export declare function getLoopbackForwardPlan(allow: readonly string[], proxyPort: number, platform?: AppPlatform): LoopbackForwardPlan;
66
76
  /**
67
77
  * Only the exception is worth a line: forwarded ports just work, but an entry
68
78
  * the device host will not forward changes what the reader would expect.
69
79
  */
70
80
  export declare function formatLoopbackForwardNotice({ skipped }: LoopbackForwardPlan): string[];
71
81
  export declare function getLocalEgressEnvironmentVariables(egress: LocalEgressConfig | null): Record<string, string>;
72
- export declare function getRemoteSessionEnvironmentVariables(remoteConfig: DeviceRunSessionRemoteConfig, { egressAllow }?: LocalEgressOptions): Record<string, string>;
82
+ export declare function getRemoteSessionEnvironmentVariables(remoteConfig: DeviceRunSessionRemoteConfig, { egressAllow, platform }?: LocalEgressOptions): Record<string, string>;
73
83
  type RemoteSessionInstructionsConfigType = 'env' | 'dotenv';
74
84
  /**
75
85
  * Preview link for a session. A gated preview needs the session token, and a browser cannot send
@@ -83,5 +93,5 @@ export declare function formatPreviewUrl(remoteConfig: DeviceRunSessionRemoteCon
83
93
  * to combine.
84
94
  */
85
95
  export declare function sanitizeRemoteConfigForJson(remoteConfig: DeviceRunSessionRemoteConfig): DeviceRunSessionRemoteConfig;
86
- export declare function formatRemoteSessionInstructions(remoteConfig: DeviceRunSessionRemoteConfig, configType: RemoteSessionInstructionsConfigType, { egressAllow, egressClientRunsInline, sessionUrl }?: LocalEgressOptions): string;
96
+ export declare function formatRemoteSessionInstructions(remoteConfig: DeviceRunSessionRemoteConfig, configType: RemoteSessionInstructionsConfigType, { egressAllow, egressClientRunsInline, sessionUrl, platform }?: LocalEgressOptions): string;
87
97
  export {};
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_FLAG_VALUES = exports.DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES = exports.EAS_SIMULATOR_WAITLIST_URL = void 0;
3
+ exports.ANDROID_EMULATOR_EGRESS_RELAY_PORT = exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_FLAG_VALUES = exports.DEVICE_RUN_SESSION_TYPE_FLAG_OPTIONS = exports.DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES = exports.EAS_SIMULATOR_WAITLIST_URL = void 0;
4
4
  exports.formatSimulatorUnavailableMessage = formatSimulatorUnavailableMessage;
5
+ exports.deviceRunSessionTypesForFlagValue = deviceRunSessionTypesForFlagValue;
5
6
  exports.deviceRunSessionTypeToFlagValue = deviceRunSessionTypeToFlagValue;
6
7
  exports.getLocalEgressConfig = getLocalEgressConfig;
7
8
  exports.getLoopbackForwardPlan = getLoopbackForwardPlan;
@@ -36,6 +37,15 @@ exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES = {
36
37
  [generated_1.DeviceRunSessionType.WebPreviewOnly]: 'web-preview-only',
37
38
  };
38
39
  exports.DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE = Object.fromEntries(Object.entries(exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES).map(([type, value]) => [value, type]));
40
+ // Legacy ServeSim and WebPreviewOnly share a flag value, so list each value once.
41
+ exports.DEVICE_RUN_SESSION_TYPE_FLAG_OPTIONS = [
42
+ ...new Set(Object.values(exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES)),
43
+ ];
44
+ // Every enum value behind a flag value, so filtering by web-preview-only also
45
+ // matches sessions created with the legacy ServeSim type.
46
+ function deviceRunSessionTypesForFlagValue(value) {
47
+ return Object.keys(exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES).filter(type => exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES[type] === value);
48
+ }
39
49
  function deviceRunSessionTypeToFlagValue(type) {
40
50
  return exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES[type];
41
51
  }
@@ -49,7 +59,7 @@ exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_BY_FLAG_VALUE = Object.fromEntries(Obj
49
59
  * started with `--egress local`. `allow` comes from the developer's flags, not
50
60
  * from the worker.
51
61
  */
52
- function getLocalEgressConfig(remoteConfig, allow = []) {
62
+ function getLocalEgressConfig(remoteConfig, allow = [], platform = generated_1.AppPlatform.Ios) {
53
63
  const { egressUrl, egressToken, egressFingerprint, egressPort } = remoteConfig;
54
64
  if (!egressUrl || !egressToken || !egressFingerprint || egressPort == null) {
55
65
  return null;
@@ -60,8 +70,11 @@ function getLocalEgressConfig(remoteConfig, allow = []) {
60
70
  fingerprint: egressFingerprint,
61
71
  port: egressPort,
62
72
  allow: [...allow],
73
+ platform,
63
74
  };
64
75
  }
76
+ /** The worker relay that the Android emulator's proxy points at; see build-tools androidLocalEgress.ts. */
77
+ exports.ANDROID_EMULATOR_EGRESS_RELAY_PORT = 8898;
65
78
  /**
66
79
  * Which `--egress-allow` entries also become loopback port forwards. iOS never
67
80
  * sends loopback-literal requests to the system proxy, and Expo CLI rewrites
@@ -72,7 +85,11 @@ function getLocalEgressConfig(remoteConfig, allow = []) {
72
85
  * `adb reverse`. The device host only permits unprivileged ports, and the proxy
73
86
  * port is already taken by the tunnel server, so those entries are skipped.
74
87
  */
75
- function getLoopbackForwardPlan(allow, proxyPort) {
88
+ function getLoopbackForwardPlan(allow, proxyPort, platform = generated_1.AppPlatform.Ios) {
89
+ const reservedPorts = new Set([
90
+ proxyPort,
91
+ ...(platform === generated_1.AppPlatform.Android ? [exports.ANDROID_EMULATOR_EGRESS_RELAY_PORT] : []),
92
+ ]);
76
93
  const ports = new Set();
77
94
  const skipped = [];
78
95
  for (const destination of allow) {
@@ -81,7 +98,7 @@ function getLoopbackForwardPlan(allow, proxyPort) {
81
98
  continue;
82
99
  }
83
100
  const port = Number(match[1]);
84
- if (port < 1024 || port === proxyPort) {
101
+ if (port < 1024 || reservedPorts.has(port)) {
85
102
  skipped.push(destination);
86
103
  continue;
87
104
  }
@@ -112,12 +129,14 @@ function getLocalEgressEnvironmentVariables(egress) {
112
129
  [env_1.EAS_SIMULATOR_EGRESS_FINGERPRINT]: egress.fingerprint,
113
130
  [env_1.EAS_SIMULATOR_EGRESS_PORT]: String(egress.port),
114
131
  [env_1.EAS_SIMULATOR_EGRESS_ALLOW]: egress.allow.join(','),
132
+ // Always written, so pasted exports for one session replace another session's value.
133
+ [env_1.EAS_SIMULATOR_EGRESS_PLATFORM]: egress.platform === generated_1.AppPlatform.Android ? 'android' : 'ios',
115
134
  };
116
135
  }
117
- function getRemoteSessionEnvironmentVariables(remoteConfig, { egressAllow } = {}) {
136
+ function getRemoteSessionEnvironmentVariables(remoteConfig, { egressAllow, platform } = {}) {
118
137
  return {
119
138
  ...getControllerEnvironmentVariables(remoteConfig),
120
- ...getLocalEgressEnvironmentVariables(getLocalEgressConfig(remoteConfig, egressAllow)),
139
+ ...getLocalEgressEnvironmentVariables(getLocalEgressConfig(remoteConfig, egressAllow, platform)),
121
140
  };
122
141
  }
123
142
  function getControllerEnvironmentVariables(remoteConfig) {
@@ -200,23 +219,26 @@ function sanitizeRemoteConfigForJson(remoteConfig) {
200
219
  }
201
220
  }
202
221
  }
203
- function formatRemoteSessionInstructions(remoteConfig, configType, { egressAllow, egressClientRunsInline = false, sessionUrl } = {}) {
222
+ function formatRemoteSessionInstructions(remoteConfig, configType, { egressAllow, egressClientRunsInline = false, sessionUrl, platform } = {}) {
204
223
  const instructions = formatControllerInstructions(remoteConfig, configType);
205
- const egress = getLocalEgressConfig(remoteConfig, egressAllow);
224
+ const egress = getLocalEgressConfig(remoteConfig, egressAllow, platform);
206
225
  if (!egress) {
207
226
  return instructions;
208
227
  }
209
228
  const egressCommand = configType === 'env' ? 'eas simulator:egress --config-type env' : 'eas simulator:egress';
210
229
  const summary = "🔀 Local egress: the simulator's HTTP(S) traffic exits from this machine." +
211
230
  (egress.allow.length > 0 ? ` It can also reach ${egress.allow.join(', ')}.` : '');
212
- const guardNotice = 'Connections that bypass the proxy are refused inside the simulator. The Logs section of the ' +
213
- `session page lists what was refused and which library tried${sessionUrl ? `: ${(0, log_1.link)(sessionUrl)}` : '.'}`;
231
+ const guardNotice = egress.platform === generated_1.AppPlatform.Android
232
+ ? 'Traffic that cannot use the tunnel, such as UDP, is refused on the device host. The Logs ' +
233
+ `section of the session page lists what was refused${sessionUrl ? `: ${(0, log_1.link)(sessionUrl)}` : '.'}`
234
+ : 'Connections that bypass the proxy are refused inside the simulator. The Logs section of the ' +
235
+ `session page lists what was refused and which library tried${sessionUrl ? `: ${(0, log_1.link)(sessionUrl)}` : '.'}`;
214
236
  return [
215
237
  instructions,
216
238
  '',
217
239
  summary,
218
240
  guardNotice,
219
- ...formatLoopbackForwardNotice(getLoopbackForwardPlan(egress.allow, egress.port)),
241
+ ...formatLoopbackForwardNotice(getLoopbackForwardPlan(egress.allow, egress.port, egress.platform)),
220
242
  // In interactive mode the client starts in this terminal once the session is
221
243
  // ready and stops with it, so there is nothing for the reader to run.
222
244
  ...(egressClientRunsInline
@@ -0,0 +1,8 @@
1
+ import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
2
+ import { PublishUpdateGroupInput } from '../graphql/generated';
3
+ export declare function resolveUpdateGroupsSupersedingActiveRolloutsAsync(graphqlClient: ExpoGraphqlClient, updateGroups: PublishUpdateGroupInput[], { appId, branchName, forceEndActiveRollout, rolloutPercentage, }: {
4
+ appId: string;
5
+ branchName: string;
6
+ forceEndActiveRollout: boolean;
7
+ rolloutPercentage?: number;
8
+ }): Promise<PublishUpdateGroupInput[]>;