eas-cli 0.38.3 → 0.41.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 (78) hide show
  1. package/README.md +277 -29
  2. package/build/api.d.ts +1 -0
  3. package/build/api.js +13 -1
  4. package/build/build/build.js +3 -3
  5. package/build/build/context.d.ts +2 -1
  6. package/build/build/createContext.d.ts +3 -2
  7. package/build/build/createContext.js +3 -3
  8. package/build/build/local.d.ts +9 -1
  9. package/build/build/local.js +35 -5
  10. package/build/build/metadata.js +14 -0
  11. package/build/build/runBuildAndSubmit.d.ts +15 -0
  12. package/build/build/runBuildAndSubmit.js +173 -0
  13. package/build/commands/branch/create.d.ts +0 -1
  14. package/build/commands/branch/create.js +0 -1
  15. package/build/commands/branch/delete.d.ts +0 -1
  16. package/build/commands/branch/delete.js +1 -2
  17. package/build/commands/branch/list.d.ts +0 -1
  18. package/build/commands/branch/list.js +1 -2
  19. package/build/commands/branch/publish.d.ts +1 -18
  20. package/build/commands/branch/publish.js +2 -354
  21. package/build/commands/branch/rename.d.ts +0 -1
  22. package/build/commands/branch/rename.js +0 -1
  23. package/build/commands/branch/view.d.ts +0 -1
  24. package/build/commands/branch/view.js +0 -1
  25. package/build/commands/build/configure.js +1 -1
  26. package/build/commands/build/index.d.ts +0 -5
  27. package/build/commands/build/index.js +8 -159
  28. package/build/commands/build/inspect.d.ts +22 -0
  29. package/build/commands/build/inspect.js +129 -0
  30. package/build/commands/channel/create.d.ts +0 -1
  31. package/build/commands/channel/create.js +0 -1
  32. package/build/commands/channel/edit.d.ts +0 -1
  33. package/build/commands/channel/edit.js +1 -2
  34. package/build/commands/channel/list.d.ts +0 -1
  35. package/build/commands/channel/list.js +0 -1
  36. package/build/commands/channel/view.d.ts +0 -1
  37. package/build/commands/channel/view.js +3 -4
  38. package/build/commands/credentials.js +1 -7
  39. package/build/commands/diagnostics.d.ts +1 -0
  40. package/build/commands/diagnostics.js +20 -1
  41. package/build/commands/submit.js +1 -1
  42. package/build/commands/update/configure.d.ts +0 -2
  43. package/build/commands/update/configure.js +23 -15
  44. package/build/commands/update/delete.d.ts +0 -1
  45. package/build/commands/update/delete.js +0 -1
  46. package/build/commands/update/index.d.ts +19 -0
  47. package/build/commands/update/index.js +384 -0
  48. package/build/commands/update/view.d.ts +0 -1
  49. package/build/commands/update/view.js +0 -1
  50. package/build/credentials/context.d.ts +5 -0
  51. package/build/credentials/context.js +12 -7
  52. package/build/credentials/ios/actions/AscApiKeyUtils.js +1 -1
  53. package/build/credentials/ios/appstore/ensureAppExists.js +3 -3
  54. package/build/credentials/manager/ManageAndroid.d.ts +3 -3
  55. package/build/credentials/manager/ManageAndroid.js +21 -13
  56. package/build/credentials/manager/ManageIos.d.ts +3 -3
  57. package/build/credentials/manager/ManageIos.js +23 -13
  58. package/build/credentials/manager/SelectBuildProfileFromEasJson.d.ts +2 -3
  59. package/build/credentials/manager/SelectBuildProfileFromEasJson.js +3 -6
  60. package/build/credentials/manager/SelectPlatform.d.ts +1 -2
  61. package/build/credentials/manager/SelectPlatform.js +3 -3
  62. package/build/graphql/generated.d.ts +31 -11
  63. package/build/graphql/generated.js +6 -1
  64. package/build/graphql/types/Submission.js +1 -0
  65. package/build/project/expoSdk.d.ts +3 -0
  66. package/build/project/expoSdk.js +30 -0
  67. package/build/project/ios/target.js +32 -7
  68. package/build/prompts.d.ts +3 -3
  69. package/build/submit/context.js +0 -1
  70. package/build/submit/ios/AppProduce.js +3 -3
  71. package/build/submit/ios/IosSubmitCommand.js +7 -2
  72. package/build/submit/utils/urls.js +1 -1
  73. package/build/submit/utils/wait.js +1 -1
  74. package/build/update/utils.js +5 -5
  75. package/build/utils/profiles.d.ts +1 -1
  76. package/build/utils/profiles.js +80 -30
  77. package/oclif.manifest.json +1 -1
  78. package/package.json +7 -7
@@ -0,0 +1,384 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultPublishPlatforms = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const config_1 = require("@expo/config");
6
+ const config_plugins_1 = require("@expo/config-plugins");
7
+ const eas_build_job_1 = require("@expo/eas-build-job");
8
+ const command_1 = require("@oclif/command");
9
+ const assert_1 = (0, tslib_1.__importDefault)(require("assert"));
10
+ const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
11
+ const dateformat_1 = (0, tslib_1.__importDefault)(require("dateformat"));
12
+ const graphql_tag_1 = (0, tslib_1.__importDefault)(require("graphql-tag"));
13
+ const api_1 = require("../../api");
14
+ const EasCommand_1 = (0, tslib_1.__importDefault)(require("../../commandUtils/EasCommand"));
15
+ const client_1 = require("../../graphql/client");
16
+ const PublishMutation_1 = require("../../graphql/mutations/PublishMutation");
17
+ const log_1 = (0, tslib_1.__importDefault)(require("../../log"));
18
+ const ora_1 = require("../../ora");
19
+ const projectUtils_1 = require("../../project/projectUtils");
20
+ const publish_1 = require("../../project/publish");
21
+ const workflow_1 = require("../../project/workflow");
22
+ const prompts_1 = require("../../prompts");
23
+ const utils_1 = require("../../update/utils");
24
+ const uniqBy_1 = (0, tslib_1.__importDefault)(require("../../utils/expodash/uniqBy"));
25
+ const formatFields_1 = (0, tslib_1.__importDefault)(require("../../utils/formatFields"));
26
+ const vcs_1 = require("../../vcs");
27
+ const create_1 = require("../branch/create");
28
+ const list_1 = require("../branch/list");
29
+ const view_1 = require("../branch/view");
30
+ const create_2 = require("../channel/create");
31
+ exports.defaultPublishPlatforms = ['android', 'ios'];
32
+ async function getUpdateGroupAsync({ group, }) {
33
+ const { updatesByGroup } = await (0, client_1.withErrorHandlingAsync)(client_1.graphqlClient
34
+ .query((0, graphql_tag_1.default) `
35
+ query getUpdateGroupAsync($group: ID!) {
36
+ updatesByGroup(group: $group) {
37
+ id
38
+ group
39
+ runtimeVersion
40
+ manifestFragment
41
+ platform
42
+ message
43
+ }
44
+ }
45
+ `, {
46
+ group,
47
+ }, { additionalTypenames: ['Update'] })
48
+ .toPromise());
49
+ return updatesByGroup;
50
+ }
51
+ async function ensureChannelExistsAsync({ appId, branchId, channelName, }) {
52
+ var _a;
53
+ try {
54
+ await (0, create_2.createUpdateChannelOnAppAsync)({
55
+ appId,
56
+ channelName,
57
+ branchId,
58
+ });
59
+ log_1.default.withTick(`Created a channel: ${chalk_1.default.bold(channelName)} pointed at branch: ${chalk_1.default.bold(channelName)}.`);
60
+ }
61
+ catch (e) {
62
+ const isIgnorableError = ((_a = e.graphQLErrors) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
63
+ e.graphQLErrors[0].extensions.errorCode === 'CHANNEL_ALREADY_EXISTS';
64
+ if (!isIgnorableError) {
65
+ throw e;
66
+ }
67
+ }
68
+ }
69
+ async function ensureBranchExistsAsync({ appId, name: branchName, }) {
70
+ const { app } = await (0, view_1.viewUpdateBranchAsync)({
71
+ appId,
72
+ name: branchName,
73
+ });
74
+ const updateBranch = app === null || app === void 0 ? void 0 : app.byId.updateBranchByName;
75
+ if (updateBranch) {
76
+ const { id, updates } = updateBranch;
77
+ await ensureChannelExistsAsync({ appId, branchId: id, channelName: branchName });
78
+ return { id, updates };
79
+ }
80
+ const newUpdateBranch = await (0, create_1.createUpdateBranchOnAppAsync)({ appId, name: branchName });
81
+ log_1.default.withTick(`Created branch: ${chalk_1.default.bold(branchName)}`);
82
+ await ensureChannelExistsAsync({ appId, branchId: newUpdateBranch.id, channelName: branchName });
83
+ return { id: newUpdateBranch.id, updates: [] };
84
+ }
85
+ class UpdatePublish extends EasCommand_1.default {
86
+ async runAsync() {
87
+ var _a, _b, _c;
88
+ let { flags: { branch: branchName, json: jsonFlag, auto: autoFlag, message, republish, group, 'input-dir': inputDir, 'skip-bundler': skipBundler, }, } = this.parse(UpdatePublish);
89
+ const platformFlag = this.parse(UpdatePublish).flags.platform;
90
+ // If a group was specified, that means we are republishing it.
91
+ republish = group ? true : republish;
92
+ const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
93
+ const { exp } = (0, config_1.getConfig)(projectDir, {
94
+ skipSDKVersionRequirement: true,
95
+ isPublicConfig: true,
96
+ });
97
+ const runtimeVersions = await getRuntimeVersionObjectAsync(exp, platformFlag, projectDir);
98
+ const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
99
+ await checkEASUpdateURLIsSetAsync(exp);
100
+ if (!branchName && autoFlag) {
101
+ branchName =
102
+ (await (0, vcs_1.getVcsClient)().getBranchNameAsync()) ||
103
+ `branch-${Math.random().toString(36).substr(2, 4)}`;
104
+ }
105
+ if (!branchName) {
106
+ const validationMessage = 'Branch name may not be empty.';
107
+ if (jsonFlag) {
108
+ throw new Error(validationMessage);
109
+ }
110
+ const branches = await (0, list_1.listBranchesAsync)({ projectId });
111
+ if (branches.length === 0) {
112
+ ({ name: branchName } = await (0, prompts_1.promptAsync)({
113
+ type: 'text',
114
+ name: 'name',
115
+ message: 'No branches found. Creating a new one. Please name the new branch:',
116
+ initial: (await (0, vcs_1.getVcsClient)().getBranchNameAsync()) ||
117
+ `branch-${Math.random().toString(36).substr(2, 4)}`,
118
+ validate: value => (value ? true : validationMessage),
119
+ }));
120
+ }
121
+ else {
122
+ branchName = await (0, prompts_1.selectAsync)('Which branch would you like to publish on?', branches.map(branch => {
123
+ return {
124
+ title: `${branch.name} ${chalk_1.default.grey(`- current update: ${(0, utils_1.formatUpdate)(branch.updates[0])}`)}`,
125
+ value: branch.name,
126
+ };
127
+ }));
128
+ }
129
+ (0, assert_1.default)(branchName, 'Branch name must be specified.');
130
+ }
131
+ const { id: branchId, updates } = await ensureBranchExistsAsync({
132
+ appId: projectId,
133
+ name: branchName,
134
+ });
135
+ let unsortedUpdateInfoGroups = {};
136
+ let oldMessage, oldRuntimeVersion;
137
+ if (republish) {
138
+ // If we are republishing, we don't need to worry about building the bundle or uploading the assets.
139
+ // Instead we get the `updateInfoGroup` from the update we wish to republish.
140
+ let updatesToRepublish;
141
+ if (group) {
142
+ updatesToRepublish = await getUpdateGroupAsync({ group });
143
+ }
144
+ else {
145
+ // Drop into interactive mode if the user has not specified an update group to republish.
146
+ if (jsonFlag) {
147
+ throw new Error('You must specify the update group to republish.');
148
+ }
149
+ const updateGroups = (0, uniqBy_1.default)(updates, u => u.group)
150
+ .filter(update => {
151
+ // Only show groups that have updates on the specified platform(s).
152
+ return platformFlag === 'all' || update.platform === platformFlag;
153
+ })
154
+ .map(update => ({
155
+ title: formatUpdateTitle(update),
156
+ value: update.group,
157
+ }));
158
+ if (updateGroups.length === 0) {
159
+ throw new Error(`There are no updates on branch "${branchName}" published on the platform(s) ${platformFlag}. Did you mean to publish a new update instead?`);
160
+ }
161
+ const selectedUpdateGroup = await (0, prompts_1.selectAsync)('which update would you like to republish?', updateGroups);
162
+ updatesToRepublish = updates.filter(update => update.group === selectedUpdateGroup);
163
+ }
164
+ const updatesToRepublishFilteredByPlatform = updatesToRepublish.filter(
165
+ // Only republish to the specified platforms
166
+ update => platformFlag === 'all' || update.platform === platformFlag);
167
+ if (updatesToRepublishFilteredByPlatform.length === 0) {
168
+ throw new Error(`There are no updates on branch "${branchName}" published on the platform(s) "${platformFlag}" with group ID "${group ? group : updatesToRepublish[0].group}". Did you mean to publish a new update instead?`);
169
+ }
170
+ let publicationPlatformMessage;
171
+ if (platformFlag === 'all') {
172
+ if (updatesToRepublishFilteredByPlatform.length !== exports.defaultPublishPlatforms.length) {
173
+ log_1.default.warn(`You are republishing an update that wasn't published for all platforms.`);
174
+ }
175
+ publicationPlatformMessage = `The republished update will appear on the same plaforms it was originally published on: ${updatesToRepublishFilteredByPlatform
176
+ .map(update => update.platform)
177
+ .join(', ')}`;
178
+ }
179
+ else {
180
+ publicationPlatformMessage = `The republished update will appear only on: ${platformFlag}`;
181
+ }
182
+ log_1.default.withTick(publicationPlatformMessage);
183
+ for (const update of updatesToRepublishFilteredByPlatform) {
184
+ const { manifestFragment } = update;
185
+ const platform = update.platform;
186
+ unsortedUpdateInfoGroups[platform] = JSON.parse(manifestFragment);
187
+ }
188
+ // These are the same for each member of an update group
189
+ group = updatesToRepublishFilteredByPlatform[0].group;
190
+ oldMessage = (_a = updatesToRepublishFilteredByPlatform[0].message) !== null && _a !== void 0 ? _a : '';
191
+ oldRuntimeVersion = updatesToRepublishFilteredByPlatform[0].runtimeVersion;
192
+ if (!message) {
193
+ const validationMessage = 'publish message may not be empty.';
194
+ if (jsonFlag) {
195
+ throw new Error(validationMessage);
196
+ }
197
+ ({ publishMessage: message } = await (0, prompts_1.promptAsync)({
198
+ type: 'text',
199
+ name: 'publishMessage',
200
+ message: `Please enter an update message.`,
201
+ initial: `Republish "${oldMessage}" - group: ${group}`,
202
+ validate: (value) => (value ? true : validationMessage),
203
+ }));
204
+ }
205
+ }
206
+ else {
207
+ if (!message && autoFlag) {
208
+ message = (_b = (await (0, vcs_1.getVcsClient)().getLastCommitMessageAsync())) === null || _b === void 0 ? void 0 : _b.trim();
209
+ }
210
+ if (!message) {
211
+ const validationMessage = 'publish message may not be empty.';
212
+ if (jsonFlag) {
213
+ throw new Error(validationMessage);
214
+ }
215
+ ({ publishMessage: message } = await (0, prompts_1.promptAsync)({
216
+ type: 'text',
217
+ name: 'publishMessage',
218
+ message: `Please enter an update message.`,
219
+ initial: (_c = (await (0, vcs_1.getVcsClient)().getLastCommitMessageAsync())) === null || _c === void 0 ? void 0 : _c.trim(),
220
+ validate: (value) => (value ? true : validationMessage),
221
+ }));
222
+ }
223
+ // build bundle and upload assets for a new publish
224
+ if (!skipBundler) {
225
+ await (0, publish_1.buildBundlesAsync)({ projectDir, inputDir });
226
+ }
227
+ const assetSpinner = (0, ora_1.ora)('Uploading assets...').start();
228
+ try {
229
+ const platforms = platformFlag === 'all' ? exports.defaultPublishPlatforms : [platformFlag];
230
+ const assets = await (0, publish_1.collectAssetsAsync)({ inputDir: inputDir, platforms });
231
+ await (0, publish_1.uploadAssetsAsync)(assets);
232
+ unsortedUpdateInfoGroups = await (0, publish_1.buildUnsortedUpdateInfoGroupAsync)(assets, exp);
233
+ assetSpinner.succeed('Uploaded assets!');
234
+ }
235
+ catch (e) {
236
+ assetSpinner.fail('Failed to upload assets');
237
+ throw e;
238
+ }
239
+ }
240
+ const runtimeToPlatformMapping = {};
241
+ for (const runtime of new Set(Object.values(runtimeVersions))) {
242
+ runtimeToPlatformMapping[runtime] = Object.entries(runtimeVersions)
243
+ .filter(pair => pair[1] === runtime)
244
+ .map(pair => pair[0]);
245
+ }
246
+ // Sort the updates into different groups based on their platform specific runtime versions
247
+ const updateGroups = Object.entries(runtimeToPlatformMapping).map(([runtime, platforms]) => {
248
+ const localUpdateInfoGroup = Object.fromEntries(platforms.map(platform => [
249
+ platform,
250
+ unsortedUpdateInfoGroups[platform],
251
+ ]));
252
+ if (republish && !oldRuntimeVersion) {
253
+ throw new Error('Can not find the runtime version of the update group that is being republished.');
254
+ }
255
+ return {
256
+ branchId,
257
+ updateInfoGroup: localUpdateInfoGroup,
258
+ runtimeVersion: republish ? oldRuntimeVersion : runtime,
259
+ message,
260
+ };
261
+ });
262
+ let newUpdates;
263
+ const publishSpinner = (0, ora_1.ora)('Publishing...').start();
264
+ try {
265
+ newUpdates = await PublishMutation_1.PublishMutation.publishUpdateGroupAsync(updateGroups);
266
+ publishSpinner.succeed('Published!');
267
+ }
268
+ catch (e) {
269
+ publishSpinner.fail('Failed to published updates');
270
+ throw e;
271
+ }
272
+ if (jsonFlag) {
273
+ log_1.default.log(JSON.stringify(newUpdates));
274
+ }
275
+ else {
276
+ if (new Set(newUpdates.map(update => update.group)).size > 1) {
277
+ log_1.default.addNewLineIfNone();
278
+ log_1.default.log('👉 Since multiple runtime versions are defined, multiple update groups have been published.');
279
+ }
280
+ log_1.default.addNewLineIfNone();
281
+ for (const runtime of new Set(Object.values(runtimeVersions))) {
282
+ const platforms = newUpdates
283
+ .filter(update => update.runtimeVersion === runtime)
284
+ .map(update => update.platform);
285
+ const newUpdate = newUpdates.find(update => update.runtimeVersion === runtime);
286
+ if (!newUpdate) {
287
+ throw new Error(`Publish response is missing updates with runtime ${runtime}.`);
288
+ }
289
+ log_1.default.log((0, formatFields_1.default)([
290
+ { label: 'branch', value: branchName },
291
+ { label: 'runtime version', value: runtime },
292
+ { label: 'platform', value: platforms.join(', ') },
293
+ { label: 'update group ID', value: newUpdate.group },
294
+ { label: 'message', value: message },
295
+ ]));
296
+ log_1.default.addNewLineIfNone();
297
+ }
298
+ }
299
+ }
300
+ }
301
+ exports.default = UpdatePublish;
302
+ UpdatePublish.description = 'Publish an update group.';
303
+ UpdatePublish.flags = {
304
+ branch: command_1.flags.string({
305
+ description: 'Branch to publish the update group on',
306
+ required: false,
307
+ }),
308
+ message: command_1.flags.string({
309
+ description: 'A short message describing the update',
310
+ required: false,
311
+ }),
312
+ republish: command_1.flags.boolean({
313
+ description: 'Republish an update group',
314
+ exclusive: ['input-dir', 'skip-bundler'],
315
+ }),
316
+ group: command_1.flags.string({
317
+ description: 'Update group to republish',
318
+ exclusive: ['input-dir', 'skip-bundler'],
319
+ }),
320
+ 'input-dir': command_1.flags.string({
321
+ description: 'Location of the bundle',
322
+ default: 'dist',
323
+ required: false,
324
+ }),
325
+ 'skip-bundler': command_1.flags.boolean({
326
+ description: `Skip running Expo CLI to bundle the app before publishing`,
327
+ default: false,
328
+ }),
329
+ platform: command_1.flags.enum({
330
+ char: 'p',
331
+ options: [...exports.defaultPublishPlatforms, 'all'],
332
+ default: 'all',
333
+ required: false,
334
+ }),
335
+ json: command_1.flags.boolean({
336
+ description: 'Enable JSON output, non-JSON messages will be printed to stderr',
337
+ default: false,
338
+ }),
339
+ auto: command_1.flags.boolean({
340
+ description: 'Use the current git branch and commit message for the EAS branch and update message',
341
+ default: false,
342
+ }),
343
+ };
344
+ async function getRuntimeVersionObjectAsync(exp, platformFlag, projectDir) {
345
+ var _a, _b;
346
+ const platforms = (platformFlag === 'all' ? ['android', 'ios'] : [platformFlag]);
347
+ for (const platform of platforms) {
348
+ const isPolicy = typeof ((_b = (_a = exp[platform]) === null || _a === void 0 ? void 0 : _a.runtimeVersion) !== null && _b !== void 0 ? _b : exp.runtimeVersion) === 'object';
349
+ if (isPolicy) {
350
+ const isManaged = (await (0, workflow_1.resolveWorkflowAsync)(projectDir, platform)) === eas_build_job_1.Workflow.MANAGED;
351
+ if (!isManaged) {
352
+ throw new Error('Runtime version policies are only supported in the managed workflow.');
353
+ }
354
+ }
355
+ }
356
+ return Object.fromEntries(platforms.map(platform => [platform, config_plugins_1.Updates.getRuntimeVersion(exp, platform)]));
357
+ }
358
+ function formatUpdateTitle(update) {
359
+ const { message, createdAt, actor, runtimeVersion } = update;
360
+ let actorName;
361
+ switch (actor === null || actor === void 0 ? void 0 : actor.__typename) {
362
+ case 'User': {
363
+ actorName = actor.username;
364
+ break;
365
+ }
366
+ case 'Robot': {
367
+ const { firstName, id } = actor;
368
+ actorName = firstName !== null && firstName !== void 0 ? firstName : `robot: ${id.slice(0, 4)}...`;
369
+ break;
370
+ }
371
+ default:
372
+ actorName = 'unknown';
373
+ }
374
+ return `[${(0, dateformat_1.default)(createdAt, 'mmm dd HH:MM')} by ${actorName}, runtimeVersion: ${runtimeVersion}] ${message}`;
375
+ }
376
+ async function checkEASUpdateURLIsSetAsync(exp) {
377
+ var _a;
378
+ const configuredURL = (_a = exp.updates) === null || _a === void 0 ? void 0 : _a.url;
379
+ const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
380
+ const expectedURL = (0, api_1.getEASUpdateURL)(projectId);
381
+ if (configuredURL !== expectedURL) {
382
+ throw new Error(`The update URL is incorrectly configured for EAS Update. Please set updates.url to ${expectedURL} in your app.json.`);
383
+ }
384
+ }
@@ -4,7 +4,6 @@ export declare function viewUpdateAsync({ groupId, }: {
4
4
  groupId: string;
5
5
  }): Promise<UpdatesByGroupQuery>;
6
6
  export default class UpdateView extends EasCommand {
7
- static hidden: boolean;
8
7
  static description: string;
9
8
  static args: {
10
9
  name: string;
@@ -68,7 +68,6 @@ class UpdateView extends EasCommand_1.default {
68
68
  }
69
69
  }
70
70
  exports.default = UpdateView;
71
- UpdateView.hidden = true;
72
71
  UpdateView.description = 'Update group details.';
73
72
  UpdateView.args = [
74
73
  {
@@ -1,4 +1,5 @@
1
1
  import { ExpoConfig } from '@expo/config';
2
+ import { Env } from '@expo/eas-build-job';
2
3
  import { Actor } from '../user/User';
3
4
  import * as AndroidGraphqlClient from './android/api/GraphqlClient';
4
5
  import * as IosGraphqlClient from './ios/api/GraphqlClient';
@@ -18,7 +19,11 @@ export declare class CredentialsContext {
18
19
  nonInteractive?: boolean;
19
20
  projectDir: string;
20
21
  user: Actor;
22
+ env?: Env;
21
23
  });
24
+ static getExpoConfigInProject(projectDir: string, { env }?: {
25
+ env?: Env;
26
+ }): ExpoConfig | null;
22
27
  get hasProjectContext(): boolean;
23
28
  get exp(): ExpoConfig;
24
29
  ensureProjectContext(): void;
@@ -14,7 +14,7 @@ const IosGraphqlClient = (0, tslib_1.__importStar)(require("./ios/api/GraphqlCli
14
14
  const AppStoreApi_1 = (0, tslib_1.__importDefault)(require("./ios/appstore/AppStoreApi"));
15
15
  class CredentialsContext {
16
16
  constructor(options) {
17
- var _a;
17
+ var _a, _b;
18
18
  this.options = options;
19
19
  this.android = AndroidGraphqlClient;
20
20
  this.appStore = new AppStoreApi_1.default();
@@ -25,12 +25,17 @@ class CredentialsContext {
25
25
  this.nonInteractive = (_a = options.nonInteractive) !== null && _a !== void 0 ? _a : false;
26
26
  this.resolvedExp = options.exp;
27
27
  if (!this.resolvedExp) {
28
- try {
29
- this.resolvedExp = (0, expoConfig_1.getExpoConfig)(options.projectDir);
30
- }
31
- catch (error) {
32
- // ignore error, context might be created outside of expo project
33
- }
28
+ this.resolvedExp =
29
+ (_b = CredentialsContext.getExpoConfigInProject(this.projectDir, { env: options.env })) !== null && _b !== void 0 ? _b : undefined;
30
+ }
31
+ }
32
+ static getExpoConfigInProject(projectDir, { env } = {}) {
33
+ try {
34
+ return (0, expoConfig_1.getExpoConfig)(projectDir, { env });
35
+ }
36
+ catch (error) {
37
+ // ignore error, context might be created outside of expo project
38
+ return null;
34
39
  }
35
40
  }
36
41
  get hasProjectContext() {
@@ -93,7 +93,7 @@ async function promptForAscApiKeyAsync(ctx) {
93
93
  }
94
94
  async function promptForKeyP8AndIdAsync() {
95
95
  var _a, _b;
96
- log_1.default.log(chalk_1.default.bold('An App Store Connect Api key is required to upload your app to the Apple App Store'));
96
+ log_1.default.log(chalk_1.default.bold('An App Store Connect Api key is required to upload your app to the Apple App Store Connect'));
97
97
  log_1.default.log(`If you're not sure what this is or how to create one, ${(0, log_1.learnMore)('https://expo.fyi/creating-asc-api-key')}`);
98
98
  const { keyP8Path } = await (0, prompts_1.promptAsync)({
99
99
  type: 'text',
@@ -96,10 +96,10 @@ exports.syncCapabilityIdentifiersAsync = syncCapabilityIdentifiersAsync;
96
96
  async function ensureAppExistsAsync(authCtx, { name, language, companyName, bundleIdentifier, sku, }) {
97
97
  var _a;
98
98
  const context = (0, authenticate_1.getRequestContext)(authCtx);
99
- const spinner = (0, ora_1.ora)(`Linking to App Store ${chalk_1.default.dim(bundleIdentifier)}`).start();
99
+ const spinner = (0, ora_1.ora)(`Linking to App Store Connect ${chalk_1.default.dim(bundleIdentifier)}`).start();
100
100
  let app = await apple_utils_1.App.findAsync(context, { bundleId: bundleIdentifier });
101
101
  if (!app) {
102
- spinner.text = `Creating App Store app ${chalk_1.default.bold(name)} ${chalk_1.default.dim(bundleIdentifier)}`;
102
+ spinner.text = `Creating App Store Connect app ${chalk_1.default.bold(name)} ${chalk_1.default.dim(bundleIdentifier)}`;
103
103
  try {
104
104
  // Assert contract errors when the user needs to create an app.
105
105
  await (0, contractMessages_1.assertContractMessagesAsync)(context, spinner);
@@ -125,7 +125,7 @@ async function ensureAppExistsAsync(authCtx, { name, language, companyName, bund
125
125
  else {
126
126
  // TODO: Update app name when API gives us that possibility
127
127
  }
128
- spinner.succeed(`Prepared App Store for ${chalk_1.default.bold(name)} ${chalk_1.default.dim(bundleIdentifier)}`);
128
+ spinner.succeed(`Prepared App Store Connect for ${chalk_1.default.bold(name)} ${chalk_1.default.dim(bundleIdentifier)}`);
129
129
  return app;
130
130
  }
131
131
  exports.ensureAppExistsAsync = ensureAppExistsAsync;
@@ -1,10 +1,10 @@
1
- import { CredentialsContext } from '../context';
2
1
  import { ActionInfo } from './Actions';
3
2
  import { Action } from './HelperActions';
4
3
  export declare class ManageAndroid {
5
4
  private callingAction;
6
- constructor(callingAction: Action);
7
- runAsync(ctx: CredentialsContext, currentActions?: ActionInfo[]): Promise<void>;
5
+ private projectDir;
6
+ constructor(callingAction: Action, projectDir: string);
7
+ runAsync(currentActions?: ActionInfo[]): Promise<void>;
8
8
  private createProjectContextAsync;
9
9
  private runProjectSpecificActionAsync;
10
10
  }
@@ -25,16 +25,27 @@ const SetUpGoogleServiceAccountKey_1 = require("../android/actions/SetUpGoogleSe
25
25
  const UpdateCredentialsJson_1 = require("../android/actions/UpdateCredentialsJson");
26
26
  const UseExistingGoogleServiceAccountKey_1 = require("../android/actions/UseExistingGoogleServiceAccountKey");
27
27
  const printCredentials_1 = require("../android/utils/printCredentials");
28
+ const context_1 = require("../context");
28
29
  const Actions_1 = require("./Actions");
29
30
  const AndroidActions_1 = require("./AndroidActions");
30
31
  const HelperActions_1 = require("./HelperActions");
31
32
  const SelectAndroidBuildCredentials_1 = require("./SelectAndroidBuildCredentials");
32
33
  const SelectBuildProfileFromEasJson_1 = require("./SelectBuildProfileFromEasJson");
33
34
  class ManageAndroid {
34
- constructor(callingAction) {
35
+ constructor(callingAction, projectDir) {
35
36
  this.callingAction = callingAction;
37
+ this.projectDir = projectDir;
36
38
  }
37
- async runAsync(ctx, currentActions = AndroidActions_1.highLevelActions) {
39
+ async runAsync(currentActions = AndroidActions_1.highLevelActions) {
40
+ const hasProjectContext = !!context_1.CredentialsContext.getExpoConfigInProject(this.projectDir);
41
+ const buildProfile = hasProjectContext
42
+ ? await new SelectBuildProfileFromEasJson_1.SelectBuildProfileFromEasJson(this.projectDir, eas_build_job_1.Platform.ANDROID).runAsync()
43
+ : null;
44
+ const ctx = new context_1.CredentialsContext({
45
+ projectDir: process.cwd(),
46
+ user: await (0, actions_1.ensureLoggedInAsync)(),
47
+ env: buildProfile === null || buildProfile === void 0 ? void 0 : buildProfile.env,
48
+ });
38
49
  const accountName = ctx.hasProjectContext
39
50
  ? (0, projectUtils_1.getProjectAccountName)(ctx.exp, ctx.user)
40
51
  : (0, actions_1.ensureActorHasUsername)(ctx.user);
@@ -42,7 +53,11 @@ class ManageAndroid {
42
53
  if (!account) {
43
54
  throw new Error(`You do not have access to account: ${accountName}`);
44
55
  }
45
- const { gradleContext } = await this.createProjectContextAsync(ctx);
56
+ let gradleContext;
57
+ if (ctx.hasProjectContext) {
58
+ (0, assert_1.default)(buildProfile, 'buildProfile must be defined in a project context');
59
+ gradleContext = await this.createProjectContextAsync(ctx, buildProfile);
60
+ }
46
61
  while (true) {
47
62
  try {
48
63
  if (ctx.hasProjectContext) {
@@ -114,20 +129,13 @@ class ManageAndroid {
114
129
  await new HelperActions_1.PressAnyKeyToContinue().runAsync();
115
130
  }
116
131
  }
117
- async createProjectContextAsync(ctx) {
118
- if (!ctx.hasProjectContext) {
119
- return {};
120
- }
132
+ async createProjectContextAsync(ctx, buildProfile) {
133
+ (0, assert_1.default)(ctx.hasProjectContext, 'createProjectContextAsync: must have project context.');
121
134
  const maybeProjectId = await (0, projectUtils_1.promptToCreateProjectIfNotExistsAsync)(ctx.exp);
122
135
  if (!maybeProjectId) {
123
136
  throw new Error('Your project must be registered with EAS in order to use the credentials manager.');
124
137
  }
125
- const buildProfile = await new SelectBuildProfileFromEasJson_1.SelectBuildProfileFromEasJson(ctx.projectDir, eas_build_job_1.Platform.ANDROID).runAsync(ctx);
126
- const gradleContext = await (0, gradle_1.resolveGradleBuildContextAsync)(ctx.projectDir, buildProfile);
127
- return {
128
- gradleContext,
129
- buildProfile,
130
- };
138
+ return await (0, gradle_1.resolveGradleBuildContextAsync)(ctx.projectDir, buildProfile);
131
139
  }
132
140
  async runProjectSpecificActionAsync(ctx, action, gradleContext) {
133
141
  (0, assert_1.default)(ctx.hasProjectContext, 'You must be in your project directory in order to perform this action');
@@ -1,10 +1,10 @@
1
- import { CredentialsContext } from '../context';
2
1
  import { ActionInfo } from './Actions';
3
2
  import { Action } from './HelperActions';
4
3
  export declare class ManageIos {
5
4
  private callingAction;
6
- constructor(callingAction: Action);
7
- runAsync(ctx: CredentialsContext, currentActions?: ActionInfo[]): Promise<void>;
5
+ private projectDir;
6
+ constructor(callingAction: Action, projectDir: string);
7
+ runAsync(currentActions?: ActionInfo[]): Promise<void>;
8
8
  private createProjectContextAsync;
9
9
  private runAccountSpecificActionAsync;
10
10
  private runProjectSpecificActionAsync;
@@ -13,6 +13,7 @@ const projectUtils_1 = require("../../project/projectUtils");
13
13
  const prompts_1 = require("../../prompts");
14
14
  const Account_1 = require("../../user/Account");
15
15
  const actions_1 = require("../../user/actions");
16
+ const context_1 = require("../context");
16
17
  const AscApiKeyUtils_1 = require("../ios/actions/AscApiKeyUtils");
17
18
  const AssignAscApiKey_1 = require("../ios/actions/AssignAscApiKey");
18
19
  const AssignPushKey_1 = require("../ios/actions/AssignPushKey");
@@ -41,10 +42,20 @@ const IosActions_1 = require("./IosActions");
41
42
  const SelectBuildProfileFromEasJson_1 = require("./SelectBuildProfileFromEasJson");
42
43
  const SelectIosDistributionTypeGraphqlFromBuildProfile_1 = require("./SelectIosDistributionTypeGraphqlFromBuildProfile");
43
44
  class ManageIos {
44
- constructor(callingAction) {
45
+ constructor(callingAction, projectDir) {
45
46
  this.callingAction = callingAction;
47
+ this.projectDir = projectDir;
46
48
  }
47
- async runAsync(ctx, currentActions = IosActions_1.highLevelActions) {
49
+ async runAsync(currentActions = IosActions_1.highLevelActions) {
50
+ const hasProjectContext = !!context_1.CredentialsContext.getExpoConfigInProject(this.projectDir);
51
+ const buildProfile = hasProjectContext
52
+ ? await new SelectBuildProfileFromEasJson_1.SelectBuildProfileFromEasJson(this.projectDir, eas_build_job_1.Platform.IOS).runAsync()
53
+ : null;
54
+ const ctx = new context_1.CredentialsContext({
55
+ projectDir: process.cwd(),
56
+ user: await (0, actions_1.ensureLoggedInAsync)(),
57
+ env: buildProfile === null || buildProfile === void 0 ? void 0 : buildProfile.env,
58
+ });
48
59
  const buildCredentialsActions = (0, IosActions_1.getBuildCredentialsActions)(ctx);
49
60
  const pushKeyActions = (0, IosActions_1.getPushKeyActions)(ctx);
50
61
  const ascApiKeyActions = (0, IosActions_1.getAscApiKeyActions)(ctx);
@@ -56,7 +67,14 @@ class ManageIos {
56
67
  if (!account) {
57
68
  throw new Error(`You do not have access to account: ${accountName}`);
58
69
  }
59
- const { app, targets, buildProfile } = await this.createProjectContextAsync(ctx, account);
70
+ let app = null;
71
+ let targets = null;
72
+ if (ctx.hasProjectContext) {
73
+ (0, assert_1.default)(buildProfile, 'buildProfile must be defined in project context');
74
+ const projectContext = await this.createProjectContextAsync(ctx, account, buildProfile);
75
+ app = projectContext.app;
76
+ targets = projectContext.targets;
77
+ }
60
78
  while (true) {
61
79
  try {
62
80
  if (ctx.hasProjectContext) {
@@ -128,20 +146,13 @@ class ManageIos {
128
146
  await new HelperActions_1.PressAnyKeyToContinue().runAsync();
129
147
  }
130
148
  }
131
- async createProjectContextAsync(ctx, account) {
132
- if (!ctx.hasProjectContext) {
133
- return {
134
- app: null,
135
- targets: null,
136
- buildProfile: null,
137
- };
138
- }
149
+ async createProjectContextAsync(ctx, account, buildProfile) {
150
+ (0, assert_1.default)(ctx.hasProjectContext, 'createProjectContextAsync: must have project context.');
139
151
  const maybeProjectId = await (0, projectUtils_1.promptToCreateProjectIfNotExistsAsync)(ctx.exp);
140
152
  if (!maybeProjectId) {
141
153
  throw new Error('Your project must be registered with EAS in order to use the credentials manager.');
142
154
  }
143
155
  const app = { account, projectName: ctx.exp.slug };
144
- const buildProfile = await new SelectBuildProfileFromEasJson_1.SelectBuildProfileFromEasJson(ctx.projectDir, eas_build_job_1.Platform.IOS).runAsync(ctx);
145
156
  const xcodeBuildContext = await (0, scheme_1.resolveXcodeBuildContextAsync)({
146
157
  projectDir: ctx.projectDir,
147
158
  nonInteractive: ctx.nonInteractive,
@@ -151,7 +162,6 @@ class ManageIos {
151
162
  return {
152
163
  app,
153
164
  targets,
154
- buildProfile,
155
165
  };
156
166
  }
157
167
  async runAccountSpecificActionAsync(ctx, account, action) {