eas-cli 21.8.0 → 22.2.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 (68) hide show
  1. package/README.md +209 -186
  2. package/build/build/android/prepareJob.js +1 -0
  3. package/build/build/ios/prepareJob.js +1 -0
  4. package/build/build/metadata.js +0 -1
  5. package/build/build/runBuildAndSubmit.js +1 -1
  6. package/build/build/utils/formatBuild.js +2 -2
  7. package/build/build/utils/url.js +3 -5
  8. package/build/commandUtils/context/contextUtils/getProjectIdAsync.js +10 -3
  9. package/build/commandUtils/new/configs.js +1 -1
  10. package/build/commands/account/view.js +1 -2
  11. package/build/commands/build/cancel.js +3 -3
  12. package/build/commands/build/download.js +1 -1
  13. package/build/commands/fingerprint/compare.js +100 -48
  14. package/build/commands/go.d.ts +1 -0
  15. package/build/commands/go.js +10 -47
  16. package/build/commands/project/icon/set.js +4 -40
  17. package/build/commands/project/init.d.ts +1 -0
  18. package/build/commands/project/init.js +13 -0
  19. package/build/commands/simulator/availability.js +2 -1
  20. package/build/commands/simulator/index.d.ts +1 -0
  21. package/build/commands/simulator/index.js +10 -5
  22. package/build/commands/simulator/stop.js +1 -0
  23. package/build/commands/submit.d.ts +1 -0
  24. package/build/commands/submit.js +8 -1
  25. package/build/commands/update/index.js +1 -1
  26. package/build/commands/update/revert-update-rollout.js +1 -1
  27. package/build/commands/update/rollback.js +1 -1
  28. package/build/credentials/ios/api/graphql/queries/AppleDeviceQuery.js +20 -13
  29. package/build/credentials/ios/api/graphql/queries/AppleTeamQuery.d.ts +14 -2
  30. package/build/credentials/ios/api/graphql/queries/AppleTeamQuery.js +47 -7
  31. package/build/credentials/ios/appstore/ensureTestFlightGroup.d.ts +3 -1
  32. package/build/credentials/ios/appstore/ensureTestFlightGroup.js +14 -11
  33. package/build/graphql/generated.d.ts +703 -932
  34. package/build/graphql/generated.js +16 -2
  35. package/build/graphql/queries/ChannelInsightsQuery.js +4 -1
  36. package/build/graphql/queries/DeviceRunSessionQuery.js +5 -0
  37. package/build/graphql/types/Account.js +1 -4
  38. package/build/graphql/types/Build.js +13 -8
  39. package/build/graphql/types/Submission.js +0 -1
  40. package/build/graphql/types/Update.js +4 -1
  41. package/build/project/accountSelection.js +1 -3
  42. package/build/project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync.js +3 -5
  43. package/build/project/projectIcon.d.ts +40 -0
  44. package/build/project/projectIcon.js +132 -0
  45. package/build/project/projectNotConfiguredError.d.ts +17 -0
  46. package/build/project/projectNotConfiguredError.js +24 -0
  47. package/build/simulator/env.d.ts +1 -1
  48. package/build/simulator/env.js +12 -2
  49. package/build/simulator/utils.js +26 -0
  50. package/build/submit/ArchiveSource.js +3 -3
  51. package/build/submit/context.d.ts +2 -0
  52. package/build/submit/context.js +1 -0
  53. package/build/submit/ios/AppProduce.js +1 -1
  54. package/build/submit/ios/IosSubmitCommand.js +2 -0
  55. package/build/submit/ios/ensureTestFlightSetup.d.ts +7 -0
  56. package/build/submit/ios/ensureTestFlightSetup.js +81 -0
  57. package/build/submit/status.js +1 -1
  58. package/build/submit/utils/formatSubmission.js +2 -2
  59. package/build/update/queries.js +1 -1
  60. package/build/update/republish.js +3 -3
  61. package/build/update/roll-back-to-embedded.js +1 -1
  62. package/build/update/utils.d.ts +2 -1
  63. package/build/update/utils.js +7 -7
  64. package/build/uploads.d.ts +5 -0
  65. package/build/uploads.js +22 -0
  66. package/build/user/User.js +1 -1
  67. package/oclif.manifest.json +222 -186
  68. package/package.json +7 -7
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureTestFlightSetupForExistingAppAsync = ensureTestFlightSetupForExistingAppAsync;
4
+ const tslib_1 = require("tslib");
5
+ const apple_utils_1 = require("@expo/apple-utils");
6
+ const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
7
+ const authenticateTypes_1 = require("../../credentials/ios/appstore/authenticateTypes");
8
+ const authenticate_1 = require("../../credentials/ios/appstore/authenticate");
9
+ const ensureTestFlightGroup_1 = require("../../credentials/ios/appstore/ensureTestFlightGroup");
10
+ const resolveCredentials_1 = require("../../credentials/ios/appstore/resolveCredentials");
11
+ const AscApiKeyUtils_1 = require("../../credentials/ios/actions/AscApiKeyUtils");
12
+ const log_1 = tslib_1.__importDefault(require("../../log"));
13
+ const bundleIdentifier_1 = require("../../project/ios/bundleIdentifier");
14
+ /**
15
+ * Best-effort TestFlight internal group setup for an App Store Connect app
16
+ * that already exists with `ascAppId` provided.
17
+ */
18
+ async function ensureTestFlightSetupForExistingAppAsync(ctx, ascAppIdentifier) {
19
+ if (!ctx.autoTestFlightSetup) {
20
+ return;
21
+ }
22
+ try {
23
+ const bundleIdentifier = ctx.applicationIdentifierOverride ??
24
+ ctx.profile.bundleIdentifier ??
25
+ (await (0, bundleIdentifier_1.getBundleIdentifierAsync)(ctx.projectDir, ctx.exp, ctx.vcsClient));
26
+ const appLookupParams = {
27
+ account: (0, nullthrows_1.default)(ctx.user.accounts.find(a => a.name === ctx.accountName), `You do not have access to account: ${ctx.accountName}`),
28
+ projectName: ctx.projectName,
29
+ bundleIdentifier,
30
+ };
31
+ if (!ctx.credentialsCtx.appStore.authCtx) {
32
+ const teamType = (0, resolveCredentials_1.resolveAppleTeamTypeFromEnvironment)() ?? authenticateTypes_1.AppleTeamType.COMPANY_OR_ORGANIZATION;
33
+ if ((0, resolveCredentials_1.hasAscEnvVars)()) {
34
+ const teamId = process.env.EXPO_APPLE_TEAM_ID;
35
+ if (!process.env.EXPO_ASC_API_KEY_PATH ||
36
+ !process.env.EXPO_ASC_KEY_ID ||
37
+ !process.env.EXPO_ASC_ISSUER_ID ||
38
+ !teamId) {
39
+ log_1.default.log('App Store Connect credentials are incomplete, skipping TestFlight setup');
40
+ return;
41
+ }
42
+ await ctx.credentialsCtx.appStore.ensureAuthenticatedAsync({
43
+ mode: authenticateTypes_1.AuthenticationMode.API_KEY,
44
+ teamId,
45
+ teamType,
46
+ });
47
+ }
48
+ else {
49
+ const resolvedKey = await (0, AscApiKeyUtils_1.resolveAscApiKeyForAppCredentialsAsync)({
50
+ graphqlClient: ctx.graphqlClient,
51
+ app: appLookupParams,
52
+ });
53
+ const teamId = resolvedKey?.teamId ?? process.env.EXPO_APPLE_TEAM_ID;
54
+ if (!resolvedKey || !teamId) {
55
+ log_1.default.log('No complete App Store Connect credentials, skipping TestFlight setup');
56
+ return;
57
+ }
58
+ log_1.default.log('Using App Store Connect API Key from EAS credentials service.');
59
+ await ctx.credentialsCtx.appStore.ensureAuthenticatedAsync({
60
+ mode: authenticateTypes_1.AuthenticationMode.API_KEY,
61
+ ascApiKey: resolvedKey.ascApiKey,
62
+ teamId,
63
+ teamName: resolvedKey.teamName,
64
+ teamType,
65
+ });
66
+ }
67
+ }
68
+ const authCtx = ctx.credentialsCtx.appStore.authCtx;
69
+ if (!authCtx) {
70
+ log_1.default.debug('No App Store Connect API key available, skipping TestFlight setup');
71
+ return;
72
+ }
73
+ const app = await apple_utils_1.App.infoAsync((0, authenticate_1.getRequestContext)(authCtx), { id: ascAppIdentifier });
74
+ await (0, ensureTestFlightGroup_1.ensureTestFlightGroupExistsAsync)(app, { nonInteractive: ctx.nonInteractive });
75
+ }
76
+ catch (error) {
77
+ // Group setup is a convenience on top of the submission and must never
78
+ // block it.
79
+ log_1.default.warn('Skipping TestFlight group setup:', error);
80
+ }
81
+ }
@@ -58,7 +58,7 @@ function toEasBuildLinkage(easSubmission) {
58
58
  return {
59
59
  easSubmissionId: easSubmission?.id ?? null,
60
60
  easBuildId: easSubmission?.submittedBuild?.id ?? null,
61
- runtimeVersion: easSubmission?.submittedBuild?.runtimeVersion ?? null,
61
+ runtimeVersion: easSubmission?.submittedBuild?.runtime?.version ?? null,
62
62
  fingerprintHash: easSubmission?.submittedBuild?.fingerprint?.hash ?? null,
63
63
  };
64
64
  }
@@ -45,7 +45,7 @@ function formatGraphQLSubmission(submission) {
45
45
  ? [
46
46
  {
47
47
  label: 'Application Identifier',
48
- value: sanitize(submission.androidConfig?.applicationIdentifier),
48
+ value: sanitize(submittedBuild?.appIdentifier),
49
49
  },
50
50
  { label: 'Track', value: sanitize(submission.androidConfig?.track)?.toLowerCase() },
51
51
  {
@@ -61,7 +61,7 @@ function formatGraphQLSubmission(submission) {
61
61
  label: submission.platform === generated_1.AppPlatform.Android ? 'Version code' : 'Build number',
62
62
  value: sanitize(submittedBuild?.appBuildVersion),
63
63
  },
64
- { label: 'Runtime Version', value: sanitize(submittedBuild?.runtimeVersion) },
64
+ { label: 'Runtime Version', value: sanitize(submittedBuild?.runtime?.version) },
65
65
  { label: 'Fingerprint', value: submittedBuild?.fingerprint?.hash },
66
66
  { label: 'Commit', value: sanitize(submittedBuild?.gitCommitHash) },
67
67
  { label: 'Error Code', value: sanitize(submission.error?.errorCode) },
@@ -134,7 +134,7 @@ async function selectUpdateGroupOnBranchAsync(graphqlClient, { projectId, branch
134
134
  .map(group => {
135
135
  const first = group[0];
136
136
  return first
137
- ? `${first.group} (runtime: ${first.runtimeVersion}, message: ${first.message ?? 'N/A'})`
137
+ ? `${first.group} (runtime: ${first.runtime.version}, message: ${first.message ?? 'N/A'})`
138
138
  : 'unknown';
139
139
  })
140
140
  .join('\n ');
@@ -38,14 +38,14 @@ async function republishAsync({ graphqlClient, app, updatesToPublish, targetBran
38
38
  const isSameGroup = (update) => update.groupId === arbitraryUpdate.groupId &&
39
39
  update.branchId === arbitraryUpdate.branchId &&
40
40
  update.branchName === arbitraryUpdate.branchName &&
41
- update.runtimeVersion === arbitraryUpdate.runtimeVersion &&
41
+ update.runtime.version === arbitraryUpdate.runtime.version &&
42
42
  update.manifestHostOverride === arbitraryUpdate.manifestHostOverride &&
43
43
  update.assetHostOverride === arbitraryUpdate.assetHostOverride;
44
44
  (0, assert_1.default)(updatesToPublish.every(isSameGroup), 'All updates being republished must belong to the same update group');
45
45
  (0, assert_1.default)(updatesToPublish.every(u => u.isRollBackToEmbedded) ||
46
46
  updatesToPublish.every(u => !u.isRollBackToEmbedded), 'All updates must either be roll back to embedded updates or not');
47
47
  (0, assert_1.default)(!updatesToPublish.some(u => !!u.rolloutControlUpdate), 'Cannot republish an update that is being rolled-out. Either complete the update rollout and then republish or publish a new rollout update.');
48
- const { runtimeVersion } = arbitraryUpdate;
48
+ const runtimeVersion = arbitraryUpdate.runtime.version;
49
49
  // If codesigning was created for the original update, we need to add it to the republish.
50
50
  // If one wishes to not sign the republish or sign with a different key, a normal publish should
51
51
  // be performed.
@@ -156,7 +156,7 @@ async function republishAsync({ graphqlClient, app, updatesToPublish, targetBran
156
156
  log_1.default.addNewLineIfNone();
157
157
  log_1.default.log((0, formatFields_1.default)([
158
158
  { label: 'Branch', value: targetBranchName },
159
- { label: 'Runtime version', value: arbitraryRepublishedUpdate.runtimeVersion },
159
+ { label: 'Runtime version', value: arbitraryRepublishedUpdate.runtime.version },
160
160
  { label: 'Platform', value: updatesRepublished.map(update => update.platform).join(', ') },
161
161
  { label: 'Update group ID', value: arbitraryRepublishedUpdate.group },
162
162
  ...(updatesRepublishedByPlatform.android
@@ -47,7 +47,7 @@ async function publishRollBackToEmbeddedUpdateAsync({ graphqlClient, projectId,
47
47
  else {
48
48
  log_1.default.addNewLineIfNone();
49
49
  for (const runtime of (0, uniqBy_1.default)(runtimeToPlatformsAndFingerprintInfoMapping, version => version.runtimeVersion)) {
50
- const newUpdatesForRuntimeVersion = newUpdates.filter(update => update.runtimeVersion === runtime.runtimeVersion);
50
+ const newUpdatesForRuntimeVersion = newUpdates.filter(update => update.runtime.version === runtime.runtimeVersion);
51
51
  if (newUpdatesForRuntimeVersion.length === 0) {
52
52
  throw new Error(`Publish response is missing updates with runtime ${runtime.runtimeVersion}.`);
53
53
  }
@@ -7,7 +7,8 @@ export type FormatUpdateParameter = Pick<Update, 'id' | 'createdAt' | 'message'>
7
7
  };
8
8
  export type UpdateJsonInfo = {
9
9
  branch: string;
10
- } & Pick<UpdateFragment, 'id' | 'createdAt' | 'group' | 'message' | 'runtimeVersion' | 'platform' | 'manifestPermalink' | 'gitCommitHash'>;
10
+ runtimeVersion: string;
11
+ } & Pick<UpdateFragment, 'id' | 'createdAt' | 'group' | 'message' | 'platform' | 'manifestPermalink' | 'gitCommitHash'>;
11
12
  export type UpdateGroupDescription = FormatUpdateParameter & {
12
13
  branch: string;
13
14
  group: string;
@@ -106,7 +106,7 @@ function ensureValidVersions(exp, platform) {
106
106
  }
107
107
  }
108
108
  function formatUpdateTitle(update) {
109
- const { message, createdAt, actor, runtimeVersion } = update;
109
+ const { message, createdAt, actor, runtime } = update;
110
110
  let actorName;
111
111
  switch (actor?.__typename) {
112
112
  case 'User':
@@ -124,7 +124,7 @@ function formatUpdateTitle(update) {
124
124
  actorName = 'unknown';
125
125
  }
126
126
  }
127
- return `[${(0, dateformat_1.default)(createdAt, 'mmm dd HH:MM')} by ${actorName}, runtimeVersion: ${runtimeVersion}] ${message}`;
127
+ return `[${(0, dateformat_1.default)(createdAt, 'mmm dd HH:MM')} by ${actorName}, runtimeVersion: ${runtime.version}] ${message}`;
128
128
  }
129
129
  function getUpdateJsonInfosForUpdates(updates) {
130
130
  return updates.map(update => ({
@@ -133,7 +133,7 @@ function getUpdateJsonInfosForUpdates(updates) {
133
133
  group: update.group,
134
134
  branch: update.branch.name,
135
135
  message: update.message,
136
- runtimeVersion: update.runtimeVersion,
136
+ runtimeVersion: update.runtime.version,
137
137
  platform: update.platform,
138
138
  manifestPermalink: update.manifestPermalink,
139
139
  isRollBackToEmbedded: update.isRollBackToEmbedded,
@@ -143,7 +143,7 @@ function getUpdateJsonInfosForUpdates(updates) {
143
143
  function getUpdateGroupDescriptions(updateGroups) {
144
144
  return updateGroups.map(updateGroup => ({
145
145
  message: formatUpdateMessage(updateGroup[0]),
146
- runtimeVersion: updateGroup[0].runtimeVersion,
146
+ runtimeVersion: updateGroup[0].runtime.version,
147
147
  isRollBackToEmbedded: updateGroup[0].isRollBackToEmbedded,
148
148
  rolloutPercentage: updateGroup[0].rolloutPercentage ?? undefined,
149
149
  codeSigningKey: updateGroup[0].codeSigningInfo?.keyid,
@@ -155,7 +155,7 @@ function getUpdateGroupDescriptionsWithBranch(updateGroups) {
155
155
  return updateGroups.map(updateGroup => ({
156
156
  branch: updateGroup[0].branch.name,
157
157
  message: formatUpdateMessage(updateGroup[0]),
158
- runtimeVersion: updateGroup[0].runtimeVersion,
158
+ runtimeVersion: updateGroup[0].runtime.version,
159
159
  isRollBackToEmbedded: updateGroup[0].isRollBackToEmbedded,
160
160
  rolloutPercentage: updateGroup[0].rolloutPercentage ?? undefined,
161
161
  codeSigningKey: updateGroup[0].codeSigningInfo?.keyid,
@@ -172,7 +172,7 @@ function getBranchDescription(branch) {
172
172
  branch: branch.name,
173
173
  update: {
174
174
  message: formatUpdateMessage(latestUpdate),
175
- runtimeVersion: latestUpdate.runtimeVersion,
175
+ runtimeVersion: latestUpdate.runtime.version,
176
176
  isRollBackToEmbedded: latestUpdate.isRollBackToEmbedded,
177
177
  rolloutPercentage: latestUpdate.rolloutPercentage ?? undefined,
178
178
  codeSigningKey: latestUpdate.codeSigningInfo?.keyid,
@@ -211,7 +211,7 @@ async function prewarmDiffingAsync(graphqlClient, appId, newUpdates) {
211
211
  appId,
212
212
  branchName: update.branch.name,
213
213
  platform: exports.updatePublishPlatformToAppPlatform[updatePublishPlatform],
214
- runtimeVersion: update.runtimeVersion,
214
+ runtimeVersion: update.runtime.version,
215
215
  limit: 2,
216
216
  });
217
217
  if (updateIds.length !== 2) {
@@ -20,3 +20,8 @@ export declare function uploadAppScopedFileAtPathToGCSAsync(graphqlClient: ExpoG
20
20
  handleProgressEvent?: ProgressHandler;
21
21
  }): Promise<string>;
22
22
  export declare function uploadWithPresignedPostWithRetryAsync(file: string, presignedPost: PresignedPost, onAssetUploadBegin: () => void): Promise<Response>;
23
+ /**
24
+ * Computes the base64-encoded MD5 checksum of a file, the format GCS expects
25
+ * in the `Content-MD5` request header.
26
+ */
27
+ export declare function computeFileMd5Base64Async(file: string): Promise<string>;
package/build/uploads.js CHANGED
@@ -4,7 +4,9 @@ exports.uploadFileAtPathToGCSAsync = uploadFileAtPathToGCSAsync;
4
4
  exports.uploadAccountScopedFileAtPathToGCSAsync = uploadAccountScopedFileAtPathToGCSAsync;
5
5
  exports.uploadAppScopedFileAtPathToGCSAsync = uploadAppScopedFileAtPathToGCSAsync;
6
6
  exports.uploadWithPresignedPostWithRetryAsync = uploadWithPresignedPostWithRetryAsync;
7
+ exports.computeFileMd5Base64Async = computeFileMd5Base64Async;
7
8
  const tslib_1 = require("tslib");
9
+ const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
8
10
  const form_data_1 = tslib_1.__importDefault(require("form-data"));
9
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
10
12
  const promise_retry_1 = tslib_1.__importDefault(require("promise-retry"));
@@ -78,12 +80,18 @@ async function uploadWithPresignedPostAsync(file, presignedPost) {
78
80
  async function uploadWithSignedUrlWithProgressAsync(file, signedUrl, handleProgressEvent) {
79
81
  const fileStat = await fs_extra_1.default.stat(file);
80
82
  const fileSize = fileStat.size;
83
+ if (fileSize === 0) {
84
+ throw new Error(`Failed to upload ${file}: the file is empty. It may not have been written correctly. Retry the command, and report this issue if it persists.`);
85
+ }
86
+ const contentMd5 = await computeFileMd5Base64Async(file);
81
87
  const readStream = fs_extra_1.default.createReadStream(file);
82
88
  const uploadPromise = (0, fetch_1.default)(signedUrl.url, {
83
89
  method: 'PUT',
84
90
  body: readStream,
85
91
  headers: {
86
92
  ...signedUrl.headers,
93
+ 'Content-Length': String(fileSize), // make GCS reject the request if the file size changes during the upload
94
+ 'Content-MD5': contentMd5, // make GCS reject the request if the uploaded bytes do not match this checksum
87
95
  },
88
96
  });
89
97
  let currentSize = 0;
@@ -99,6 +107,9 @@ async function uploadWithSignedUrlWithProgressAsync(file, signedUrl, handleProgr
99
107
  });
100
108
  try {
101
109
  const response = await uploadPromise;
110
+ if (currentSize !== fileSize) {
111
+ throw new Error(`Failed to upload ${file}: sent ${currentSize} of ${fileSize} bytes. The file may have changed during the upload. Retry the command, and report this issue if it persists.`);
112
+ }
102
113
  handleProgressEvent({ isComplete: true });
103
114
  return response;
104
115
  }
@@ -107,3 +118,14 @@ async function uploadWithSignedUrlWithProgressAsync(file, signedUrl, handleProgr
107
118
  throw error;
108
119
  }
109
120
  }
121
+ /**
122
+ * Computes the base64-encoded MD5 checksum of a file, the format GCS expects
123
+ * in the `Content-MD5` request header.
124
+ */
125
+ async function computeFileMd5Base64Async(file) {
126
+ const hash = node_crypto_1.default.createHash('md5');
127
+ for await (const chunk of fs_extra_1.default.createReadStream(file)) {
128
+ hash.update(chunk);
129
+ }
130
+ return hash.digest('base64');
131
+ }
@@ -10,7 +10,7 @@ const generated_1 = require("../graphql/generated");
10
10
  * then organization accounts.
11
11
  */
12
12
  function getCreatableAccountNames(actor) {
13
- const creatableAccounts = actor.accounts.filter(a => a.users.find(it => it.actor.id === actor.id)?.role !== generated_1.Role.ViewOnly);
13
+ const creatableAccounts = actor.accounts.filter(a => a.viewerUserPermission.role !== generated_1.Role.ViewOnly);
14
14
  if (actor.__typename === 'Robot') {
15
15
  return creatableAccounts.map(it => it.name);
16
16
  }