eas-cli 21.3.0 → 21.5.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 (53) hide show
  1. package/README.md +338 -149
  2. package/build/build/build.js +102 -17
  3. package/build/build/local.js +64 -7
  4. package/build/commandUtils/workflow/compositeFunctions.d.ts +1 -0
  5. package/build/commandUtils/workflow/compositeFunctions.js +64 -0
  6. package/build/commandUtils/workflow/validation.js +3 -0
  7. package/build/commands/account/usage.d.ts +3 -0
  8. package/build/commands/account/usage.js +6 -5
  9. package/build/commands/integrations/posthog/connect.js +1 -1
  10. package/build/commands/observe/events.js +5 -2
  11. package/build/commands/project/new.d.ts +1 -1
  12. package/build/commands/simulator/events.d.ts +16 -0
  13. package/build/commands/simulator/events.js +136 -0
  14. package/build/commands/simulator/get.js +2 -0
  15. package/build/commands/simulator/list.js +2 -0
  16. package/build/commands/simulator/start.d.ts +1 -0
  17. package/build/commands/simulator/start.js +91 -24
  18. package/build/commands/submit/cancel.d.ts +20 -0
  19. package/build/commands/submit/cancel.js +116 -0
  20. package/build/commands/submit/list.d.ts +27 -0
  21. package/build/commands/submit/list.js +100 -0
  22. package/build/commands/submit/retry.d.ts +18 -0
  23. package/build/commands/submit/retry.js +123 -0
  24. package/build/commands/submit/status.d.ts +19 -0
  25. package/build/commands/submit/status.js +116 -0
  26. package/build/commands/submit/view.d.ts +17 -0
  27. package/build/commands/submit/view.js +96 -0
  28. package/build/graphql/generated.d.ts +780 -40
  29. package/build/graphql/generated.js +3 -0
  30. package/build/graphql/mutations/SubmissionMutation.d.ts +3 -1
  31. package/build/graphql/mutations/SubmissionMutation.js +33 -0
  32. package/build/graphql/queries/DeviceRunSessionQuery.d.ts +2 -1
  33. package/build/graphql/queries/DeviceRunSessionQuery.js +22 -0
  34. package/build/graphql/queries/SubmissionQuery.d.ts +3 -2
  35. package/build/graphql/queries/SubmissionQuery.js +19 -2
  36. package/build/graphql/types/SubmissionWithSubmittedBuild.d.ts +1 -0
  37. package/build/graphql/types/SubmissionWithSubmittedBuild.js +25 -0
  38. package/build/simulator/events.d.ts +7 -0
  39. package/build/simulator/events.js +95 -0
  40. package/build/simulator/utils.js +1 -1
  41. package/build/submit/queries.d.ts +34 -0
  42. package/build/submit/queries.js +94 -0
  43. package/build/submit/status.d.ts +31 -0
  44. package/build/submit/status.js +187 -0
  45. package/build/submit/utils/formatSubmission.d.ts +2 -0
  46. package/build/submit/utils/formatSubmission.js +78 -0
  47. package/build/utils/promise.d.ts +3 -2
  48. package/build/utils/promise.js +17 -3
  49. package/build/utils/terminalText.d.ts +1 -0
  50. package/build/utils/terminalText.js +14 -0
  51. package/build/utils/usage/checkForOverages.js +1 -1
  52. package/oclif.manifest.json +3229 -2628
  53. package/package.json +5 -5
@@ -37,6 +37,9 @@ class SimulatorStart extends EasCommand_1.default {
37
37
  description: 'Device platform',
38
38
  options: PLATFORM_FLAG_VALUES,
39
39
  })(),
40
+ name: core_1.Flags.string({
41
+ description: 'Human-readable name for the simulator session, shown in eas simulator:list and on expo.dev. Defaults to unnamed.',
42
+ }),
40
43
  type: core_1.Flags.option({
41
44
  description: 'Type of simulator session to create',
42
45
  options: Object.values(utils_1.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES),
@@ -75,6 +78,9 @@ class SimulatorStart extends EasCommand_1.default {
75
78
  const { projectId, projectDir, loggedIn: { graphqlClient }, } = await this.getContextAsync(SimulatorStart, {
76
79
  nonInteractive,
77
80
  });
81
+ // The server rejects blank names, so trim here and treat a whitespace-only
82
+ // --name as if it had been omitted rather than surfacing a validation error.
83
+ const name = flags.name?.trim() || undefined;
78
84
  await (0, env_1.loadSimulatorEnvAsync)(projectDir);
79
85
  const existingDeviceRunSessionId = process.env[env_1.EAS_SIMULATOR_SESSION_ID];
80
86
  if (existingDeviceRunSessionId && !flags.force) {
@@ -90,9 +96,11 @@ class SimulatorStart extends EasCommand_1.default {
90
96
  const createSpinner = (0, ora_1.ora)('🚀 Creating simulator session').start();
91
97
  let deviceRunSessionId;
92
98
  let deviceRunSessionUrl;
99
+ let sessionInterrupt;
93
100
  try {
94
101
  const session = await DeviceRunSessionMutation_1.DeviceRunSessionMutation.createDeviceRunSessionAsync(graphqlClient, {
95
102
  appId: projectId,
103
+ name,
96
104
  platform,
97
105
  type: utils_1.DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE[flags.type],
98
106
  packageVersion: flags['package-version'],
@@ -101,6 +109,7 @@ class SimulatorStart extends EasCommand_1.default {
101
109
  deviceRunSessionId = session.id;
102
110
  (0, nullthrows_1.default)(session.turtleJobRun?.id, 'Expected simulator session to start');
103
111
  deviceRunSessionUrl = (0, url_1.getDeviceRunSessionUrl)(session.app.ownerAccount.name, session.app.slug, deviceRunSessionId);
112
+ sessionInterrupt = registerSessionInterrupt(deviceRunSessionId);
104
113
  const simulatorEnvWritten = !jsonFlag && flags['out-config-type'] === OUT_CONFIG_TYPE_VALUES.Dotenv
105
114
  ? await writeSimulatorEnvSafelyAsync(projectDir, {
106
115
  [env_1.EAS_SIMULATOR_SESSION_ID]: deviceRunSessionId,
@@ -110,14 +119,21 @@ class SimulatorStart extends EasCommand_1.default {
110
119
  }
111
120
  catch (err) {
112
121
  createSpinner.fail('Failed to create simulator session');
122
+ sessionInterrupt?.dispose();
113
123
  throw err;
114
124
  }
115
125
  const pollSpinner = (0, ora_1.ora)(`⏳ Waiting for ${flags.type} session to be ready`).start();
116
126
  const deadline = Date.now() + POLL_TIMEOUT_MS;
117
127
  let remoteConfig;
118
128
  try {
119
- while (Date.now() < deadline) {
120
- const session = await DeviceRunSessionQuery_1.DeviceRunSessionQuery.byIdAsync(graphqlClient, deviceRunSessionId);
129
+ while (!sessionInterrupt.signal.aborted && Date.now() < deadline) {
130
+ const session = await Promise.race([
131
+ DeviceRunSessionQuery_1.DeviceRunSessionQuery.byIdAsync(graphqlClient, deviceRunSessionId),
132
+ sessionInterrupt.abortPromise,
133
+ ]);
134
+ if (!session) {
135
+ break;
136
+ }
121
137
  if (session.status === generated_1.DeviceRunSessionStatus.Errored ||
122
138
  session.status === generated_1.DeviceRunSessionStatus.Stopped) {
123
139
  throw new Error(`Simulator session ${deviceRunSessionId} ${session.status.toLowerCase()} before the ${flags.type} session was ready. ${(0, log_1.link)(deviceRunSessionUrl)}`);
@@ -133,17 +149,29 @@ class SimulatorStart extends EasCommand_1.default {
133
149
  pollSpinner.succeed(`🎉 ${flags.type} session is ready`);
134
150
  break;
135
151
  }
136
- await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS);
152
+ await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS, sessionInterrupt.signal);
137
153
  }
138
154
  }
139
155
  catch (err) {
140
156
  pollSpinner.fail(`Failed while polling for ${flags.type} session to be ready`);
141
157
  await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
158
+ sessionInterrupt.dispose();
142
159
  throw err;
143
160
  }
161
+ if (sessionInterrupt.signal.aborted) {
162
+ await stopDeviceRunSessionAfterInterruptAsync({
163
+ graphqlClient,
164
+ deviceRunSessionId,
165
+ projectDir,
166
+ spinner: pollSpinner,
167
+ sessionInterrupt,
168
+ });
169
+ return;
170
+ }
144
171
  if (!remoteConfig) {
145
172
  pollSpinner.fail(`Timed out waiting for ${flags.type} session to be ready`);
146
173
  await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
174
+ sessionInterrupt.dispose();
147
175
  throw new Error(`Timed out after ${Math.round(POLL_TIMEOUT_MS / 1000)}s waiting for ${flags.type} session to be ready. ${(0, log_1.link)(deviceRunSessionUrl)}`);
148
176
  }
149
177
  if (flags['out-config-type'] === OUT_CONFIG_TYPE_VALUES.Dotenv) {
@@ -152,9 +180,21 @@ class SimulatorStart extends EasCommand_1.default {
152
180
  [env_1.EAS_SIMULATOR_SESSION_ID]: deviceRunSessionId,
153
181
  });
154
182
  }
183
+ if (sessionInterrupt.signal.aborted) {
184
+ await stopDeviceRunSessionAfterInterruptAsync({
185
+ graphqlClient,
186
+ deviceRunSessionId,
187
+ projectDir,
188
+ spinner: pollSpinner,
189
+ sessionInterrupt,
190
+ });
191
+ return;
192
+ }
155
193
  if (jsonFlag) {
194
+ sessionInterrupt.dispose();
156
195
  (0, json_1.printJsonOnlyOutput)({
157
196
  id: deviceRunSessionId,
197
+ name,
158
198
  type: flags.type,
159
199
  deviceRunSessionUrl,
160
200
  remoteConfig,
@@ -165,6 +205,7 @@ class SimulatorStart extends EasCommand_1.default {
165
205
  log_1.default.log((0, utils_1.formatRemoteSessionInstructions)(remoteConfig, flags['out-config-type']));
166
206
  log_1.default.newLine();
167
207
  if (nonInteractive) {
208
+ sessionInterrupt.dispose();
168
209
  log_1.default.log(`When you are done, stop the session with: eas simulator:stop --id ${deviceRunSessionId}`);
169
210
  return;
170
211
  }
@@ -173,6 +214,7 @@ class SimulatorStart extends EasCommand_1.default {
173
214
  deviceRunSessionId,
174
215
  deviceRunSessionUrl,
175
216
  projectDir,
217
+ sessionInterrupt,
176
218
  });
177
219
  }
178
220
  }
@@ -205,25 +247,9 @@ async function writeSimulatorEnvSafelyAsync(projectDir, environmentVariables) {
205
247
  return false;
206
248
  }
207
249
  }
208
- async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessionId, deviceRunSessionUrl, projectDir, }) {
250
+ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessionId, deviceRunSessionUrl, projectDir, sessionInterrupt, }) {
209
251
  const spinner = (0, ora_1.ora)(`Simulator session active — press Ctrl+C to stop, or run \`eas simulator:stop --id ${deviceRunSessionId}\` from another shell`).start();
210
- const abortController = new AbortController();
211
- const { signal } = abortController;
212
- const abortPromise = new Promise(resolve => {
213
- signal.addEventListener('abort', () => {
214
- resolve();
215
- }, { once: true });
216
- });
217
- const sigintHandler = () => {
218
- if (signal.aborted) {
219
- // Force exit on a second Ctrl+C in case cleanup is hanging. The session may still be
220
- // running on EAS, so tell the user how to make sure it gets terminated.
221
- spinner.fail(`Aborted before the simulator session could be stopped. Run \`eas simulator:stop --id ${deviceRunSessionId}\` to terminate it and avoid unexpected charges.`);
222
- process.exit(130);
223
- }
224
- abortController.abort();
225
- };
226
- process.on('SIGINT', sigintHandler);
252
+ const { signal } = sessionInterrupt;
227
253
  try {
228
254
  while (!signal.aborted) {
229
255
  let session;
@@ -232,7 +258,7 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
232
258
  }
233
259
  catch (err) {
234
260
  log_1.default.debug(`Failed to poll simulator session: ${err instanceof Error ? err.message : String(err)}`);
235
- await Promise.race([(0, promise_1.sleepAsync)(POLL_INTERVAL_MS), abortPromise]);
261
+ await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS, signal);
236
262
  continue;
237
263
  }
238
264
  const jobRunStatus = session.turtleJobRun?.status;
@@ -248,7 +274,7 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
248
274
  await resetSimulatorEnvVerboseAsync(projectDir);
249
275
  return;
250
276
  }
251
- await Promise.race([(0, promise_1.sleepAsync)(POLL_INTERVAL_MS), abortPromise]);
277
+ await (0, promise_1.sleepAsync)(POLL_INTERVAL_MS, signal);
252
278
  }
253
279
  spinner.text = 'Stopping simulator session...';
254
280
  const stopped = await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
@@ -261,8 +287,49 @@ async function waitForSessionEndOrInterruptAsync({ graphqlClient, deviceRunSessi
261
287
  }
262
288
  }
263
289
  finally {
264
- process.removeListener('SIGINT', sigintHandler);
290
+ sessionInterrupt.dispose();
291
+ }
292
+ }
293
+ function registerSessionInterrupt(deviceRunSessionId) {
294
+ const abortController = new AbortController();
295
+ const { signal } = abortController;
296
+ const abortPromise = new Promise(resolve => {
297
+ signal.addEventListener('abort', () => {
298
+ resolve();
299
+ }, { once: true });
300
+ });
301
+ const sigintHandler = () => {
302
+ if (signal.aborted) {
303
+ // Force exit on a second Ctrl+C in case cleanup is hanging. The session may still be
304
+ // running on EAS, so tell the user how to make sure it gets terminated.
305
+ log_1.default.error(`Aborted before the simulator session could be stopped. Run \`eas simulator:stop --id ${deviceRunSessionId}\` to terminate it and avoid unexpected charges.`);
306
+ process.exit(130);
307
+ }
308
+ abortController.abort();
309
+ };
310
+ process.on('SIGINT', sigintHandler);
311
+ return {
312
+ signal,
313
+ abortPromise,
314
+ dispose: () => process.removeListener('SIGINT', sigintHandler),
315
+ };
316
+ }
317
+ async function stopDeviceRunSessionAfterInterruptAsync({ graphqlClient, deviceRunSessionId, projectDir, spinner, sessionInterrupt, }) {
318
+ try {
319
+ spinner.text = 'Stopping simulator session...';
320
+ const stopped = await ensureDeviceRunSessionStoppedSafelyAsync(graphqlClient, deviceRunSessionId);
321
+ if (stopped) {
322
+ spinner.succeed('Simulator session stopped');
323
+ await resetSimulatorEnvVerboseAsync(projectDir);
324
+ }
325
+ else {
326
+ spinner.fail(`Could not confirm the simulator session was stopped. Run \`eas simulator:stop --id ${deviceRunSessionId}\` to terminate it and avoid unexpected charges.`);
327
+ }
328
+ }
329
+ finally {
330
+ sessionInterrupt.dispose();
265
331
  }
332
+ process.exit(130);
266
333
  }
267
334
  async function resetSimulatorEnvVerboseAsync(projectDir) {
268
335
  try {
@@ -0,0 +1,20 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
3
+ import { AppPlatform } from '../../graphql/generated';
4
+ import { RequestedPlatform } from '../../platform';
5
+ export declare function selectSubmissionToCancelAsync(graphqlClient: ExpoGraphqlClient, projectId: string, projectDisplayName: string, platform?: AppPlatform): Promise<string | null>;
6
+ export default class SubmissionCancel extends EasCommand {
7
+ static description: string;
8
+ static args: {
9
+ SUBMISSION_ID: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
10
+ };
11
+ static flags: {
12
+ platform: import("@oclif/core/lib/interfaces").OptionFlag<RequestedPlatform | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ };
15
+ static contextDefinition: {
16
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
17
+ projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
18
+ };
19
+ runAsync(): Promise<void>;
20
+ }
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.selectSubmissionToCancelAsync = selectSubmissionToCancelAsync;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
7
+ const flags_1 = require("../../commandUtils/flags");
8
+ const generated_1 = require("../../graphql/generated");
9
+ const SubmissionMutation_1 = require("../../graphql/mutations/SubmissionMutation");
10
+ const log_1 = tslib_1.__importDefault(require("../../log"));
11
+ const ora_1 = require("../../ora");
12
+ const platform_1 = require("../../platform");
13
+ const projectUtils_1 = require("../../project/projectUtils");
14
+ const prompts_1 = require("../../prompts");
15
+ const queries_1 = require("../../submit/queries");
16
+ const CANCELLABLE_STATUSES = [
17
+ generated_1.SubmissionStatus.AwaitingBuild,
18
+ generated_1.SubmissionStatus.InQueue,
19
+ generated_1.SubmissionStatus.InProgress,
20
+ ];
21
+ async function selectSubmissionToCancelAsync(graphqlClient, projectId, projectDisplayName, platform) {
22
+ const spinner = (0, ora_1.ora)().start('Fetching the uncompleted submissions…');
23
+ let cancellableSubmissions;
24
+ try {
25
+ cancellableSubmissions = await (0, queries_1.getRecentSubmissionsWithStatusesAsync)(graphqlClient, {
26
+ projectId,
27
+ platform,
28
+ statuses: CANCELLABLE_STATUSES,
29
+ });
30
+ spinner.stop();
31
+ }
32
+ catch (error) {
33
+ spinner.fail(`Something went wrong and we couldn't fetch the submissions for the project ${projectDisplayName}.`);
34
+ throw error;
35
+ }
36
+ if (cancellableSubmissions.length === 0) {
37
+ log_1.default.warn(`We couldn't find any uncompleted submissions for the project ${projectDisplayName}.`);
38
+ return null;
39
+ }
40
+ else {
41
+ const submissionId = await (0, prompts_1.selectAsync)('Which submission do you want to cancel?', cancellableSubmissions.map(submission => ({
42
+ title: (0, queries_1.formatSubmissionChoice)(submission),
43
+ value: submission.id,
44
+ })));
45
+ return (await (0, prompts_1.confirmAsync)({
46
+ message: 'Are you sure you want to cancel it?',
47
+ }))
48
+ ? submissionId
49
+ : null;
50
+ }
51
+ }
52
+ class SubmissionCancel extends EasCommand_1.default {
53
+ static description = 'cancel a submission';
54
+ static args = {
55
+ SUBMISSION_ID: core_1.Args.string({}),
56
+ };
57
+ static flags = {
58
+ ...flags_1.EASNonInteractiveFlag,
59
+ platform: core_1.Flags.option({
60
+ char: 'p',
61
+ description: 'Filter submissions by the platform if submission ID is not provided',
62
+ options: Object.values(platform_1.RequestedPlatform),
63
+ })(),
64
+ };
65
+ static contextDefinition = {
66
+ ...this.ContextOptions.ProjectId,
67
+ ...this.ContextOptions.LoggedIn,
68
+ };
69
+ async runAsync() {
70
+ const { args: { SUBMISSION_ID: submissionIdFromArg }, flags: { 'non-interactive': nonInteractive, platform }, } = await this.parse(SubmissionCancel);
71
+ if (submissionIdFromArg && platform) {
72
+ throw new Error('Submission ID cannot be used together with the platform flag. The flag is used to filter the list of submissions when not providing the submission ID');
73
+ }
74
+ if (!submissionIdFromArg && nonInteractive) {
75
+ throw new Error('Submission ID must be provided in non-interactive mode');
76
+ }
77
+ const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(SubmissionCancel, {
78
+ nonInteractive,
79
+ });
80
+ let submissionId = submissionIdFromArg ?? null;
81
+ if (!submissionId) {
82
+ const displayName = await (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId);
83
+ submissionId = await selectSubmissionToCancelAsync(graphqlClient, projectId, displayName, toAppPlatform(platform));
84
+ if (!submissionId) {
85
+ return;
86
+ }
87
+ }
88
+ const spinner = (0, ora_1.ora)().start('Canceling the submission…');
89
+ try {
90
+ const { status } = await SubmissionMutation_1.SubmissionMutation.cancelSubmissionAsync(graphqlClient, submissionId);
91
+ if (status === generated_1.SubmissionStatus.Canceled) {
92
+ spinner.succeed('Submission canceled');
93
+ }
94
+ else {
95
+ spinner.text = 'Submission is already completed';
96
+ spinner.stopAndPersist();
97
+ }
98
+ }
99
+ catch (error) {
100
+ spinner.fail(`Something went wrong and we couldn't cancel your submission ${submissionId}`);
101
+ throw error;
102
+ }
103
+ }
104
+ }
105
+ exports.default = SubmissionCancel;
106
+ const toAppPlatform = (requestedPlatform) => {
107
+ if (!requestedPlatform || requestedPlatform === platform_1.RequestedPlatform.All) {
108
+ return undefined;
109
+ }
110
+ else if (requestedPlatform === platform_1.RequestedPlatform.Android) {
111
+ return generated_1.AppPlatform.Android;
112
+ }
113
+ else {
114
+ return generated_1.AppPlatform.Ios;
115
+ }
116
+ };
@@ -0,0 +1,27 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ import { RequestedPlatform } from '../../platform';
3
+ declare enum SubmissionStatus {
4
+ AWAITING_BUILD = "awaiting-build",
5
+ IN_QUEUE = "in-queue",
6
+ IN_PROGRESS = "in-progress",
7
+ FINISHED = "finished",
8
+ ERRORED = "errored",
9
+ CANCELED = "canceled"
10
+ }
11
+ export default class SubmissionList extends EasCommand {
12
+ static description: string;
13
+ static flags: {
14
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
16
+ limit: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
17
+ offset: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
18
+ platform: import("@oclif/core/lib/interfaces").OptionFlag<RequestedPlatform | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
19
+ status: import("@oclif/core/lib/interfaces").OptionFlag<SubmissionStatus | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
20
+ };
21
+ static contextDefinition: {
22
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
23
+ projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
24
+ };
25
+ runAsync(): Promise<void>;
26
+ }
27
+ export {};
@@ -0,0 +1,100 @@
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 generated_1 = require("../../graphql/generated");
9
+ const platform_1 = require("../../platform");
10
+ const projectUtils_1 = require("../../project/projectUtils");
11
+ const queries_1 = require("../../submit/queries");
12
+ const json_1 = require("../../utils/json");
13
+ var SubmissionStatus;
14
+ (function (SubmissionStatus) {
15
+ SubmissionStatus["AWAITING_BUILD"] = "awaiting-build";
16
+ SubmissionStatus["IN_QUEUE"] = "in-queue";
17
+ SubmissionStatus["IN_PROGRESS"] = "in-progress";
18
+ SubmissionStatus["FINISHED"] = "finished";
19
+ SubmissionStatus["ERRORED"] = "errored";
20
+ SubmissionStatus["CANCELED"] = "canceled";
21
+ })(SubmissionStatus || (SubmissionStatus = {}));
22
+ class SubmissionList extends EasCommand_1.default {
23
+ static description = 'list submissions for your project';
24
+ static flags = {
25
+ platform: core_1.Flags.option({
26
+ options: Object.values(platform_1.RequestedPlatform),
27
+ char: 'p',
28
+ })(),
29
+ status: core_1.Flags.option({
30
+ options: Object.values(SubmissionStatus),
31
+ description: 'Filter only submissions with the specified status',
32
+ })(),
33
+ ...pagination_1.EasPaginatedQueryFlags,
34
+ limit: (0, pagination_1.getLimitFlagWithCustomValues)({ defaultTo: 10, limit: queries_1.SUBMISSIONS_LIMIT }),
35
+ ...flags_1.EasNonInteractiveAndJsonFlags,
36
+ };
37
+ static contextDefinition = {
38
+ ...this.ContextOptions.ProjectId,
39
+ ...this.ContextOptions.LoggedIn,
40
+ };
41
+ async runAsync() {
42
+ const { flags } = await this.parse(SubmissionList);
43
+ const paginatedQueryOptions = (0, pagination_1.getPaginatedQueryOptions)(flags);
44
+ const { json: jsonFlag, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
45
+ const { platform: requestedPlatform, status: submissionStatus } = flags;
46
+ if (jsonFlag) {
47
+ (0, json_1.enableJsonOutput)();
48
+ }
49
+ const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(SubmissionList, {
50
+ nonInteractive,
51
+ });
52
+ const platform = toAppPlatform(requestedPlatform);
53
+ const graphqlSubmissionStatus = toGraphQLSubmissionStatus(submissionStatus);
54
+ const displayName = await (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId);
55
+ await (0, queries_1.listAndRenderSubmissionsOnAppAsync)(graphqlClient, {
56
+ projectId,
57
+ projectDisplayName: displayName,
58
+ filter: {
59
+ platform,
60
+ status: graphqlSubmissionStatus,
61
+ },
62
+ paginatedQueryOptions,
63
+ });
64
+ }
65
+ }
66
+ exports.default = SubmissionList;
67
+ const toAppPlatform = (requestedPlatform) => {
68
+ if (!requestedPlatform || requestedPlatform === platform_1.RequestedPlatform.All) {
69
+ return undefined;
70
+ }
71
+ else if (requestedPlatform === platform_1.RequestedPlatform.Android) {
72
+ return generated_1.AppPlatform.Android;
73
+ }
74
+ else {
75
+ return generated_1.AppPlatform.Ios;
76
+ }
77
+ };
78
+ const toGraphQLSubmissionStatus = (submissionStatus) => {
79
+ if (!submissionStatus) {
80
+ return undefined;
81
+ }
82
+ else if (submissionStatus === SubmissionStatus.AWAITING_BUILD) {
83
+ return generated_1.SubmissionStatus.AwaitingBuild;
84
+ }
85
+ else if (submissionStatus === SubmissionStatus.IN_QUEUE) {
86
+ return generated_1.SubmissionStatus.InQueue;
87
+ }
88
+ else if (submissionStatus === SubmissionStatus.IN_PROGRESS) {
89
+ return generated_1.SubmissionStatus.InProgress;
90
+ }
91
+ else if (submissionStatus === SubmissionStatus.FINISHED) {
92
+ return generated_1.SubmissionStatus.Finished;
93
+ }
94
+ else if (submissionStatus === SubmissionStatus.ERRORED) {
95
+ return generated_1.SubmissionStatus.Errored;
96
+ }
97
+ else {
98
+ return generated_1.SubmissionStatus.Canceled;
99
+ }
100
+ };
@@ -0,0 +1,18 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ import { RequestedPlatform } from '../../platform';
3
+ export default class SubmissionRetry extends EasCommand {
4
+ static description: string;
5
+ static args: {
6
+ SUBMISSION_ID: 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<RequestedPlatform | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ };
13
+ static contextDefinition: {
14
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
15
+ projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
16
+ };
17
+ runAsync(): Promise<void>;
18
+ }
@@ -0,0 +1,123 @@
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 generated_1 = require("../../graphql/generated");
8
+ const SubmissionMutation_1 = require("../../graphql/mutations/SubmissionMutation");
9
+ const SubmissionQuery_1 = require("../../graphql/queries/SubmissionQuery");
10
+ const log_1 = tslib_1.__importDefault(require("../../log"));
11
+ const ora_1 = require("../../ora");
12
+ const platform_1 = require("../../platform");
13
+ const projectUtils_1 = require("../../project/projectUtils");
14
+ const prompts_1 = require("../../prompts");
15
+ const queries_1 = require("../../submit/queries");
16
+ const urls_1 = require("../../submit/utils/urls");
17
+ const json_1 = require("../../utils/json");
18
+ async function selectSubmissionToRetryAsync(graphqlClient, projectId, projectDisplayName, platform) {
19
+ const spinner = (0, ora_1.ora)().start('Fetching the retryable submissions…');
20
+ let submissions;
21
+ try {
22
+ // Only failed submissions can be retried, so filter by status on the server — recent
23
+ // finished submissions must not push retryable ones off the page.
24
+ submissions = await (0, queries_1.getRecentSubmissionsWithStatusesAsync)(graphqlClient, {
25
+ projectId,
26
+ platform,
27
+ statuses: [generated_1.SubmissionStatus.Errored],
28
+ });
29
+ spinner.stop();
30
+ }
31
+ catch (error) {
32
+ spinner.fail(`Something went wrong and we couldn't fetch the submissions for the project ${projectDisplayName}.`);
33
+ throw error;
34
+ }
35
+ const retryableSubmissions = submissions.filter(submission => submission.canRetry);
36
+ if (retryableSubmissions.length === 0) {
37
+ log_1.default.warn(`We couldn't find any retryable submissions for the project ${projectDisplayName}. Submissions can be retried only for a limited time after they fail.`);
38
+ return null;
39
+ }
40
+ return await (0, prompts_1.selectAsync)('Which submission do you want to retry?', retryableSubmissions.map(submission => ({
41
+ title: (0, queries_1.formatSubmissionChoice)(submission),
42
+ value: submission.id,
43
+ })));
44
+ }
45
+ class SubmissionRetry extends EasCommand_1.default {
46
+ static description = 'retry a failed submission';
47
+ static args = {
48
+ SUBMISSION_ID: core_1.Args.string({}),
49
+ };
50
+ static flags = {
51
+ platform: core_1.Flags.option({
52
+ char: 'p',
53
+ description: 'Filter submissions by the platform if submission ID is not provided',
54
+ options: Object.values(platform_1.RequestedPlatform),
55
+ })(),
56
+ ...flags_1.EasNonInteractiveAndJsonFlags,
57
+ };
58
+ static contextDefinition = {
59
+ ...this.ContextOptions.ProjectId,
60
+ ...this.ContextOptions.LoggedIn,
61
+ };
62
+ async runAsync() {
63
+ const { args: { SUBMISSION_ID: submissionIdFromArg }, flags, } = await this.parse(SubmissionRetry);
64
+ const { json: jsonFlag, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
65
+ if (submissionIdFromArg && flags.platform) {
66
+ throw new Error('Submission ID cannot be used together with the platform flag. The flag is used to filter the list of submissions when not providing the submission ID');
67
+ }
68
+ if (!submissionIdFromArg && nonInteractive) {
69
+ throw new Error('Submission ID must be provided in non-interactive mode');
70
+ }
71
+ if (jsonFlag) {
72
+ (0, json_1.enableJsonOutput)();
73
+ }
74
+ const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(SubmissionRetry, {
75
+ nonInteractive,
76
+ });
77
+ let submissionId = submissionIdFromArg ?? null;
78
+ if (!submissionId) {
79
+ const displayName = await (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId);
80
+ submissionId = await selectSubmissionToRetryAsync(graphqlClient, projectId, displayName, toAppPlatform(flags.platform));
81
+ if (!submissionId) {
82
+ return;
83
+ }
84
+ }
85
+ else {
86
+ const submission = await SubmissionQuery_1.SubmissionQuery.byIdWithSubmittedBuildAsync(graphqlClient, submissionId);
87
+ if (!submission.canRetry) {
88
+ const retryWindowHint = submission.maxRetryTimeMinutes > 0
89
+ ? `, for up to ${submission.maxRetryTimeMinutes} minutes after they complete`
90
+ : '';
91
+ throw new Error(`Submission ${submissionId} cannot be retried. Only failed submissions can be retried${retryWindowHint}.`);
92
+ }
93
+ }
94
+ const spinner = (0, ora_1.ora)().start('Retrying the submission…');
95
+ let retriedSubmission;
96
+ try {
97
+ retriedSubmission = await SubmissionMutation_1.SubmissionMutation.retrySubmissionAsync(graphqlClient, submissionId);
98
+ spinner.succeed('Created a new submission');
99
+ }
100
+ catch (error) {
101
+ spinner.fail(`Something went wrong and we couldn't retry your submission ${submissionId}`);
102
+ throw error;
103
+ }
104
+ if (jsonFlag) {
105
+ (0, json_1.printJsonOnlyOutput)(retriedSubmission);
106
+ }
107
+ else {
108
+ (0, urls_1.printSubmissionDetailsUrls)([retriedSubmission]);
109
+ }
110
+ }
111
+ }
112
+ exports.default = SubmissionRetry;
113
+ const toAppPlatform = (requestedPlatform) => {
114
+ if (!requestedPlatform || requestedPlatform === platform_1.RequestedPlatform.All) {
115
+ return undefined;
116
+ }
117
+ else if (requestedPlatform === platform_1.RequestedPlatform.Android) {
118
+ return generated_1.AppPlatform.Android;
119
+ }
120
+ else {
121
+ return generated_1.AppPlatform.Ios;
122
+ }
123
+ };
@@ -0,0 +1,19 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ import { RequestedPlatform } from '../../platform';
3
+ export default class SubmissionStatus extends EasCommand {
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
+ platform: import("@oclif/core/lib/interfaces").OptionFlag<RequestedPlatform | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ profile: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
+ };
12
+ static contextDefinition: {
13
+ vcsClient: import("../../commandUtils/context/VcsClientContextField").default;
14
+ analytics: import("../../commandUtils/context/AnalyticsContextField").default;
15
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
16
+ privateProjectConfig: import("../../commandUtils/context/PrivateProjectConfigContextField").PrivateProjectConfigContextField;
17
+ };
18
+ runAsync(): Promise<void>;
19
+ }