eas-cli 20.5.1 → 21.0.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.
- package/README.md +128 -175
- package/build/analytics/AnalyticsManager.js +3 -0
- package/build/analytics/agent.d.ts +5 -0
- package/build/analytics/agent.js +26 -0
- package/build/commandUtils/workflow/buildProfileUtils.d.ts +11 -29
- package/build/commandUtils/workflow/buildProfileUtils.js +47 -126
- package/build/commandUtils/workflow/creation.d.ts +11 -3
- package/build/commandUtils/workflow/creation.js +151 -261
- package/build/commands/integrations/posthog/dashboard.d.ts +1 -0
- package/build/commands/integrations/posthog/dashboard.js +30 -6
- package/build/commands/observe/metrics.js +1 -1
- package/build/commands/project/init.d.ts +0 -7
- package/build/commands/project/init.js +4 -274
- package/build/commands/simulator/get.js +57 -4
- package/build/commands/workflow/create.d.ts +3 -0
- package/build/commands/workflow/create.js +118 -87
- package/build/credentials/ios/appstore/bundleIdCapabilities.js +9 -3
- package/build/graphql/generated.d.ts +204 -242
- package/build/graphql/generated.js +41 -4
- package/build/graphql/mutations/PostHogMutation.d.ts +2 -1
- package/build/graphql/mutations/PostHogMutation.js +14 -0
- package/build/graphql/queries/DeviceRunSessionQuery.js +15 -0
- package/build/graphql/queries/UserQuery.js +0 -10
- package/build/graphql/queries/WorkflowRunQuery.js +1 -0
- package/build/integrations/asc/utils.js +6 -4
- package/build/observe/metricNames.d.ts +1 -1
- package/build/observe/metricNames.js +7 -6
- package/build/project/android/applicationId.d.ts +2 -1
- package/build/project/android/applicationId.js +19 -11
- package/build/project/ios/bundleIdentifier.d.ts +2 -1
- package/build/project/ios/bundleIdentifier.js +19 -11
- package/build/project/projectInitialization.d.ts +9 -0
- package/build/project/projectInitialization.js +277 -0
- package/build/project/publish.js +73 -40
- package/oclif.manifest.json +264 -310
- package/package.json +8 -7
- package/build/commands/project/onboarding.d.ts +0 -14
- package/build/commands/project/onboarding.js +0 -362
- package/build/graphql/mutations/UserPreferencesMutation.d.ts +0 -10
- package/build/graphql/mutations/UserPreferencesMutation.js +0 -41
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureOwnerSlugConsistencyAsync = ensureOwnerSlugConsistencyAsync;
|
|
4
|
+
exports.initializeWithExplicitIDAsync = initializeWithExplicitIDAsync;
|
|
5
|
+
exports.initializeWithoutExplicitIDAsync = initializeWithoutExplicitIDAsync;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const config_1 = require("@expo/config");
|
|
8
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
9
|
+
const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
|
|
10
|
+
const expoConfig_1 = require("./expoConfig");
|
|
11
|
+
const fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync_1 = require("./fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync");
|
|
12
|
+
const url_1 = require("../build/utils/url");
|
|
13
|
+
const getProjectIdAsync_1 = require("../commandUtils/context/contextUtils/getProjectIdAsync");
|
|
14
|
+
const projectNameValidation_1 = require("../commandUtils/projectNameValidation");
|
|
15
|
+
const generated_1 = require("../graphql/generated");
|
|
16
|
+
const AppMutation_1 = require("../graphql/mutations/AppMutation");
|
|
17
|
+
const AppQuery_1 = require("../graphql/queries/AppQuery");
|
|
18
|
+
const log_1 = tslib_1.__importStar(require("../log"));
|
|
19
|
+
const ora_1 = require("../ora");
|
|
20
|
+
const prompts_1 = require("../prompts");
|
|
21
|
+
async function saveProjectIdAndLogSuccessAsync(projectDir, projectId) {
|
|
22
|
+
await (0, getProjectIdAsync_1.saveProjectIdToAppConfigAsync)(projectDir, projectId);
|
|
23
|
+
log_1.default.withTick(`Project successfully linked (ID: ${chalk_1.default.bold(projectId)}) (modified app.json)`);
|
|
24
|
+
}
|
|
25
|
+
async function modifyExpoConfigAsync(projectDir, modifications) {
|
|
26
|
+
let result;
|
|
27
|
+
try {
|
|
28
|
+
result = await (0, expoConfig_1.createOrModifyExpoConfigAsync)(projectDir, modifications);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error instanceof config_1.ConfigError && error.code === 'MODULE_NOT_FOUND') {
|
|
32
|
+
log_1.default.warn('Cannot determine which native SDK version your project uses because the module `expo` is not installed.');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
switch (result.type) {
|
|
40
|
+
case 'success':
|
|
41
|
+
break;
|
|
42
|
+
case 'warn': {
|
|
43
|
+
log_1.default.warn();
|
|
44
|
+
log_1.default.warn(`Warning: Your project uses dynamic app configuration, and cannot be automatically modified.`);
|
|
45
|
+
log_1.default.warn(chalk_1.default.dim('https://docs.expo.dev/workflow/configuration/#dynamic-configuration-with-appconfigjs'));
|
|
46
|
+
log_1.default.warn();
|
|
47
|
+
log_1.default.warn(`To complete the setup process, add the following in your ${chalk_1.default.bold((0, config_1.getProjectConfigDescription)(projectDir))}:`);
|
|
48
|
+
log_1.default.warn();
|
|
49
|
+
log_1.default.warn(chalk_1.default.bold(JSON.stringify(modifications, null, 2)));
|
|
50
|
+
log_1.default.warn();
|
|
51
|
+
throw new Error(result.message);
|
|
52
|
+
}
|
|
53
|
+
case 'fail':
|
|
54
|
+
throw new Error(result.message);
|
|
55
|
+
default:
|
|
56
|
+
throw new Error('Unexpected result type from modifyConfigAsync');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function ensureOwnerSlugConsistencyAsync(graphqlClient, projectId, projectDir, { force, nonInteractive }) {
|
|
60
|
+
const exp = await (0, expoConfig_1.getPrivateExpoConfigAsync)(projectDir);
|
|
61
|
+
const appForProjectId = await AppQuery_1.AppQuery.byIdAsync(graphqlClient, projectId);
|
|
62
|
+
const correctOwner = appForProjectId.ownerAccount.name;
|
|
63
|
+
const correctSlug = appForProjectId.slug;
|
|
64
|
+
if (exp.owner && exp.owner !== correctOwner) {
|
|
65
|
+
if (force) {
|
|
66
|
+
await modifyExpoConfigAsync(projectDir, { owner: correctOwner });
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const message = `Project owner (${correctOwner}) does not match the value configured in the "owner" field (${exp.owner}).`;
|
|
70
|
+
if (nonInteractive) {
|
|
71
|
+
throw new Error(`Project config error: ${message} Use --force flag to overwrite.`);
|
|
72
|
+
}
|
|
73
|
+
const confirm = await (0, prompts_1.confirmAsync)({
|
|
74
|
+
message: `${message}. Do you wish to overwrite it?`,
|
|
75
|
+
});
|
|
76
|
+
if (!confirm) {
|
|
77
|
+
throw new Error('Aborting');
|
|
78
|
+
}
|
|
79
|
+
await modifyExpoConfigAsync(projectDir, { owner: correctOwner });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (!exp.owner) {
|
|
83
|
+
await modifyExpoConfigAsync(projectDir, { owner: correctOwner });
|
|
84
|
+
}
|
|
85
|
+
if (exp.slug && exp.slug !== correctSlug) {
|
|
86
|
+
if (force) {
|
|
87
|
+
await modifyExpoConfigAsync(projectDir, { slug: correctSlug });
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const message = `Project slug (${correctSlug}) does not match the value configured in the "slug" field (${exp.slug}).`;
|
|
91
|
+
if (nonInteractive) {
|
|
92
|
+
throw new Error(`Project config error: ${message} Use --force flag to overwrite.`);
|
|
93
|
+
}
|
|
94
|
+
const confirm = await (0, prompts_1.confirmAsync)({
|
|
95
|
+
message: `${message}. Do you wish to overwrite it?`,
|
|
96
|
+
});
|
|
97
|
+
if (!confirm) {
|
|
98
|
+
throw new Error('Aborting');
|
|
99
|
+
}
|
|
100
|
+
await modifyExpoConfigAsync(projectDir, { slug: correctSlug });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else if (!exp.slug) {
|
|
104
|
+
await modifyExpoConfigAsync(projectDir, { slug: correctSlug });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function setExplicitIDAsync(projectId, projectDir, { force, nonInteractive }) {
|
|
108
|
+
const exp = await (0, expoConfig_1.getPrivateExpoConfigAsync)(projectDir);
|
|
109
|
+
const existingProjectId = exp.extra?.eas?.projectId;
|
|
110
|
+
if (projectId === existingProjectId) {
|
|
111
|
+
log_1.default.succeed(`Project already linked (ID: ${chalk_1.default.bold(existingProjectId)})`);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!existingProjectId) {
|
|
115
|
+
await saveProjectIdAndLogSuccessAsync(projectDir, projectId);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (projectId !== existingProjectId) {
|
|
119
|
+
if (force) {
|
|
120
|
+
await saveProjectIdAndLogSuccessAsync(projectDir, projectId);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (nonInteractive) {
|
|
124
|
+
throw new Error(`Project is already linked to a different ID: ${chalk_1.default.bold(existingProjectId)}. Use --force flag to overwrite.`);
|
|
125
|
+
}
|
|
126
|
+
const confirm = await (0, prompts_1.confirmAsync)({
|
|
127
|
+
message: `Project is already linked to a different ID: ${chalk_1.default.bold(existingProjectId)}. Do you wish to overwrite it?`,
|
|
128
|
+
});
|
|
129
|
+
if (!confirm) {
|
|
130
|
+
throw new Error('Aborting');
|
|
131
|
+
}
|
|
132
|
+
await saveProjectIdAndLogSuccessAsync(projectDir, projectId);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async function initializeWithExplicitIDAsync(projectId, projectDir, { force, nonInteractive }) {
|
|
136
|
+
await setExplicitIDAsync(projectId, projectDir, {
|
|
137
|
+
force,
|
|
138
|
+
nonInteractive,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async function initializeWithoutExplicitIDAsync(graphqlClient, actor, projectDir, { force, nonInteractive }) {
|
|
142
|
+
const exp = await (0, expoConfig_1.getPrivateExpoConfigAsync)(projectDir);
|
|
143
|
+
const existingProjectId = exp.extra?.eas?.projectId;
|
|
144
|
+
if (existingProjectId) {
|
|
145
|
+
log_1.default.succeed(`Project already linked (ID: ${chalk_1.default.bold(existingProjectId)}). To re-configure, remove the "extra.eas.projectId" field from your app config.`);
|
|
146
|
+
return existingProjectId;
|
|
147
|
+
}
|
|
148
|
+
const allAccounts = actor.accounts;
|
|
149
|
+
const accountNamesWhereUserHasSufficientPermissionsToCreateApp = new Set(allAccounts
|
|
150
|
+
.filter(a => a.users.find(it => it.actor.id === actor.id)?.role !== generated_1.Role.ViewOnly)
|
|
151
|
+
.map(it => it.name));
|
|
152
|
+
// if no owner field, ask the user which account they want to use to create/link the project
|
|
153
|
+
let accountName = exp.owner;
|
|
154
|
+
if (!accountName) {
|
|
155
|
+
if (allAccounts.length === 1) {
|
|
156
|
+
accountName = allAccounts[0].name;
|
|
157
|
+
}
|
|
158
|
+
else if (nonInteractive) {
|
|
159
|
+
if (!force) {
|
|
160
|
+
throw new Error(`There are multiple accounts that you have access to: ${allAccounts
|
|
161
|
+
.map(a => a.name)
|
|
162
|
+
.join(', ')}. Explicitly set the owner property in your app config or run this command with the --force flag to proceed with a default account: ${allAccounts[0].name}.`);
|
|
163
|
+
}
|
|
164
|
+
accountName = allAccounts[0].name;
|
|
165
|
+
log_1.default.log(`Using default account ${accountName} for non-interactive and force mode`);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
const choices = getAccountChoices(actor, accountNamesWhereUserHasSufficientPermissionsToCreateApp);
|
|
169
|
+
accountName = (await (0, prompts_1.promptAsync)({
|
|
170
|
+
type: 'select',
|
|
171
|
+
name: 'account',
|
|
172
|
+
message: 'Which account should own this project?',
|
|
173
|
+
choices,
|
|
174
|
+
})).account.name;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (!accountName) {
|
|
178
|
+
throw new Error('No account selected for project. Canceling.');
|
|
179
|
+
}
|
|
180
|
+
const projectName = (0, projectNameValidation_1.validSlugName)(exp.slug); // This filters out invalid characters
|
|
181
|
+
const projectFullName = `@${accountName}/${projectName}`;
|
|
182
|
+
(0, projectNameValidation_1.validateFullNameAndSlug)(projectFullName, projectName);
|
|
183
|
+
const existingProjectIdOnServer = await (0, fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync_1.findProjectIdByAccountNameAndSlugNullableAsync)(graphqlClient, accountName, projectName);
|
|
184
|
+
if (existingProjectIdOnServer) {
|
|
185
|
+
if (!force) {
|
|
186
|
+
if (nonInteractive) {
|
|
187
|
+
throw new Error(`Existing project found: ${projectFullName} (ID: ${existingProjectIdOnServer}). Use --force flag to continue with this project.`);
|
|
188
|
+
}
|
|
189
|
+
const affirmedLink = await (0, prompts_1.confirmAsync)({
|
|
190
|
+
message: `Existing project found: ${projectFullName} (ID: ${existingProjectIdOnServer}). Link this project?`,
|
|
191
|
+
});
|
|
192
|
+
if (!affirmedLink) {
|
|
193
|
+
throw new Error(`Project ID configuration canceled. Re-run the command to select a different account/project.`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
await saveProjectIdAndLogSuccessAsync(projectDir, existingProjectIdOnServer);
|
|
197
|
+
return existingProjectIdOnServer;
|
|
198
|
+
}
|
|
199
|
+
if (!accountNamesWhereUserHasSufficientPermissionsToCreateApp.has(accountName)) {
|
|
200
|
+
throw new Error(`You don't have permission to create a new project on the ${accountName} account and no matching project already exists on the account.`);
|
|
201
|
+
}
|
|
202
|
+
if (!force) {
|
|
203
|
+
if (nonInteractive) {
|
|
204
|
+
throw new Error(`Project does not exist: ${projectFullName}. Use --force flag to create this project.`);
|
|
205
|
+
}
|
|
206
|
+
const affirmedCreate = await (0, prompts_1.confirmAsync)({
|
|
207
|
+
message: `Would you like to create a project for ${projectFullName}?`,
|
|
208
|
+
});
|
|
209
|
+
if (!affirmedCreate) {
|
|
210
|
+
throw new Error(`Project ID configuration canceled for ${projectFullName}.`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const projectDashboardUrl = (0, url_1.getProjectDashboardUrl)(accountName, projectName);
|
|
214
|
+
const projectLink = (0, log_1.link)(projectDashboardUrl, { text: projectFullName });
|
|
215
|
+
const account = (0, nullthrows_1.default)(allAccounts.find(a => a.name === accountName));
|
|
216
|
+
const spinner = (0, ora_1.ora)(`Creating ${chalk_1.default.bold(projectFullName)}`).start();
|
|
217
|
+
let createdProjectId;
|
|
218
|
+
try {
|
|
219
|
+
createdProjectId = await AppMutation_1.AppMutation.createAppAsync(graphqlClient, {
|
|
220
|
+
accountId: account.id,
|
|
221
|
+
projectName,
|
|
222
|
+
});
|
|
223
|
+
spinner.succeed(`Created ${chalk_1.default.bold(projectLink)}`);
|
|
224
|
+
}
|
|
225
|
+
catch (err) {
|
|
226
|
+
spinner.fail();
|
|
227
|
+
throw err;
|
|
228
|
+
}
|
|
229
|
+
await saveProjectIdAndLogSuccessAsync(projectDir, createdProjectId);
|
|
230
|
+
return createdProjectId;
|
|
231
|
+
}
|
|
232
|
+
function getAccountChoices(actor, namesWithSufficientPermissions) {
|
|
233
|
+
const allAccounts = actor.accounts;
|
|
234
|
+
const sortedAccounts = actor.__typename === 'Robot'
|
|
235
|
+
? allAccounts
|
|
236
|
+
: [...allAccounts].sort((a, _b) => actor.__typename === 'User' ? (a.name === actor.username ? -1 : 1) : 0);
|
|
237
|
+
if (actor.__typename !== 'Robot') {
|
|
238
|
+
const personalAccount = allAccounts?.find(account => account?.ownerUserActor?.id === actor.id);
|
|
239
|
+
const personalAccountChoice = personalAccount
|
|
240
|
+
? {
|
|
241
|
+
title: personalAccount.name,
|
|
242
|
+
value: personalAccount,
|
|
243
|
+
description: !namesWithSufficientPermissions.has(personalAccount.name)
|
|
244
|
+
? '(Personal) (Viewer Role)'
|
|
245
|
+
: '(Personal)',
|
|
246
|
+
}
|
|
247
|
+
: undefined;
|
|
248
|
+
const userAccounts = allAccounts
|
|
249
|
+
?.filter(account => account.ownerUserActor && account.name !== actor.username)
|
|
250
|
+
.map(account => ({
|
|
251
|
+
title: account.name,
|
|
252
|
+
value: account,
|
|
253
|
+
description: !namesWithSufficientPermissions.has(account.name)
|
|
254
|
+
? '(Team) (Viewer Role)'
|
|
255
|
+
: '(Team)',
|
|
256
|
+
}));
|
|
257
|
+
const organizationAccounts = allAccounts
|
|
258
|
+
?.filter(account => account.name !== actor.username && !account.ownerUserActor)
|
|
259
|
+
.map(account => ({
|
|
260
|
+
title: account.name,
|
|
261
|
+
value: account,
|
|
262
|
+
description: !namesWithSufficientPermissions.has(account.name)
|
|
263
|
+
? '(Organization) (Viewer Role)'
|
|
264
|
+
: '(Organization)',
|
|
265
|
+
}));
|
|
266
|
+
let choices = [];
|
|
267
|
+
if (personalAccountChoice) {
|
|
268
|
+
choices = [personalAccountChoice];
|
|
269
|
+
}
|
|
270
|
+
return [...choices, ...userAccounts, ...organizationAccounts].sort((a, _b) => actor.__typename === 'User' ? (a.value.name === actor.username ? -1 : 1) : 0);
|
|
271
|
+
}
|
|
272
|
+
return sortedAccounts.map(account => ({
|
|
273
|
+
title: account.name,
|
|
274
|
+
value: account,
|
|
275
|
+
description: !namesWithSufficientPermissions.has(account.name) ? '(Viewer Role)' : undefined,
|
|
276
|
+
}));
|
|
277
|
+
}
|
package/build/project/publish.js
CHANGED
|
@@ -338,57 +338,90 @@ async function uploadAssetsAsync(graphqlClient, assetsForUpdateInfoGroup, projec
|
|
|
338
338
|
...assetsForUpdateInfoGroup[platform].assets,
|
|
339
339
|
];
|
|
340
340
|
}
|
|
341
|
-
const assetsWithStorageKey = await Promise.all(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
341
|
+
const [assetLimitPerUpdateGroup, assetsWithStorageKey] = await Promise.all([
|
|
342
|
+
PublishQuery_1.PublishQuery.getAssetLimitPerUpdateGroupAsync(graphqlClient, projectId),
|
|
343
|
+
Promise.all(assets.map(async (asset) => {
|
|
344
|
+
return {
|
|
345
|
+
...asset,
|
|
346
|
+
storageKey: await getStorageKeyForAssetAsync(asset),
|
|
347
|
+
};
|
|
348
|
+
})),
|
|
349
|
+
]);
|
|
347
350
|
const uniqueAssets = (0, uniqBy_1.default)(assetsWithStorageKey, asset => asset.storageKey);
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
+
// "finished" = no longer in the pending (still-missing) set.
|
|
352
|
+
const notifyProgress = (pendingAssets) => {
|
|
353
|
+
const pendingKeys = new Set(pendingAssets.map(a => a.storageKey));
|
|
354
|
+
onAssetUploadResultsChanged?.(uniqueAssets.map(asset => ({ asset, finished: !pendingKeys.has(asset.storageKey) })));
|
|
355
|
+
};
|
|
356
|
+
notifyProgress(uniqueAssets);
|
|
357
|
+
const missingAssets = await filterOutAssetsThatAlreadyExistAsync(graphqlClient, uniqueAssets);
|
|
351
358
|
const uniqueUploadedAssetCount = missingAssets.length;
|
|
352
359
|
const uniqueUploadedAssetPaths = missingAssets.map(asset => asset.originalPath).filter(filter_1.truthy);
|
|
353
360
|
if (cancelationToken.isCanceledOrFinished) {
|
|
354
361
|
throw Error('Canceled upload');
|
|
355
362
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
onAssetUploadResultsChanged?.(uniqueAssets.map(asset => ({ asset, finished: !missingAssetStorageKeys.has(asset.storageKey) })));
|
|
363
|
+
notifyProgress(missingAssets);
|
|
364
|
+
// Just past the finalize cloud function's event max age plus a startup buffer. Beyond this,
|
|
365
|
+
// waiting longer can't help, so we re-upload to generate a fresh event with a new retry window.
|
|
366
|
+
const FINALIZE_POLL_MS = 55_000;
|
|
367
|
+
const MAX_UPLOAD_ATTEMPTS = 3;
|
|
363
368
|
const assetUploadPromiseLimit = (0, promise_limit_1.default)(15);
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
while (missingAssets.length > 0) {
|
|
378
|
-
if (cancelationToken.isCanceledOrFinished) {
|
|
379
|
-
throw Error('Canceled upload');
|
|
369
|
+
// Sign URLs in chunks (endpoint caps at 100), then upload all from one pool so it stays saturated.
|
|
370
|
+
const uploadBatchAsync = async (assetsToUpload, onBegin) => {
|
|
371
|
+
const signedAssets = [];
|
|
372
|
+
for (const assetChunk of (0, chunk_1.default)(assetsToUpload, 100)) {
|
|
373
|
+
if (cancelationToken.isCanceledOrFinished) {
|
|
374
|
+
throw Error('Canceled upload');
|
|
375
|
+
}
|
|
376
|
+
const { specifications } = await PublishMutation_1.PublishMutation.getUploadURLsAsync(graphqlClient, assetChunk.map(a => a.contentType));
|
|
377
|
+
if (specifications.length !== assetChunk.length) {
|
|
378
|
+
throw new Error(`Upload URL signing returned ${specifications.length} URLs for ${assetChunk.length} assets. ` +
|
|
379
|
+
`This is likely a transient server error; please retry, and contact support if it persists.`);
|
|
380
|
+
}
|
|
381
|
+
assetChunk.forEach((asset, i) => signedAssets.push({ asset, specification: specifications[i] }));
|
|
380
382
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
asset,
|
|
388
|
-
finished: !missingAssetStorageKeys.has(asset.storageKey),
|
|
383
|
+
await Promise.all(signedAssets.map(({ asset, specification }) => assetUploadPromiseLimit(async () => {
|
|
384
|
+
if (cancelationToken.isCanceledOrFinished) {
|
|
385
|
+
throw Error('Canceled upload');
|
|
386
|
+
}
|
|
387
|
+
const presignedPost = JSON.parse(specification);
|
|
388
|
+
await (0, uploads_1.uploadWithPresignedPostWithRetryAsync)(asset.path, presignedPost, onBegin);
|
|
389
389
|
})));
|
|
390
|
+
};
|
|
391
|
+
const pollForFinalizationAsync = async (pendingAssets) => {
|
|
392
|
+
const deadline = Date.now() + FINALIZE_POLL_MS;
|
|
393
|
+
let pollDelay = 1;
|
|
394
|
+
while (pendingAssets.length > 0 && Date.now() < deadline) {
|
|
395
|
+
if (cancelationToken.isCanceledOrFinished) {
|
|
396
|
+
throw Error('Canceled upload');
|
|
397
|
+
}
|
|
398
|
+
const waitPromise = new Promise(resolve => setTimeout(resolve, Math.min(pollDelay * 1000, 5000)));
|
|
399
|
+
const remaining = await filterOutAssetsThatAlreadyExistAsync(graphqlClient, pendingAssets);
|
|
400
|
+
if (remaining.length < pendingAssets.length) {
|
|
401
|
+
notifyProgress(remaining);
|
|
402
|
+
}
|
|
403
|
+
pendingAssets = remaining;
|
|
404
|
+
pollDelay++;
|
|
405
|
+
await waitPromise; // awaited after the check so jest.runAllTimers can flush it in tests
|
|
406
|
+
}
|
|
407
|
+
return pendingAssets;
|
|
408
|
+
};
|
|
409
|
+
// Re-upload assets that don't finalize in time to trigger a fresh finalize event and retry window.
|
|
410
|
+
let pendingAssets = missingAssets;
|
|
411
|
+
for (let attempt = 0; attempt < MAX_UPLOAD_ATTEMPTS && pendingAssets.length > 0; attempt++) {
|
|
412
|
+
await uploadBatchAsync(pendingAssets, onAssetUploadBegin);
|
|
413
|
+
pendingAssets = await pollForFinalizationAsync(pendingAssets);
|
|
390
414
|
}
|
|
391
415
|
cancelationToken.isCanceledOrFinished = true;
|
|
416
|
+
if (pendingAssets.length > 0) {
|
|
417
|
+
notifyProgress(pendingAssets);
|
|
418
|
+
const unfinalizedAssets = pendingAssets
|
|
419
|
+
.map(asset => `\n- ${asset.originalPath ?? asset.path}`)
|
|
420
|
+
.join('');
|
|
421
|
+
throw new Error(`Update not published: ${pendingAssets.length} asset(s) uploaded but were not processed by the server after ${MAX_UPLOAD_ATTEMPTS} attempts:${unfinalizedAssets}\n\n` +
|
|
422
|
+
`The upload succeeded, but the server did not finish processing these assets in time. ` +
|
|
423
|
+
`This is usually temporary. Re-run \`eas update\` to try again, and contact support if it keeps happening.`);
|
|
424
|
+
}
|
|
392
425
|
return {
|
|
393
426
|
assetCount: assets.length,
|
|
394
427
|
launchAssetCount: launchAssets.length,
|