eas-cli 26.0.0 → 27.2.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 (82) hide show
  1. package/README.md +293 -148
  2. package/build/analytics/AnalyticsManager.d.ts +2 -0
  3. package/build/analytics/AnalyticsManager.js +2 -0
  4. package/build/build/build.d.ts +1 -2
  5. package/build/build/build.js +9 -4
  6. package/build/build/errors.d.ts +2 -0
  7. package/build/build/errors.js +4 -1
  8. package/build/build/evaluateConfigWithEnvVarsAsync.js +1 -3
  9. package/build/build/freeTierNearLimitAgentUpdatesTip.d.ts +98 -0
  10. package/build/build/freeTierNearLimitAgentUpdatesTip.js +205 -0
  11. package/build/build/runBuildAndSubmit.d.ts +2 -0
  12. package/build/build/runBuildAndSubmit.js +3 -0
  13. package/build/build/simulatorsLaunchHint.d.ts +7 -0
  14. package/build/build/simulatorsLaunchHint.js +40 -0
  15. package/build/build/utils/expoTokenRole.d.ts +4 -0
  16. package/build/build/utils/expoTokenRole.js +14 -0
  17. package/build/commandUtils/EasCommand.js +3 -3
  18. package/build/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.js +2 -1
  19. package/build/commandUtils/workflow/referencedFiles.d.ts +6 -0
  20. package/build/commandUtils/workflow/referencedFiles.js +63 -0
  21. package/build/commandUtils/workflow/types.d.ts +1 -1
  22. package/build/commandUtils/workflow/utils.js +34 -5
  23. package/build/commands/account/login.js +6 -0
  24. package/build/commands/account/view.d.ts +0 -7
  25. package/build/commands/account/view.js +4 -74
  26. package/build/commands/build/index.js +8 -1
  27. package/build/commands/observe/session.js +4 -3
  28. package/build/commands/observe/trace.d.ts +17 -0
  29. package/build/commands/observe/trace.js +58 -0
  30. package/build/commands/observe/traces.d.ts +33 -0
  31. package/build/commands/observe/traces.js +159 -0
  32. package/build/commands/simulator/control.js +41 -6
  33. package/build/commands/simulator/logs.d.ts +22 -0
  34. package/build/commands/simulator/logs.js +188 -0
  35. package/build/commands/workflow/cancel.js +9 -20
  36. package/build/commands/workflow/run.js +9 -0
  37. package/build/commands/workflow/runs.js +1 -1
  38. package/build/graphql/generated.d.ts +698 -5
  39. package/build/graphql/generated.js +25 -4
  40. package/build/graphql/mutations/UserPreferenceMutation.d.ts +5 -0
  41. package/build/graphql/mutations/UserPreferenceMutation.js +24 -0
  42. package/build/graphql/mutations/WorkflowRevisionMutation.d.ts +3 -2
  43. package/build/graphql/mutations/WorkflowRevisionMutation.js +12 -3
  44. package/build/graphql/queries/AccountQuery.d.ts +3 -1
  45. package/build/graphql/queries/AccountQuery.js +54 -0
  46. package/build/graphql/queries/ObserveQuery.d.ts +24 -1
  47. package/build/graphql/queries/ObserveQuery.js +114 -1
  48. package/build/graphql/queries/UserPreferenceQuery.d.ts +8 -0
  49. package/build/graphql/queries/UserPreferenceQuery.js +28 -0
  50. package/build/graphql/queries/WorkflowRunQuery.js +6 -0
  51. package/build/graphql/types/Observe.d.ts +1 -0
  52. package/build/graphql/types/Observe.js +53 -1
  53. package/build/graphql/types/WorkflowRun.js +1 -0
  54. package/build/help.js +13 -6
  55. package/build/log.d.ts +2 -0
  56. package/build/log.js +10 -0
  57. package/build/observe/fetchSessions.d.ts +12 -1
  58. package/build/observe/fetchSessions.js +39 -2
  59. package/build/observe/fetchSpans.d.ts +27 -0
  60. package/build/observe/fetchSpans.js +36 -0
  61. package/build/observe/formatSessions.d.ts +3 -1
  62. package/build/observe/formatSessions.js +40 -3
  63. package/build/observe/formatSpans.d.ts +110 -0
  64. package/build/observe/formatSpans.js +250 -0
  65. package/build/observe/spanFilters.d.ts +5 -0
  66. package/build/observe/spanFilters.js +32 -0
  67. package/build/project/projectStatus.js +1 -0
  68. package/build/simulator/artifacts.d.ts +9 -0
  69. package/build/simulator/artifacts.js +97 -0
  70. package/build/simulator/download.d.ts +2 -0
  71. package/build/simulator/download.js +57 -0
  72. package/build/simulator/events.js +2 -10
  73. package/build/simulator/preview.d.ts +26 -0
  74. package/build/simulator/preview.js +156 -0
  75. package/build/simulator/utils.d.ts +5 -0
  76. package/build/simulator/utils.js +42 -0
  77. package/build/user/accountPermissions.d.ts +11 -0
  78. package/build/user/accountPermissions.js +89 -0
  79. package/oclif.manifest.json +920 -422
  80. package/package.json +6 -6
  81. package/build/build/freeTierLimitGuidance.d.ts +0 -19
  82. package/build/build/freeTierLimitGuidance.js +0 -39
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectReferencedWorkflowFilesAsync = collectReferencedWorkflowFilesAsync;
4
+ const tslib_1 = require("tslib");
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
+ const path_1 = tslib_1.__importDefault(require("path"));
7
+ const parse_1 = require("./parse");
8
+ const WORKFLOW_CALL_USES_REGEX = /^\.\/\.eas\/workflows\/(?:(?!\$\{\{)[^/\\])+\.ya?ml$/;
9
+ async function collectReferencedWorkflowFilesAsync({ projectDir, rootFileName, rootYamlConfig, }) {
10
+ let rootYaml;
11
+ try {
12
+ rootYaml = (0, parse_1.parsedYamlFromWorkflowContents)({ yamlConfig: rootYamlConfig });
13
+ }
14
+ catch {
15
+ return [];
16
+ }
17
+ const collectedFileNames = new Set([rootFileName]);
18
+ const referencedFiles = [];
19
+ const pendingCalls = getWorkflowCalls(rootFileName, rootYaml);
20
+ for (const call of pendingCalls) {
21
+ const fileName = path_1.default.posix.basename(call.uses);
22
+ if (collectedFileNames.has(fileName)) {
23
+ continue;
24
+ }
25
+ collectedFileNames.add(fileName);
26
+ const { yamlConfig, parsedYaml } = await readReferencedWorkflowFileAsync(projectDir, fileName, call);
27
+ referencedFiles.push({ fileName, yamlConfig });
28
+ pendingCalls.push(...getWorkflowCalls(fileName, parsedYaml));
29
+ }
30
+ return referencedFiles;
31
+ }
32
+ function getWorkflowCalls(callerFileName, parsedYaml) {
33
+ const jobs = parsedYaml?.jobs;
34
+ if (!jobs || typeof jobs !== 'object') {
35
+ return [];
36
+ }
37
+ return Object.entries(jobs).flatMap(([callerJobKey, job]) => {
38
+ const uses = job?.uses;
39
+ return typeof uses === 'string' && WORKFLOW_CALL_USES_REGEX.test(uses)
40
+ ? [{ callerFileName, callerJobKey, uses }]
41
+ : [];
42
+ });
43
+ }
44
+ async function readReferencedWorkflowFileAsync(projectDir, fileName, { callerFileName, callerJobKey, uses }) {
45
+ const filePath = path_1.default.join(projectDir, '.eas', 'workflows', fileName);
46
+ const describeCall = `Job "${callerJobKey}" in ${callerFileName} uses ${uses}, but ${filePath}`;
47
+ let yamlConfig;
48
+ try {
49
+ yamlConfig = await fs_1.default.promises.readFile(filePath, 'utf8');
50
+ }
51
+ catch (error) {
52
+ if (error.code === 'ENOENT') {
53
+ throw new Error(`${describeCall} does not exist.`);
54
+ }
55
+ throw new Error(`${describeCall} could not be read: ${error.message}`);
56
+ }
57
+ try {
58
+ return { yamlConfig, parsedYaml: (0, parse_1.parsedYamlFromWorkflowContents)({ yamlConfig }) };
59
+ }
60
+ catch (error) {
61
+ throw new Error(`${describeCall} is not valid YAML: ${error.message}`);
62
+ }
63
+ }
@@ -13,7 +13,7 @@ export type WorkflowRunResult = {
13
13
  triggerType: WorkflowTriggerType;
14
14
  trigger: string | null;
15
15
  startedAt: string;
16
- finishedAt: string;
16
+ finishedAt: string | null;
17
17
  workflowId: string;
18
18
  workflowName: string | null;
19
19
  workflowFileName: string;
@@ -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;
@@ -12,6 +12,7 @@ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
12
  const path_1 = tslib_1.__importDefault(require("path"));
13
13
  const local_1 = require("../../build/local");
14
14
  const runBuildAndSubmit_1 = require("../../build/runBuildAndSubmit");
15
+ const simulatorsLaunchHint_1 = require("../../build/simulatorsLaunchHint");
15
16
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
16
17
  const flags_1 = require("../../commandUtils/flags");
17
18
  const generated_1 = require("../../graphql/generated");
@@ -127,7 +128,7 @@ class Build extends EasCommand_1.default {
127
128
  : [generated_1.StatuspageServiceName.EasBuild]);
128
129
  }
129
130
  const flagsWithPlatform = await this.ensurePlatformSelectedAsync(flags);
130
- const { buildProfiles } = await (0, runBuildAndSubmit_1.runBuildAndSubmitAsync)({
131
+ const { buildProfiles, builds } = await (0, runBuildAndSubmit_1.runBuildAndSubmitAsync)({
131
132
  graphqlClient,
132
133
  analytics,
133
134
  vcsClient,
@@ -142,6 +143,12 @@ class Build extends EasCommand_1.default {
142
143
  buildProfiles,
143
144
  nonInteractive: flags.nonInteractive,
144
145
  });
146
+ if (builds?.some(build => build?.status === generated_1.BuildStatus.Finished)) {
147
+ await (0, simulatorsLaunchHint_1.maybeShowSimulatorsLaunchHintAsync)(authenticationInfo, analytics, {
148
+ actor,
149
+ nonInteractive: flags.nonInteractive,
150
+ });
151
+ }
145
152
  }
146
153
  sanitizeFlags(flags) {
147
154
  const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
@@ -24,7 +24,7 @@ const SESSION_PAGE_SIZE = 100;
24
24
  // users narrow further with --days / --sort.
25
25
  const PICKER_CANDIDATE_LIMIT = 25;
26
26
  class ObserveSession extends EasCommand_1.default {
27
- static description = 'display the timeline of metric and log events for a specific session';
27
+ static description = 'display the timeline of metric, log, and request trace span events for a specific session';
28
28
  static args = {
29
29
  sessionId: core_1.Args.string({
30
30
  description: 'Session ID to inspect (omit in interactive mode to pick one from a list)',
@@ -90,12 +90,12 @@ class ObserveSession extends EasCommand_1.default {
90
90
  environment: flags.environment,
91
91
  });
92
92
  }
93
- const { entries, metadata, hasMoreMetricEvents, hasMoreLogEvents } = await (0, planGating_1.withObservePlanGateHandlingAsync)(() => (0, fetchSessions_1.fetchObserveSessionEventsAsync)(graphqlClient, projectId, {
93
+ const { entries, metadata, hasMoreMetricEvents, hasMoreLogEvents, hasMoreSpans } = await (0, planGating_1.withObservePlanGateHandlingAsync)(() => (0, fetchSessions_1.fetchObserveSessionEventsAsync)(graphqlClient, projectId, {
94
94
  sessionId,
95
95
  limit: SESSION_PAGE_SIZE,
96
96
  }));
97
97
  if (json) {
98
- (0, json_1.printJsonOnlyOutput)((0, formatSessions_1.buildObserveSessionEventsJson)(entries, sessionId, metadata, hasMoreMetricEvents, hasMoreLogEvents));
98
+ (0, json_1.printJsonOnlyOutput)((0, formatSessions_1.buildObserveSessionEventsJson)(entries, sessionId, metadata, hasMoreMetricEvents, hasMoreLogEvents, hasMoreSpans));
99
99
  }
100
100
  else {
101
101
  log_1.default.addNewLineIfNone();
@@ -103,6 +103,7 @@ class ObserveSession extends EasCommand_1.default {
103
103
  metadata,
104
104
  hasMoreMetricEvents,
105
105
  hasMoreLogEvents,
106
+ hasMoreSpans,
106
107
  }));
107
108
  }
108
109
  }
@@ -0,0 +1,17 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ export default class ObserveTrace extends EasCommand {
3
+ static description: string;
4
+ static args: {
5
+ traceId: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static flags: {
8
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ 'project-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
+ };
12
+ static contextDefinition: {
13
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
14
+ projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
15
+ };
16
+ runAsync(): Promise<void>;
17
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
6
+ const errors_1 = require("../../commandUtils/errors");
7
+ const flags_1 = require("../../commandUtils/flags");
8
+ const ObserveQuery_1 = require("../../graphql/queries/ObserveQuery");
9
+ const log_1 = tslib_1.__importDefault(require("../../log"));
10
+ const formatSpans_1 = require("../../observe/formatSpans");
11
+ const planGating_1 = require("../../observe/planGating");
12
+ const json_1 = require("../../utils/json");
13
+ // A trace ID is the 32-character hex string of the OTLP JSON encoding.
14
+ const TRACE_ID_REGEX = /^[0-9a-f]{32}$/i;
15
+ class ObserveTrace extends EasCommand_1.default {
16
+ static description = 'display every span of a single request trace by its trace ID, oldest first, with child spans indented under their parent. Trace IDs are shown by `eas observe:traces`. In `--json` output a span with no `parentSpanId` is a root span, and a span with no `http` object is not an HTTP request';
17
+ static args = {
18
+ traceId: core_1.Args.string({
19
+ description: 'ID of the trace to display',
20
+ required: true,
21
+ }),
22
+ };
23
+ static flags = {
24
+ ...flags_1.EasProjectIdFlag,
25
+ ...flags_1.EasNonInteractiveAndJsonFlags,
26
+ };
27
+ static contextDefinition = {
28
+ ...this.ContextOptions.ProjectId,
29
+ ...this.ContextOptions.LoggedIn,
30
+ };
31
+ async runAsync() {
32
+ const { flags, args } = await this.parse(ObserveTrace);
33
+ const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
34
+ const traceId = args.traceId;
35
+ if (!TRACE_ID_REGEX.test(traceId)) {
36
+ throw new errors_1.EasCommandError(`"${traceId}" is not a valid trace ID. A trace ID is 32 hexadecimal characters; copy it from the Trace ID column of \`eas observe:traces\`.`);
37
+ }
38
+ const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(ObserveTrace, {
39
+ nonInteractive,
40
+ projectIdOverride: flags['project-id'],
41
+ });
42
+ if (json) {
43
+ (0, json_1.enableJsonOutput)();
44
+ }
45
+ const trace = await (0, planGating_1.withObservePlanGateHandlingAsync)(() => ObserveQuery_1.ObserveQuery.traceByIdAsync(graphqlClient, { appId: projectId, id: traceId }));
46
+ if (!trace) {
47
+ throw new errors_1.EasCommandError(`No trace found with ID "${traceId}". Trace IDs come from \`eas observe:traces\`, and traces age out of retention.`);
48
+ }
49
+ if (json) {
50
+ (0, json_1.printJsonOnlyOutput)((0, formatSpans_1.buildObserveTraceJson)(trace));
51
+ }
52
+ else {
53
+ log_1.default.addNewLineIfNone();
54
+ log_1.default.log((0, formatSpans_1.buildObserveTraceTable)(trace));
55
+ }
56
+ }
57
+ }
58
+ exports.default = ObserveTrace;
@@ -0,0 +1,33 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ export default class ObserveTraces extends EasCommand {
3
+ static description: string;
4
+ static flags: {
5
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
6
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ 'project-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ 'session-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ kind: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
+ status: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ host: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
+ 'http-status': import("@oclif/core/lib/interfaces").OptionFlag<number[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
14
+ 'min-duration': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
15
+ 'root-only': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
16
+ 'all-spans': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
17
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
18
+ 'update-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
19
+ 'build-number': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
20
+ 'app-version': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
21
+ start: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
22
+ end: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
23
+ days: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
24
+ limit: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
25
+ after: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
26
+ platform: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
27
+ };
28
+ static contextDefinition: {
29
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
30
+ projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
31
+ };
32
+ runAsync(): Promise<void>;
33
+ }
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
6
+ const flags_1 = require("../../commandUtils/flags");
7
+ const pagination_1 = require("../../commandUtils/pagination");
8
+ const ObserveQuery_1 = require("../../graphql/queries/ObserveQuery");
9
+ const log_1 = tslib_1.__importDefault(require("../../log"));
10
+ const fetchSpans_1 = require("../../observe/fetchSpans");
11
+ const flags_2 = require("../../observe/flags");
12
+ const formatSpans_1 = require("../../observe/formatSpans");
13
+ const planGating_1 = require("../../observe/planGating");
14
+ const platforms_1 = require("../../observe/platforms");
15
+ const spanFilters_1 = require("../../observe/spanFilters");
16
+ const startAndEndTime_1 = require("../../observe/startAndEndTime");
17
+ const json_1 = require("../../utils/json");
18
+ const DEFAULT_SPANS_LIMIT = 20;
19
+ class ObserveTraces extends EasCommand_1.default {
20
+ static description = 'display request trace spans recorded by the app, newest first. With no span filters, a summary of span names and kinds with counts is returned. Pass --all-spans or a span filter (--name, --kind, --status, --host, --http-status, --min-duration, --root-only, --session-id) to list individual spans';
21
+ static flags = {
22
+ ...flags_2.ObservePlatformFlag,
23
+ ...flags_2.ObserveAfterFlag,
24
+ limit: (0, pagination_1.getLimitFlagWithCustomValues)({
25
+ defaultTo: DEFAULT_SPANS_LIMIT,
26
+ limit: 100,
27
+ }),
28
+ ...flags_2.ObserveTimeRangeFlags,
29
+ ...flags_2.ObserveAppVersionFlag,
30
+ ...flags_2.ObserveBuildNumberFlag,
31
+ ...flags_2.ObserveUpdateIdFlag,
32
+ ...flags_2.ObserveEnvironmentFlag,
33
+ 'session-id': core_1.Flags.string({
34
+ description: 'Filter by session ID',
35
+ }),
36
+ name: core_1.Flags.string({
37
+ description: 'Filter by span name, such as GET or POST (can be specified multiple times)',
38
+ multiple: true,
39
+ }),
40
+ kind: core_1.Flags.option({
41
+ description: 'Filter by span kind (can be specified multiple times)',
42
+ multiple: true,
43
+ options: spanFilters_1.allowedSpanKindFlagValues,
44
+ })(),
45
+ status: core_1.Flags.option({
46
+ description: 'Filter by span status (can be specified multiple times)',
47
+ multiple: true,
48
+ options: spanFilters_1.allowedSpanStatusFlagValues,
49
+ })(),
50
+ host: core_1.Flags.string({
51
+ description: 'Filter by request host (can be specified multiple times)',
52
+ multiple: true,
53
+ }),
54
+ 'http-status': core_1.Flags.integer({
55
+ description: 'Filter by HTTP response status code (can be specified multiple times)',
56
+ multiple: true,
57
+ }),
58
+ 'min-duration': core_1.Flags.integer({
59
+ description: 'Only spans that took at least this many milliseconds',
60
+ min: 0,
61
+ }),
62
+ 'root-only': core_1.Flags.boolean({
63
+ description: 'Only root spans (spans with no parent)',
64
+ default: false,
65
+ }),
66
+ 'all-spans': core_1.Flags.boolean({
67
+ description: 'List individual spans instead of the summary of span names + counts, even with no span filter',
68
+ default: false,
69
+ }),
70
+ ...flags_1.EasProjectIdFlag,
71
+ ...flags_1.EasNonInteractiveAndJsonFlags,
72
+ };
73
+ static contextDefinition = {
74
+ ...this.ContextOptions.ProjectId,
75
+ ...this.ContextOptions.LoggedIn,
76
+ };
77
+ async runAsync() {
78
+ const { flags } = await this.parse(ObserveTraces);
79
+ const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
80
+ const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(ObserveTraces, {
81
+ nonInteractive,
82
+ projectIdOverride: flags['project-id'],
83
+ });
84
+ if (json) {
85
+ (0, json_1.enableJsonOutput)();
86
+ }
87
+ const { daysBack, startTime, endTime } = (0, startAndEndTime_1.resolveTimeRange)(flags);
88
+ const platforms = (0, platforms_1.observePlatformsFromFlag)(flags.platform);
89
+ const hasSpanFilter = flags['session-id'] !== undefined ||
90
+ (flags.name?.length ?? 0) > 0 ||
91
+ (flags.kind?.length ?? 0) > 0 ||
92
+ (flags.status?.length ?? 0) > 0 ||
93
+ (flags.host?.length ?? 0) > 0 ||
94
+ (flags['http-status']?.length ?? 0) > 0 ||
95
+ flags['min-duration'] !== undefined ||
96
+ flags['root-only'];
97
+ // The names summary has no span-level filters and no pagination, so any of
98
+ // those (or --all-spans) means the caller wants the span list.
99
+ if (!hasSpanFilter && !flags['all-spans'] && !flags.after) {
100
+ const { names, isTruncated } = await (0, planGating_1.withObservePlanGateHandlingAsync)(() => ObserveQuery_1.ObserveQuery.spanNamesAsync(graphqlClient, {
101
+ appId: projectId,
102
+ input: {
103
+ startTime,
104
+ endTime,
105
+ ...(platforms?.length && { platforms }),
106
+ ...(flags.environment && { environment: flags.environment }),
107
+ ...(flags['app-version'] && { appVersion: flags['app-version'] }),
108
+ ...(flags['build-number'] && { appBuildNumber: flags['build-number'] }),
109
+ ...(flags['update-id'] && { appUpdateId: flags['update-id'] }),
110
+ },
111
+ }));
112
+ if (json) {
113
+ (0, json_1.printJsonOnlyOutput)((0, formatSpans_1.buildObserveSpanNamesJson)(names, isTruncated));
114
+ }
115
+ else {
116
+ log_1.default.addNewLineIfNone();
117
+ log_1.default.log((0, formatSpans_1.buildObserveSpanNamesTable)(names, {
118
+ daysBack,
119
+ startTime,
120
+ endTime,
121
+ isTruncated,
122
+ }));
123
+ }
124
+ return;
125
+ }
126
+ const { spans, pageInfo } = await (0, planGating_1.withObservePlanGateHandlingAsync)(() => (0, fetchSpans_1.fetchObserveSpansAsync)(graphqlClient, projectId, {
127
+ limit: flags.limit ?? DEFAULT_SPANS_LIMIT,
128
+ ...(flags.after && { after: flags.after }),
129
+ startTime,
130
+ endTime,
131
+ platforms,
132
+ appVersion: flags['app-version'],
133
+ buildNumber: flags['build-number'],
134
+ updateId: flags['update-id'],
135
+ environment: flags.environment,
136
+ sessionId: flags['session-id'],
137
+ names: flags.name,
138
+ kinds: (0, spanFilters_1.spanKindsFromFlag)(flags.kind),
139
+ statusCodes: (0, spanFilters_1.spanStatusCodesFromFlag)(flags.status),
140
+ hosts: flags.host,
141
+ httpStatusCodes: flags['http-status'],
142
+ minDurationMs: flags['min-duration'],
143
+ rootOnly: flags['root-only'],
144
+ }));
145
+ if (json) {
146
+ (0, json_1.printJsonOnlyOutput)((0, formatSpans_1.buildObserveSpansJson)(spans, pageInfo));
147
+ }
148
+ else {
149
+ log_1.default.addNewLineIfNone();
150
+ log_1.default.log((0, formatSpans_1.buildObserveSpansTable)(spans, pageInfo, {
151
+ daysBack,
152
+ startTime,
153
+ endTime,
154
+ sessionId: flags['session-id'],
155
+ }));
156
+ }
157
+ }
158
+ }
159
+ exports.default = ObserveTraces;