eas-cli 24.14.0 → 25.1.1

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 (39) hide show
  1. package/README.md +208 -158
  2. package/build/billing/resolveAccount.js +38 -14
  3. package/build/build/utils/url.d.ts +1 -0
  4. package/build/build/utils/url.js +4 -0
  5. package/build/commandUtils/EasCommand.js +11 -5
  6. package/build/commandUtils/context/contextUtils/getProjectIdAsync.js +1 -1
  7. package/build/commandUtils/new/configs.d.ts +2 -2
  8. package/build/commandUtils/new/configs.js +8 -20
  9. package/build/commandUtils/usageUtils.d.ts +14 -0
  10. package/build/commandUtils/usageUtils.js +40 -2
  11. package/build/commands/account/usage.js +55 -2
  12. package/build/commands/account/view.d.ts +6 -1
  13. package/build/commands/account/view.js +38 -8
  14. package/build/commands/simulator/get.js +5 -2
  15. package/build/commands/simulator/index.d.ts +3 -0
  16. package/build/commands/simulator/index.js +37 -2
  17. package/build/easSelect.d.ts +30 -0
  18. package/build/easSelect.js +57 -0
  19. package/build/graphql/generated.d.ts +370 -946
  20. package/build/graphql/generated.js +5 -74
  21. package/build/graphql/queries/AccountQuery.js +27 -1
  22. package/build/graphql/queries/DeviceRunSessionQuery.js +1 -0
  23. package/build/graphql/types/Account.js +8 -2
  24. package/build/project/accountSelection.d.ts +2 -3
  25. package/build/project/accountSelection.js +12 -15
  26. package/build/project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync.js +4 -4
  27. package/build/project/projectInitialization.js +7 -6
  28. package/build/prompts.d.ts +2 -1
  29. package/build/prompts.js +2 -0
  30. package/build/simulator/frameAncestors.d.ts +9 -0
  31. package/build/simulator/frameAncestors.js +66 -0
  32. package/build/simulator/utils.d.ts +20 -5
  33. package/build/simulator/utils.js +105 -20
  34. package/build/user/User.d.ts +17 -1
  35. package/build/user/User.js +37 -2
  36. package/build/user/roles.d.ts +6 -0
  37. package/build/user/roles.js +35 -0
  38. package/oclif.manifest.json +23 -3
  39. package/package.json +6 -6
@@ -17,6 +17,7 @@ const log_1 = tslib_1.__importStar(require("../../log"));
17
17
  const ora_1 = require("../../ora");
18
18
  const prompts_1 = require("../../prompts");
19
19
  const egress_1 = require("../../simulator/egress");
20
+ const frameAncestors_1 = require("../../simulator/frameAncestors");
20
21
  const networkCapture_1 = require("../../simulator/networkCapture");
21
22
  const env_1 = require("../../simulator/env");
22
23
  const expoGo_1 = require("../../simulator/expoGo");
@@ -39,7 +40,7 @@ const APP_PLATFORM_BY_FLAG_VALUE = {
39
40
  class Simulator extends EasCommand_1.default {
40
41
  static aliases = ['simulator:start', 'sim:start'];
41
42
  static hiddenAliases = ['sim'];
42
- static description = '[EXPERIMENTAL] start a remote simulator session on EAS and get instructions to connect to it';
43
+ static description = '[EXPERIMENTAL] start a remote simulator session on EAS and get instructions to connect to it. The default browser preview link requires sign-in.';
43
44
  static flags = {
44
45
  platform: core_1.Flags.option({
45
46
  char: 'p',
@@ -120,6 +121,14 @@ class Simulator extends EasCommand_1.default {
120
121
  multiple: true,
121
122
  dependsOn: ['egress'],
122
123
  }),
124
+ 'cors-origin': core_1.Flags.string({
125
+ description: 'Origin of a page that may call the simulator preview API cross-origin, for example to render the device with @expo/hub-client, such as https://app.example.com or https://*.example.com. Repeat for multiple origins. Embedding the preview in a frame does not need this; use --frame-ancestor for that. The page still needs the printed preview URL and its token.',
126
+ multiple: true,
127
+ }),
128
+ 'frame-ancestor': core_1.Flags.string({
129
+ description: 'Origin of a page that may embed the simulator preview in a frame, such as https://app.example.com or https://*.example.com. Repeat for multiple origins. The embedding page loads the printed preview URL, which carries the session token, so anyone who can read that page can also control the simulator.',
130
+ multiple: true,
131
+ }),
123
132
  force: core_1.Flags.boolean({
124
133
  description: '[default: true] Create a new simulator session even when an existing simulator session is present in the environment.',
125
134
  default: true,
@@ -130,6 +139,9 @@ class Simulator extends EasCommand_1.default {
130
139
  options: Object.values(OUT_CONFIG_TYPE_VALUES),
131
140
  default: OUT_CONFIG_TYPE_VALUES.Dotenv,
132
141
  })(),
142
+ 'public-link': core_1.Flags.boolean({
143
+ description: 'Enable the simulator preview Share button and print a shareable link containing an access token. Anyone with the link can control the simulator. With --json, include previewApiUrl and its token for API clients when available.',
144
+ }),
133
145
  ...flags_1.EasNonInteractiveAndJsonFlags,
134
146
  };
135
147
  static contextDefinition = {
@@ -202,6 +214,20 @@ class Simulator extends EasCommand_1.default {
202
214
  catch (err) {
203
215
  throw new errors_1.EasCommandError(err instanceof Error ? err.message : String(err));
204
216
  }
217
+ let frameAncestors = [];
218
+ try {
219
+ frameAncestors = (0, frameAncestors_1.parseFrameAncestorList)(flags['frame-ancestor'] ?? []);
220
+ }
221
+ catch (err) {
222
+ throw new errors_1.EasCommandError(err instanceof Error ? err.message : String(err));
223
+ }
224
+ let corsOrigins = [];
225
+ try {
226
+ corsOrigins = (0, frameAncestors_1.parseCorsOriginList)(flags['cors-origin'] ?? []);
227
+ }
228
+ catch (err) {
229
+ throw new errors_1.EasCommandError(err instanceof Error ? err.message : String(err));
230
+ }
205
231
  if (flags['network-capture'] && platform !== generated_1.AppPlatform.Ios) {
206
232
  throw new errors_1.EasCommandError('Network capture is only supported on iOS simulator sessions. Re-run without --network-capture, or pass --platform ios.');
207
233
  }
@@ -221,6 +247,7 @@ class Simulator extends EasCommand_1.default {
221
247
  const createSpinner = (0, ora_1.ora)('🚀 Creating simulator session').start();
222
248
  let deviceRunSessionId;
223
249
  let deviceRunSessionUrl;
250
+ let deviceRunSessionPreviewUrl;
224
251
  let sessionInterrupt;
225
252
  try {
226
253
  const agentIdentity = await agentIdentityInputAsync();
@@ -240,6 +267,7 @@ class Simulator extends EasCommand_1.default {
240
267
  ...(tags?.length ? { tags } : {}),
241
268
  platform,
242
269
  type: utils_1.DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE[flags.type],
270
+ publicPreview: flags['public-link'] ?? false,
243
271
  packageVersion: flags['package-version'],
244
272
  networkCapture: flags['network-capture'],
245
273
  ...(networkCaptureFields.length ? { networkCaptureFields } : {}),
@@ -258,6 +286,8 @@ class Simulator extends EasCommand_1.default {
258
286
  ...(openUrl ? { openUrl } : {}),
259
287
  ...(resourceClass ? { resourceClass } : {}),
260
288
  ...(egress ? { egress } : {}),
289
+ ...(frameAncestors.length ? { frameAncestors } : {}),
290
+ ...(corsOrigins.length ? { corsOrigins } : {}),
261
291
  requestOrigin: generated_1.DeviceRunSessionRequestOrigin.EasCli,
262
292
  ...agentIdentity,
263
293
  maxRunTimeMinutes: flags['max-duration-minutes'],
@@ -266,6 +296,7 @@ class Simulator extends EasCommand_1.default {
266
296
  deviceRunSessionId = session.id;
267
297
  (0, nullthrows_1.default)(session.turtleJobRun?.id, 'Expected simulator session to start');
268
298
  deviceRunSessionUrl = (0, url_1.getDeviceRunSessionUrl)(session.app.ownerAccount.name, session.app.slug, deviceRunSessionId);
299
+ deviceRunSessionPreviewUrl = (0, url_1.getDeviceRunSessionPreviewUrl)(session.app.ownerAccount.name, session.app.slug, deviceRunSessionId);
269
300
  sessionInterrupt = registerSessionInterrupt(deviceRunSessionId);
270
301
  const simulatorEnvWritten = !jsonFlag && flags['out-config-type'] === OUT_CONFIG_TYPE_VALUES.Dotenv
271
302
  ? await writeSimulatorEnvSafelyAsync(projectDir, {
@@ -368,7 +399,7 @@ class Simulator extends EasCommand_1.default {
368
399
  name,
369
400
  type: flags.type,
370
401
  deviceRunSessionUrl,
371
- remoteConfig: (0, utils_1.sanitizeRemoteConfigForJson)(remoteConfig),
402
+ remoteConfig: (0, utils_1.sanitizeRemoteConfigForJson)(remoteConfig, deviceRunSessionPreviewUrl, flags['public-link'], { frameAncestors, corsOrigins }),
372
403
  });
373
404
  return;
374
405
  }
@@ -377,6 +408,10 @@ class Simulator extends EasCommand_1.default {
377
408
  egressAllow,
378
409
  egressClientRunsInline: !nonInteractive,
379
410
  sessionUrl: deviceRunSessionUrl,
411
+ privatePreviewUrl: deviceRunSessionPreviewUrl,
412
+ publicLink: flags['public-link'],
413
+ frameAncestors,
414
+ corsOrigins,
380
415
  platform,
381
416
  }));
382
417
  log_1.default.newLine();
@@ -0,0 +1,30 @@
1
+ import { Choice, PromptObject } from 'prompts';
2
+ import { SelectPrompt } from 'prompts/lib/elements';
3
+ export type SelectChoice = Choice & {
4
+ /**
5
+ * Shown next to the prompt message while this choice is highlighted and disabled, in place of the
6
+ * prompt's `warn`. prompts never shows the description of a disabled choice.
7
+ */
8
+ disabledReason?: string;
9
+ };
10
+ type SelectQuestion = Omit<PromptObject, 'choices'> & {
11
+ choices: SelectChoice[];
12
+ };
13
+ /**
14
+ * Customized select prompt.
15
+ *
16
+ * Additional parameters:
17
+ *
18
+ * @param choices[].disabledReason
19
+ * Why the choice is disabled. Use it when the reason differs per choice, because `warn` is the
20
+ * same for every choice.
21
+ **/
22
+ export default class EasSelect extends SelectPrompt {
23
+ private readonly disabledReasons;
24
+ private defaultWarn;
25
+ constructor(opts: SelectQuestion);
26
+ get warn(): string | undefined;
27
+ set warn(value: string | undefined);
28
+ }
29
+ export declare const easSelect: (args: PromptObject) => Promise<any>;
30
+ export {};
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.easSelect = void 0;
4
+ const elements_1 = require("prompts/lib/elements");
5
+ /**
6
+ * Customized select prompt.
7
+ *
8
+ * Additional parameters:
9
+ *
10
+ * @param choices[].disabledReason
11
+ * Why the choice is disabled. Use it when the reason differs per choice, because `warn` is the
12
+ * same for every choice.
13
+ **/
14
+ class EasSelect extends elements_1.SelectPrompt {
15
+ disabledReasons;
16
+ constructor(opts) {
17
+ super(opts);
18
+ this.disabledReasons = opts.choices.map(choice => choice.disabledReason);
19
+ // Start on an enabled choice when the initial one is disabled.
20
+ if (this.choices[this.cursor]?.disabled) {
21
+ const firstEnabledIndex = this.choices.findIndex(choice => !choice.disabled);
22
+ if (firstEnabledIndex !== -1) {
23
+ this.moveCursor(firstEnabledIndex);
24
+ }
25
+ }
26
+ // SelectPrompt renders at the end of its constructor, before `disabledReasons` is set, so render
27
+ // again to show the reason of the highlighted choice.
28
+ this.render();
29
+ }
30
+ // SelectPrompt assigns `warn` in its constructor and reads it in render() when the highlighted
31
+ // choice is disabled.
32
+ get warn() {
33
+ const reason = this.disabledReasons?.[this.cursor];
34
+ return this.choices[this.cursor]?.disabled && reason ? `- ${reason}` : this.defaultWarn;
35
+ }
36
+ set warn(value) {
37
+ this.defaultWarn = value;
38
+ }
39
+ }
40
+ exports.default = EasSelect;
41
+ // prompts enables j/k navigation only when `constructor.name` is SelectPrompt or MultiselectPrompt.
42
+ Object.defineProperty(EasSelect, 'name', { value: 'SelectPrompt' });
43
+ const easSelect = (args) => {
44
+ return new Promise((res, rej) => {
45
+ const p = new EasSelect(args);
46
+ p.on('submit', x => {
47
+ res(x);
48
+ });
49
+ p.on('exit', x => {
50
+ res(x);
51
+ });
52
+ p.on('abort', x => {
53
+ rej(x);
54
+ });
55
+ });
56
+ };
57
+ exports.easSelect = easSelect;