eas-cli 21.4.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 (41) hide show
  1. package/README.md +238 -116
  2. package/build/build/local.js +64 -7
  3. package/build/commandUtils/workflow/compositeFunctions.d.ts +1 -0
  4. package/build/commandUtils/workflow/compositeFunctions.js +64 -0
  5. package/build/commandUtils/workflow/validation.js +3 -0
  6. package/build/commands/account/usage.d.ts +3 -0
  7. package/build/commands/account/usage.js +6 -5
  8. package/build/commands/integrations/posthog/connect.js +1 -1
  9. package/build/commands/project/new.d.ts +1 -1
  10. package/build/commands/simulator/start.js +83 -24
  11. package/build/commands/submit/cancel.d.ts +20 -0
  12. package/build/commands/submit/cancel.js +116 -0
  13. package/build/commands/submit/list.d.ts +27 -0
  14. package/build/commands/submit/list.js +100 -0
  15. package/build/commands/submit/retry.d.ts +18 -0
  16. package/build/commands/submit/retry.js +123 -0
  17. package/build/commands/submit/status.d.ts +19 -0
  18. package/build/commands/submit/status.js +116 -0
  19. package/build/commands/submit/view.d.ts +17 -0
  20. package/build/commands/submit/view.js +96 -0
  21. package/build/graphql/generated.d.ts +580 -4
  22. package/build/graphql/generated.js +3 -0
  23. package/build/graphql/mutations/SubmissionMutation.d.ts +3 -1
  24. package/build/graphql/mutations/SubmissionMutation.js +33 -0
  25. package/build/graphql/queries/SubmissionQuery.d.ts +3 -2
  26. package/build/graphql/queries/SubmissionQuery.js +19 -2
  27. package/build/graphql/types/SubmissionWithSubmittedBuild.d.ts +1 -0
  28. package/build/graphql/types/SubmissionWithSubmittedBuild.js +25 -0
  29. package/build/submit/queries.d.ts +34 -0
  30. package/build/submit/queries.js +94 -0
  31. package/build/submit/status.d.ts +31 -0
  32. package/build/submit/status.js +187 -0
  33. package/build/submit/utils/formatSubmission.d.ts +2 -0
  34. package/build/submit/utils/formatSubmission.js +78 -0
  35. package/build/utils/promise.d.ts +3 -2
  36. package/build/utils/promise.js +17 -3
  37. package/build/utils/terminalText.d.ts +1 -0
  38. package/build/utils/terminalText.js +14 -0
  39. package/build/utils/usage/checkForOverages.js +1 -1
  40. package/oclif.manifest.json +1064 -564
  41. package/package.json +5 -5
@@ -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
+ }
@@ -0,0 +1,116 @@
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 flags_1 = require("../../commandUtils/flags");
8
+ const generated_1 = require("../../graphql/generated");
9
+ const log_1 = tslib_1.__importDefault(require("../../log"));
10
+ const ora_1 = require("../../ora");
11
+ const platform_1 = require("../../platform");
12
+ const queries_1 = require("../../submit/queries");
13
+ const status_1 = require("../../submit/status");
14
+ const app_1 = require("../../testflight/app");
15
+ const json_1 = require("../../utils/json");
16
+ const ANDROID_STATUS_UNAVAILABLE_MESSAGE = 'Google Play app status is not available through EAS yet. Run `eas submit:list -p android` to see recent Android submissions.';
17
+ class SubmissionStatus extends EasCommand_1.default {
18
+ static description = 'show the status of your app on the App Store: the live version and TestFlight builds\n\n' +
19
+ 'This command reads from App Store Connect and requires an ASC API key. Provide one via:\n' +
20
+ ' - Environment variables: EXPO_ASC_API_KEY_PATH, EXPO_ASC_KEY_ID, EXPO_ASC_ISSUER_ID\n' +
21
+ ' - eas.json submit profile: ascApiKeyPath, ascApiKeyId, ascApiKeyIssuerId\n' +
22
+ ' - EAS credentials service: run `eas credentials` to set up an API key\n' +
23
+ 'Without a key, the command offers an interactive Apple login; in non-interactive mode it fails.\n\n' +
24
+ 'Google Play app status is not available through EAS yet. Run `eas submit:list -p android` to see recent Android submissions.';
25
+ static examples = [
26
+ '$ eas submit:status \t # live App Store version and TestFlight builds',
27
+ '$ eas submit:status --json --non-interactive \t # machine-readable output',
28
+ ];
29
+ static flags = {
30
+ platform: core_1.Flags.option({
31
+ char: 'p',
32
+ options: Object.values(platform_1.RequestedPlatform),
33
+ })(),
34
+ profile: core_1.Flags.string({
35
+ char: 'e',
36
+ description: 'Name of the submit profile from eas.json used to resolve the App Store Connect API key. Defaults to "production".',
37
+ }),
38
+ ...flags_1.EasNonInteractiveAndJsonFlags,
39
+ };
40
+ static contextDefinition = {
41
+ ...this.ContextOptions.ProjectConfig,
42
+ ...this.ContextOptions.LoggedIn,
43
+ ...this.ContextOptions.Analytics,
44
+ ...this.ContextOptions.Vcs,
45
+ };
46
+ async runAsync() {
47
+ const { flags } = await this.parse(SubmissionStatus);
48
+ const { json: jsonFlag, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
49
+ const requestedPlatform = flags.platform ?? platform_1.RequestedPlatform.All;
50
+ // Redirect stdout before context setup — resolving the project config can log messages,
51
+ // and with --json those must go to stderr.
52
+ if (jsonFlag) {
53
+ (0, json_1.enableJsonOutput)();
54
+ }
55
+ const { loggedIn: { actor, graphqlClient }, privateProjectConfig: { exp, projectId, projectDir }, analytics, vcsClient, } = await this.getContextAsync(SubmissionStatus, {
56
+ nonInteractive,
57
+ withServerSideEnvironment: null,
58
+ });
59
+ const includeIos = [platform_1.RequestedPlatform.All, platform_1.RequestedPlatform.Ios].includes(requestedPlatform);
60
+ const includeAndroid = [platform_1.RequestedPlatform.All, platform_1.RequestedPlatform.Android].includes(requestedPlatform);
61
+ let iosStatus = null;
62
+ let iosSubmissions = [];
63
+ if (includeIos) {
64
+ const spinner = (0, ora_1.ora)().start('Fetching submissions…');
65
+ try {
66
+ iosSubmissions = await (0, queries_1.getRecentSubmissionsAsync)(graphqlClient, {
67
+ projectId,
68
+ filter: { platform: generated_1.AppPlatform.Ios },
69
+ });
70
+ spinner.stop();
71
+ }
72
+ catch (error) {
73
+ spinner.fail("Something went wrong and we couldn't fetch the submissions for this project.");
74
+ throw error;
75
+ }
76
+ const app = await (0, app_1.resolveTestFlightAppAsync)({
77
+ actor,
78
+ analytics,
79
+ exp,
80
+ graphqlClient,
81
+ nonInteractive,
82
+ profileName: flags.profile,
83
+ projectDir,
84
+ projectId,
85
+ vcsClient,
86
+ });
87
+ const ascSpinner = (0, ora_1.ora)().start('Fetching App Store status…');
88
+ try {
89
+ iosStatus = await (0, status_1.getIosStoreStatusAsync)(app, iosSubmissions);
90
+ ascSpinner.stop();
91
+ }
92
+ catch (error) {
93
+ ascSpinner.fail("Something went wrong and we couldn't fetch the App Store status.");
94
+ throw error;
95
+ }
96
+ }
97
+ if (jsonFlag) {
98
+ (0, json_1.printJsonOnlyOutput)({
99
+ ...(includeIos && { ios: iosStatus }),
100
+ ...(includeAndroid && {
101
+ android: { available: false, message: ANDROID_STATUS_UNAVAILABLE_MESSAGE },
102
+ }),
103
+ });
104
+ return;
105
+ }
106
+ if (iosStatus) {
107
+ (0, status_1.renderIosStoreStatus)(iosStatus, iosSubmissions);
108
+ }
109
+ if (includeAndroid) {
110
+ log_1.default.addNewLineIfNone();
111
+ log_1.default.log(chalk_1.default.bold('Android — Google Play'));
112
+ log_1.default.log(chalk_1.default.dim(` ${ANDROID_STATUS_UNAVAILABLE_MESSAGE}`));
113
+ }
114
+ }
115
+ }
116
+ exports.default = SubmissionStatus;
@@ -0,0 +1,17 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ import { RequestedPlatform } from '../../platform';
3
+ export default class SubmissionView 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
+ platform: import("@oclif/core/lib/interfaces").OptionFlag<RequestedPlatform | 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,96 @@
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 SubmissionQuery_1 = require("../../graphql/queries/SubmissionQuery");
9
+ const log_1 = tslib_1.__importDefault(require("../../log"));
10
+ const ora_1 = require("../../ora");
11
+ const platform_1 = require("../../platform");
12
+ const projectUtils_1 = require("../../project/projectUtils");
13
+ const queries_1 = require("../../submit/queries");
14
+ const formatSubmission_1 = require("../../submit/utils/formatSubmission");
15
+ const json_1 = require("../../utils/json");
16
+ class SubmissionView extends EasCommand_1.default {
17
+ static description = 'view a submission for your project';
18
+ static args = {
19
+ SUBMISSION_ID: core_1.Args.string({}),
20
+ };
21
+ static flags = {
22
+ platform: core_1.Flags.option({
23
+ char: 'p',
24
+ description: 'Show the most recent submission for the platform when submission ID is not provided',
25
+ options: Object.values(platform_1.RequestedPlatform),
26
+ })(),
27
+ ...flags_1.EasJsonOnlyFlag,
28
+ };
29
+ static contextDefinition = {
30
+ ...this.ContextOptions.ProjectId,
31
+ ...this.ContextOptions.LoggedIn,
32
+ };
33
+ async runAsync() {
34
+ const { args: { SUBMISSION_ID: submissionId }, flags, } = await this.parse(SubmissionView);
35
+ if (submissionId && flags.platform) {
36
+ throw new Error('Submission ID cannot be used together with the platform flag. The platform flag filters the submissions when no submission ID is provided');
37
+ }
38
+ if (flags.json) {
39
+ (0, json_1.enableJsonOutput)();
40
+ }
41
+ const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(SubmissionView, {
42
+ nonInteractive: true,
43
+ });
44
+ const displayName = await (0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId);
45
+ const spinner = (0, ora_1.ora)().start('Fetching the submission…');
46
+ try {
47
+ let submission;
48
+ if (submissionId) {
49
+ submission = await SubmissionQuery_1.SubmissionQuery.byIdWithSubmittedBuildAsync(graphqlClient, submissionId);
50
+ }
51
+ else {
52
+ submission = await (0, queries_1.getLatestSubmissionAsync)(graphqlClient, {
53
+ projectId,
54
+ filter: { platform: toAppPlatform(flags.platform) },
55
+ });
56
+ if (!submission) {
57
+ spinner.fail(`Couldn't find any submissions for the project ${displayName}`);
58
+ throw new Error(`No submissions found for the project ${displayName}`);
59
+ }
60
+ }
61
+ if (submissionId) {
62
+ spinner.succeed(`Found a matching submission for the project ${displayName}`);
63
+ }
64
+ else {
65
+ spinner.succeed(`Showing the last submission for the project ${displayName}`);
66
+ }
67
+ if (flags.json) {
68
+ (0, json_1.printJsonOnlyOutput)(submission);
69
+ }
70
+ else {
71
+ log_1.default.log(`\n${(0, formatSubmission_1.formatGraphQLSubmission)(submission)}`);
72
+ }
73
+ }
74
+ catch (err) {
75
+ if (submissionId) {
76
+ spinner.fail(`Something went wrong and we couldn't fetch the submission with id ${submissionId}`);
77
+ }
78
+ else {
79
+ spinner.fail(`Something went wrong and we couldn't fetch the last submission for the project ${displayName}`);
80
+ }
81
+ throw err;
82
+ }
83
+ }
84
+ }
85
+ exports.default = SubmissionView;
86
+ const toAppPlatform = (requestedPlatform) => {
87
+ if (!requestedPlatform || requestedPlatform === platform_1.RequestedPlatform.All) {
88
+ return undefined;
89
+ }
90
+ else if (requestedPlatform === platform_1.RequestedPlatform.Android) {
91
+ return generated_1.AppPlatform.Android;
92
+ }
93
+ else {
94
+ return generated_1.AppPlatform.Ios;
95
+ }
96
+ };