eas-cli 25.1.1 → 25.3.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 (61) hide show
  1. package/README.md +282 -162
  2. package/build/analytics/AnalyticsManager.d.ts +7 -1
  3. package/build/analytics/AnalyticsManager.js +12 -1
  4. package/build/billing/resolveAccount.d.ts +12 -0
  5. package/build/billing/resolveAccount.js +1 -0
  6. package/build/build/build.d.ts +3 -1
  7. package/build/build/build.js +14 -12
  8. package/build/build/context.d.ts +4 -0
  9. package/build/build/createContext.d.ts +5 -1
  10. package/build/build/createContext.js +3 -1
  11. package/build/build/freeTierLimitCheckout.d.ts +39 -0
  12. package/build/build/freeTierLimitCheckout.js +106 -0
  13. package/build/build/freeTierLimitGuidance.d.ts +19 -0
  14. package/build/build/freeTierLimitGuidance.js +39 -0
  15. package/build/build/runBuildAndSubmit.d.ts +7 -1
  16. package/build/build/runBuildAndSubmit.js +6 -2
  17. package/build/build/utils/url.d.ts +1 -0
  18. package/build/build/utils/url.js +4 -0
  19. package/build/commandUtils/EasCommand.d.ts +9 -0
  20. package/build/commandUtils/EasCommand.js +12 -1
  21. package/build/commandUtils/context/ExperimentationContextField.d.ts +13 -0
  22. package/build/commandUtils/context/ExperimentationContextField.js +79 -0
  23. package/build/commandUtils/context/contextUtils/createGraphqlClient.d.ts +3 -0
  24. package/build/commandUtils/context/contextUtils/createGraphqlClient.js +29 -2
  25. package/build/commandUtils/errors.d.ts +5 -1
  26. package/build/commandUtils/errors.js +4 -3
  27. package/build/commands/analytics.js +1 -1
  28. package/build/commands/build/index.d.ts +1 -0
  29. package/build/commands/build/index.js +4 -1
  30. package/build/commands/simulator/control.d.ts +26 -0
  31. package/build/commands/simulator/control.js +250 -0
  32. package/build/commands/simulator/index.d.ts +1 -0
  33. package/build/commands/simulator/index.js +18 -4
  34. package/build/commands/update/republish.d.ts +1 -1
  35. package/build/env.d.ts +6 -0
  36. package/build/env.js +6 -0
  37. package/build/experimentation/AnalyticsExposureLogger.d.ts +7 -0
  38. package/build/experimentation/AnalyticsExposureLogger.js +21 -0
  39. package/build/experimentation/ExperimentNamespace.d.ts +24 -0
  40. package/build/experimentation/ExperimentNamespace.js +69 -0
  41. package/build/experimentation/ExperimentOverrides.d.ts +17 -0
  42. package/build/experimentation/ExperimentOverrides.js +68 -0
  43. package/build/experimentation/ExperimentationClient.d.ts +32 -0
  44. package/build/experimentation/ExperimentationClient.js +125 -0
  45. package/build/experimentation/LazyExperimentationClient.d.ts +12 -0
  46. package/build/experimentation/LazyExperimentationClient.js +22 -0
  47. package/build/graphql/generated.d.ts +12 -0
  48. package/build/graphql/queries/ExperimentationConfigQuery.d.ts +10 -0
  49. package/build/graphql/queries/ExperimentationConfigQuery.js +49 -0
  50. package/build/graphql/queries/UserQuery.d.ts +3 -1
  51. package/build/graphql/queries/UserQuery.js +2 -1
  52. package/build/help.d.ts +4 -0
  53. package/build/help.js +56 -0
  54. package/build/simulator/hostActions.d.ts +70 -0
  55. package/build/simulator/hostActions.js +411 -0
  56. package/build/simulator/utils.d.ts +5 -0
  57. package/build/simulator/utils.js +11 -0
  58. package/build/user/SessionManager.d.ts +8 -1
  59. package/build/user/SessionManager.js +7 -2
  60. package/oclif.manifest.json +917 -3
  61. package/package.json +8 -6
@@ -1,8 +1,11 @@
1
1
  import { Actor } from '../user/User';
2
- export type AnalyticsEvent = CommandEvent | BuildEvent | SubmissionEvent | MetadataEvent | BillingEvent | SimulatorEvent;
2
+ export type AnalyticsEvent = CommandEvent | BuildEvent | SubmissionEvent | MetadataEvent | BillingEvent | SimulatorEvent | ExperimentationEvent;
3
3
  export declare enum CommandEvent {
4
4
  ACTION = "action"
5
5
  }
6
+ export declare enum ExperimentationEvent {
7
+ EXPERIMENT_VIEWED = "Experiment Viewed"
8
+ }
6
9
  export declare enum BillingEvent {
7
10
  SUBSCRIBE_COMMAND = "billing cli subscribe command"
8
11
  }
@@ -38,6 +41,7 @@ export declare enum BuildEvent {
38
41
  BUILD_REQUEST_ATTEMPT = "build cli build request attempt",
39
42
  BUILD_REQUEST_SUCCESS = "build cli build request success",
40
43
  BUILD_REQUEST_FAIL = "build cli build request fail",
44
+ FREE_TIER_LIMIT_CHECKOUT_PROMPT = "build cli free tier limit checkout prompt",
41
45
  BUILD_STATUS_COMMAND = "build cli build status",
42
46
  CREDENTIALS_SYNC_COMMAND = "build cli credentials sync command",
43
47
  CREDENTIALS_SYNC_UPDATE_LOCAL_ATTEMPT = "build cli credentials sync update local attempt",
@@ -71,6 +75,8 @@ export interface Analytics {
71
75
  export interface AnalyticsWithOrchestration extends Analytics {
72
76
  setActor(actor: Actor): void;
73
77
  flushAsync(): Promise<void>;
78
+ /** The persisted RudderStack anonymous ID, or null when analytics is disabled. */
79
+ getDeviceId(): string | null;
74
80
  }
75
81
  /**
76
82
  * Sets the user's analytics enabled preference. Note that this will only take effect
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MetadataEvent = exports.SimulatorEvent = exports.BuildEvent = exports.SubmissionEvent = exports.BillingEvent = exports.CommandEvent = void 0;
3
+ exports.MetadataEvent = exports.SimulatorEvent = exports.BuildEvent = exports.SubmissionEvent = exports.BillingEvent = exports.ExperimentationEvent = exports.CommandEvent = void 0;
4
4
  exports.setAnalyticsEnabledAsync = setAnalyticsEnabledAsync;
5
5
  exports.getAnalyticsEnabledAsync = getAnalyticsEnabledAsync;
6
6
  exports.isAnalyticsOptedOutAsync = isAnalyticsOptedOutAsync;
@@ -24,6 +24,10 @@ var CommandEvent;
24
24
  (function (CommandEvent) {
25
25
  CommandEvent["ACTION"] = "action";
26
26
  })(CommandEvent || (exports.CommandEvent = CommandEvent = {}));
27
+ var ExperimentationEvent;
28
+ (function (ExperimentationEvent) {
29
+ ExperimentationEvent["EXPERIMENT_VIEWED"] = "Experiment Viewed";
30
+ })(ExperimentationEvent || (exports.ExperimentationEvent = ExperimentationEvent = {}));
27
31
  var BillingEvent;
28
32
  (function (BillingEvent) {
29
33
  BillingEvent["SUBSCRIBE_COMMAND"] = "billing cli subscribe command";
@@ -62,6 +66,7 @@ var BuildEvent;
62
66
  BuildEvent["BUILD_REQUEST_ATTEMPT"] = "build cli build request attempt";
63
67
  BuildEvent["BUILD_REQUEST_SUCCESS"] = "build cli build request success";
64
68
  BuildEvent["BUILD_REQUEST_FAIL"] = "build cli build request fail";
69
+ BuildEvent["FREE_TIER_LIMIT_CHECKOUT_PROMPT"] = "build cli free tier limit checkout prompt";
65
70
  BuildEvent["BUILD_STATUS_COMMAND"] = "build cli build status";
66
71
  BuildEvent["CREDENTIALS_SYNC_COMMAND"] = "build cli credentials sync command";
67
72
  BuildEvent["CREDENTIALS_SYNC_UPDATE_LOCAL_ATTEMPT"] = "build cli credentials sync update local attempt";
@@ -144,6 +149,9 @@ class NoOpAnalytics {
144
149
  logEvent() { }
145
150
  setActor() { }
146
151
  async flushAsync() { }
152
+ getDeviceId() {
153
+ return null;
154
+ }
147
155
  }
148
156
  const RudderstackAnalyticsConfig = process.env.EXPO_STAGING || process.env.EXPO_LOCAL
149
157
  ? {
@@ -185,6 +193,9 @@ class RudderstackAnalytics {
185
193
  });
186
194
  this.identifiedActor = actor;
187
195
  }
196
+ getDeviceId() {
197
+ return this.persistentDeviceId;
198
+ }
188
199
  logEvent(name, properties) {
189
200
  const userId = this.identifiedActor?.id;
190
201
  const deviceId = this.persistentDeviceId;
@@ -1,4 +1,5 @@
1
1
  import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
2
+ import { Permission } from '../graphql/generated';
2
3
  import { type AccountSubscriptionInfo } from '../graphql/queries/AccountQuery';
3
4
  import { Actor } from '../user/User';
4
5
  export type BillingAccount = {
@@ -7,6 +8,17 @@ export type BillingAccount = {
7
8
  subscription: AccountSubscriptionInfo | null;
8
9
  };
9
10
  type SubscriptionFilter = 'subscribed' | 'unsubscribed';
11
+ type ViewerPermissions = {
12
+ permissions: readonly Permission[];
13
+ effectivePermissions: readonly Permission[];
14
+ };
15
+ /**
16
+ * Whether the viewer can manage billing on the account with the credential used for this command.
17
+ * The scopes of a scoped credential cap `effectivePermissions`.
18
+ */
19
+ export declare function canManageBilling(account: {
20
+ viewerUserPermission2: ViewerPermissions;
21
+ }): boolean;
10
22
  export declare function resolveBillingAccountAsync({ graphqlClient, actor, accountName, nonInteractive, subscriptionFilter, }: {
11
23
  graphqlClient: ExpoGraphqlClient;
12
24
  actor: Actor;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.canManageBilling = canManageBilling;
3
4
  exports.resolveBillingAccountAsync = resolveBillingAccountAsync;
4
5
  const tslib_1 = require("tslib");
5
6
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
@@ -1,6 +1,8 @@
1
1
  import { ArchiveSource, BuildJob, Platform } from '@expo/eas-build-job';
2
2
  import { CredentialsSource } from '@expo/eas-json';
3
3
  import { BuildContext } from './context';
4
+ import { FreeTierLimitCheckoutExperiment } from './freeTierLimitCheckout';
5
+ import { FreeTierLimitAgentGuidanceExperiment } from './freeTierLimitGuidance';
4
6
  import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
5
7
  import { BuildFragment, BuildMetadataInput, BuildParamsInput } from '../graphql/generated';
6
8
  import { BuildResult } from '../graphql/mutations/BuildMutation';
@@ -21,7 +23,7 @@ interface Builder<TPlatform extends Platform, Credentials, TJob extends BuildJob
21
23
  }
22
24
  export type BuildRequestSender = () => Promise<BuildFragment | undefined>;
23
25
  export declare function prepareBuildRequestForPlatformAsync<TPlatform extends Platform, Credentials, TJob extends BuildJob>(builder: Builder<TPlatform, Credentials, TJob>): Promise<BuildRequestSender>;
24
- export declare function handleBuildRequestError(error: any, platform: Platform, accountName?: string): never;
26
+ export declare function handleBuildRequestErrorAsync(error: any, platform: Platform, accountName?: string, freeTierLimitAgentGuidanceExperiment?: FreeTierLimitAgentGuidanceExperiment, freeTierLimitCheckoutExperiment?: FreeTierLimitCheckoutExperiment): Promise<never>;
25
27
  export type MaybeBuildFragment = BuildFragment | null;
26
28
  export declare function waitForBuildEndAsync(graphqlClient: ExpoGraphqlClient, { buildIds, accountName }: {
27
29
  buildIds: string[];
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prepareBuildRequestForPlatformAsync = prepareBuildRequestForPlatformAsync;
4
- exports.handleBuildRequestError = handleBuildRequestError;
4
+ exports.handleBuildRequestErrorAsync = handleBuildRequestErrorAsync;
5
5
  exports.waitForBuildEndAsync = waitForBuildEndAsync;
6
6
  const tslib_1 = require("tslib");
7
7
  const eas_build_job_1 = require("@expo/eas-build-job");
@@ -11,15 +11,17 @@ const cli_progress_1 = tslib_1.__importDefault(require("cli-progress"));
11
11
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
12
  const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
13
13
  const errors_1 = require("./errors");
14
+ const freeTierLimitCheckout_1 = require("./freeTierLimitCheckout");
15
+ const freeTierLimitGuidance_1 = require("./freeTierLimitGuidance");
14
16
  const graphql_1 = require("./graphql");
15
17
  const local_1 = require("./local");
16
18
  const logs_1 = require("./logs");
17
19
  const metadata_1 = require("./metadata");
18
20
  const printBuildInfo_1 = require("./utils/printBuildInfo");
19
21
  const repository_1 = require("./utils/repository");
22
+ const url_1 = require("./utils/url");
20
23
  const AnalyticsManager_1 = require("../analytics/AnalyticsManager");
21
24
  const common_1 = require("../analytics/common");
22
- const api_1 = require("../api");
23
25
  const plans_1 = require("../billing/plans");
24
26
  const watcher_1 = require("../commandUtils/logs/watcher");
25
27
  const cli_1 = require("../fingerprint/cli");
@@ -121,7 +123,7 @@ async function prepareBuildRequestForPlatformAsync(builder) {
121
123
  return await sendBuildRequestAsync(builder, job, graphqlMetadata, buildParams);
122
124
  }
123
125
  catch (error) {
124
- handleBuildRequestError(error, job.platform, ctx.accountName);
126
+ return await handleBuildRequestErrorAsync(error, job.platform, ctx.accountName, (0, freeTierLimitGuidance_1.getFreeTierLimitAgentGuidanceExperiment)(ctx), (0, freeTierLimitCheckout_1.getFreeTierLimitCheckoutExperiment)(ctx));
125
127
  }
126
128
  }
127
129
  else {
@@ -140,7 +142,7 @@ const SERVER_SIDE_DEFINED_ERRORS = {
140
142
  EAS_BUILD_LEGACY_RESOURCE_CLASS_NOT_AVAILABLE: errors_1.EasBuildLegacyResourceClassNotAvailableError,
141
143
  VALIDATION_ERROR: errors_1.RequestValidationError,
142
144
  };
143
- function handleBuildRequestError(error, platform, accountName) {
145
+ async function handleBuildRequestErrorAsync(error, platform, accountName, freeTierLimitAgentGuidanceExperiment, freeTierLimitCheckoutExperiment) {
144
146
  logBuildRequestErrorDebugInfo(error);
145
147
  const graphQLErrors = Array.isArray(error?.graphQLErrors)
146
148
  ? error.graphQLErrors
@@ -151,9 +153,12 @@ function handleBuildRequestError(error, platform, accountName) {
151
153
  const message = graphQLErrors[0]?.message;
152
154
  const isFreeTierLimitError = graphQLErrorCode === 'EAS_BUILD_FREE_TIER_LIMIT_EXCEEDED' ||
153
155
  graphQLErrorCode === 'EAS_BUILD_FREE_TIER_IOS_LIMIT_EXCEEDED';
154
- throw new ErrorClass(isFreeTierLimitError
155
- ? `${message}\nRun ${(0, plans_1.formatStarterSubscribeCommand)(accountName)} to upgrade to the Starter plan.`
156
- : message);
156
+ if (!isFreeTierLimitError) {
157
+ throw new ErrorClass(message);
158
+ }
159
+ const limitMessage = await (0, freeTierLimitGuidance_1.maybeAppendFreeTierLimitAgentGuidanceAsync)(`${message}\nRun ${(0, plans_1.formatStarterSubscribeCommand)(accountName)} to upgrade to the Starter plan.`, platform, freeTierLimitAgentGuidanceExperiment);
160
+ const messageAlreadyPrinted = await (0, freeTierLimitCheckout_1.maybeOfferFreeTierLimitCheckoutAsync)(limitMessage, freeTierLimitCheckoutExperiment);
161
+ throw new ErrorClass(limitMessage, { messageAlreadyPrinted });
157
162
  }
158
163
  else if (graphQLErrorCode === 'EAS_BUILD_DOWN_FOR_MAINTENANCE') {
159
164
  throw new errors_1.EasBuildDownForMaintenanceError(`EAS Build is down for maintenance. Try again later. Check ${(0, log_1.link)('https://status.expo.dev/')} for updates.`);
@@ -437,7 +442,7 @@ async function handleSingleBuildProgressAsync({ build, accountName, }, { spinner
437
442
  }
438
443
  else {
439
444
  (0, ora_1.updateSpinnerText)(spinner, {
440
- text: `Build concurrency limit reached for your account. Build will enter queue once a concurrency becomes available. Add additional concurrencies at ${(0, log_1.link)(formatAccountBillingUrl(accountName))}.`,
445
+ text: `Build concurrency limit reached for your account. Build will enter queue once a concurrency becomes available. Add additional concurrencies at ${(0, log_1.link)((0, url_1.getAccountBillingUrl)(accountName))}.`,
441
446
  });
442
447
  }
443
448
  break;
@@ -455,7 +460,7 @@ async function handleSingleBuildProgressAsync({ build, accountName, }, { spinner
455
460
  if (build.priority !== generated_1.BuildPriority.High) {
456
461
  log_1.default.newLine();
457
462
  log_1.default.log('Start builds sooner in the priority queue.');
458
- log_1.default.log(`Sign up for a paid plan at ${(0, log_1.link)(formatAccountBillingUrl(accountName))}`);
463
+ log_1.default.log(`Sign up for a paid plan at ${(0, log_1.link)((0, url_1.getAccountBillingUrl)(accountName))}`);
459
464
  }
460
465
  log_1.default.newLine();
461
466
  log_1.default.log(`Waiting in ${priorityToQueueDisplayName[build.priority]}`);
@@ -597,9 +602,6 @@ function formatEstimatedWaitTime(estimatedWaitTimeLeftSeconds) {
597
602
  return `starting in about ${n}0 minutes...`;
598
603
  }
599
604
  }
600
- function formatAccountBillingUrl(accountName) {
601
- return new URL(`/accounts/${accountName}/settings/billing`, (0, api_1.getExpoWebsiteBaseUrl)()).toString();
602
- }
603
605
  async function computeAndMaybeUploadRuntimeAndFingerprintMetadataAsync(ctx) {
604
606
  const runtimeAndFingerprintMetadata = await computeAndMaybeUploadFingerprintFromExpoUpdatesAsync(ctx);
605
607
  if (!runtimeAndFingerprintMetadata?.fingerprintHash) {
@@ -7,9 +7,11 @@ import { LocalBuildOptions } from './local';
7
7
  import { Analytics, AnalyticsEventProperties } from '../analytics/AnalyticsManager';
8
8
  import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
9
9
  import { CredentialsContext } from '../credentials/context';
10
+ import { LazyExperimentationClient } from '../experimentation/LazyExperimentationClient';
10
11
  import { Target } from '../credentials/ios/types';
11
12
  import { BuildResourceClass } from '../graphql/generated';
12
13
  import { GradleBuildContext } from '../project/android/gradle';
14
+ import { LoggedInAuthenticationInfo } from '../user/SessionManager';
13
15
  import { CustomBuildConfigMetadata } from '../project/customBuildConfig';
14
16
  import { XcodeBuildContext } from '../project/ios/scheme';
15
17
  import { Actor } from '../user/User';
@@ -61,4 +63,6 @@ export interface BuildContext<T extends Platform> {
61
63
  isVerboseLoggingEnabled: boolean;
62
64
  whatToTest?: string;
63
65
  env: Env;
66
+ experimentation?: LazyExperimentationClient;
67
+ authenticationInfo?: LoggedInAuthenticationInfo;
64
68
  }
@@ -6,10 +6,12 @@ import { LocalBuildOptions } from './local';
6
6
  import { Analytics } from '../analytics/AnalyticsManager';
7
7
  import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectConfigContextField';
8
8
  import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
9
+ import { LazyExperimentationClient } from '../experimentation/LazyExperimentationClient';
9
10
  import { CustomBuildConfigMetadata } from '../project/customBuildConfig';
11
+ import { LoggedInAuthenticationInfo } from '../user/SessionManager';
10
12
  import { Actor } from '../user/User';
11
13
  import { Client } from '../vcs/vcs';
12
- export declare function createBuildContextAsync<T extends Platform>({ buildProfileName, buildProfile, easJsonCliConfig, clearCache, localBuildOptions, nonInteractive, noWait, platform, projectDir, resourceClassFlag, message, actor, graphqlClient, analytics, vcsClient, getDynamicPrivateProjectConfigAsync, customBuildConfigMetadata, buildLoggerLevel, freezeCredentials, refreshAdHocProvisioningProfile: refreshAdHocProvisioningProfileFlag, isVerboseLoggingEnabled, whatToTest, env, }: {
14
+ export declare function createBuildContextAsync<T extends Platform>({ buildProfileName, buildProfile, easJsonCliConfig, clearCache, localBuildOptions, nonInteractive, noWait, platform, projectDir, resourceClassFlag, message, actor, graphqlClient, analytics, vcsClient, getDynamicPrivateProjectConfigAsync, customBuildConfigMetadata, buildLoggerLevel, freezeCredentials, refreshAdHocProvisioningProfile: refreshAdHocProvisioningProfileFlag, isVerboseLoggingEnabled, whatToTest, env, experimentation, authenticationInfo, }: {
13
15
  buildProfileName: string;
14
16
  buildProfile: BuildProfile<T>;
15
17
  easJsonCliConfig: EasJson['cli'];
@@ -33,4 +35,6 @@ export declare function createBuildContextAsync<T extends Platform>({ buildProfi
33
35
  isVerboseLoggingEnabled: boolean;
34
36
  whatToTest?: string;
35
37
  env: Env;
38
+ experimentation?: LazyExperimentationClient;
39
+ authenticationInfo?: LoggedInAuthenticationInfo;
36
40
  }): Promise<BuildContext<T>>;
@@ -16,7 +16,7 @@ const AnalyticsManager_1 = require("../analytics/AnalyticsManager");
16
16
  const context_1 = require("../credentials/context");
17
17
  const projectUtils_1 = require("../project/projectUtils");
18
18
  const workflow_1 = require("../project/workflow");
19
- async function createBuildContextAsync({ buildProfileName, buildProfile, easJsonCliConfig, clearCache = false, localBuildOptions, nonInteractive, noWait, platform, projectDir, resourceClassFlag, message, actor, graphqlClient, analytics, vcsClient, getDynamicPrivateProjectConfigAsync, customBuildConfigMetadata, buildLoggerLevel, freezeCredentials, refreshAdHocProvisioningProfile: refreshAdHocProvisioningProfileFlag, isVerboseLoggingEnabled, whatToTest, env, }) {
19
+ async function createBuildContextAsync({ buildProfileName, buildProfile, easJsonCliConfig, clearCache = false, localBuildOptions, nonInteractive, noWait, platform, projectDir, resourceClassFlag, message, actor, graphqlClient, analytics, vcsClient, getDynamicPrivateProjectConfigAsync, customBuildConfigMetadata, buildLoggerLevel, freezeCredentials, refreshAdHocProvisioningProfile: refreshAdHocProvisioningProfileFlag, isVerboseLoggingEnabled, whatToTest, env, experimentation, authenticationInfo, }) {
20
20
  const { exp, projectId } = await getDynamicPrivateProjectConfigAsync({
21
21
  env,
22
22
  });
@@ -97,6 +97,8 @@ async function createBuildContextAsync({ buildProfileName, buildProfile, easJson
97
97
  isVerboseLoggingEnabled,
98
98
  env,
99
99
  whatToTest,
100
+ experimentation,
101
+ authenticationInfo,
100
102
  };
101
103
  if (platform === eas_build_job_1.Platform.ANDROID) {
102
104
  const common = commonContext;
@@ -0,0 +1,39 @@
1
+ import { Analytics, AnalyticsEventProperties } from '../analytics/AnalyticsManager';
2
+ import { LazyExperimentationClient } from '../experimentation/LazyExperimentationClient';
3
+ import { LoggedInAuthenticationInfo } from '../user/SessionManager';
4
+ import { Actor } from '../user/User';
5
+ export declare const FREE_TIER_LIMIT_CHECKOUT_EXPERIMENT_NAMESPACE = "cli-build-free-tier-limit-checkout";
6
+ export type FreeTierLimitCheckoutVariant = 'control' | 'treatment';
7
+ export type FreeTierLimitCheckoutPromptAnswer = 'yes' | 'no' | 'cancel';
8
+ export type FreeTierLimitCheckoutExperiment = {
9
+ experimentation: LazyExperimentationClient;
10
+ authenticationInfo: LoggedInAuthenticationInfo;
11
+ analytics: Analytics;
12
+ analyticsEventProperties: AnalyticsEventProperties;
13
+ actor: Actor;
14
+ accountId: string;
15
+ accountName: string;
16
+ nonInteractive: boolean;
17
+ runFromCI: boolean;
18
+ };
19
+ export declare function getFreeTierLimitCheckoutExperiment(ctx: {
20
+ experimentation?: LazyExperimentationClient;
21
+ authenticationInfo?: LoggedInAuthenticationInfo;
22
+ analytics: Analytics;
23
+ analyticsEventProperties: AnalyticsEventProperties;
24
+ user: Actor;
25
+ accountId: string;
26
+ accountName: string;
27
+ nonInteractive: boolean;
28
+ runFromCI: boolean;
29
+ }): FreeTierLimitCheckoutExperiment | undefined;
30
+ /**
31
+ * Only a person at an interactive terminal who can manage billing for the account is eligible.
32
+ * Non-interactive runs, CI, coding agents, and credentials that cannot manage billing are not.
33
+ */
34
+ export declare function isEligibleForFreeTierLimitCheckout({ actor, accountId, nonInteractive, runFromCI, }: FreeTierLimitCheckoutExperiment): boolean;
35
+ export declare function resolveFreeTierLimitCheckoutVariantAsync(experiment: FreeTierLimitCheckoutExperiment): Promise<FreeTierLimitCheckoutVariant>;
36
+ /**
37
+ * In the treatment arm, prints the limit error and offers to open the Starter plan checkout.
38
+ */
39
+ export declare function maybeOfferFreeTierLimitCheckoutAsync(message: string, experiment: FreeTierLimitCheckoutExperiment | undefined): Promise<boolean>;
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FREE_TIER_LIMIT_CHECKOUT_EXPERIMENT_NAMESPACE = void 0;
4
+ exports.getFreeTierLimitCheckoutExperiment = getFreeTierLimitCheckoutExperiment;
5
+ exports.isEligibleForFreeTierLimitCheckout = isEligibleForFreeTierLimitCheckout;
6
+ exports.resolveFreeTierLimitCheckoutVariantAsync = resolveFreeTierLimitCheckoutVariantAsync;
7
+ exports.maybeOfferFreeTierLimitCheckoutAsync = maybeOfferFreeTierLimitCheckoutAsync;
8
+ const tslib_1 = require("tslib");
9
+ const url_1 = require("./utils/url");
10
+ const agent_1 = require("../analytics/agent");
11
+ const AnalyticsManager_1 = require("../analytics/AnalyticsManager");
12
+ const billingClient_1 = require("../billing/billingClient");
13
+ const openUrl_1 = require("../billing/openUrl");
14
+ const plans_1 = require("../billing/plans");
15
+ const resolveAccount_1 = require("../billing/resolveAccount");
16
+ const log_1 = tslib_1.__importStar(require("../log"));
17
+ const ora_1 = require("../ora");
18
+ const prompts_1 = require("../prompts");
19
+ exports.FREE_TIER_LIMIT_CHECKOUT_EXPERIMENT_NAMESPACE = 'cli-build-free-tier-limit-checkout';
20
+ const STARTER_PLAN = plans_1.SUBSCRIBABLE_PLANS.starter;
21
+ function getFreeTierLimitCheckoutExperiment(ctx) {
22
+ if (!ctx.experimentation || !ctx.authenticationInfo) {
23
+ return undefined;
24
+ }
25
+ return {
26
+ experimentation: ctx.experimentation,
27
+ authenticationInfo: ctx.authenticationInfo,
28
+ analytics: ctx.analytics,
29
+ analyticsEventProperties: ctx.analyticsEventProperties,
30
+ actor: ctx.user,
31
+ accountId: ctx.accountId,
32
+ accountName: ctx.accountName,
33
+ nonInteractive: ctx.nonInteractive,
34
+ runFromCI: ctx.runFromCI,
35
+ };
36
+ }
37
+ /**
38
+ * Only a person at an interactive terminal who can manage billing for the account is eligible.
39
+ * Non-interactive runs, CI, coding agents, and credentials that cannot manage billing are not.
40
+ */
41
+ function isEligibleForFreeTierLimitCheckout({ actor, accountId, nonInteractive, runFromCI, }) {
42
+ if (nonInteractive || runFromCI || (0, agent_1.getAgentTelemetryContext)()) {
43
+ return false;
44
+ }
45
+ const account = actor.accounts.find(candidate => candidate.id === accountId);
46
+ return account !== undefined && (0, resolveAccount_1.canManageBilling)(account);
47
+ }
48
+ async function resolveFreeTierLimitCheckoutVariantAsync(experiment) {
49
+ if (!isEligibleForFreeTierLimitCheckout(experiment)) {
50
+ return 'control';
51
+ }
52
+ const client = await experiment.experimentation.getClientAsync();
53
+ return client
54
+ .getAccountNamespace(exports.FREE_TIER_LIMIT_CHECKOUT_EXPERIMENT_NAMESPACE, {
55
+ accountId: experiment.accountId,
56
+ })
57
+ .getParam('variant', 'control');
58
+ }
59
+ async function createCheckoutUrlAsync({ authenticationInfo, accountId, }) {
60
+ const spinner = (0, ora_1.ora)(`Creating a checkout session for the ${STARTER_PLAN.label} plan`).start();
61
+ try {
62
+ const session = await new billingClient_1.BillingClient(authenticationInfo).createCheckoutSessionAsync(accountId, STARTER_PLAN.planType);
63
+ if (!session.url) {
64
+ throw new Error('The checkout session did not include a URL.');
65
+ }
66
+ spinner.stop();
67
+ return session.url;
68
+ }
69
+ catch (error) {
70
+ spinner.fail('Failed to create a checkout session');
71
+ log_1.default.debug(error);
72
+ return null;
73
+ }
74
+ }
75
+ /**
76
+ * In the treatment arm, prints the limit error and offers to open the Starter plan checkout.
77
+ */
78
+ async function maybeOfferFreeTierLimitCheckoutAsync(message, experiment) {
79
+ if (!experiment || (await resolveFreeTierLimitCheckoutVariantAsync(experiment)) !== 'treatment') {
80
+ return false;
81
+ }
82
+ log_1.default.error(message);
83
+ // Ctrl+C resolves to no answer instead of exiting, so the build error below still reports.
84
+ const confirmed = await (0, prompts_1.confirmAsync)({
85
+ message: `Open the ${STARTER_PLAN.label} plan checkout in your browser now?`,
86
+ initial: false,
87
+ }, { onCancel: () => false });
88
+ const answer = confirmed === true ? 'yes' : confirmed === false ? 'no' : 'cancel';
89
+ let checkoutCreated = false;
90
+ if (answer === 'yes') {
91
+ const checkoutUrl = await createCheckoutUrlAsync(experiment);
92
+ if (checkoutUrl) {
93
+ checkoutCreated = true;
94
+ await (0, openUrl_1.openOrPrintUrlAsync)(checkoutUrl, { label: 'Checkout page', open: true });
95
+ }
96
+ else {
97
+ log_1.default.log(`Upgrade your plan at ${(0, log_1.link)((0, url_1.getAccountBillingUrl)(experiment.accountName))}`);
98
+ }
99
+ }
100
+ experiment.analytics.logEvent(AnalyticsManager_1.BuildEvent.FREE_TIER_LIMIT_CHECKOUT_PROMPT, {
101
+ ...experiment.analyticsEventProperties,
102
+ answer,
103
+ checkout_created: checkoutCreated,
104
+ });
105
+ return true;
106
+ }
@@ -0,0 +1,19 @@
1
+ import { Platform } from '@expo/eas-build-job';
2
+ import { LazyExperimentationClient } from '../experimentation/LazyExperimentationClient';
3
+ export declare const FREE_TIER_LIMIT_AGENT_GUIDANCE_EXPERIMENT_NAMESPACE = "cli-build-free-tier-limit-agent-guidance";
4
+ export type FreeTierLimitAgentGuidanceVariant = 'control' | 'treatment';
5
+ export type FreeTierLimitAgentGuidanceExperiment = {
6
+ experimentation: LazyExperimentationClient;
7
+ accountId: string;
8
+ };
9
+ export declare function getFreeTierLimitAgentGuidanceExperiment(ctx: {
10
+ experimentation?: LazyExperimentationClient;
11
+ accountId: string;
12
+ }): FreeTierLimitAgentGuidanceExperiment | undefined;
13
+ /**
14
+ * Resolves the account's variant. Only runs driven by a coding agent are eligible. Other runs get
15
+ * control before the client loads, so they make no config request and log no exposure.
16
+ */
17
+ export declare function resolveFreeTierLimitAgentGuidanceVariantAsync({ experimentation, accountId, }: FreeTierLimitAgentGuidanceExperiment): Promise<FreeTierLimitAgentGuidanceVariant>;
18
+ export declare function formatFreeTierLimitAgentGuidance(platform: Platform): string;
19
+ export declare function maybeAppendFreeTierLimitAgentGuidanceAsync(message: string, platform: Platform, experiment: FreeTierLimitAgentGuidanceExperiment | undefined): Promise<string>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FREE_TIER_LIMIT_AGENT_GUIDANCE_EXPERIMENT_NAMESPACE = void 0;
4
+ exports.getFreeTierLimitAgentGuidanceExperiment = getFreeTierLimitAgentGuidanceExperiment;
5
+ exports.resolveFreeTierLimitAgentGuidanceVariantAsync = resolveFreeTierLimitAgentGuidanceVariantAsync;
6
+ exports.formatFreeTierLimitAgentGuidance = formatFreeTierLimitAgentGuidance;
7
+ exports.maybeAppendFreeTierLimitAgentGuidanceAsync = maybeAppendFreeTierLimitAgentGuidanceAsync;
8
+ const agent_1 = require("../analytics/agent");
9
+ const platform_1 = require("../platform");
10
+ exports.FREE_TIER_LIMIT_AGENT_GUIDANCE_EXPERIMENT_NAMESPACE = 'cli-build-free-tier-limit-agent-guidance';
11
+ function getFreeTierLimitAgentGuidanceExperiment(ctx) {
12
+ return ctx.experimentation
13
+ ? { experimentation: ctx.experimentation, accountId: ctx.accountId }
14
+ : undefined;
15
+ }
16
+ /**
17
+ * Resolves the account's variant. Only runs driven by a coding agent are eligible. Other runs get
18
+ * control before the client loads, so they make no config request and log no exposure.
19
+ */
20
+ async function resolveFreeTierLimitAgentGuidanceVariantAsync({ experimentation, accountId, }) {
21
+ if (!(0, agent_1.getAgentTelemetryContext)()) {
22
+ return 'control';
23
+ }
24
+ const client = await experimentation.getClientAsync();
25
+ return client
26
+ .getAccountNamespace(exports.FREE_TIER_LIMIT_AGENT_GUIDANCE_EXPERIMENT_NAMESPACE, { accountId })
27
+ .getParam('variant', 'control');
28
+ }
29
+ function formatFreeTierLimitAgentGuidance(platform) {
30
+ const platformName = platform_1.requestedPlatformDisplayNames[platform];
31
+ return `Fix: Human required: ${platformName} builds for this account are blocked until the Free plan resets. Upgrading costs money, so an account owner or admin decides.`;
32
+ }
33
+ async function maybeAppendFreeTierLimitAgentGuidanceAsync(message, platform, experiment) {
34
+ if (!experiment ||
35
+ (await resolveFreeTierLimitAgentGuidanceVariantAsync(experiment)) !== 'treatment') {
36
+ return message;
37
+ }
38
+ return `${message}\n${formatFreeTierLimitAgentGuidance(platform)}`;
39
+ }
@@ -5,6 +5,8 @@ import { LocalBuildOptions } from './local';
5
5
  import { Analytics } from '../analytics/AnalyticsManager';
6
6
  import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectConfigContextField';
7
7
  import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
8
+ import { LazyExperimentationClient } from '../experimentation/LazyExperimentationClient';
9
+ import { LoggedInAuthenticationInfo } from '../user/SessionManager';
8
10
  import { BuildFragment } from '../graphql/generated';
9
11
  import { RequestedPlatform } from '../platform';
10
12
  import { SimulatorRunTarget } from '../run/ios/run';
@@ -30,7 +32,7 @@ export interface BuildFlags {
30
32
  whatToTest?: string;
31
33
  simulator?: SimulatorRunTarget;
32
34
  }
33
- export declare function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, projectDir, flags, actor, getDynamicPrivateProjectConfigAsync, downloadSimBuildAutoConfirm, envOverride, }: {
35
+ export declare function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, projectDir, flags, actor, getDynamicPrivateProjectConfigAsync, downloadSimBuildAutoConfirm, envOverride, experimentation, authenticationInfo, }: {
34
36
  graphqlClient: ExpoGraphqlClient;
35
37
  analytics: Analytics;
36
38
  vcsClient: Client;
@@ -40,6 +42,10 @@ export declare function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsCl
40
42
  getDynamicPrivateProjectConfigAsync: DynamicConfigContextFn;
41
43
  downloadSimBuildAutoConfirm?: boolean;
42
44
  envOverride?: Env;
45
+ /** Enables the Free plan limit experiments on the build request error path. */
46
+ experimentation?: LazyExperimentationClient;
47
+ /** Lets the Free plan limit checkout experiment create a checkout session. */
48
+ authenticationInfo?: LoggedInAuthenticationInfo;
43
49
  }): Promise<{
44
50
  buildIds: string[];
45
51
  buildProfiles?: ProfileData<'build'>[];
@@ -49,7 +49,7 @@ let metroConfigValidated = false;
49
49
  let sdkVersionChecked = false;
50
50
  let lockfileChecked = false;
51
51
  let hasWarnedAboutUsageOverages = false;
52
- async function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, projectDir, flags, actor, getDynamicPrivateProjectConfigAsync, downloadSimBuildAutoConfirm, envOverride, }) {
52
+ async function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, projectDir, flags, actor, getDynamicPrivateProjectConfigAsync, downloadSimBuildAutoConfirm, envOverride, experimentation, authenticationInfo, }) {
53
53
  await vcsClient.ensureRepoExistsAsync();
54
54
  await (0, repository_1.ensureRepoIsCleanAsync)(vcsClient, flags.nonInteractive);
55
55
  await (0, configure_1.ensureProjectConfiguredAsync)({
@@ -129,6 +129,8 @@ async function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, pro
129
129
  customBuildConfigMetadata: customBuildConfigMetadataByPlatform[platform],
130
130
  env,
131
131
  easJsonAccessor,
132
+ experimentation,
133
+ authenticationInfo,
132
134
  });
133
135
  if (maybeBuild) {
134
136
  startedBuilds.push({ build: maybeBuild, buildProfile });
@@ -222,7 +224,7 @@ async function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, pro
222
224
  buildProfiles,
223
225
  };
224
226
  }
225
- async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildProfile, easJsonCliConfig, actor, graphqlClient, analytics, vcsClient, getDynamicPrivateProjectConfigAsync, customBuildConfigMetadata, env, easJsonAccessor, }) {
227
+ async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildProfile, easJsonCliConfig, actor, graphqlClient, analytics, vcsClient, getDynamicPrivateProjectConfigAsync, customBuildConfigMetadata, env, easJsonAccessor, experimentation, authenticationInfo, }) {
226
228
  const buildCtx = await (0, createContext_1.createBuildContextAsync)({
227
229
  buildProfileName: buildProfile.profileName,
228
230
  resourceClassFlag: flags.resourceClass,
@@ -247,6 +249,8 @@ async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildP
247
249
  isVerboseLoggingEnabled: flags.isVerboseLoggingEnabled ?? false,
248
250
  whatToTest: flags.whatToTest,
249
251
  env,
252
+ experimentation,
253
+ authenticationInfo,
250
254
  });
251
255
  if (!lockfileChecked && !flags.localBuildOptions.localBuildMode) {
252
256
  if (!process.env.EAS_BUILD_SKIP_LOCKFILE_CHECK) {
@@ -1,6 +1,7 @@
1
1
  import { BuildFragment } from '../../graphql/generated';
2
2
  export declare function getProjectDashboardUrl(accountName: string, projectName: string): string;
3
3
  export declare function getProjectPageUrl(accountName: string, projectName: string, page?: string | null): string;
4
+ export declare function getAccountBillingUrl(accountName: string): string;
4
5
  export declare function getBuildLogsUrl(build: BuildFragment, hash?: string): string;
5
6
  export declare function getArtifactUrl(artifactId: string): string;
6
7
  export declare function getInternalDistributionInstallUrl(build: BuildFragment): string;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getProjectDashboardUrl = getProjectDashboardUrl;
4
4
  exports.getProjectPageUrl = getProjectPageUrl;
5
+ exports.getAccountBillingUrl = getAccountBillingUrl;
5
6
  exports.getBuildLogsUrl = getBuildLogsUrl;
6
7
  exports.getArtifactUrl = getArtifactUrl;
7
8
  exports.getInternalDistributionInstallUrl = getInternalDistributionInstallUrl;
@@ -24,6 +25,9 @@ function getProjectPageUrl(accountName, projectName, page) {
24
25
  const projectPath = `/accounts/${encodeURIComponent(accountName)}/projects/${encodeURIComponent(projectName)}`;
25
26
  return new URL(page ? `${projectPath}/${page}` : projectPath, (0, api_1.getExpoWebsiteBaseUrl)()).toString();
26
27
  }
28
+ function getAccountBillingUrl(accountName) {
29
+ return new URL(`/accounts/${accountName}/settings/billing`, (0, api_1.getExpoWebsiteBaseUrl)()).toString();
30
+ }
27
31
  function getBuildLogsUrl(build, hash) {
28
32
  const { app } = build;
29
33
  const url = `/accounts/${app.ownerAccount.name}/projects/${app.slug}/builds/${build.id}${hash ? `#${hash}` : ''}`;
@@ -2,6 +2,7 @@ import { Command } from '@oclif/core';
2
2
  import AnalyticsContextField from './context/AnalyticsContextField';
3
3
  import ContextField from './context/ContextField';
4
4
  import DynamicLoggedInContextField from './context/DynamicLoggedInContextField';
5
+ import ExperimentationContextField from './context/ExperimentationContextField';
5
6
  import { DynamicPrivateProjectConfigContextField, DynamicPublicProjectConfigContextField } from './context/DynamicProjectConfigContextField';
6
7
  import LoggedInContextField from './context/LoggedInContextField';
7
8
  import MaybeLoggedInContextField from './context/MaybeLoggedInContextField';
@@ -113,6 +114,14 @@ export default abstract class EasCommand extends Command {
113
114
  ProjectId: {
114
115
  projectId: ProjectIdContextField;
115
116
  };
117
+ /**
118
+ * Experimentation client for user, account, and device experiments.
119
+ * Declare a login field first so user experiments see the actor.
120
+ * Account experiments take the account ID from the command.
121
+ */
122
+ Experimentation: {
123
+ experimentation: ExperimentationContextField;
124
+ };
116
125
  };
117
126
  /**
118
127
  * Context allows for subclasses (commands) to declare their prerequisites in a type-safe manner.
@@ -7,6 +7,7 @@ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
7
  const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
8
8
  const AnalyticsContextField_1 = tslib_1.__importDefault(require("./context/AnalyticsContextField"));
9
9
  const DynamicLoggedInContextField_1 = tslib_1.__importDefault(require("./context/DynamicLoggedInContextField"));
10
+ const ExperimentationContextField_1 = tslib_1.__importDefault(require("./context/ExperimentationContextField"));
10
11
  const DynamicProjectConfigContextField_1 = require("./context/DynamicProjectConfigContextField");
11
12
  const LoggedInContextField_1 = tslib_1.__importDefault(require("./context/LoggedInContextField"));
12
13
  const MaybeLoggedInContextField_1 = tslib_1.__importDefault(require("./context/MaybeLoggedInContextField"));
@@ -104,6 +105,14 @@ class EasCommand extends core_1.Command {
104
105
  ProjectId: {
105
106
  projectId: new ProjectIdContextField_1.ProjectIdContextField(),
106
107
  },
108
+ /**
109
+ * Experimentation client for user, account, and device experiments.
110
+ * Declare a login field first so user experiments see the actor.
111
+ * Account experiments take the account ID from the command.
112
+ */
113
+ Experimentation: {
114
+ experimentation: new ExperimentationContextField_1.default(),
115
+ },
107
116
  };
108
117
  /**
109
118
  * Context allows for subclasses (commands) to declare their prerequisites in a type-safe manner.
@@ -186,7 +195,9 @@ class EasCommand extends core_1.Command {
186
195
  const commandId = this.id ?? 'unknown';
187
196
  let baseMessage = `${commandId} command failed.`;
188
197
  if (err instanceof errors_1.EasCommandError) {
189
- log_1.default.error(err.message);
198
+ if (!err.messageAlreadyPrinted) {
199
+ log_1.default.error(err.message);
200
+ }
190
201
  }
191
202
  else if (err instanceof core_2.CombinedError && err?.graphQLErrors) {
192
203
  const cleanGQLErrorsMessage = err?.graphQLErrors