eas-cli 20.5.1 → 21.0.1

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 (59) hide show
  1. package/README.md +171 -178
  2. package/build/analytics/AnalyticsManager.js +3 -0
  3. package/build/analytics/agent.d.ts +5 -0
  4. package/build/analytics/agent.js +26 -0
  5. package/build/build/utils/url.d.ts +1 -0
  6. package/build/build/utils/url.js +6 -1
  7. package/build/commandUtils/workflow/buildProfileUtils.d.ts +11 -29
  8. package/build/commandUtils/workflow/buildProfileUtils.js +47 -126
  9. package/build/commandUtils/workflow/creation.d.ts +11 -3
  10. package/build/commandUtils/workflow/creation.js +151 -261
  11. package/build/commands/browse.d.ts +17 -0
  12. package/build/commands/browse.js +90 -0
  13. package/build/commands/deploy/index.d.ts +1 -0
  14. package/build/commands/deploy/index.js +15 -1
  15. package/build/commands/integrations/posthog/dashboard.d.ts +1 -0
  16. package/build/commands/integrations/posthog/dashboard.js +30 -6
  17. package/build/commands/observe/metrics.js +1 -1
  18. package/build/commands/open.d.ts +1 -4
  19. package/build/commands/open.js +4 -32
  20. package/build/commands/project/delete.d.ts +16 -0
  21. package/build/commands/project/delete.js +129 -0
  22. package/build/commands/project/init.d.ts +0 -7
  23. package/build/commands/project/init.js +4 -274
  24. package/build/commands/simulator/get.js +57 -4
  25. package/build/commands/simulator/start.js +1 -0
  26. package/build/commands/workflow/create.d.ts +3 -0
  27. package/build/commands/workflow/create.js +118 -87
  28. package/build/credentials/ios/appstore/bundleIdCapabilities.js +9 -3
  29. package/build/graphql/generated.d.ts +253 -253
  30. package/build/graphql/generated.js +41 -4
  31. package/build/graphql/mutations/AppMutation.d.ts +2 -0
  32. package/build/graphql/mutations/AppMutation.js +19 -0
  33. package/build/graphql/mutations/PostHogMutation.d.ts +2 -1
  34. package/build/graphql/mutations/PostHogMutation.js +14 -0
  35. package/build/graphql/queries/DeviceRunSessionQuery.js +15 -0
  36. package/build/graphql/queries/UserQuery.js +0 -10
  37. package/build/graphql/queries/WorkflowRunQuery.js +1 -0
  38. package/build/integrations/asc/utils.js +6 -4
  39. package/build/observe/metricNames.d.ts +1 -1
  40. package/build/observe/metricNames.js +7 -6
  41. package/build/project/android/applicationId.d.ts +2 -1
  42. package/build/project/android/applicationId.js +19 -11
  43. package/build/project/ios/bundleIdentifier.d.ts +2 -1
  44. package/build/project/ios/bundleIdentifier.js +19 -11
  45. package/build/project/projectInitialization.d.ts +9 -0
  46. package/build/project/projectInitialization.js +277 -0
  47. package/build/project/publish.js +73 -40
  48. package/build/user/sudo.d.ts +14 -0
  49. package/build/user/sudo.js +62 -0
  50. package/build/worker/deployment.d.ts +11 -1
  51. package/build/worker/deployment.js +71 -22
  52. package/build/worker/queries.d.ts +2 -1
  53. package/build/worker/queries.js +18 -0
  54. package/oclif.manifest.json +1764 -1602
  55. package/package.json +9 -8
  56. package/build/commands/project/onboarding.d.ts +0 -14
  57. package/build/commands/project/onboarding.js +0 -362
  58. package/build/graphql/mutations/UserPreferencesMutation.d.ts +0 -10
  59. 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
+ }
@@ -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(assets.map(async (asset) => {
342
- return {
343
- ...asset,
344
- storageKey: await getStorageKeyForAssetAsync(asset),
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
- onAssetUploadResultsChanged?.(uniqueAssets.map(asset => ({ asset, finished: false })));
349
- let missingAssets = await filterOutAssetsThatAlreadyExistAsync(graphqlClient, uniqueAssets);
350
- let missingAssetStorageKeys = new Set(missingAssets.map(a => a.storageKey));
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
- const missingAssetChunks = (0, chunk_1.default)(missingAssets, 100);
357
- const specifications = [];
358
- for (const missingAssets of missingAssetChunks) {
359
- const { specifications: chunkSpecifications } = await PublishMutation_1.PublishMutation.getUploadURLsAsync(graphqlClient, missingAssets.map(ma => ma.contentType));
360
- specifications.push(...chunkSpecifications);
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
- const [assetLimitPerUpdateGroup] = await Promise.all([
365
- PublishQuery_1.PublishQuery.getAssetLimitPerUpdateGroupAsync(graphqlClient, projectId),
366
- Promise.all(missingAssets.map((missingAsset, i) => {
367
- return assetUploadPromiseLimit(async () => {
368
- if (cancelationToken.isCanceledOrFinished) {
369
- throw Error('Canceled upload');
370
- }
371
- const presignedPost = JSON.parse(specifications[i]);
372
- await (0, uploads_1.uploadWithPresignedPostWithRetryAsync)(missingAsset.path, presignedPost, onAssetUploadBegin);
373
- });
374
- })),
375
- ]);
376
- let timeout = 1;
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
- const timeoutPromise = new Promise(resolve => setTimeout(resolve, Math.min(timeout * 1000, 5000))); // linear backoff
382
- missingAssets = await filterOutAssetsThatAlreadyExistAsync(graphqlClient, missingAssets);
383
- missingAssetStorageKeys = new Set(missingAssets.map(a => a.storageKey));
384
- await timeoutPromise; // await after filterOutAssetsThatAlreadyExistAsync for easy mocking with jest.runAllTimers
385
- timeout += 1;
386
- onAssetUploadResultsChanged?.(uniqueAssets.map(asset => ({
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,
@@ -0,0 +1,14 @@
1
+ import { LoggedInAuthenticationInfo } from './SessionManager';
2
+ export declare const SUDO_MODE_REQUIRED_ERROR_CODE = "SUDO_MODE_REQUIRED";
3
+ /**
4
+ * Whether the error is the server signaling that the current session must be upgraded
5
+ * to sudo mode before performing this operation.
6
+ */
7
+ export declare function isSudoModeRequiredError(error: unknown): boolean;
8
+ /**
9
+ * Upgrade the current session to sudo mode by re-confirming the user's password
10
+ * (and OTP if two-factor authentication is enabled). Sudo mode is required for
11
+ * destructive operations like project deletion, and expires server-side after a
12
+ * few minutes.
13
+ */
14
+ export declare function promptForSudoModeUpgradeAsync(authenticationInfo: LoggedInAuthenticationInfo): Promise<void>;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUDO_MODE_REQUIRED_ERROR_CODE = void 0;
4
+ exports.isSudoModeRequiredError = isSudoModeRequiredError;
5
+ exports.promptForSudoModeUpgradeAsync = promptForSudoModeUpgradeAsync;
6
+ const tslib_1 = require("tslib");
7
+ const ApiV2Error_1 = require("../ApiV2Error");
8
+ const api_1 = require("../api");
9
+ const client_1 = require("../graphql/client");
10
+ const log_1 = tslib_1.__importDefault(require("../log"));
11
+ const prompts_1 = require("../prompts");
12
+ exports.SUDO_MODE_REQUIRED_ERROR_CODE = 'SUDO_MODE_REQUIRED';
13
+ /**
14
+ * Whether the error is the server signaling that the current session must be upgraded
15
+ * to sudo mode before performing this operation.
16
+ */
17
+ function isSudoModeRequiredError(error) {
18
+ return (error instanceof client_1.GraphqlError &&
19
+ error.graphQLErrors.some(e => e?.extensions?.errorCode === exports.SUDO_MODE_REQUIRED_ERROR_CODE));
20
+ }
21
+ /**
22
+ * Upgrade the current session to sudo mode by re-confirming the user's password
23
+ * (and OTP if two-factor authentication is enabled). Sudo mode is required for
24
+ * destructive operations like project deletion, and expires server-side after a
25
+ * few minutes.
26
+ */
27
+ async function promptForSudoModeUpgradeAsync(authenticationInfo) {
28
+ if (!authenticationInfo.sessionSecret) {
29
+ throw new Error('This action requires sudo mode, which is only available for user sessions. ' +
30
+ 'Access tokens (EXPO_TOKEN) cannot be upgraded to sudo mode; log in with `eas login` instead.');
31
+ }
32
+ log_1.default.log('This action requires sudo mode. Confirm your password to continue.');
33
+ const { password } = await (0, prompts_1.promptAsync)({
34
+ type: 'password',
35
+ name: 'password',
36
+ message: 'Password:',
37
+ });
38
+ if (!password) {
39
+ throw new Error('Password is required for sudo mode.');
40
+ }
41
+ const apiV2Client = new api_1.ApiV2Client(authenticationInfo);
42
+ try {
43
+ await apiV2Client.postAsync('auth/upgradeSudo', { body: { password } });
44
+ }
45
+ catch (error) {
46
+ if (error instanceof ApiV2Error_1.ApiV2Error && error.expoApiV2ErrorCode === 'ONE_TIME_PASSWORD_REQUIRED') {
47
+ log_1.default.log('One-time password from authenticator required.');
48
+ const { otp } = await (0, prompts_1.promptAsync)({
49
+ type: 'text',
50
+ name: 'otp',
51
+ message: 'One-time password or backup code:',
52
+ });
53
+ if (!otp) {
54
+ throw new Error('Cancelled sudo mode upgrade.');
55
+ }
56
+ await apiV2Client.postAsync('auth/upgradeSudo', { body: { password, otp } });
57
+ }
58
+ else {
59
+ throw error;
60
+ }
61
+ }
62
+ }
@@ -5,19 +5,29 @@ import { selectPaginatedAsync } from '../utils/relay';
5
5
  export declare function getSignedDeploymentUrlAsync(graphqlClient: ExpoGraphqlClient, options: {
6
6
  appId: string;
7
7
  deploymentIdentifier?: string | null;
8
+ /** Custom dev domain name (preview URL subdomain) requested through the `--dev-domain` flag */
9
+ devDomainName?: string;
8
10
  /** Callback which is invoked when the project is going to setup the dev domain */
9
11
  onSetupDevDomain?: () => any;
10
12
  /** If the terminal is running in non interactive mode or not */
11
13
  nonInteractive?: boolean;
12
14
  }): Promise<string>;
15
+ /**
16
+ * Assert that a user-provided dev domain name (preview URL subdomain) is valid.
17
+ * Unlike the interactive prompt, which reformats invalid input while typing,
18
+ * this throws an error when the name contains invalid characters.
19
+ */
20
+ export declare function assertValidDevDomainName(name: string): void;
13
21
  /**
14
22
  * Assign a dev domain name to a project.
23
+ * - When a dev domain name is provided, it will assign that name without prompting.
15
24
  * - When running in interactive mode, it will prompt the user with a suggested domain name.
16
25
  * - When running in non interactive mode, it will auto-assign the suggested domain name.
17
26
  */
18
- export declare function assignDevDomainNameAsync({ graphqlClient, appId, nonInteractive, }: {
27
+ export declare function assignDevDomainNameAsync({ graphqlClient, appId, devDomainName: requestedDevDomainName, nonInteractive, }: {
19
28
  graphqlClient: ExpoGraphqlClient;
20
29
  appId: string;
30
+ devDomainName?: string;
21
31
  nonInteractive?: boolean;
22
32
  }): ReturnType<typeof DeploymentsMutation.assignDevDomainNameAsync>;
23
33
  export declare function assignWorkerDeploymentAliasAsync({ graphqlClient, appId, deploymentId, aliasName, }: {