eas-cli 25.3.0 → 27.1.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 (81) hide show
  1. package/README.md +268 -198
  2. package/build/build/build.js +6 -0
  3. package/build/build/createContext.d.ts +4 -3
  4. package/build/build/createContext.js +1 -4
  5. package/build/build/errors.d.ts +2 -0
  6. package/build/build/errors.js +4 -1
  7. package/build/build/evaluateConfigWithEnvVarsAsync.js +1 -3
  8. package/build/build/runBuildAndSubmit.d.ts +7 -2
  9. package/build/build/runBuildAndSubmit.js +9 -8
  10. package/build/build/utils/expoTokenRole.d.ts +4 -0
  11. package/build/build/utils/expoTokenRole.js +14 -0
  12. package/build/commandUtils/EasCommand.js +3 -3
  13. package/build/commandUtils/context/DynamicProjectConfigContextField.d.ts +2 -2
  14. package/build/commandUtils/context/DynamicProjectConfigContextField.js +40 -61
  15. package/build/commandUtils/context/LoggedInContextField.js +1 -2
  16. package/build/commandUtils/context/MaybeLoggedInContextField.js +1 -2
  17. package/build/commandUtils/context/OptionalPrivateProjectConfigContextField.js +3 -1
  18. package/build/commandUtils/context/PrivateProjectConfigContextField.js +3 -1
  19. package/build/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.js +2 -1
  20. package/build/commandUtils/context/contextUtils/getProjectIdAsync.d.ts +1 -0
  21. package/build/commandUtils/context/contextUtils/getProjectIdAsync.js +5 -2
  22. package/build/commandUtils/workflow/referencedFiles.d.ts +6 -0
  23. package/build/commandUtils/workflow/referencedFiles.js +63 -0
  24. package/build/commandUtils/workflow/types.d.ts +1 -1
  25. package/build/commandUtils/workflow/utils.js +34 -5
  26. package/build/commands/account/login.js +6 -0
  27. package/build/commands/account/view.d.ts +0 -7
  28. package/build/commands/account/view.js +4 -74
  29. package/build/commands/browse.js +1 -1
  30. package/build/commands/build/dev.js +3 -3
  31. package/build/commands/channel/delete.js +1 -1
  32. package/build/commands/channel/rollout.js +1 -1
  33. package/build/commands/credentials/configure-build.js +1 -1
  34. package/build/commands/deploy/alias/delete.js +1 -1
  35. package/build/commands/deploy/alias/index.js +1 -1
  36. package/build/commands/deploy/delete.js +1 -1
  37. package/build/commands/go.js +1 -1
  38. package/build/commands/observe/event.js +1 -1
  39. package/build/commands/observe/events.js +1 -1
  40. package/build/commands/project/new.js +1 -1
  41. package/build/commands/simulator/control.js +42 -7
  42. package/build/commands/simulator/get.js +14 -1
  43. package/build/commands/simulator/index.js +12 -4
  44. package/build/commands/simulator/logs.d.ts +22 -0
  45. package/build/commands/simulator/logs.js +188 -0
  46. package/build/commands/workflow/cancel.js +9 -20
  47. package/build/commands/workflow/list.js +1 -1
  48. package/build/commands/workflow/logs.js +1 -1
  49. package/build/commands/workflow/run.js +10 -1
  50. package/build/commands/workflow/runs.js +1 -1
  51. package/build/commands/workflow/status.js +1 -1
  52. package/build/commands/workflow/view.js +1 -1
  53. package/build/graphql/generated.d.ts +438 -115
  54. package/build/graphql/generated.js +40 -9
  55. package/build/graphql/mutations/WorkflowRevisionMutation.d.ts +3 -2
  56. package/build/graphql/mutations/WorkflowRevisionMutation.js +12 -3
  57. package/build/graphql/queries/DeviceRunSessionQuery.d.ts +8 -1
  58. package/build/graphql/queries/DeviceRunSessionQuery.js +67 -0
  59. package/build/graphql/queries/WorkflowRunQuery.js +6 -0
  60. package/build/graphql/types/WorkflowRun.js +1 -0
  61. package/build/help.js +13 -6
  62. package/build/log.d.ts +2 -0
  63. package/build/log.js +10 -0
  64. package/build/project/projectStatus.js +1 -0
  65. package/build/simulator/artifacts.d.ts +9 -0
  66. package/build/simulator/artifacts.js +97 -0
  67. package/build/simulator/download.d.ts +2 -0
  68. package/build/simulator/download.js +57 -0
  69. package/build/simulator/events.js +2 -10
  70. package/build/simulator/jobRunErrors.d.ts +22 -0
  71. package/build/simulator/jobRunErrors.js +134 -0
  72. package/build/simulator/preview.d.ts +26 -0
  73. package/build/simulator/preview.js +156 -0
  74. package/build/simulator/utils.d.ts +5 -0
  75. package/build/simulator/utils.js +42 -0
  76. package/build/user/SessionManager.d.ts +10 -0
  77. package/build/user/SessionManager.js +12 -0
  78. package/build/user/accountPermissions.d.ts +11 -0
  79. package/build/user/accountPermissions.js +89 -0
  80. package/oclif.manifest.json +169 -21
  81. package/package.json +7 -7
@@ -16,11 +16,12 @@ const chalk_1 = tslib_1.__importDefault(require("chalk"));
16
16
  const fs = tslib_1.__importStar(require("node:fs"));
17
17
  const logs_1 = require("./logs");
18
18
  const types_1 = require("./types");
19
+ const url_1 = require("../../build/utils/url");
19
20
  const generated_1 = require("../../graphql/generated");
20
21
  const format_1 = require("../logs/format");
21
22
  const watcher_1 = require("../logs/watcher");
22
23
  const WorkflowRunQuery_1 = require("../../graphql/queries/WorkflowRunQuery");
23
- const log_1 = tslib_1.__importDefault(require("../../log"));
24
+ const log_1 = tslib_1.__importStar(require("../../log"));
24
25
  const ora_1 = require("../../ora");
25
26
  const formatFields_1 = tslib_1.__importDefault(require("../../utils/formatFields"));
26
27
  const centrifuge_1 = require("../../utils/centrifuge");
@@ -78,7 +79,7 @@ function choiceFromWorkflowJob(job, index) {
78
79
  }
79
80
  function processWorkflowRuns(runs) {
80
81
  return runs.map(run => {
81
- const finishedAt = run.status === generated_1.WorkflowRunStatus.InProgress ? null : run.updatedAt;
82
+ const finishedAt = isWorkflowRunFinal(run.status) ? (run.finalizedAt ?? null) : null;
82
83
  const { triggerType, trigger } = computeTriggerInfoForWorkflowRun(run);
83
84
  return {
84
85
  id: run.id,
@@ -129,6 +130,19 @@ function isJobCompleted(status) {
129
130
  return false;
130
131
  }
131
132
  }
133
+ function isWorkflowRunFinal(status) {
134
+ switch (status) {
135
+ case generated_1.WorkflowRunStatus.Success:
136
+ case generated_1.WorkflowRunStatus.Failure:
137
+ case generated_1.WorkflowRunStatus.Canceled:
138
+ return true;
139
+ case generated_1.WorkflowRunStatus.New:
140
+ case generated_1.WorkflowRunStatus.Waiting:
141
+ case generated_1.WorkflowRunStatus.InProgress:
142
+ case generated_1.WorkflowRunStatus.ActionRequired:
143
+ return false;
144
+ }
145
+ }
132
146
  async function logsForFailedWorkflowRunAsync(graphqlClient, workflowRun) {
133
147
  const jobs = workflowRun.jobs.filter(job => job.status === generated_1.WorkflowJobStatus.Failure);
134
148
  return await Promise.all(jobs.map(async (job) => {
@@ -213,13 +227,12 @@ async function maybeReadStdinAsync() {
213
227
  }
214
228
  async function showWorkflowStatusAsync(graphqlClient, { workflowRunId, spinnerUsesStdErr, waitForCompletion = true, }) {
215
229
  log_1.default.log('Waiting for workflow run to complete. You can press Ctrl+C to exit.');
230
+ const waitingToStartPrefixText = (0, chalk_1.default) `{bold.yellow Workflow run is waiting to start:}`;
216
231
  const spinner = (0, ora_1.ora)({
217
232
  stream: spinnerUsesStdErr ? process.stderr : process.stdout,
218
233
  text: '',
219
234
  }).start();
220
- (0, ora_1.updateSpinnerText)(spinner, {
221
- prefixText: (0, chalk_1.default) `{bold.yellow Workflow run is waiting to start:}`,
222
- });
235
+ (0, ora_1.updateSpinnerText)(spinner, { prefixText: waitingToStartPrefixText });
223
236
  const watcher = new watcher_1.LogsWatcher(() => (0, centrifuge_1.createRealtimeLogsClient)(graphqlClient), () => {
224
237
  renderActiveWorkflowRun();
225
238
  });
@@ -234,7 +247,23 @@ async function showWorkflowStatusAsync(graphqlClient, { workflowRunId, spinnerUs
234
247
  failedFetchesCount = 0;
235
248
  switch (workflowRun.status) {
236
249
  case generated_1.WorkflowRunStatus.New:
250
+ // A queued run returns to NEW once its concurrency group frees up.
251
+ (0, ora_1.updateSpinnerText)(spinner, { prefixText: waitingToStartPrefixText });
237
252
  break;
253
+ case generated_1.WorkflowRunStatus.Waiting: {
254
+ const { blockingWorkflowRun, workflow: { app }, } = workflowRun;
255
+ // The blocking run is in the same app: concurrency groups are app-scoped.
256
+ const actionRequiredSuffix = blockingWorkflowRun?.status === generated_1.WorkflowRunStatus.ActionRequired
257
+ ? ` — it needs your action first: ${(0, log_1.link)((0, url_1.getWorkflowRunUrl)(app.ownerAccount.name, app.slug, blockingWorkflowRun.id))}`
258
+ : '';
259
+ const reason = blockingWorkflowRun
260
+ ? `Waiting for ${blockingWorkflowRun.name}${actionRequiredSuffix}`
261
+ : 'Waiting for its concurrency group';
262
+ (0, ora_1.updateSpinnerText)(spinner, {
263
+ prefixText: (0, chalk_1.default) `{bold.yellow Workflow run is queued:} ${reason}`,
264
+ });
265
+ break;
266
+ }
238
267
  case generated_1.WorkflowRunStatus.InProgress: {
239
268
  (0, ora_1.updateSpinnerText)(spinner, {
240
269
  prefixText: (0, chalk_1.default) `{bold.green Workflow run is in progress:}`,
@@ -8,6 +8,7 @@ const flags_1 = require("../../commandUtils/flags");
8
8
  const log_1 = tslib_1.__importDefault(require("../../log"));
9
9
  const prompts_1 = require("../../prompts");
10
10
  const User_1 = require("../../user/User");
11
+ const accountPermissions_1 = require("../../user/accountPermissions");
11
12
  const deviceLogin_1 = require("../../user/deviceLogin");
12
13
  class AccountLogin extends EasCommand_1.default {
13
14
  static description = 'log in with your Expo account';
@@ -59,6 +60,11 @@ class AccountLogin extends EasCommand_1.default {
59
60
  }
60
61
  if (actor && !resume) {
61
62
  log_1.default.warn(`You are already logged in as ${chalk_1.default.bold((0, User_1.getActorDisplayName)(actor))}.`);
63
+ const { hasLimitedAccount } = (0, accountPermissions_1.logAccountPermissions)(actor);
64
+ if (hasLimitedAccount) {
65
+ log_1.default.newLine();
66
+ log_1.default.log('The permissions granted during authentication limit your access to some accounts. Log in again and change the permission grant.');
67
+ }
62
68
  const shouldContinue = nonInteractive ||
63
69
  (await (0, prompts_1.confirmAsync)({
64
70
  message: 'Do you want to continue?',
@@ -6,11 +6,4 @@ export default class AccountView extends EasCommand {
6
6
  maybeLoggedIn: import("../../commandUtils/context/MaybeLoggedInContextField").default;
7
7
  };
8
8
  runAsync(): Promise<void>;
9
- /**
10
- * Whether the scopes of the credential used for this command remove any of the permissions that
11
- * the viewer's role grants on the account.
12
- */
13
- private static isLimitedByCredentials;
14
- private static getLabelForPermissions;
15
- private static getLabelForRole;
16
9
  }
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
5
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
6
- const generated_1 = require("../../graphql/generated");
7
6
  const log_1 = tslib_1.__importDefault(require("../../log"));
8
7
  const User_1 = require("../../user/User");
9
- const roles_1 = require("../../user/roles");
8
+ const accountPermissions_1 = require("../../user/accountPermissions");
10
9
  class AccountView extends EasCommand_1.default {
11
10
  static description = 'show the username you are logged in as';
12
11
  static aliases = ['whoami'];
@@ -24,29 +23,10 @@ class AccountView extends EasCommand_1.default {
24
23
  if ('email' in actor) {
25
24
  log_1.default.log(actor.email);
26
25
  }
27
- // personal account is included, only show if more accounts that personal account
28
- // but do show personal account in list if there are more, or if the credentials used for
29
- // this command limit the permissions on it
30
- const accountExcludingPersonalAccount = actor.accounts.filter(account => !('username' in actor) || account.name !== actor.username);
31
- const hasLimitedAccount = actor.accounts.some(AccountView.isLimitedByCredentials);
32
- if (accountExcludingPersonalAccount.length > 0 || hasLimitedAccount) {
26
+ const { hasLimitedAccount } = (0, accountPermissions_1.logAccountPermissions)(actor);
27
+ if (hasLimitedAccount) {
33
28
  log_1.default.newLine();
34
- log_1.default.log('Accounts:');
35
- actor.accounts.forEach(account => {
36
- const { permissions, effectivePermissions } = account.viewerUserPermission2;
37
- const roleLabel = AccountView.getLabelForPermissions(permissions);
38
- if (AccountView.isLimitedByCredentials(account)) {
39
- const effectiveRoleLabel = AccountView.getLabelForPermissions(effectivePermissions);
40
- log_1.default.log(`• ${account.name} (Role: ${roleLabel}, ${chalk_1.default.yellow(`limited to ${effectiveRoleLabel} by the current credentials`)})`);
41
- }
42
- else {
43
- log_1.default.log(`• ${account.name} (Role: ${roleLabel})`);
44
- }
45
- });
46
- if (hasLimitedAccount) {
47
- log_1.default.newLine();
48
- log_1.default.log(`The permissions granted during authentication limit your access to some accounts. Run ${chalk_1.default.bold('eas login')} to change the permission grant.`);
49
- }
29
+ log_1.default.log(`The permissions granted during authentication limit your access to some accounts. Run ${chalk_1.default.bold('eas login')} to change the permission grant.`);
50
30
  }
51
31
  }
52
32
  else {
@@ -54,55 +34,5 @@ class AccountView extends EasCommand_1.default {
54
34
  process.exit(1);
55
35
  }
56
36
  }
57
- /**
58
- * Whether the scopes of the credential used for this command remove any of the permissions that
59
- * the viewer's role grants on the account.
60
- */
61
- static isLimitedByCredentials(account) {
62
- const { permissions, effectivePermissions } = account.viewerUserPermission2;
63
- return permissions.some(permission => !effectivePermissions.includes(permission));
64
- }
65
- static getLabelForPermissions(permissions) {
66
- const role = (0, roles_1.getRoleForPermissions)(permissions);
67
- if (role !== generated_1.Role.Custom) {
68
- return AccountView.getLabelForRole(role);
69
- }
70
- if (permissions.length === 0) {
71
- return 'No permissions';
72
- }
73
- return `Custom: ${permissions
74
- .map(permission => permission.toLowerCase().replaceAll('_', ' '))
75
- .join(', ')}`;
76
- }
77
- static getLabelForRole(role) {
78
- switch (role) {
79
- case generated_1.Role.Owner:
80
- return 'Owner';
81
- case generated_1.Role.Admin:
82
- return 'Admin';
83
- case generated_1.Role.Developer:
84
- return 'Developer';
85
- case generated_1.Role.ReleaseManager:
86
- return 'Release Manager';
87
- case generated_1.Role.Runner:
88
- return 'Runner';
89
- case generated_1.Role.ViewOnly:
90
- return 'Viewer';
91
- case generated_1.Role.Custom:
92
- case generated_1.Role.HasAdmin:
93
- case generated_1.Role.NotAdmin:
94
- return 'Custom';
95
- // A role added to the API after this version of the CLI was published. TypeScript narrows
96
- // `role` to `never` here, but the server can still send one, so render its name rather than
97
- // returning undefined.
98
- default: {
99
- const unknownRole = role;
100
- return unknownRole
101
- .split('_')
102
- .map(word => word.charAt(0) + word.slice(1).toLowerCase())
103
- .join(' ');
104
- }
105
- }
106
- }
107
37
  }
108
38
  exports.default = AccountView;
@@ -29,7 +29,7 @@ const PROJECT_PAGES = {
29
29
  settings: 'settings',
30
30
  };
31
31
  class Browse extends EasCommand_1.default {
32
- static description = 'Transition from the terminal to the web browser to view and interact with your project on https://expo.dev';
32
+ static description = 'transition from the terminal to the web browser to view and interact with your project on https://expo.dev';
33
33
  static args = {
34
34
  page: core_1.Args.string({
35
35
  description: 'Project subpage to open. Defaults to the project dashboard.',
@@ -84,7 +84,7 @@ class BuildDev extends EasCommand_1.default {
84
84
  vcsClient,
85
85
  });
86
86
  const workflow = await (0, workflow_1.resolveWorkflowAsync)(projectDir, platform, vcsClient);
87
- const { env } = await (0, evaluateConfigWithEnvVarsAsync_1.evaluateConfigWithEnvVarsAsync)({
87
+ const evaluatedConfig = await (0, evaluateConfigWithEnvVarsAsync_1.evaluateConfigWithEnvVarsAsync)({
88
88
  buildProfile: buildProfile.profile,
89
89
  buildProfileName: buildProfile.profileName,
90
90
  graphqlClient,
@@ -92,7 +92,7 @@ class BuildDev extends EasCommand_1.default {
92
92
  opts: { env: buildProfile.profile.env },
93
93
  });
94
94
  const fingerprint = await (0, cli_1.createFingerprintAsync)(projectDir, {
95
- env,
95
+ env: evaluatedConfig.env,
96
96
  workflow,
97
97
  platforms: [platform],
98
98
  });
@@ -157,7 +157,7 @@ class BuildDev extends EasCommand_1.default {
157
157
  actor,
158
158
  getDynamicPrivateProjectConfigAsync,
159
159
  downloadSimBuildAutoConfirm: true,
160
- envOverride: env,
160
+ evaluatedConfig,
161
161
  });
162
162
  if (!flags['skip-bundler']) {
163
163
  await this.startDevServerAsync({ projectDir, platform });
@@ -12,7 +12,7 @@ const prompts_1 = require("../../prompts");
12
12
  const json_1 = require("../../utils/json");
13
13
  const pollForBackgroundJobReceiptAsync_1 = require("../../utils/pollForBackgroundJobReceiptAsync");
14
14
  class ChannelDelete extends EasCommand_1.default {
15
- static description = 'Delete a channel';
15
+ static description = 'delete a channel';
16
16
  static args = {
17
17
  name: core_1.Args.string({
18
18
  required: false,
@@ -17,7 +17,7 @@ var ActionRawFlagValue;
17
17
  ActionRawFlagValue["VIEW"] = "view";
18
18
  })(ActionRawFlagValue || (ActionRawFlagValue = {}));
19
19
  class ChannelRollout extends EasCommand_1.default {
20
- static description = 'Roll a new branch out on a channel incrementally.';
20
+ static description = 'roll a new branch out on a channel incrementally';
21
21
  static args = {
22
22
  channel: core_1.Args.string({
23
23
  description: 'channel on which the rollout should be done',
@@ -8,7 +8,7 @@ const SelectBuildProfileFromEasJson_1 = require("../../credentials/manager/Selec
8
8
  const SetUpBuildCredentialsCommandAction_1 = require("../../credentials/manager/SetUpBuildCredentialsCommandAction");
9
9
  const platform_1 = require("../../platform");
10
10
  class InitializeBuildCredentials extends EasCommand_1.default {
11
- static description = 'Set up credentials for building your project.';
11
+ static description = 'set up credentials for building your project';
12
12
  static flags = {
13
13
  platform: core_1.Flags.option({
14
14
  char: 'p',
@@ -11,7 +11,7 @@ const prompts_1 = require("../../../prompts");
11
11
  const json_1 = require("../../../utils/json");
12
12
  const deployment_1 = require("../../../worker/deployment");
13
13
  class WorkerAliasDelete extends EasCommand_1.default {
14
- static description = 'Delete deployment aliases.';
14
+ static description = 'delete deployment aliases';
15
15
  static aliases = ['worker:alias:delete'];
16
16
  static state = 'preview';
17
17
  static args = {
@@ -12,7 +12,7 @@ const json_1 = require("../../../utils/json");
12
12
  const deployment_1 = require("../../../worker/deployment");
13
13
  const logs_1 = require("../../../worker/utils/logs");
14
14
  class WorkerAlias extends EasCommand_1.default {
15
- static description = 'Assign deployment aliases.';
15
+ static description = 'assign deployment aliases';
16
16
  static aliases = ['worker:alias', 'deploy:promote'];
17
17
  static state = 'preview';
18
18
  static flags = {
@@ -11,7 +11,7 @@ const prompts_1 = require("../../prompts");
11
11
  const json_1 = require("../../utils/json");
12
12
  const deployment_1 = require("../../worker/deployment");
13
13
  class WorkerDelete extends EasCommand_1.default {
14
- static description = 'Delete a deployment.';
14
+ static description = 'delete a deployment';
15
15
  static aliases = ['worker:delete'];
16
16
  static state = 'preview';
17
17
  static args = {
@@ -83,7 +83,7 @@ async function withSuppressedOutputAsync(fn) {
83
83
  }
84
84
  /* eslint-enable no-console */
85
85
  class Go extends EasCommand_1.default {
86
- static description = 'Create a custom Expo Go and submit to TestFlight';
86
+ static description = 'create a custom Expo Go and submit to TestFlight';
87
87
  static hidden = true;
88
88
  static flags = {
89
89
  'bundle-id': core_1.Flags.string({
@@ -15,7 +15,7 @@ const formatEvents_1 = require("../../observe/formatEvents");
15
15
  const planGating_1 = require("../../observe/planGating");
16
16
  const json_1 = require("../../utils/json");
17
17
  class ObserveEvent extends EasCommand_1.default {
18
- static description = 'display a single Observe event (metric, log, or error) by its ID. IDs are included in event data when the `--json` flag is passed to `eas observe:session`, `eas observe:metrics`, or `eas observe:events`.';
18
+ static description = 'display a single Observe event (metric, log, or error) by its ID. IDs are included in event data when the `--json` flag is passed to `eas observe:session`, `eas observe:metrics`, or `eas observe:events`';
19
19
  static args = {
20
20
  id: core_1.Args.string({
21
21
  description: 'ID of the event to display',
@@ -16,7 +16,7 @@ const startAndEndTime_1 = require("../../observe/startAndEndTime");
16
16
  const json_1 = require("../../utils/json");
17
17
  const DEFAULT_EVENTS_LIMIT = 10;
18
18
  class ObserveEvents extends EasCommand_1.default {
19
- static description = 'display individual events emitted by the app via `logEvent`, filtered by the event name in the argument. With no arguments, a list of the available event names and associated event counts is returned.';
19
+ static description = 'display individual events emitted by the app via `logEvent`, filtered by the event name in the argument. With no arguments, a list of the available event names and associated event counts is returned';
20
20
  static args = {
21
21
  eventName: core_1.Args.string({
22
22
  description: 'Event name to filter by',
@@ -71,7 +71,7 @@ async function generateProjectFilesAsync(projectDir, app, packageManager) {
71
71
  }
72
72
  class New extends EasCommand_1.default {
73
73
  static aliases = ['new'];
74
- static description = 'Create a new project configured with Expo Application Services (EAS)';
74
+ static description = 'create a new project configured with Expo Application Services (EAS)';
75
75
  static args = {
76
76
  path: core_1.Args.string({
77
77
  description: 'Path to create the project (defaults to current directory)',
@@ -17,7 +17,7 @@ const utils_1 = require("../../simulator/utils");
17
17
  const json_1 = require("../../utils/json");
18
18
  class SimulatorControl extends EasCommand_1.default {
19
19
  static aliases = ['sim:control'];
20
- static description = '[EXPERIMENTAL] run a serve-sim action on a remote iOS simulator session on EAS. Run without an action to list the actions the session supports. To save a screenshot locally, run `eas simulator:control screenshot.capture --output ./screenshot.png`.';
20
+ static description = '[EXPERIMENTAL] run a serve-sim action on a remote iOS simulator session on EAS. Run without an action to list the actions the session supports. To save a screenshot locally, run `eas simulator:control screenshot.capture --output ./screenshot.png`';
21
21
  static strict = false;
22
22
  static examples = [
23
23
  '$ eas simulator:control',
@@ -113,7 +113,7 @@ class SimulatorControl extends EasCommand_1.default {
113
113
  }
114
114
  printCatalog(catalog, jsonFlag) {
115
115
  if (jsonFlag) {
116
- (0, json_1.printJsonOnlyOutput)(catalog);
116
+ (0, json_1.printJsonOnlyOutput)(Object.fromEntries(Object.entries(catalog).map(([name, entry]) => [name, withUploadPathHelp(entry)])));
117
117
  return;
118
118
  }
119
119
  const names = Object.keys(catalog).sort();
@@ -129,7 +129,7 @@ class SimulatorControl extends EasCommand_1.default {
129
129
  }
130
130
  printActionHelp(action, entry, jsonFlag) {
131
131
  if (jsonFlag) {
132
- (0, json_1.printJsonOnlyOutput)({ ...entry, action });
132
+ (0, json_1.printJsonOnlyOutput)({ ...withUploadPathHelp(entry), action });
133
133
  return;
134
134
  }
135
135
  log_1.default.newLine();
@@ -156,6 +156,11 @@ class SimulatorControl extends EasCommand_1.default {
156
156
  log_1.default.newLine();
157
157
  log_1.default.log(' Action arguments refer to the simulator host. Use --output for the local filename.');
158
158
  }
159
+ const uploadHelp = uploadPathHelp(entry);
160
+ if (uploadHelp) {
161
+ log_1.default.newLine();
162
+ log_1.default.log(` ${uploadHelp}`);
163
+ }
159
164
  log_1.default.newLine();
160
165
  }
161
166
  async runActionAsync(connection, entry, { sessionId, action, values, outputPath, jsonFlag, }) {
@@ -212,18 +217,48 @@ class SimulatorControl extends EasCommand_1.default {
212
217
  }
213
218
  }
214
219
  exports.default = SimulatorControl;
215
- async function findLocalUploadAsync({ upload: param, uploadWhen = {} }, params) {
220
+ function uploadPathHelp(entry) {
221
+ if (!entry.upload) {
222
+ return undefined;
223
+ }
224
+ return entry.uploadAs === 'id'
225
+ ? 'This action requires a local file to upload. host: paths are not supported.'
226
+ : 'File paths are local. Use host:/absolute/path for files on the simulator host.';
227
+ }
228
+ function withUploadPathHelp(entry) {
229
+ const help = uploadPathHelp(entry);
230
+ return help
231
+ ? { ...entry, description: [entry.description, help].filter(Boolean).join('\n\n') }
232
+ : entry;
233
+ }
234
+ async function findLocalUploadAsync({ upload: param, uploadWhen = {}, uploadAs }, params) {
216
235
  const value = param ? params[param] : undefined;
217
236
  const applies = Object.entries(uploadWhen).every(([name, expected]) => params[name] === expected);
218
237
  if (!param || typeof value !== 'string' || !applies) {
219
238
  return null;
220
239
  }
221
- const stat = await fs.stat(value).catch(() => null);
240
+ if (value.startsWith('host:')) {
241
+ if (uploadAs === 'id') {
242
+ throw new Error('This action requires a local file to upload; host: paths are not supported.');
243
+ }
244
+ const hostPath = value.slice('host:'.length);
245
+ if (!path_1.default.posix.isAbsolute(hostPath)) {
246
+ throw new Error(`A host: path must be absolute, for example host:/tmp/app.tar.gz. For a local filename beginning with host:, use ./${value}.`);
247
+ }
248
+ params[param] = hostPath;
249
+ return null;
250
+ }
251
+ const stat = await fs.stat(value).catch((error) => {
252
+ if (error.code === 'ENOENT' || error.code === 'ENOTDIR') {
253
+ return null;
254
+ }
255
+ throw error;
256
+ });
222
257
  if (stat?.isDirectory()) {
223
258
  throw new Error(`${value} is a folder. Pass the path of a file.`);
224
259
  }
225
- if (!stat && !path_1.default.isAbsolute(value)) {
226
- throw new Error(`${value} does not exist on this computer. Pass the path of a local file, or an absolute path on the simulator host.`);
260
+ if (!stat) {
261
+ throw new Error(`${value} does not exist on this computer. Pass a local file, or prefix an absolute simulator-host path with host:.`);
227
262
  }
228
263
  return stat ? { param, path: value } : null;
229
264
  }
@@ -10,13 +10,14 @@ const DeviceRunSessionQuery_1 = require("../../graphql/queries/DeviceRunSessionQ
10
10
  const log_1 = tslib_1.__importStar(require("../../log"));
11
11
  const ora_1 = require("../../ora");
12
12
  const env_1 = require("../../simulator/env");
13
+ const jobRunErrors_1 = require("../../simulator/jobRunErrors");
13
14
  const utils_1 = require("../../simulator/utils");
14
15
  const files_1 = require("../../utils/files");
15
16
  const formatFields_1 = tslib_1.__importDefault(require("../../utils/formatFields"));
16
17
  const json_1 = require("../../utils/json");
17
18
  class SimulatorGet extends EasCommand_1.default {
18
19
  static aliases = ['sim:get'];
19
- static description = "[EXPERIMENTAL] get info about a remote simulator session on EAS by its simulator session ID. Preview links follow the session's saved sharing preference.";
20
+ static description = "[EXPERIMENTAL] get info about a remote simulator session on EAS by its simulator session ID. Preview links follow the session's saved sharing preference";
20
21
  static flags = {
21
22
  id: core_1.Flags.string({
22
23
  description: `Simulator session ID. Defaults to ${env_1.SIMULATOR_DOTENV_FILE_NAME}.`,
@@ -53,6 +54,10 @@ class SimulatorGet extends EasCommand_1.default {
53
54
  }
54
55
  const deviceRunSessionUrl = (0, url_1.getDeviceRunSessionUrl)(session.app.ownerAccount.name, session.app.slug, session.id);
55
56
  const deviceRunSessionPreviewUrl = (0, url_1.getDeviceRunSessionPreviewUrl)(session.app.ownerAccount.name, session.app.slug, session.id);
57
+ const errors = session.status === generated_1.DeviceRunSessionStatus.Errored ||
58
+ session.turtleJobRun?.status === generated_1.JobRunStatus.Errored
59
+ ? await (0, jobRunErrors_1.fetchSimulatorSessionErrorsAsync)(graphqlClient, session.id)
60
+ : [];
56
61
  if (jsonFlag) {
57
62
  (0, json_1.printJsonOnlyOutput)({
58
63
  id: session.id,
@@ -70,11 +75,19 @@ class SimulatorGet extends EasCommand_1.default {
70
75
  ? (0, utils_1.sanitizeRemoteConfigForJson)(session.remoteConfig, deviceRunSessionPreviewUrl, session.publicPreview)
71
76
  : session.remoteConfig,
72
77
  artifacts: session.artifacts,
78
+ errors,
73
79
  });
74
80
  return;
75
81
  }
76
82
  log_1.default.newLine();
77
83
  log_1.default.log(formatSessionFields(session, deviceRunSessionUrl));
84
+ if (errors.length > 0) {
85
+ log_1.default.newLine();
86
+ log_1.default.gray('Session errors:');
87
+ for (const error of errors) {
88
+ log_1.default.error(` ${(0, jobRunErrors_1.formatSimulatorSessionError)(error)}`);
89
+ }
90
+ }
78
91
  if (session.status === generated_1.DeviceRunSessionStatus.InProgress) {
79
92
  log_1.default.newLine();
80
93
  if (session.remoteConfig) {
@@ -21,6 +21,7 @@ const frameAncestors_1 = require("../../simulator/frameAncestors");
21
21
  const networkCapture_1 = require("../../simulator/networkCapture");
22
22
  const env_1 = require("../../simulator/env");
23
23
  const expoGo_1 = require("../../simulator/expoGo");
24
+ const jobRunErrors_1 = require("../../simulator/jobRunErrors");
24
25
  const requestAnalytics_1 = require("../../simulator/requestAnalytics");
25
26
  const utils_1 = require("../../simulator/utils");
26
27
  const json_1 = require("../../utils/json");
@@ -40,7 +41,7 @@ const APP_PLATFORM_BY_FLAG_VALUE = {
40
41
  class Simulator extends EasCommand_1.default {
41
42
  static aliases = ['simulator:start', 'sim:start'];
42
43
  static hiddenAliases = ['sim'];
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.';
44
+ 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';
44
45
  static flags = {
45
46
  platform: core_1.Flags.option({
46
47
  char: 'p',
@@ -341,13 +342,13 @@ class Simulator extends EasCommand_1.default {
341
342
  }
342
343
  if (session.status === generated_1.DeviceRunSessionStatus.Errored ||
343
344
  session.status === generated_1.DeviceRunSessionStatus.Stopped) {
344
- throw new Error(`Simulator session ${deviceRunSessionId} ${session.status.toLowerCase()} before the ${flags.type} session was ready. ${(0, log_1.link)(deviceRunSessionUrl)}`);
345
+ throw new Error(`Simulator session ${deviceRunSessionId} ${session.status.toLowerCase()} before the ${flags.type} session was ready. ${(0, log_1.link)(deviceRunSessionUrl)}${await formatJobRunErrorsAsync(graphqlClient, deviceRunSessionId, sessionInterrupt.signal)}`);
345
346
  }
346
347
  const jobRunStatus = session.turtleJobRun?.status;
347
348
  if (jobRunStatus === generated_1.JobRunStatus.Errored ||
348
349
  jobRunStatus === generated_1.JobRunStatus.Canceled ||
349
350
  jobRunStatus === generated_1.JobRunStatus.Finished) {
350
- throw new Error(`Turtle job run for simulator session ${deviceRunSessionId} ${jobRunStatus.toLowerCase()} before the ${flags.type} session was ready. ${(0, log_1.link)(deviceRunSessionUrl)}`);
351
+ throw new Error(`Turtle job run for simulator session ${deviceRunSessionId} ${jobRunStatus.toLowerCase()} before the ${flags.type} session was ready. ${(0, log_1.link)(deviceRunSessionUrl)}${await formatJobRunErrorsAsync(graphqlClient, deviceRunSessionId, sessionInterrupt.signal)}`);
351
352
  }
352
353
  if (session.remoteConfig) {
353
354
  remoteConfig = session.remoteConfig;
@@ -479,6 +480,13 @@ class Simulator extends EasCommand_1.default {
479
480
  }
480
481
  }
481
482
  exports.default = Simulator;
483
+ // Returns the reasons the session's job run failed, one per line, or an empty string when none are available.
484
+ async function formatJobRunErrorsAsync(graphqlClient, deviceRunSessionId, signal) {
485
+ const errors = await (0, jobRunErrors_1.fetchSimulatorSessionErrorsAsync)(graphqlClient, deviceRunSessionId, {
486
+ signal,
487
+ });
488
+ return errors.map(error => `\n${(0, jobRunErrors_1.formatSimulatorSessionError)(error)}`).join('');
489
+ }
482
490
  async function resolvePlatformAsync(platform, nonInteractive) {
483
491
  if (platform) {
484
492
  return APP_PLATFORM_BY_FLAG_VALUE[platform];
@@ -528,7 +536,7 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
528
536
  if (session.status === generated_1.DeviceRunSessionStatus.Errored ||
529
537
  jobRunStatus === generated_1.JobRunStatus.Errored) {
530
538
  spinner.fail(`Simulator session errored. ${(0, log_1.link)(deviceRunSessionUrl)}`);
531
- throw new Error(`Simulator session ${deviceRunSessionId} errored.`);
539
+ throw new Error(`Simulator session ${deviceRunSessionId} errored.${await formatJobRunErrorsAsync(graphqlClient, deviceRunSessionId, signal)}`);
532
540
  }
533
541
  if (session.status === generated_1.DeviceRunSessionStatus.Stopped ||
534
542
  jobRunStatus === generated_1.JobRunStatus.Canceled ||
@@ -0,0 +1,22 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ export default class SimulatorLogs extends EasCommand {
3
+ static aliases: string[];
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ artifact: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
+ output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ follow: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<"all" | "user-apps", import("@oclif/core/lib/interfaces").CustomOptions>;
14
+ limit: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
15
+ timestamp: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
16
+ };
17
+ static contextDefinition: {
18
+ projectDir: import("../../commandUtils/context/ProjectDirContextField").default;
19
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
20
+ };
21
+ runAsync(): Promise<void>;
22
+ }