eas-cli 0.30.0 → 0.32.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 (81) hide show
  1. package/README.md +26 -26
  2. package/build/build/android/prepareJob.js +3 -3
  3. package/build/build/ios/prepareJob.js +3 -14
  4. package/build/build/utils/printBuildInfo.js +1 -1
  5. package/build/build/utils/updates.js +1 -1
  6. package/build/commands/branch/create.js +1 -4
  7. package/build/commands/branch/delete.js +1 -4
  8. package/build/commands/branch/list.js +1 -4
  9. package/build/commands/branch/publish.js +1 -4
  10. package/build/commands/branch/rename.js +1 -4
  11. package/build/commands/branch/view.js +1 -4
  12. package/build/commands/build/cancel.js +1 -2
  13. package/build/commands/build/configure.js +2 -2
  14. package/build/commands/build/index.js +3 -3
  15. package/build/commands/build/list.js +1 -2
  16. package/build/commands/build/view.js +1 -2
  17. package/build/commands/channel/create.js +1 -4
  18. package/build/commands/channel/edit.js +1 -4
  19. package/build/commands/channel/list.js +1 -4
  20. package/build/commands/channel/rollout.js +1 -4
  21. package/build/commands/channel/view.js +1 -4
  22. package/build/commands/config.js +1 -2
  23. package/build/commands/device/list.js +1 -2
  24. package/build/commands/device/view.js +1 -2
  25. package/build/commands/project/info.js +1 -4
  26. package/build/commands/project/init.js +1 -4
  27. package/build/commands/secret/create.js +1 -2
  28. package/build/commands/secret/delete.js +1 -2
  29. package/build/commands/secret/list.js +1 -2
  30. package/build/commands/submit.js +2 -5
  31. package/build/commands/webhook/create.js +1 -4
  32. package/build/commands/webhook/delete.js +1 -4
  33. package/build/commands/webhook/list.js +1 -4
  34. package/build/credentials/android/actions/SetupGoogleServiceAccountKey.js +3 -3
  35. package/build/credentials/android/credentials.d.ts +2 -0
  36. package/build/credentials/android/utils/googleServiceAccountKey.js +1 -0
  37. package/build/credentials/context.d.ts +1 -1
  38. package/build/credentials/context.js +5 -5
  39. package/build/credentials/errors.d.ts +3 -0
  40. package/build/credentials/errors.js +7 -1
  41. package/build/credentials/ios/actions/AscApiKeyUtils.d.ts +5 -0
  42. package/build/credentials/ios/actions/AscApiKeyUtils.js +63 -0
  43. package/build/credentials/ios/actions/DistributionCertificateUtils.js +5 -5
  44. package/build/credentials/ios/actions/SetupAdhocProvisioningProfile.d.ts +1 -0
  45. package/build/credentials/ios/actions/SetupAdhocProvisioningProfile.js +48 -4
  46. package/build/credentials/ios/appstore/AppStoreApi.d.ts +7 -1
  47. package/build/credentials/ios/appstore/AppStoreApi.js +17 -0
  48. package/build/credentials/ios/appstore/Credentials.js +3 -3
  49. package/build/credentials/ios/appstore/Credentials.types.d.ts +13 -0
  50. package/build/credentials/ios/appstore/ascApiKey.d.ts +9 -0
  51. package/build/credentials/ios/appstore/ascApiKey.js +99 -0
  52. package/build/credentials/ios/credentials.d.ts +17 -0
  53. package/build/credentials/ios/credentials.js +16 -1
  54. package/build/credentials/ios/utils/printCredentials.js +12 -7
  55. package/build/devices/context.js +1 -1
  56. package/build/graphql/generated.d.ts +24 -1
  57. package/build/graphql/generated.js +2 -0
  58. package/build/log.d.ts +11 -1
  59. package/build/log.js +21 -10
  60. package/build/project/projectUtils.d.ts +4 -1
  61. package/build/project/projectUtils.js +13 -3
  62. package/build/submit/ArchiveSource.d.ts +7 -2
  63. package/build/submit/ArchiveSource.js +91 -8
  64. package/build/submit/android/AndroidSubmitCommand.js +3 -8
  65. package/build/submit/android/AndroidSubmitter.js +31 -9
  66. package/build/submit/android/ServiceAccountSource.d.ts +24 -5
  67. package/build/submit/android/ServiceAccountSource.js +54 -75
  68. package/build/submit/context.d.ts +4 -0
  69. package/build/submit/context.js +7 -1
  70. package/build/submit/ios/AscApiKeySource.d.ts +28 -0
  71. package/build/submit/ios/AscApiKeySource.js +51 -0
  72. package/build/submit/ios/IosSubmitCommand.d.ts +2 -0
  73. package/build/submit/ios/IosSubmitCommand.js +51 -3
  74. package/build/submit/ios/IosSubmitter.d.ts +3 -1
  75. package/build/submit/ios/IosSubmitter.js +48 -4
  76. package/build/submit/submit.js +1 -1
  77. package/build/submit/utils/builds.d.ts +3 -1
  78. package/build/submit/utils/builds.js +6 -6
  79. package/build/utils/json.js +2 -6
  80. package/oclif.manifest.json +1 -1
  81. package/package.json +8 -7
@@ -16,10 +16,9 @@ const User_1 = require("../../user/User");
16
16
  const actions_1 = require("../../user/actions");
17
17
  class EnvironmentSecretCreate extends EasCommand_1.default {
18
18
  async runAsync() {
19
- var _a;
20
19
  const actor = await (0, actions_1.ensureLoggedInAsync)();
21
20
  let { flags: { name, value: secretValue, scope, force }, } = this.parse(EnvironmentSecretCreate);
22
- const projectDir = (_a = (await (0, projectUtils_1.findProjectRootAsync)())) !== null && _a !== void 0 ? _a : process.cwd();
21
+ const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
23
22
  const { exp } = (0, config_1.getConfig)(projectDir, { skipSDKVersionRequirement: true });
24
23
  const accountName = await (0, projectUtils_1.getProjectAccountNameAsync)(exp);
25
24
  const { slug } = exp;
@@ -13,8 +13,7 @@ const projectUtils_1 = require("../../project/projectUtils");
13
13
  const prompts_1 = require("../../prompts");
14
14
  class EnvironmentSecretDelete extends EasCommand_1.default {
15
15
  async runAsync() {
16
- var _a;
17
- const projectDir = (_a = (await (0, projectUtils_1.findProjectRootAsync)())) !== null && _a !== void 0 ? _a : process.cwd();
16
+ const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
18
17
  const { exp } = (0, config_1.getConfig)(projectDir, { skipSDKVersionRequirement: true });
19
18
  const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
20
19
  const projectAccountName = await (0, projectUtils_1.getProjectAccountNameAsync)(exp);
@@ -12,8 +12,7 @@ const isEasEnabledForProject_1 = require("../../project/isEasEnabledForProject")
12
12
  const projectUtils_1 = require("../../project/projectUtils");
13
13
  class EnvironmentSecretList extends EasCommand_1.default {
14
14
  async runAsync() {
15
- var _a;
16
- const projectDir = (_a = (await (0, projectUtils_1.findProjectRootAsync)())) !== null && _a !== void 0 ? _a : process.cwd();
15
+ const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
17
16
  const { exp } = (0, config_1.getConfig)(projectDir, { skipSDKVersionRequirement: true });
18
17
  const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
19
18
  const projectAccountName = await (0, projectUtils_1.getProjectAccountNameAsync)(exp);
@@ -17,10 +17,9 @@ const submit_1 = require("../submit/submit");
17
17
  const urls_1 = require("../submit/utils/urls");
18
18
  class Submit extends EasCommand_1.default {
19
19
  async runAsync() {
20
- var _a;
21
20
  const { flags: rawFlags } = this.parse(Submit);
22
21
  const flags = await this.sanitizeFlagsAsync(rawFlags);
23
- const projectDir = (_a = (await (0, projectUtils_1.findProjectRootAsync)())) !== null && _a !== void 0 ? _a : process.cwd();
22
+ const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
24
23
  const { exp } = (0, config_1.getConfig)(projectDir, { skipSDKVersionRequirement: true });
25
24
  const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
26
25
  if (!(await (0, isEasEnabledForProject_1.isEasEnabledForProjectAsync)(projectId))) {
@@ -78,9 +77,7 @@ class Submit extends EasCommand_1.default {
78
77
  }
79
78
  exports.default = Submit;
80
79
  Submit.description = `submit build archive to app store
81
- See how to configure submits with eas.json: ${(0, log_1.learnMore)('https://docs.expo.dev/submit/eas-json/', {
82
- learnMoreMessage: '',
83
- })}`;
80
+ See how to configure submits with eas.json: ${(0, log_1.link)('https://docs.expo.dev/submit/eas-json/')}`;
84
81
  Submit.aliases = ['build:submit'];
85
82
  Submit.flags = {
86
83
  platform: command_1.flags.enum({
@@ -13,10 +13,7 @@ class WebhookCreate extends EasCommand_1.default {
13
13
  async runAsync() {
14
14
  const { flags } = this.parse(WebhookCreate);
15
15
  const webhookInputParams = await (0, input_1.prepareInputParamsAsync)(flags);
16
- const projectDir = await (0, projectUtils_1.findProjectRootAsync)(process.cwd());
17
- if (!projectDir) {
18
- throw new Error('Please run this command inside a project directory.');
19
- }
16
+ const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
20
17
  const { exp } = (0, config_1.getConfig)(projectDir, { skipSDKVersionRequirement: true });
21
18
  const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
22
19
  const spinner = (0, ora_1.ora)('Creating a webhook').start();
@@ -16,10 +16,7 @@ const formatWebhook_1 = require("../../webhooks/formatWebhook");
16
16
  class WebhookDelete extends EasCommand_1.default {
17
17
  async runAsync() {
18
18
  let { args: { ID: webhookId }, } = this.parse(WebhookDelete);
19
- const projectDir = await (0, projectUtils_1.findProjectRootAsync)(process.cwd());
20
- if (!projectDir) {
21
- throw new Error('Please run this command inside a project directory.');
22
- }
19
+ const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
23
20
  const { exp } = (0, config_1.getConfig)(projectDir, { skipSDKVersionRequirement: true });
24
21
  const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
25
22
  let webhook = webhookId && (await WebhookQuery_1.WebhookQuery.byIdAsync(webhookId));
@@ -14,10 +14,7 @@ const formatWebhook_1 = require("../../webhooks/formatWebhook");
14
14
  class WebhookList extends EasCommand_1.default {
15
15
  async runAsync() {
16
16
  const { flags: { event }, } = this.parse(WebhookList);
17
- const projectDir = await (0, projectUtils_1.findProjectRootAsync)(process.cwd());
18
- if (!projectDir) {
19
- throw new Error('Please run this command inside a project directory.');
20
- }
17
+ const projectDir = await (0, projectUtils_1.findProjectRootAsync)();
21
18
  const { exp } = (0, config_1.getConfig)(projectDir, { skipSDKVersionRequirement: true });
22
19
  const projectId = await (0, projectUtils_1.getProjectIdAsync)(exp);
23
20
  const projectFullName = await (0, projectUtils_1.getProjectFullNameAsync)(exp);
@@ -14,14 +14,14 @@ class SetupGoogleServiceAccountKey {
14
14
  this.app = app;
15
15
  }
16
16
  async runAsync(ctx) {
17
- if (ctx.nonInteractive) {
18
- throw new errors_1.MissingCredentialsNonInteractiveError('Google Service Account Keys cannot be set up in --non-interactive mode.');
19
- }
20
17
  const isKeySetup = await this.isGoogleServiceAccountKeySetupAsync(ctx);
21
18
  if (isKeySetup) {
22
19
  log_1.default.succeed('Google Service Account Key already set up.');
23
20
  return (0, nullthrows_1.default)(await ctx.android.getAndroidAppCredentialsWithCommonFieldsAsync(this.app), 'androidAppCredentials cannot be null if google service account key is already set up');
24
21
  }
22
+ if (ctx.nonInteractive) {
23
+ throw new errors_1.MissingCredentialsNonInteractiveError('Google Service Account Keys cannot be set up in --non-interactive mode.');
24
+ }
25
25
  const keysForAccount = await ctx.android.getGoogleServiceAccountKeysForAccountAsync(this.app.account);
26
26
  let googleServiceAccountKey = null;
27
27
  if (keysForAccount.length === 0) {
@@ -15,6 +15,8 @@ export declare type KeystoreWithType = Keystore & {
15
15
  export declare type GoogleServiceAccountKey = {
16
16
  [key: string]: any;
17
17
  private_key: string;
18
+ type: string;
19
+ client_email: string;
18
20
  };
19
21
  export declare type AndroidCredentials = {
20
22
  experienceName: string;
@@ -13,6 +13,7 @@ const date_1 = require("../../../utils/date");
13
13
  exports.MinimalGoogleServiceAccountKeySchema = joi_1.default.object({
14
14
  type: joi_1.default.string().required(),
15
15
  private_key: joi_1.default.string().required(),
16
+ client_email: joi_1.default.string().required(),
16
17
  });
17
18
  function fileIsServiceAccountKey(keyJsonPath) {
18
19
  try {
@@ -12,7 +12,7 @@ export declare class CredentialsContext {
12
12
  readonly projectDir: string;
13
13
  readonly user: Actor;
14
14
  private shouldAskAuthenticateAppStore;
15
- private _exp?;
15
+ private resolvedExp?;
16
16
  constructor(options: {
17
17
  exp?: ExpoConfig;
18
18
  nonInteractive?: boolean;
@@ -23,10 +23,10 @@ class CredentialsContext {
23
23
  this.projectDir = options.projectDir;
24
24
  this.user = options.user;
25
25
  this.nonInteractive = (_a = options.nonInteractive) !== null && _a !== void 0 ? _a : false;
26
- this._exp = options.exp;
27
- if (!this._exp) {
26
+ this.resolvedExp = options.exp;
27
+ if (!this.resolvedExp) {
28
28
  try {
29
- this._exp = (0, expoConfig_1.getExpoConfig)(options.projectDir);
29
+ this.resolvedExp = (0, expoConfig_1.getExpoConfig)(options.projectDir);
30
30
  }
31
31
  catch (error) {
32
32
  // ignore error, context might be created outside of expo project
@@ -34,11 +34,11 @@ class CredentialsContext {
34
34
  }
35
35
  }
36
36
  get hasProjectContext() {
37
- return !!this._exp;
37
+ return !!this.resolvedExp;
38
38
  }
39
39
  get exp() {
40
40
  this.ensureProjectContext();
41
- return this._exp;
41
+ return this.resolvedExp;
42
42
  }
43
43
  ensureProjectContext() {
44
44
  if (this.hasProjectContext) {
@@ -1,3 +1,6 @@
1
1
  export declare class MissingCredentialsNonInteractiveError extends Error {
2
2
  constructor(message?: string);
3
3
  }
4
+ export declare class MissingCredentialsError extends Error {
5
+ constructor(message?: string);
6
+ }
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MissingCredentialsNonInteractiveError = void 0;
3
+ exports.MissingCredentialsError = exports.MissingCredentialsNonInteractiveError = void 0;
4
4
  class MissingCredentialsNonInteractiveError extends Error {
5
5
  constructor(message) {
6
6
  super(message !== null && message !== void 0 ? message : 'Credentials are not set up. Please run this command again in interactive mode.');
7
7
  }
8
8
  }
9
9
  exports.MissingCredentialsNonInteractiveError = MissingCredentialsNonInteractiveError;
10
+ class MissingCredentialsError extends Error {
11
+ constructor(message) {
12
+ super(message !== null && message !== void 0 ? message : 'Credentials are not set up.');
13
+ }
14
+ }
15
+ exports.MissingCredentialsError = MissingCredentialsError;
@@ -0,0 +1,5 @@
1
+ import { AscApiKey } from '../appstore/Credentials.types';
2
+ import { AscApiKeyPath, MinimalAscApiKey } from '../credentials';
3
+ export declare function promptForAscApiKeyAsync(): Promise<AscApiKeyPath>;
4
+ export declare function promptForIssuerIdAsync(): Promise<string>;
5
+ export declare function getMinimalAscApiKeyAsync(ascApiKey: AscApiKey): Promise<MinimalAscApiKey>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMinimalAscApiKeyAsync = exports.promptForIssuerIdAsync = exports.promptForAscApiKeyAsync = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
6
+ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
7
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
8
+ const uuid = (0, tslib_1.__importStar)(require("uuid"));
9
+ const log_1 = (0, tslib_1.__importStar)(require("../../../log"));
10
+ const prompts_1 = require("../../../prompts");
11
+ const promptForCredentials_1 = require("../../utils/promptForCredentials");
12
+ const credentials_1 = require("../credentials");
13
+ async function promptForAscApiKeyAsync() {
14
+ var _a, _b;
15
+ 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'));
16
+ 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')}`);
17
+ const { keyP8Path } = await (0, prompts_1.promptAsync)({
18
+ type: 'text',
19
+ name: 'keyP8Path',
20
+ message: 'Path to App Store Connect Api Key:',
21
+ initial: 'AuthKey_ABCD.p8',
22
+ // eslint-disable-next-line async-protect/async-suffix
23
+ validate: async (filePath) => {
24
+ try {
25
+ const stats = await fs_extra_1.default.stat(filePath);
26
+ if (stats.isFile()) {
27
+ return true;
28
+ }
29
+ return 'Input is not a file.';
30
+ }
31
+ catch {
32
+ return 'File does not exist.';
33
+ }
34
+ },
35
+ });
36
+ const regex = /^AuthKey_(?<keyId>\w+)\.p8$/; // Common ASC Api file name downloaded from Apple
37
+ const bestEffortKeyId = (_b = (_a = path_1.default.basename(keyP8Path).match(regex)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.keyId;
38
+ const ascApiKeyMetadata = await (0, promptForCredentials_1.getCredentialsFromUserAsync)(credentials_1.ascApiKeyMetadataSchema, {
39
+ keyId: bestEffortKeyId,
40
+ });
41
+ return { ...ascApiKeyMetadata, keyP8Path };
42
+ }
43
+ exports.promptForAscApiKeyAsync = promptForAscApiKeyAsync;
44
+ async function promptForIssuerIdAsync() {
45
+ log_1.default.log(chalk_1.default.bold('An App Store Connect Issuer ID is required'));
46
+ log_1.default.log(`If you're not sure what this is or how to find yours, ${(0, log_1.learnMore)('https://expo.fyi/asc-issuer-id')}`);
47
+ const { issuerId } = await (0, prompts_1.promptAsync)({
48
+ type: 'text',
49
+ name: 'issuerId',
50
+ message: 'App Store Connect Issuer ID:',
51
+ validate: (input) => uuid.validate(input),
52
+ });
53
+ return issuerId;
54
+ }
55
+ exports.promptForIssuerIdAsync = promptForIssuerIdAsync;
56
+ async function getMinimalAscApiKeyAsync(ascApiKey) {
57
+ var _a;
58
+ return {
59
+ ...ascApiKey,
60
+ issuerId: (_a = ascApiKey.issuerId) !== null && _a !== void 0 ? _a : (await promptForIssuerIdAsync()),
61
+ };
62
+ }
63
+ exports.getMinimalAscApiKeyAsync = getMinimalAscApiKeyAsync;
@@ -37,7 +37,7 @@ function formatDistributionCertificate(distributionCertificate, validSerialNumbe
37
37
  return line;
38
38
  }
39
39
  exports.formatDistributionCertificate = formatDistributionCertificate;
40
- async function _selectDistributionCertificateAsync(distCerts, validDistributionCertificates) {
40
+ async function selectDistributionCertificateAsync(distCerts, validDistributionCertificates) {
41
41
  const validDistCertSerialNumbers = validDistributionCertificates === null || validDistributionCertificates === void 0 ? void 0 : validDistributionCertificates.map(distCert => distCert.serialNumber);
42
42
  const { chosenDistCert } = await (0, prompts_1.promptAsync)({
43
43
  type: 'select',
@@ -60,12 +60,12 @@ async function selectDistributionCertificateWithDependenciesAsync(ctx, account)
60
60
  return null;
61
61
  }
62
62
  if (!ctx.appStore.authCtx) {
63
- return _selectDistributionCertificateAsync(distCertsForAccount);
63
+ return selectDistributionCertificateAsync(distCertsForAccount);
64
64
  }
65
65
  // get valid certs on the developer portal
66
66
  const certInfoFromApple = await ctx.appStore.listDistributionCertificatesAsync();
67
67
  const validDistCerts = await (0, CredentialsUtils_1.filterRevokedDistributionCertsFromEasServers)(distCertsForAccount, certInfoFromApple);
68
- return _selectDistributionCertificateAsync(distCertsForAccount, validDistCerts);
68
+ return selectDistributionCertificateAsync(distCertsForAccount, validDistCerts);
69
69
  }
70
70
  exports.selectDistributionCertificateWithDependenciesAsync = selectDistributionCertificateWithDependenciesAsync;
71
71
  /**
@@ -79,7 +79,7 @@ async function selectValidDistributionCertificateAsync(ctx, appLookupParams) {
79
79
  return null;
80
80
  }
81
81
  if (!ctx.appStore.authCtx) {
82
- return _selectDistributionCertificateAsync(distCertsForAccount);
82
+ return selectDistributionCertificateAsync(distCertsForAccount);
83
83
  }
84
84
  // filter by apple team
85
85
  (0, assert_1.default)(ctx.appStore.authCtx, 'authentication to the Apple App Store is required');
@@ -91,7 +91,7 @@ async function selectValidDistributionCertificateAsync(ctx, appLookupParams) {
91
91
  const certInfoFromApple = await ctx.appStore.listDistributionCertificatesAsync();
92
92
  const validDistCerts = (0, CredentialsUtils_1.filterRevokedDistributionCertsFromEasServers)(distCertsForAppleTeam, certInfoFromApple);
93
93
  log_1.default.log(`${validDistCerts.length}/${distCertsForAccount.length} Distribution Certificates are currently valid for Apple Team ${(_a = ctx.appStore.authCtx) === null || _a === void 0 ? void 0 : _a.team.id}.`);
94
- return _selectDistributionCertificateAsync(validDistCerts);
94
+ return selectDistributionCertificateAsync(validDistCerts);
95
95
  }
96
96
  exports.selectValidDistributionCertificateAsync = selectValidDistributionCertificateAsync;
97
97
  const APPLE_DIST_CERTS_TOO_MANY_GENERATED_ERROR = `
@@ -8,6 +8,7 @@ export declare class SetupAdhocProvisioningProfile {
8
8
  runWithDistributionCertificateAsync(ctx: CredentialsContext, distCert: AppleDistributionCertificateFragment): Promise<IosAppBuildCredentialsFragment>;
9
9
  private areBuildCredentialsSetupAsync;
10
10
  private shouldUseExistingProfileAsync;
11
+ private promptForReuseActionAsync;
11
12
  private registerDevicesAsync;
12
13
  }
13
14
  export declare function doUDIDsMatch(udidsA: string[], udidsB: string[]): boolean;
@@ -16,6 +16,12 @@ const AppleTeamUtils_1 = require("./AppleTeamUtils");
16
16
  const BuildCredentialsUtils_1 = require("./BuildCredentialsUtils");
17
17
  const DeviceUtils_1 = require("./DeviceUtils");
18
18
  const SetupDistributionCertificate_1 = require("./SetupDistributionCertificate");
19
+ var ReuseAction;
20
+ (function (ReuseAction) {
21
+ ReuseAction[ReuseAction["Yes"] = 0] = "Yes";
22
+ ReuseAction[ReuseAction["ShowDevices"] = 1] = "ShowDevices";
23
+ ReuseAction[ReuseAction["No"] = 2] = "No";
24
+ })(ReuseAction || (ReuseAction = {}));
19
25
  class SetupAdhocProvisioningProfile {
20
26
  constructor(app) {
21
27
  this.app = app;
@@ -108,10 +114,23 @@ class SetupAdhocProvisioningProfile {
108
114
  const provisionedDevices = provisioningProfile.appleDevices;
109
115
  const allRegisteredDevicesAreProvisioned = doUDIDsMatch(registeredAppleDevices.map(({ identifier }) => identifier), provisionedDevices.map(({ identifier }) => identifier));
110
116
  if (allRegisteredDevicesAreProvisioned) {
111
- return await (0, prompts_1.confirmAsync)({
112
- message: `All your registered devices are present in the Provisioning Profile. Would you like to reuse it?`,
113
- initial: true,
114
- });
117
+ const reuseAction = await this.promptForReuseActionAsync();
118
+ if (reuseAction === ReuseAction.Yes) {
119
+ return true;
120
+ }
121
+ else if (reuseAction === ReuseAction.No) {
122
+ return false;
123
+ }
124
+ else {
125
+ log_1.default.newLine();
126
+ log_1.default.log('Devices registered in the Provisioning Profile:');
127
+ for (const device of provisionedDevices) {
128
+ log_1.default.log(`- ${(0, DeviceUtils_1.formatDeviceLabel)(device)}`);
129
+ }
130
+ log_1.default.newLine();
131
+ return ((await this.promptForReuseActionAsync({ showShowDevicesOption: false })) ===
132
+ ReuseAction.Yes);
133
+ }
115
134
  }
116
135
  else {
117
136
  const missingDevices = (0, differenceBy_1.default)(registeredAppleDevices, provisionedDevices, 'identifier');
@@ -125,6 +144,31 @@ class SetupAdhocProvisioningProfile {
125
144
  }));
126
145
  }
127
146
  }
147
+ async promptForReuseActionAsync({ showShowDevicesOption = true, } = {}) {
148
+ const { selected } = await (0, prompts_1.promptAsync)({
149
+ type: 'select',
150
+ name: 'selected',
151
+ message: `${showShowDevicesOption
152
+ ? 'All your registered devices are present in the Provisioning Profile. '
153
+ : ''}Would you like to reuse the profile?`,
154
+ choices: [
155
+ { title: 'Yes', value: ReuseAction.Yes },
156
+ ...(showShowDevicesOption
157
+ ? [
158
+ {
159
+ title: 'Show devices and ask me again',
160
+ value: ReuseAction.ShowDevices,
161
+ },
162
+ ]
163
+ : []),
164
+ {
165
+ title: 'No, let me choose devices again',
166
+ value: ReuseAction.No,
167
+ },
168
+ ],
169
+ });
170
+ return selected;
171
+ }
128
172
  async registerDevicesAsync(ctx, appleTeam) {
129
173
  const action = new action_1.default(this.app.account, appleTeam);
130
174
  const method = await action.runAsync();
@@ -1,4 +1,4 @@
1
- import { DistributionCertificate, DistributionCertificateStoreInfo, ProvisioningProfile, ProvisioningProfileStoreInfo, PushKey, PushKeyStoreInfo } from './Credentials.types';
1
+ import { AscApiKey, AscApiKeyInfo, DistributionCertificate, DistributionCertificateStoreInfo, ProvisioningProfile, ProvisioningProfileStoreInfo, PushKey, PushKeyStoreInfo } from './Credentials.types';
2
2
  import { AuthCtx, Options as AuthenticateOptions } from './authenticate';
3
3
  import { AppLookupParams, IosCapabilitiesOptions } from './ensureAppExists';
4
4
  import { ProfileClass } from './provisioningProfile';
@@ -17,4 +17,10 @@ export default class AppStoreApi {
17
17
  createProvisioningProfileAsync(bundleIdentifier: string, distCert: DistributionCertificate, profileName: string, profileClass?: ProfileClass): Promise<ProvisioningProfile>;
18
18
  revokeProvisioningProfileAsync(bundleIdentifier: string, profileClass?: ProfileClass): Promise<void>;
19
19
  createOrReuseAdhocProvisioningProfileAsync(udids: string[], bundleIdentifier: string, distCertSerialNumber: string): Promise<ProvisioningProfile>;
20
+ listAscApiKeysAsync(): Promise<AscApiKeyInfo[]>;
21
+ getAscApiKeyAsync(keyId: string): Promise<AscApiKeyInfo>;
22
+ createAscApiKeyAsync({ nickname }: {
23
+ nickname: string;
24
+ }): Promise<AscApiKey>;
25
+ revokeAscApiKeyAsync(keyId: string): Promise<AscApiKeyInfo>;
20
26
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ascApiKey_1 = require("./ascApiKey");
3
4
  const authenticate_1 = require("./authenticate");
4
5
  const distributionCertificate_1 = require("./distributionCertificate");
5
6
  const ensureAppExists_1 = require("./ensureAppExists");
@@ -61,5 +62,21 @@ class AppStoreApi {
61
62
  const ctx = await this.ensureAuthenticatedAsync();
62
63
  return await (0, provisioningProfileAdhoc_1.createOrReuseAdhocProvisioningProfileAsync)(ctx, udids, bundleIdentifier, distCertSerialNumber);
63
64
  }
65
+ async listAscApiKeysAsync() {
66
+ const ctx = await this.ensureAuthenticatedAsync();
67
+ return await (0, ascApiKey_1.listAscApiKeysAsync)(ctx);
68
+ }
69
+ async getAscApiKeyAsync(keyId) {
70
+ const ctx = await this.ensureAuthenticatedAsync();
71
+ return await (0, ascApiKey_1.getAscApiKeyAsync)(ctx, keyId);
72
+ }
73
+ async createAscApiKeyAsync({ nickname }) {
74
+ const ctx = await this.ensureAuthenticatedAsync();
75
+ return await (0, ascApiKey_1.createAscApiKeyAsync)(ctx, { nickname });
76
+ }
77
+ async revokeAscApiKeyAsync(keyId) {
78
+ const ctx = await this.ensureAuthenticatedAsync();
79
+ return await (0, ascApiKey_1.revokeAscApiKeyAsync)(ctx, keyId);
80
+ }
64
81
  }
65
82
  exports.default = AppStoreApi;
@@ -4,8 +4,8 @@ exports.isPushKey = exports.formatPushKey = exports.isDistributionCertificate =
4
4
  const tslib_1 = require("tslib");
5
5
  const dateformat_1 = (0, tslib_1.__importDefault)(require("dateformat"));
6
6
  function formatDistributionCertificate({ name, id, status, expires, created, ownerName, }) {
7
- const expiresDate = _formatTimestamp(expires);
8
- const createdDate = _formatTimestamp(created);
7
+ const expiresDate = formatTimestamp(expires);
8
+ const createdDate = formatTimestamp(created);
9
9
  return `${name} (${status}) - ID: ${id} - expires: ${expiresDate} (created: ${createdDate}) - owner: ${ownerName}`;
10
10
  }
11
11
  exports.formatDistributionCertificate = formatDistributionCertificate;
@@ -31,6 +31,6 @@ function isPushKey(obj) {
31
31
  typeof obj.teamId === 'string');
32
32
  }
33
33
  exports.isPushKey = isPushKey;
34
- function _formatTimestamp(timestamp) {
34
+ function formatTimestamp(timestamp) {
35
35
  return (0, dateformat_1.default)(new Date(timestamp * 1000));
36
36
  }
@@ -1,3 +1,5 @@
1
+ /// <reference types="@expo/apple-utils/ts-declarations/expo__app-store" />
2
+ import { UserRole } from '@expo/apple-utils';
1
3
  export interface Device {
2
4
  id: string;
3
5
  teamId: string;
@@ -59,3 +61,14 @@ export interface PushKey {
59
61
  teamId: string;
60
62
  teamName?: string;
61
63
  }
64
+ export declare type AscApiKeyInfo = {
65
+ keyId: string;
66
+ issuerId?: string;
67
+ teamId: string;
68
+ name: string;
69
+ teamName?: string;
70
+ roles: UserRole[];
71
+ };
72
+ export declare type AscApiKey = AscApiKeyInfo & {
73
+ keyP8: string;
74
+ };
@@ -0,0 +1,9 @@
1
+ /// <reference types="@expo/apple-utils/ts-declarations/expo__app-store" />
2
+ import { ApiKey, ApiKeyProps } from '@expo/apple-utils';
3
+ import { AscApiKey, AscApiKeyInfo } from './Credentials.types';
4
+ import { AuthCtx } from './authenticate';
5
+ export declare function listAscApiKeysAsync(authCtx: AuthCtx): Promise<AscApiKeyInfo[]>;
6
+ export declare function getAscApiKeyAsync(authCtx: AuthCtx, keyId: string): Promise<AscApiKeyInfo>;
7
+ export declare function createAscApiKeyAsync(authCtx: AuthCtx, { nickname, allAppsVisible, roles, keyType, }: Partial<Pick<ApiKeyProps, 'nickname' | 'roles' | 'allAppsVisible' | 'keyType'>>): Promise<AscApiKey>;
8
+ export declare function revokeAscApiKeyAsync(authCtx: AuthCtx, keyId: string): Promise<AscApiKeyInfo>;
9
+ export declare function getAscApiKeyInfo(apiKey: ApiKey, authCtx: AuthCtx): AscApiKeyInfo;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAscApiKeyInfo = exports.revokeAscApiKeyAsync = exports.createAscApiKeyAsync = exports.getAscApiKeyAsync = exports.listAscApiKeysAsync = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const apple_utils_1 = require("@expo/apple-utils");
6
+ const log_1 = (0, tslib_1.__importDefault)(require("../../../log"));
7
+ const ora_1 = require("../../../ora");
8
+ const authenticate_1 = require("./authenticate");
9
+ async function listAscApiKeysAsync(authCtx) {
10
+ const spinner = (0, ora_1.ora)(`Fetching App Store Connect API Keys.`).start();
11
+ try {
12
+ const context = (0, authenticate_1.getRequestContext)(authCtx);
13
+ const keys = await apple_utils_1.ApiKey.getAsync(context);
14
+ spinner.succeed(`Fetched App Store Connect API Keys.`);
15
+ return keys.map(key => getAscApiKeyInfo(key, authCtx));
16
+ }
17
+ catch (error) {
18
+ spinner.fail(`Failed to fetch App Store Connect API Keys.`);
19
+ throw error;
20
+ }
21
+ }
22
+ exports.listAscApiKeysAsync = listAscApiKeysAsync;
23
+ async function getAscApiKeyAsync(authCtx, keyId) {
24
+ const spinner = (0, ora_1.ora)(`Fetching App Store Connect API Key.`).start();
25
+ try {
26
+ const context = (0, authenticate_1.getRequestContext)(authCtx);
27
+ const apiKey = await apple_utils_1.ApiKey.infoAsync(context, { id: keyId });
28
+ spinner.succeed(`Fetched App Store Connect API Key (ID: ${keyId}).`);
29
+ return getAscApiKeyInfo(apiKey, authCtx);
30
+ }
31
+ catch (error) {
32
+ log_1.default.error(error);
33
+ spinner.fail(`Failed to fetch App Store Connect API Key.`);
34
+ throw error;
35
+ }
36
+ }
37
+ exports.getAscApiKeyAsync = getAscApiKeyAsync;
38
+ async function createAscApiKeyAsync(authCtx, { nickname, allAppsVisible, roles, keyType, }) {
39
+ const spinner = (0, ora_1.ora)(`Creating App Store Connect API Key.`).start();
40
+ try {
41
+ const context = (0, authenticate_1.getRequestContext)(authCtx);
42
+ const key = await apple_utils_1.ApiKey.createAsync(context, {
43
+ nickname: nickname !== null && nickname !== void 0 ? nickname : `[expo] ${new Date().getTime()}`,
44
+ allAppsVisible: allAppsVisible !== null && allAppsVisible !== void 0 ? allAppsVisible : true,
45
+ roles: roles !== null && roles !== void 0 ? roles : [apple_utils_1.UserRole.ADMIN],
46
+ keyType: keyType !== null && keyType !== void 0 ? keyType : apple_utils_1.ApiKeyType.PUBLIC_API,
47
+ });
48
+ const keyP8 = await key.downloadAsync();
49
+ if (!keyP8) {
50
+ const { nickname, roles } = key.attributes;
51
+ const humanReadableKey = `App Store Connect Key '${nickname}' (${key.id}) with roles {${roles.join(',')}}`;
52
+ if (!key.attributes.canDownload) {
53
+ // this case would be unexpected because we just created the key
54
+ throw new Error(`${humanReadableKey} is not available for download from Apple.`);
55
+ }
56
+ else if (!key.attributes.isActive) {
57
+ throw new Error(`${humanReadableKey} is inactive and could not be downloaded.`);
58
+ }
59
+ throw new Error(`Failed to download .p8 file of ${humanReadableKey}.`);
60
+ }
61
+ return {
62
+ ...getAscApiKeyInfo(key, authCtx),
63
+ keyP8,
64
+ };
65
+ }
66
+ catch (err) {
67
+ spinner.fail('Failed to create App Store Connect API Key.');
68
+ throw err;
69
+ }
70
+ }
71
+ exports.createAscApiKeyAsync = createAscApiKeyAsync;
72
+ async function revokeAscApiKeyAsync(authCtx, keyId) {
73
+ const spinner = (0, ora_1.ora)(`Revoking App Store Connect API Key.`).start();
74
+ try {
75
+ const context = (0, authenticate_1.getRequestContext)(authCtx);
76
+ const apiKey = await apple_utils_1.ApiKey.infoAsync(context, { id: keyId });
77
+ const revokedKey = await apiKey.revokeAsync();
78
+ spinner.succeed(`Revoked App Store Connect API Key.`);
79
+ return getAscApiKeyInfo(revokedKey, authCtx);
80
+ }
81
+ catch (error) {
82
+ log_1.default.error(error);
83
+ spinner.fail(`Failed to revoke App Store Connect API Key.`);
84
+ throw error;
85
+ }
86
+ }
87
+ exports.revokeAscApiKeyAsync = revokeAscApiKeyAsync;
88
+ function getAscApiKeyInfo(apiKey, authCtx) {
89
+ var _a;
90
+ return {
91
+ name: apiKey.attributes.nickname,
92
+ keyId: apiKey.id,
93
+ issuerId: (_a = apiKey.attributes.provider) === null || _a === void 0 ? void 0 : _a.id,
94
+ teamId: authCtx.team.id,
95
+ teamName: authCtx.team.name,
96
+ roles: apiKey.attributes.roles,
97
+ };
98
+ }
99
+ exports.getAscApiKeyInfo = getAscApiKeyInfo;
@@ -1,3 +1,5 @@
1
+ /// <reference types="@expo/apple-utils/ts-declarations/expo__app-store" />
2
+ import { UserRole } from '@expo/apple-utils';
1
3
  import { AppleDevice } from '../../graphql/generated';
2
4
  import { CredentialSchema } from '../utils/promptForCredentials';
3
5
  import { DistributionCertificate, ProvisioningProfile, PushKey } from './appstore/Credentials.types';
@@ -36,5 +38,20 @@ export interface IosDistCredentials extends DistributionCertificate {
36
38
  type: 'dist-cert';
37
39
  }
38
40
  export declare const distributionCertificateSchema: CredentialSchema<DistributionCertificate>;
41
+ export declare type MinimalAscApiKey = {
42
+ keyP8: string;
43
+ keyId: string;
44
+ issuerId: string;
45
+ teamId?: string;
46
+ teamName?: string;
47
+ roles?: UserRole[];
48
+ name?: string;
49
+ };
50
+ export interface AscApiKeyPath {
51
+ keyP8Path: string;
52
+ keyId: string;
53
+ issuerId: string;
54
+ }
55
+ export declare const ascApiKeyMetadataSchema: CredentialSchema<Omit<MinimalAscApiKey, 'keyP8'>>;
39
56
  export declare const pushKeySchema: CredentialSchema<PushKey>;
40
57
  export declare const provisioningProfileSchema: CredentialSchema<ProvisioningProfile>;