eas-cli 18.9.1 → 18.11.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 (72) hide show
  1. package/README.md +230 -95
  2. package/build/build/runBuildAndSubmit.d.ts +3 -1
  3. package/build/build/runBuildAndSubmit.js +12 -4
  4. package/build/build/utils/repository.js +15 -3
  5. package/build/build/validateLockfile.d.ts +1 -0
  6. package/build/build/validateLockfile.js +37 -0
  7. package/build/commandUtils/buildFlags.d.ts +1 -0
  8. package/build/commandUtils/buildFlags.js +18 -0
  9. package/build/commandUtils/convex.d.ts +12 -0
  10. package/build/commandUtils/convex.js +77 -0
  11. package/build/commands/build/dev.d.ts +1 -0
  12. package/build/commands/build/dev.js +12 -2
  13. package/build/commands/build/resign.js +0 -1
  14. package/build/commands/build/run.d.ts +1 -0
  15. package/build/commands/build/run.js +12 -3
  16. package/build/commands/integrations/convex/connect.d.ts +24 -0
  17. package/build/commands/integrations/convex/connect.js +266 -0
  18. package/build/commands/integrations/convex/dashboard.d.ts +9 -0
  19. package/build/commands/integrations/convex/dashboard.js +42 -0
  20. package/build/commands/integrations/convex/project/delete.d.ts +13 -0
  21. package/build/commands/integrations/convex/project/delete.js +65 -0
  22. package/build/commands/integrations/convex/project.d.ts +9 -0
  23. package/build/commands/integrations/convex/project.js +28 -0
  24. package/build/commands/integrations/convex/team/delete.d.ts +17 -0
  25. package/build/commands/integrations/convex/team/delete.js +93 -0
  26. package/build/commands/integrations/convex/team/invite.d.ts +19 -0
  27. package/build/commands/integrations/convex/team/invite.js +113 -0
  28. package/build/commands/integrations/convex/team.d.ts +9 -0
  29. package/build/commands/integrations/convex/team.js +35 -0
  30. package/build/commands/observe/events.js +12 -24
  31. package/build/commands/observe/logs.d.ts +29 -0
  32. package/build/commands/observe/logs.js +163 -0
  33. package/build/commands/observe/metrics.js +11 -19
  34. package/build/commands/observe/versions.js +11 -19
  35. package/build/commands/simulator/start.js +84 -5
  36. package/build/commands/simulator/stop.js +1 -1
  37. package/build/fingerprint/cli.js +1 -0
  38. package/build/graphql/generated.d.ts +421 -7
  39. package/build/graphql/generated.js +16 -3
  40. package/build/graphql/mutations/ConvexMutation.d.ts +10 -0
  41. package/build/graphql/mutations/ConvexMutation.js +89 -0
  42. package/build/graphql/mutations/DeviceRunSessionMutation.d.ts +2 -2
  43. package/build/graphql/mutations/DeviceRunSessionMutation.js +4 -4
  44. package/build/graphql/queries/ConvexQuery.d.ts +6 -0
  45. package/build/graphql/queries/ConvexQuery.js +49 -0
  46. package/build/graphql/queries/ObserveQuery.d.ts +21 -1
  47. package/build/graphql/queries/ObserveQuery.js +80 -0
  48. package/build/graphql/types/ConvexTeamConnection.d.ts +11 -0
  49. package/build/graphql/types/ConvexTeamConnection.js +43 -0
  50. package/build/graphql/types/Observe.d.ts +1 -0
  51. package/build/graphql/types/Observe.js +26 -1
  52. package/build/observe/fetchCustomEvents.d.ts +19 -0
  53. package/build/observe/fetchCustomEvents.js +21 -0
  54. package/build/observe/formatCustomEvents.d.ts +70 -0
  55. package/build/observe/formatCustomEvents.js +140 -0
  56. package/build/observe/formatEvents.js +5 -34
  57. package/build/observe/formatMetrics.js +2 -7
  58. package/build/observe/formatUtils.d.ts +27 -0
  59. package/build/observe/formatUtils.js +64 -0
  60. package/build/observe/formatVersions.js +2 -9
  61. package/build/observe/platforms.d.ts +21 -0
  62. package/build/observe/platforms.js +48 -0
  63. package/build/observe/resolveProjectContext.d.ts +22 -0
  64. package/build/observe/resolveProjectContext.js +21 -0
  65. package/build/run/ios/run.d.ts +2 -1
  66. package/build/run/ios/run.js +6 -2
  67. package/build/run/ios/simulator.d.ts +4 -1
  68. package/build/run/ios/simulator.js +14 -2
  69. package/build/run/run.d.ts +2 -1
  70. package/build/run/run.js +2 -2
  71. package/oclif.manifest.json +3984 -3243
  72. package/package.json +4 -4
@@ -0,0 +1,113 @@
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 chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const EasCommand_1 = tslib_1.__importDefault(require("../../../../commandUtils/EasCommand"));
7
+ const convex_1 = require("../../../../commandUtils/convex");
8
+ const flags_1 = require("../../../../commandUtils/flags");
9
+ const ConvexMutation_1 = require("../../../../graphql/mutations/ConvexMutation");
10
+ const ConvexQuery_1 = require("../../../../graphql/queries/ConvexQuery");
11
+ const log_1 = tslib_1.__importStar(require("../../../../log"));
12
+ const ora_1 = require("../../../../ora");
13
+ const projectUtils_1 = require("../../../../project/projectUtils");
14
+ const prompts_1 = require("../../../../prompts");
15
+ class IntegrationsConvexTeamInvite extends EasCommand_1.default {
16
+ static description = 'send a Convex team invitation to your verified email address';
17
+ static args = {
18
+ CONVEX_TEAM: core_1.Args.string({
19
+ required: false,
20
+ description: 'Slug of the Convex team to invite yourself to',
21
+ }),
22
+ };
23
+ static flags = {
24
+ ...flags_1.EASNonInteractiveFlag,
25
+ };
26
+ static contextDefinition = {
27
+ ...this.ContextOptions.ProjectConfig,
28
+ };
29
+ async runAsync() {
30
+ const { args: { CONVEX_TEAM: team }, flags: { 'non-interactive': nonInteractive }, } = await this.parse(IntegrationsConvexTeamInvite);
31
+ const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient, actor }, } = await this.getContextAsync(IntegrationsConvexTeamInvite, {
32
+ nonInteractive,
33
+ withServerSideEnvironment: null,
34
+ });
35
+ const email = this.getActorEmail(actor);
36
+ if (!email) {
37
+ log_1.default.warn(`Could not determine your verified email address, so no Convex team invitation was sent. Run ${chalk_1.default.cyan('eas integrations:convex:team:invite')} after signing in with a user account.`);
38
+ return;
39
+ }
40
+ const account = await (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId);
41
+ const connections = await ConvexQuery_1.ConvexQuery.getConvexTeamConnectionsByAccountIdAsync(graphqlClient, account.id);
42
+ if (connections.length === 0) {
43
+ (0, convex_1.logNoConvexTeams)(account.name);
44
+ return;
45
+ }
46
+ const connection = await this.resolveConnectionAsync(connections, team, nonInteractive);
47
+ log_1.default.addNewLineIfNone();
48
+ this.logTeam(connection);
49
+ this.logPreviousInvite(connection);
50
+ log_1.default.newLine();
51
+ if (connection.hasBeenClaimed) {
52
+ log_1.default.warn('Convex team has already been claimed. Skipping Convex team invitation.');
53
+ return;
54
+ }
55
+ if (!(await (0, convex_1.confirmRecentConvexInviteAsync)(connection, { nonInteractive }))) {
56
+ log_1.default.warn('Skipped sending Convex team invitation.');
57
+ return;
58
+ }
59
+ const spinner = (0, ora_1.ora)(`Sending Convex team invitation to ${email}`).start();
60
+ try {
61
+ await ConvexMutation_1.ConvexMutation.sendConvexTeamInviteToVerifiedEmailAsync(graphqlClient, {
62
+ convexTeamConnectionId: connection.id,
63
+ });
64
+ spinner.succeed(`Sent Convex team invitation to ${chalk_1.default.bold(email)} for ${chalk_1.default.bold((0, convex_1.formatConvexTeam)(connection))}`);
65
+ log_1.default.log(`Convex dashboard: ${(0, log_1.link)((0, convex_1.getConvexTeamDashboardUrl)(connection), { dim: false })}`);
66
+ }
67
+ catch (error) {
68
+ spinner.fail('Failed to send Convex team invitation');
69
+ throw error;
70
+ }
71
+ }
72
+ getActorEmail(actor) {
73
+ return 'email' in actor && typeof actor.email === 'string' ? actor.email : null;
74
+ }
75
+ logTeam(connection) {
76
+ log_1.default.log(chalk_1.default.bold(`Convex team ${(0, convex_1.formatConvexTeam)(connection)}`));
77
+ log_1.default.log(`${chalk_1.default.bold('Dashboard')}: ${(0, log_1.link)((0, convex_1.getConvexTeamDashboardUrl)(connection), { dim: false })}`);
78
+ log_1.default.log(`${chalk_1.default.bold('Claimed')}: ${connection.hasBeenClaimed ? 'Yes' : 'No'}`);
79
+ }
80
+ logPreviousInvite(connection) {
81
+ if (!connection.invitedEmail && !connection.invitedAt) {
82
+ return;
83
+ }
84
+ log_1.default.newLine();
85
+ log_1.default.log(chalk_1.default.bold('Previous invite'));
86
+ if (connection.invitedEmail) {
87
+ log_1.default.log(`${chalk_1.default.bold('Email')}: ${connection.invitedEmail}`);
88
+ }
89
+ if (connection.invitedAt) {
90
+ log_1.default.log(`${chalk_1.default.bold('Sent at')}: ${(0, convex_1.formatConvexInviteTimestamp)(connection.invitedAt)}`);
91
+ }
92
+ }
93
+ async resolveConnectionAsync(connections, team, nonInteractive) {
94
+ if (team) {
95
+ const connection = connections.find(item => item.convexTeamSlug === team || item.convexTeamName === team || item.id === team);
96
+ if (!connection) {
97
+ throw new Error(`Convex team ${team} is not linked to this account.`);
98
+ }
99
+ return connection;
100
+ }
101
+ if (connections.length === 1) {
102
+ return connections[0];
103
+ }
104
+ if (nonInteractive) {
105
+ throw new Error('Convex team slug must be provided in non-interactive mode when multiple Convex team links exist.');
106
+ }
107
+ return await (0, prompts_1.selectAsync)('Select a Convex team link to invite yourself to', connections.map(connection => ({
108
+ title: (0, convex_1.formatConvexTeam)(connection),
109
+ value: connection,
110
+ })));
111
+ }
112
+ }
113
+ exports.default = IntegrationsConvexTeamInvite;
@@ -0,0 +1,9 @@
1
+ import EasCommand from '../../../commandUtils/EasCommand';
2
+ export default class IntegrationsConvexTeam extends EasCommand {
3
+ static description: string;
4
+ static contextDefinition: {
5
+ loggedIn: import("../../../commandUtils/context/LoggedInContextField").default;
6
+ privateProjectConfig: import("../../../commandUtils/context/PrivateProjectConfigContextField").PrivateProjectConfigContextField;
7
+ };
8
+ runAsync(): Promise<void>;
9
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const EasCommand_1 = tslib_1.__importDefault(require("../../../commandUtils/EasCommand"));
6
+ const convex_1 = require("../../../commandUtils/convex");
7
+ const ConvexQuery_1 = require("../../../graphql/queries/ConvexQuery");
8
+ const log_1 = tslib_1.__importDefault(require("../../../log"));
9
+ const projectUtils_1 = require("../../../project/projectUtils");
10
+ class IntegrationsConvexTeam extends EasCommand_1.default {
11
+ static description = "display Convex teams linked to the current Expo app's owner account";
12
+ static contextDefinition = {
13
+ ...this.ContextOptions.ProjectConfig,
14
+ };
15
+ async runAsync() {
16
+ const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(IntegrationsConvexTeam, {
17
+ nonInteractive: false,
18
+ withServerSideEnvironment: null,
19
+ });
20
+ const account = await (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId);
21
+ const connections = await ConvexQuery_1.ConvexQuery.getConvexTeamConnectionsByAccountIdAsync(graphqlClient, account.id);
22
+ if (connections.length === 0) {
23
+ (0, convex_1.logNoConvexTeams)(account.name);
24
+ return;
25
+ }
26
+ log_1.default.log(chalk_1.default.bold(`Convex teams linked to @${account.name}`));
27
+ for (const [index, connection] of connections.entries()) {
28
+ if (index > 0) {
29
+ log_1.default.newLine();
30
+ }
31
+ log_1.default.log((0, convex_1.formatConvexTeamConnection)(connection));
32
+ }
33
+ }
34
+ }
35
+ exports.default = IntegrationsConvexTeam;
@@ -6,11 +6,12 @@ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasComm
6
6
  const errors_1 = require("../../commandUtils/errors");
7
7
  const flags_1 = require("../../commandUtils/flags");
8
8
  const pagination_1 = require("../../commandUtils/pagination");
9
- const generated_1 = require("../../graphql/generated");
10
9
  const log_1 = tslib_1.__importDefault(require("../../log"));
11
10
  const fetchEvents_1 = require("../../observe/fetchEvents");
12
11
  const metricNames_1 = require("../../observe/metricNames");
13
12
  const formatEvents_1 = require("../../observe/formatEvents");
13
+ const platforms_1 = require("../../observe/platforms");
14
+ const resolveProjectContext_1 = require("../../observe/resolveProjectContext");
14
15
  const startAndEndTime_1 = require("../../observe/startAndEndTime");
15
16
  const prompts_1 = require("../../prompts");
16
17
  const json_1 = require("../../utils/json");
@@ -34,7 +35,7 @@ class ObserveEvents extends EasCommand_1.default {
34
35
  })(),
35
36
  platform: core_1.Flags.option({
36
37
  description: 'Filter by platform',
37
- options: Object.values(generated_1.AppObservePlatform).map(s => s.toLowerCase()),
38
+ options: platforms_1.allowedPlatformFlagValues,
38
39
  })(),
39
40
  after: core_1.Flags.string({
40
41
  description: 'Cursor for pagination. Use the endCursor from a previous query to fetch the next page.',
@@ -76,20 +77,13 @@ class ObserveEvents extends EasCommand_1.default {
76
77
  };
77
78
  async runAsync() {
78
79
  const { flags, args } = await this.parse(ObserveEvents);
79
- let projectId;
80
- let graphqlClient;
81
- if (flags['project-id']) {
82
- projectId = flags['project-id'];
83
- const ctx = await this.getContextAsync({ contextDefinition: ObserveEvents.loggedInOnlyContextDefinition }, { nonInteractive: flags['non-interactive'] });
84
- graphqlClient = ctx.loggedIn.graphqlClient;
85
- }
86
- else {
87
- const ctx = await this.getContextAsync(ObserveEvents, {
88
- nonInteractive: flags['non-interactive'],
89
- });
90
- projectId = ctx.projectId;
91
- graphqlClient = ctx.loggedIn.graphqlClient;
92
- }
80
+ const { projectId, graphqlClient } = await (0, resolveProjectContext_1.resolveObserveCommandContextAsync)({
81
+ command: this,
82
+ commandClass: ObserveEvents,
83
+ loggedInOnlyContextDefinition: ObserveEvents.loggedInOnlyContextDefinition,
84
+ projectIdOverride: flags['project-id'],
85
+ nonInteractive: flags['non-interactive'],
86
+ });
93
87
  if (flags.json) {
94
88
  (0, json_1.enableJsonOutput)();
95
89
  }
@@ -113,14 +107,8 @@ class ObserveEvents extends EasCommand_1.default {
113
107
  }
114
108
  const orderBy = (0, fetchEvents_1.resolveOrderBy)(flags.sort);
115
109
  const { daysBack, startTime, endTime } = (0, startAndEndTime_1.resolveTimeRange)(flags);
116
- const platform = flags.platform
117
- ? flags.platform === 'android'
118
- ? generated_1.AppObservePlatform.Android
119
- : generated_1.AppObservePlatform.Ios
120
- : undefined;
121
- const platforms = platform
122
- ? [platform === generated_1.AppObservePlatform.Android ? generated_1.AppPlatform.Android : generated_1.AppPlatform.Ios]
123
- : [generated_1.AppPlatform.Android, generated_1.AppPlatform.Ios];
110
+ const platform = (0, platforms_1.appObservePlatformFromFlag)(flags.platform);
111
+ const platforms = (0, platforms_1.appPlatformsFromFlag)(flags.platform);
124
112
  const [{ events, pageInfo }, totalEventCount] = await Promise.all([
125
113
  (0, fetchEvents_1.fetchObserveEventsAsync)(graphqlClient, projectId, {
126
114
  metricName,
@@ -0,0 +1,29 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ export default class ObserveLogs extends EasCommand {
3
+ static hidden: boolean;
4
+ static description: string;
5
+ static args: {
6
+ eventName: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ platform: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ after: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
+ limit: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
14
+ start: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
15
+ end: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
16
+ days: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
17
+ 'app-version': 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
+ 'session-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
20
+ 'all-events': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
21
+ 'project-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
22
+ };
23
+ static contextDefinition: {
24
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
25
+ projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
26
+ };
27
+ private static loggedInOnlyContextDefinition;
28
+ runAsync(): Promise<void>;
29
+ }
@@ -0,0 +1,163 @@
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 log_1 = tslib_1.__importDefault(require("../../log"));
9
+ const ObserveQuery_1 = require("../../graphql/queries/ObserveQuery");
10
+ const fetchCustomEvents_1 = require("../../observe/fetchCustomEvents");
11
+ const formatCustomEvents_1 = require("../../observe/formatCustomEvents");
12
+ const platforms_1 = require("../../observe/platforms");
13
+ const resolveProjectContext_1 = require("../../observe/resolveProjectContext");
14
+ const startAndEndTime_1 = require("../../observe/startAndEndTime");
15
+ const json_1 = require("../../utils/json");
16
+ const DEFAULT_EVENTS_LIMIT = 10;
17
+ class ObserveLogs extends EasCommand_1.default {
18
+ static hidden = true;
19
+ static description = 'display individual custom events (logs) emitted by the app, 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
+ static args = {
21
+ eventName: core_1.Args.string({
22
+ description: 'Custom event name to filter by',
23
+ required: false,
24
+ }),
25
+ };
26
+ static flags = {
27
+ platform: core_1.Flags.option({
28
+ description: 'Filter by platform',
29
+ options: platforms_1.allowedPlatformFlagValues,
30
+ })(),
31
+ after: core_1.Flags.string({
32
+ description: 'Cursor for pagination. Use the endCursor from a previous query to fetch the next page.',
33
+ }),
34
+ limit: (0, pagination_1.getLimitFlagWithCustomValues)({
35
+ defaultTo: DEFAULT_EVENTS_LIMIT,
36
+ limit: 100,
37
+ }),
38
+ start: core_1.Flags.string({
39
+ description: 'Start of time range (ISO date)',
40
+ exclusive: ['days'],
41
+ }),
42
+ end: core_1.Flags.string({
43
+ description: 'End of time range (ISO date)',
44
+ exclusive: ['days'],
45
+ }),
46
+ days: core_1.Flags.integer({
47
+ description: 'Show events from the last N days (mutually exclusive with --start/--end)',
48
+ min: 1,
49
+ exclusive: ['start', 'end'],
50
+ }),
51
+ 'app-version': core_1.Flags.string({
52
+ description: 'Filter by app version',
53
+ }),
54
+ 'update-id': core_1.Flags.string({
55
+ description: 'Filter by EAS update ID',
56
+ }),
57
+ 'session-id': core_1.Flags.string({
58
+ description: 'Filter by session ID',
59
+ }),
60
+ 'all-events': core_1.Flags.boolean({
61
+ description: 'When no event name argument is provided, list all events across all event names instead of a summary of event names + counts.',
62
+ default: false,
63
+ }),
64
+ 'project-id': core_1.Flags.string({
65
+ description: 'EAS project ID (defaults to the project ID of the current directory)',
66
+ }),
67
+ ...flags_1.EasNonInteractiveAndJsonFlags,
68
+ };
69
+ static contextDefinition = {
70
+ ...this.ContextOptions.ProjectId,
71
+ ...this.ContextOptions.LoggedIn,
72
+ };
73
+ static loggedInOnlyContextDefinition = {
74
+ ...this.ContextOptions.LoggedIn,
75
+ };
76
+ async runAsync() {
77
+ const { flags, args } = await this.parse(ObserveLogs);
78
+ if (args.eventName && flags['all-events']) {
79
+ throw new Error('--all-events cannot be combined with an event name argument. Pass an event name to filter by it, or pass --all-events to list all events across all event names.');
80
+ }
81
+ const { projectId, graphqlClient } = await (0, resolveProjectContext_1.resolveObserveCommandContextAsync)({
82
+ command: this,
83
+ commandClass: ObserveLogs,
84
+ loggedInOnlyContextDefinition: ObserveLogs.loggedInOnlyContextDefinition,
85
+ projectIdOverride: flags['project-id'],
86
+ nonInteractive: flags['non-interactive'],
87
+ });
88
+ if (flags.json) {
89
+ (0, json_1.enableJsonOutput)();
90
+ }
91
+ else {
92
+ log_1.default.warn('EAS Observe is in preview and subject to breaking changes.');
93
+ }
94
+ const { daysBack, startTime, endTime } = (0, startAndEndTime_1.resolveTimeRange)(flags);
95
+ const platform = (0, platforms_1.appObservePlatformFromFlag)(flags.platform);
96
+ if (!args.eventName && !flags['all-events']) {
97
+ const { names, isTruncated } = await ObserveQuery_1.ObserveQuery.customEventNamesAsync(graphqlClient, {
98
+ appId: projectId,
99
+ startTime,
100
+ endTime,
101
+ platform,
102
+ });
103
+ if (flags.json) {
104
+ (0, json_1.printJsonOnlyOutput)((0, formatCustomEvents_1.buildObserveCustomEventNamesJson)(names, isTruncated));
105
+ }
106
+ else {
107
+ log_1.default.addNewLineIfNone();
108
+ log_1.default.log((0, formatCustomEvents_1.buildObserveCustomEventNamesTable)(names, {
109
+ daysBack,
110
+ startTime,
111
+ endTime,
112
+ isTruncated,
113
+ }));
114
+ }
115
+ return;
116
+ }
117
+ const { events, pageInfo } = await (0, fetchCustomEvents_1.fetchObserveCustomEventsAsync)(graphqlClient, projectId, {
118
+ eventName: args.eventName,
119
+ limit: flags.limit ?? DEFAULT_EVENTS_LIMIT,
120
+ ...(flags.after && { after: flags.after }),
121
+ startTime,
122
+ endTime,
123
+ platform,
124
+ appVersion: flags['app-version'],
125
+ updateId: flags['update-id'],
126
+ sessionId: flags['session-id'],
127
+ });
128
+ if (args.eventName && events.length === 0) {
129
+ const { names, isTruncated } = await ObserveQuery_1.ObserveQuery.customEventNamesAsync(graphqlClient, {
130
+ appId: projectId,
131
+ startTime,
132
+ endTime,
133
+ platform,
134
+ });
135
+ if (flags.json) {
136
+ (0, json_1.printJsonOnlyOutput)((0, formatCustomEvents_1.buildObserveCustomEventsEmptyWithSuggestionsJson)(args.eventName, names, isTruncated));
137
+ }
138
+ else {
139
+ log_1.default.addNewLineIfNone();
140
+ log_1.default.log((0, formatCustomEvents_1.buildObserveCustomEventsEmptyWithSuggestionsTable)(args.eventName, names, {
141
+ daysBack,
142
+ startTime,
143
+ endTime,
144
+ isTruncated,
145
+ }));
146
+ }
147
+ return;
148
+ }
149
+ if (flags.json) {
150
+ (0, json_1.printJsonOnlyOutput)((0, formatCustomEvents_1.buildObserveCustomEventsJson)(events, pageInfo));
151
+ }
152
+ else {
153
+ log_1.default.addNewLineIfNone();
154
+ log_1.default.log((0, formatCustomEvents_1.buildObserveCustomEventsTable)(events, pageInfo, {
155
+ eventName: args.eventName,
156
+ daysBack,
157
+ startTime,
158
+ endTime,
159
+ }));
160
+ }
161
+ }
162
+ }
163
+ exports.default = ObserveLogs;
@@ -4,11 +4,12 @@ const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
5
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
6
6
  const flags_1 = require("../../commandUtils/flags");
7
- const generated_1 = require("../../graphql/generated");
8
7
  const log_1 = tslib_1.__importDefault(require("../../log"));
9
8
  const fetchMetrics_1 = require("../../observe/fetchMetrics");
10
9
  const formatMetrics_1 = require("../../observe/formatMetrics");
11
10
  const metricNames_1 = require("../../observe/metricNames");
11
+ const platforms_1 = require("../../observe/platforms");
12
+ const resolveProjectContext_1 = require("../../observe/resolveProjectContext");
12
13
  const startAndEndTime_1 = require("../../observe/startAndEndTime");
13
14
  const json_1 = require("../../utils/json");
14
15
  const DEFAULT_METRICS = [
@@ -35,7 +36,7 @@ class ObserveMetrics extends EasCommand_1.default {
35
36
  static flags = {
36
37
  platform: core_1.Flags.option({
37
38
  description: 'Filter by platform',
38
- options: Object.values(generated_1.AppObservePlatform).map(s => s.toLowerCase()),
39
+ options: platforms_1.allowedPlatformFlagValues,
39
40
  })(),
40
41
  metric: core_1.Flags.option({
41
42
  description: 'Metric name to display (can be specified multiple times).',
@@ -74,20 +75,13 @@ class ObserveMetrics extends EasCommand_1.default {
74
75
  };
75
76
  async runAsync() {
76
77
  const { flags } = await this.parse(ObserveMetrics);
77
- let projectId;
78
- let graphqlClient;
79
- if (flags['project-id']) {
80
- projectId = flags['project-id'];
81
- const ctx = await this.getContextAsync({ contextDefinition: ObserveMetrics.loggedInOnlyContextDefinition }, { nonInteractive: flags['non-interactive'] });
82
- graphqlClient = ctx.loggedIn.graphqlClient;
83
- }
84
- else {
85
- const ctx = await this.getContextAsync(ObserveMetrics, {
86
- nonInteractive: flags['non-interactive'],
87
- });
88
- projectId = ctx.projectId;
89
- graphqlClient = ctx.loggedIn.graphqlClient;
90
- }
78
+ const { projectId, graphqlClient } = await (0, resolveProjectContext_1.resolveObserveCommandContextAsync)({
79
+ command: this,
80
+ commandClass: ObserveMetrics,
81
+ loggedInOnlyContextDefinition: ObserveMetrics.loggedInOnlyContextDefinition,
82
+ projectIdOverride: flags['project-id'],
83
+ nonInteractive: flags['non-interactive'],
84
+ });
91
85
  if (flags.json) {
92
86
  (0, json_1.enableJsonOutput)();
93
87
  }
@@ -98,9 +92,7 @@ class ObserveMetrics extends EasCommand_1.default {
98
92
  ? flags.metric.map(metricNames_1.resolveMetricName)
99
93
  : DEFAULT_METRICS;
100
94
  const { daysBack, startTime, endTime } = (0, startAndEndTime_1.resolveTimeRange)(flags);
101
- const platforms = flags.platform
102
- ? [flags.platform === 'android' ? generated_1.AppPlatform.Android : generated_1.AppPlatform.Ios]
103
- : [generated_1.AppPlatform.Android, generated_1.AppPlatform.Ios];
95
+ const platforms = (0, platforms_1.appPlatformsFromFlag)(flags.platform);
104
96
  const { metricsMap, buildNumbersMap, updateIdsMap, totalEventCounts } = await (0, fetchMetrics_1.fetchObserveMetricsAsync)(graphqlClient, projectId, metricNames, platforms, startTime, endTime);
105
97
  const argumentsStat = flags.stat?.length
106
98
  ? Array.from(new Set(flags.stat.map(formatMetrics_1.resolveStatKey)))
@@ -4,10 +4,11 @@ const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
5
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
6
6
  const flags_1 = require("../../commandUtils/flags");
7
- const generated_1 = require("../../graphql/generated");
8
7
  const log_1 = tslib_1.__importDefault(require("../../log"));
9
8
  const fetchVersions_1 = require("../../observe/fetchVersions");
10
9
  const formatVersions_1 = require("../../observe/formatVersions");
10
+ const platforms_1 = require("../../observe/platforms");
11
+ const resolveProjectContext_1 = require("../../observe/resolveProjectContext");
11
12
  const startAndEndTime_1 = require("../../observe/startAndEndTime");
12
13
  const json_1 = require("../../utils/json");
13
14
  class ObserveVersions extends EasCommand_1.default {
@@ -16,7 +17,7 @@ class ObserveVersions extends EasCommand_1.default {
16
17
  static flags = {
17
18
  platform: core_1.Flags.option({
18
19
  description: 'Filter by platform',
19
- options: Object.values(generated_1.AppObservePlatform).map(s => s.toLowerCase()),
20
+ options: platforms_1.allowedPlatformFlagValues,
20
21
  })(),
21
22
  start: core_1.Flags.string({
22
23
  description: 'Start of time range (ISO date)',
@@ -45,20 +46,13 @@ class ObserveVersions extends EasCommand_1.default {
45
46
  };
46
47
  async runAsync() {
47
48
  const { flags } = await this.parse(ObserveVersions);
48
- let projectId;
49
- let graphqlClient;
50
- if (flags['project-id']) {
51
- projectId = flags['project-id'];
52
- const ctx = await this.getContextAsync({ contextDefinition: ObserveVersions.loggedInOnlyContextDefinition }, { nonInteractive: flags['non-interactive'] });
53
- graphqlClient = ctx.loggedIn.graphqlClient;
54
- }
55
- else {
56
- const ctx = await this.getContextAsync(ObserveVersions, {
57
- nonInteractive: flags['non-interactive'],
58
- });
59
- projectId = ctx.projectId;
60
- graphqlClient = ctx.loggedIn.graphqlClient;
61
- }
49
+ const { projectId, graphqlClient } = await (0, resolveProjectContext_1.resolveObserveCommandContextAsync)({
50
+ command: this,
51
+ commandClass: ObserveVersions,
52
+ loggedInOnlyContextDefinition: ObserveVersions.loggedInOnlyContextDefinition,
53
+ projectIdOverride: flags['project-id'],
54
+ nonInteractive: flags['non-interactive'],
55
+ });
62
56
  if (flags.json) {
63
57
  (0, json_1.enableJsonOutput)();
64
58
  }
@@ -66,9 +60,7 @@ class ObserveVersions extends EasCommand_1.default {
66
60
  log_1.default.warn('EAS Observe is in preview and subject to breaking changes.');
67
61
  }
68
62
  const { startTime, endTime } = (0, startAndEndTime_1.resolveTimeRange)(flags);
69
- const platforms = flags.platform
70
- ? [flags.platform === 'android' ? generated_1.AppPlatform.Android : generated_1.AppPlatform.Ios]
71
- : [generated_1.AppPlatform.Android, generated_1.AppPlatform.Ios];
63
+ const platforms = (0, platforms_1.appPlatformsFromFlag)(flags.platform);
72
64
  const results = await (0, fetchVersions_1.fetchObserveVersionsAsync)(graphqlClient, projectId, platforms, startTime, endTime);
73
65
  if (flags.json) {
74
66
  (0, json_1.printJsonOnlyOutput)((0, formatVersions_1.buildObserveVersionsJson)(results));