-
Notifications
You must be signed in to change notification settings - Fork 75
/
submit.ts
229 lines (206 loc) · 6.78 KB
/
submit.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import { EasJsonAccessor } from '@expo/eas-json';
import { Errors, Flags } from '@oclif/core';
import chalk from 'chalk';
import EasCommand from '../commandUtils/EasCommand';
import { StatuspageServiceName, SubmissionFragment } from '../graphql/generated';
import { toAppPlatform } from '../graphql/types/AppPlatform';
import Log from '../log';
import {
RequestedPlatform,
appPlatformDisplayNames,
appPlatformEmojis,
selectRequestedPlatformAsync,
toPlatforms,
} from '../platform';
import { SubmitArchiveFlags, createSubmissionContextAsync } from '../submit/context';
import {
exitWithNonZeroCodeIfSomeSubmissionsDidntFinish,
submitAsync,
waitToCompleteAsync,
} from '../submit/submit';
import { printSubmissionDetailsUrls } from '../submit/utils/urls';
import { getProfilesAsync } from '../utils/profiles';
import { maybeWarnAboutEasOutagesAsync } from '../utils/statuspageService';
interface RawCommandFlags {
platform?: string;
profile?: string;
latest?: boolean;
id?: string;
path?: string;
url?: string;
verbose: boolean;
wait: boolean;
'non-interactive': boolean;
'verbose-fastlane': boolean;
}
interface CommandFlags {
requestedPlatform: RequestedPlatform;
profile?: string;
archiveFlags: SubmitArchiveFlags;
verbose: boolean;
wait: boolean;
nonInteractive: boolean;
isVerboseFastlaneEnabled: boolean;
}
export default class Submit extends EasCommand {
static override description = 'submit app binary to App Store and/or Play Store';
static override aliases = ['build:submit'];
static override flags = {
platform: Flags.enum({
char: 'p',
options: ['android', 'ios', 'all'],
}),
profile: Flags.string({
char: 'e',
description:
'Name of the submit profile from eas.json. Defaults to "production" if defined in eas.json.',
}),
latest: Flags.boolean({
description: 'Submit the latest build for specified platform',
exclusive: ['id', 'path', 'url'],
}),
id: Flags.string({
description: 'ID of the build to submit',
exclusive: ['latest, path, url'],
}),
path: Flags.string({
description: 'Path to the .apk/.aab/.ipa file',
exclusive: ['latest', 'id', 'url'],
}),
url: Flags.string({
description: 'App archive url',
exclusive: ['latest', 'id', 'path'],
}),
verbose: Flags.boolean({
description: 'Always print logs from EAS Submit',
default: false,
}),
wait: Flags.boolean({
description: 'Wait for submission to complete',
default: true,
allowNo: true,
}),
'verbose-fastlane': Flags.boolean({
default: false,
description: 'Enable verbose logging for the submission process',
}),
'non-interactive': Flags.boolean({
default: false,
description: 'Run command in non-interactive mode',
}),
};
static override contextDefinition = {
...this.ContextOptions.LoggedIn,
...this.ContextOptions.ProjectConfig,
...this.ContextOptions.ProjectDir,
...this.ContextOptions.Analytics,
...this.ContextOptions.Vcs,
};
async runAsync(): Promise<void> {
const { flags: rawFlags } = await this.parse(Submit);
const {
loggedIn: { actor, graphqlClient },
privateProjectConfig: { exp, projectId, projectDir },
analytics,
vcsClient,
} = await this.getContextAsync(Submit, {
nonInteractive: false,
});
const flags = this.sanitizeFlags(rawFlags);
await maybeWarnAboutEasOutagesAsync(graphqlClient, [StatuspageServiceName.EasSubmit]);
const flagsWithPlatform = await this.ensurePlatformSelectedAsync(flags);
const platforms = toPlatforms(flagsWithPlatform.requestedPlatform);
const submissionProfiles = await getProfilesAsync({
type: 'submit',
easJsonAccessor: EasJsonAccessor.fromProjectPath(projectDir),
platforms,
profileName: flagsWithPlatform.profile,
projectDir,
});
const submissions: SubmissionFragment[] = [];
for (const submissionProfile of submissionProfiles) {
// this command doesn't make use of env when getting the project config
const ctx = await createSubmissionContextAsync({
platform: submissionProfile.platform,
projectDir,
profile: submissionProfile.profile,
archiveFlags: flagsWithPlatform.archiveFlags,
nonInteractive: flagsWithPlatform.nonInteractive,
isVerboseFastlaneEnabled: flagsWithPlatform.isVerboseFastlaneEnabled,
actor,
graphqlClient,
analytics,
exp,
projectId,
vcsClient,
specifiedProfile: flagsWithPlatform.profile,
});
if (submissionProfiles.length > 1) {
Log.newLine();
const appPlatform = toAppPlatform(submissionProfile.platform);
Log.log(
`${appPlatformEmojis[appPlatform]} ${chalk.bold(
`${appPlatformDisplayNames[appPlatform]} submission`
)}`
);
}
const submission = await submitAsync(ctx);
submissions.push(submission);
}
Log.newLine();
printSubmissionDetailsUrls(submissions);
if (flagsWithPlatform.wait) {
const completedSubmissions = await waitToCompleteAsync(graphqlClient, submissions, {
verbose: flagsWithPlatform.verbose,
});
exitWithNonZeroCodeIfSomeSubmissionsDidntFinish(completedSubmissions);
}
}
private sanitizeFlags(
flags: RawCommandFlags
): Omit<CommandFlags, 'requestedPlatform'> & { requestedPlatform?: RequestedPlatform } {
const {
platform,
verbose,
wait,
profile,
'non-interactive': nonInteractive,
'verbose-fastlane': isVerboseFastlaneEnabled,
...archiveFlags
} = flags;
if (!flags.platform && nonInteractive) {
Errors.error('--platform is required when building in non-interactive mode', { exit: 1 });
}
const requestedPlatform =
flags.platform &&
Object.values(RequestedPlatform).includes(flags.platform.toLowerCase() as RequestedPlatform)
? (flags.platform.toLowerCase() as RequestedPlatform)
: undefined;
return {
archiveFlags,
requestedPlatform,
verbose,
wait,
profile,
nonInteractive,
isVerboseFastlaneEnabled,
};
}
private async ensurePlatformSelectedAsync(
flags: Omit<CommandFlags, 'requestedPlatform'> & { requestedPlatform?: RequestedPlatform }
): Promise<CommandFlags> {
const requestedPlatform = await selectRequestedPlatformAsync(flags.requestedPlatform);
if (requestedPlatform === RequestedPlatform.All) {
if (flags.archiveFlags.id || flags.archiveFlags.path || flags.archiveFlags.url) {
Errors.error(
'--id, --path, and --url params are only supported when performing a single-platform submit',
{ exit: 1 }
);
}
}
return {
...flags,
requestedPlatform,
};
}
}