eas-cli 25.2.0 → 26.0.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 (60) hide show
  1. package/README.md +234 -216
  2. package/build/analytics/AnalyticsManager.d.ts +1 -0
  3. package/build/analytics/AnalyticsManager.js +1 -0
  4. package/build/billing/resolveAccount.d.ts +12 -0
  5. package/build/billing/resolveAccount.js +1 -0
  6. package/build/build/build.d.ts +2 -1
  7. package/build/build/build.js +12 -11
  8. package/build/build/context.d.ts +2 -0
  9. package/build/build/createContext.d.ts +6 -3
  10. package/build/build/createContext.js +2 -4
  11. package/build/build/freeTierLimitCheckout.d.ts +39 -0
  12. package/build/build/freeTierLimitCheckout.js +106 -0
  13. package/build/build/runBuildAndSubmit.d.ts +11 -3
  14. package/build/build/runBuildAndSubmit.js +11 -8
  15. package/build/build/utils/url.d.ts +1 -0
  16. package/build/build/utils/url.js +4 -0
  17. package/build/commandUtils/EasCommand.js +3 -1
  18. package/build/commandUtils/context/DynamicProjectConfigContextField.d.ts +2 -2
  19. package/build/commandUtils/context/DynamicProjectConfigContextField.js +40 -61
  20. package/build/commandUtils/context/LoggedInContextField.js +1 -2
  21. package/build/commandUtils/context/MaybeLoggedInContextField.js +1 -2
  22. package/build/commandUtils/context/OptionalPrivateProjectConfigContextField.js +3 -1
  23. package/build/commandUtils/context/PrivateProjectConfigContextField.js +3 -1
  24. package/build/commandUtils/context/contextUtils/getProjectIdAsync.d.ts +1 -0
  25. package/build/commandUtils/context/contextUtils/getProjectIdAsync.js +5 -2
  26. package/build/commandUtils/errors.d.ts +5 -1
  27. package/build/commandUtils/errors.js +4 -3
  28. package/build/commands/browse.js +1 -1
  29. package/build/commands/build/dev.js +3 -3
  30. package/build/commands/build/index.js +2 -1
  31. package/build/commands/channel/delete.js +1 -1
  32. package/build/commands/channel/rollout.js +1 -1
  33. package/build/commands/credentials/configure-build.js +1 -1
  34. package/build/commands/deploy/alias/delete.js +1 -1
  35. package/build/commands/deploy/alias/index.js +1 -1
  36. package/build/commands/deploy/delete.js +1 -1
  37. package/build/commands/go.js +1 -1
  38. package/build/commands/observe/event.js +1 -1
  39. package/build/commands/observe/events.js +1 -1
  40. package/build/commands/project/new.js +1 -1
  41. package/build/commands/simulator/control.js +1 -1
  42. package/build/commands/simulator/get.js +14 -1
  43. package/build/commands/simulator/index.d.ts +1 -0
  44. package/build/commands/simulator/index.js +30 -8
  45. package/build/commands/workflow/cancel.js +1 -1
  46. package/build/commands/workflow/list.js +1 -1
  47. package/build/commands/workflow/logs.js +1 -1
  48. package/build/commands/workflow/run.js +1 -1
  49. package/build/commands/workflow/status.js +1 -1
  50. package/build/commands/workflow/view.js +1 -1
  51. package/build/graphql/generated.d.ts +146 -112
  52. package/build/graphql/generated.js +18 -8
  53. package/build/graphql/queries/DeviceRunSessionQuery.d.ts +8 -1
  54. package/build/graphql/queries/DeviceRunSessionQuery.js +67 -0
  55. package/build/simulator/jobRunErrors.d.ts +22 -0
  56. package/build/simulator/jobRunErrors.js +134 -0
  57. package/build/user/SessionManager.d.ts +10 -0
  58. package/build/user/SessionManager.js +12 -0
  59. package/oclif.manifest.json +275 -268
  60. package/package.json +7 -7
@@ -41,6 +41,7 @@ export declare enum BuildEvent {
41
41
  BUILD_REQUEST_ATTEMPT = "build cli build request attempt",
42
42
  BUILD_REQUEST_SUCCESS = "build cli build request success",
43
43
  BUILD_REQUEST_FAIL = "build cli build request fail",
44
+ FREE_TIER_LIMIT_CHECKOUT_PROMPT = "build cli free tier limit checkout prompt",
44
45
  BUILD_STATUS_COMMAND = "build cli build status",
45
46
  CREDENTIALS_SYNC_COMMAND = "build cli credentials sync command",
46
47
  CREDENTIALS_SYNC_UPDATE_LOCAL_ATTEMPT = "build cli credentials sync update local attempt",
@@ -66,6 +66,7 @@ var BuildEvent;
66
66
  BuildEvent["BUILD_REQUEST_ATTEMPT"] = "build cli build request attempt";
67
67
  BuildEvent["BUILD_REQUEST_SUCCESS"] = "build cli build request success";
68
68
  BuildEvent["BUILD_REQUEST_FAIL"] = "build cli build request fail";
69
+ BuildEvent["FREE_TIER_LIMIT_CHECKOUT_PROMPT"] = "build cli free tier limit checkout prompt";
69
70
  BuildEvent["BUILD_STATUS_COMMAND"] = "build cli build status";
70
71
  BuildEvent["CREDENTIALS_SYNC_COMMAND"] = "build cli credentials sync command";
71
72
  BuildEvent["CREDENTIALS_SYNC_UPDATE_LOCAL_ATTEMPT"] = "build cli credentials sync update local attempt";
@@ -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,7 @@
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';
4
5
  import { FreeTierLimitAgentGuidanceExperiment } from './freeTierLimitGuidance';
5
6
  import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
6
7
  import { BuildFragment, BuildMetadataInput, BuildParamsInput } from '../graphql/generated';
@@ -22,7 +23,7 @@ interface Builder<TPlatform extends Platform, Credentials, TJob extends BuildJob
22
23
  }
23
24
  export type BuildRequestSender = () => Promise<BuildFragment | undefined>;
24
25
  export declare function prepareBuildRequestForPlatformAsync<TPlatform extends Platform, Credentials, TJob extends BuildJob>(builder: Builder<TPlatform, Credentials, TJob>): Promise<BuildRequestSender>;
25
- export declare function handleBuildRequestErrorAsync(error: any, platform: Platform, accountName?: string, freeTierLimitAgentGuidanceExperiment?: FreeTierLimitAgentGuidanceExperiment): Promise<never>;
26
+ export declare function handleBuildRequestErrorAsync(error: any, platform: Platform, accountName?: string, freeTierLimitAgentGuidanceExperiment?: FreeTierLimitAgentGuidanceExperiment, freeTierLimitCheckoutExperiment?: FreeTierLimitCheckoutExperiment): Promise<never>;
26
27
  export type MaybeBuildFragment = BuildFragment | null;
27
28
  export declare function waitForBuildEndAsync(graphqlClient: ExpoGraphqlClient, { buildIds, accountName }: {
28
29
  buildIds: string[];
@@ -11,6 +11,7 @@ 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");
14
15
  const freeTierLimitGuidance_1 = require("./freeTierLimitGuidance");
15
16
  const graphql_1 = require("./graphql");
16
17
  const local_1 = require("./local");
@@ -18,9 +19,9 @@ const logs_1 = require("./logs");
18
19
  const metadata_1 = require("./metadata");
19
20
  const printBuildInfo_1 = require("./utils/printBuildInfo");
20
21
  const repository_1 = require("./utils/repository");
22
+ const url_1 = require("./utils/url");
21
23
  const AnalyticsManager_1 = require("../analytics/AnalyticsManager");
22
24
  const common_1 = require("../analytics/common");
23
- const api_1 = require("../api");
24
25
  const plans_1 = require("../billing/plans");
25
26
  const watcher_1 = require("../commandUtils/logs/watcher");
26
27
  const cli_1 = require("../fingerprint/cli");
@@ -122,7 +123,7 @@ async function prepareBuildRequestForPlatformAsync(builder) {
122
123
  return await sendBuildRequestAsync(builder, job, graphqlMetadata, buildParams);
123
124
  }
124
125
  catch (error) {
125
- return await handleBuildRequestErrorAsync(error, job.platform, ctx.accountName, (0, freeTierLimitGuidance_1.getFreeTierLimitAgentGuidanceExperiment)(ctx));
126
+ return await handleBuildRequestErrorAsync(error, job.platform, ctx.accountName, (0, freeTierLimitGuidance_1.getFreeTierLimitAgentGuidanceExperiment)(ctx), (0, freeTierLimitCheckout_1.getFreeTierLimitCheckoutExperiment)(ctx));
126
127
  }
127
128
  }
128
129
  else {
@@ -141,7 +142,7 @@ const SERVER_SIDE_DEFINED_ERRORS = {
141
142
  EAS_BUILD_LEGACY_RESOURCE_CLASS_NOT_AVAILABLE: errors_1.EasBuildLegacyResourceClassNotAvailableError,
142
143
  VALIDATION_ERROR: errors_1.RequestValidationError,
143
144
  };
144
- async function handleBuildRequestErrorAsync(error, platform, accountName, freeTierLimitAgentGuidanceExperiment) {
145
+ async function handleBuildRequestErrorAsync(error, platform, accountName, freeTierLimitAgentGuidanceExperiment, freeTierLimitCheckoutExperiment) {
145
146
  logBuildRequestErrorDebugInfo(error);
146
147
  const graphQLErrors = Array.isArray(error?.graphQLErrors)
147
148
  ? error.graphQLErrors
@@ -152,9 +153,12 @@ async function handleBuildRequestErrorAsync(error, platform, accountName, freeTi
152
153
  const message = graphQLErrors[0]?.message;
153
154
  const isFreeTierLimitError = graphQLErrorCode === 'EAS_BUILD_FREE_TIER_LIMIT_EXCEEDED' ||
154
155
  graphQLErrorCode === 'EAS_BUILD_FREE_TIER_IOS_LIMIT_EXCEEDED';
155
- throw new ErrorClass(isFreeTierLimitError
156
- ? await (0, freeTierLimitGuidance_1.maybeAppendFreeTierLimitAgentGuidanceAsync)(`${message}\nRun ${(0, plans_1.formatStarterSubscribeCommand)(accountName)} to upgrade to the Starter plan.`, platform, freeTierLimitAgentGuidanceExperiment)
157
- : 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 });
158
162
  }
159
163
  else if (graphQLErrorCode === 'EAS_BUILD_DOWN_FOR_MAINTENANCE') {
160
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.`);
@@ -438,7 +442,7 @@ async function handleSingleBuildProgressAsync({ build, accountName, }, { spinner
438
442
  }
439
443
  else {
440
444
  (0, ora_1.updateSpinnerText)(spinner, {
441
- 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))}.`,
442
446
  });
443
447
  }
444
448
  break;
@@ -456,7 +460,7 @@ async function handleSingleBuildProgressAsync({ build, accountName, }, { spinner
456
460
  if (build.priority !== generated_1.BuildPriority.High) {
457
461
  log_1.default.newLine();
458
462
  log_1.default.log('Start builds sooner in the priority queue.');
459
- 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))}`);
460
464
  }
461
465
  log_1.default.newLine();
462
466
  log_1.default.log(`Waiting in ${priorityToQueueDisplayName[build.priority]}`);
@@ -598,9 +602,6 @@ function formatEstimatedWaitTime(estimatedWaitTimeLeftSeconds) {
598
602
  return `starting in about ${n}0 minutes...`;
599
603
  }
600
604
  }
601
- function formatAccountBillingUrl(accountName) {
602
- return new URL(`/accounts/${accountName}/settings/billing`, (0, api_1.getExpoWebsiteBaseUrl)()).toString();
603
- }
604
605
  async function computeAndMaybeUploadRuntimeAndFingerprintMetadataAsync(ctx) {
605
606
  const runtimeAndFingerprintMetadata = await computeAndMaybeUploadFingerprintFromExpoUpdatesAsync(ctx);
606
607
  if (!runtimeAndFingerprintMetadata?.fingerprintHash) {
@@ -11,6 +11,7 @@ import { LazyExperimentationClient } from '../experimentation/LazyExperimentatio
11
11
  import { Target } from '../credentials/ios/types';
12
12
  import { BuildResourceClass } from '../graphql/generated';
13
13
  import { GradleBuildContext } from '../project/android/gradle';
14
+ import { LoggedInAuthenticationInfo } from '../user/SessionManager';
14
15
  import { CustomBuildConfigMetadata } from '../project/customBuildConfig';
15
16
  import { XcodeBuildContext } from '../project/ios/scheme';
16
17
  import { Actor } from '../user/User';
@@ -63,4 +64,5 @@ export interface BuildContext<T extends Platform> {
63
64
  whatToTest?: string;
64
65
  env: Env;
65
66
  experimentation?: LazyExperimentationClient;
67
+ authenticationInfo?: LoggedInAuthenticationInfo;
66
68
  }
@@ -1,16 +1,17 @@
1
+ import { ExpoConfig } from '@expo/config';
1
2
  import { Env, Platform } from '@expo/eas-build-job';
2
3
  import { BuildProfile, EasJson, ResourceClass } from '@expo/eas-json';
3
4
  import { LoggerLevel } from '@expo/logger';
4
5
  import { BuildContext } from './context';
5
6
  import { LocalBuildOptions } from './local';
6
7
  import { Analytics } from '../analytics/AnalyticsManager';
7
- import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectConfigContextField';
8
8
  import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
9
9
  import { LazyExperimentationClient } from '../experimentation/LazyExperimentationClient';
10
10
  import { CustomBuildConfigMetadata } from '../project/customBuildConfig';
11
+ import { LoggedInAuthenticationInfo } from '../user/SessionManager';
11
12
  import { Actor } from '../user/User';
12
13
  import { Client } from '../vcs/vcs';
13
- 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, }: {
14
+ export declare function createBuildContextAsync<T extends Platform>({ buildProfileName, buildProfile, easJsonCliConfig, clearCache, localBuildOptions, nonInteractive, noWait, platform, projectDir, resourceClassFlag, message, actor, graphqlClient, analytics, vcsClient, exp, projectId, customBuildConfigMetadata, buildLoggerLevel, freezeCredentials, refreshAdHocProvisioningProfile: refreshAdHocProvisioningProfileFlag, isVerboseLoggingEnabled, whatToTest, env, experimentation, authenticationInfo, }: {
14
15
  buildProfileName: string;
15
16
  buildProfile: BuildProfile<T>;
16
17
  easJsonCliConfig: EasJson['cli'];
@@ -26,7 +27,8 @@ export declare function createBuildContextAsync<T extends Platform>({ buildProfi
26
27
  graphqlClient: ExpoGraphqlClient;
27
28
  analytics: Analytics;
28
29
  vcsClient: Client;
29
- getDynamicPrivateProjectConfigAsync: DynamicConfigContextFn;
30
+ exp: ExpoConfig;
31
+ projectId: string;
30
32
  customBuildConfigMetadata?: CustomBuildConfigMetadata;
31
33
  buildLoggerLevel?: LoggerLevel;
32
34
  freezeCredentials: boolean;
@@ -35,4 +37,5 @@ export declare function createBuildContextAsync<T extends Platform>({ buildProfi
35
37
  whatToTest?: string;
36
38
  env: Env;
37
39
  experimentation?: LazyExperimentationClient;
40
+ authenticationInfo?: LoggedInAuthenticationInfo;
38
41
  }): Promise<BuildContext<T>>;
@@ -16,10 +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, experimentation, }) {
20
- const { exp, projectId } = await getDynamicPrivateProjectConfigAsync({
21
- env,
22
- });
19
+ async function createBuildContextAsync({ buildProfileName, buildProfile, easJsonCliConfig, clearCache = false, localBuildOptions, nonInteractive, noWait, platform, projectDir, resourceClassFlag, message, actor, graphqlClient, analytics, vcsClient, exp, projectId, customBuildConfigMetadata, buildLoggerLevel, freezeCredentials, refreshAdHocProvisioningProfile: refreshAdHocProvisioningProfileFlag, isVerboseLoggingEnabled, whatToTest, env, experimentation, authenticationInfo, }) {
23
20
  const projectName = exp.slug;
24
21
  const [account, workflow] = await Promise.all([
25
22
  (0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId),
@@ -98,6 +95,7 @@ async function createBuildContextAsync({ buildProfileName, buildProfile, easJson
98
95
  env,
99
96
  whatToTest,
100
97
  experimentation,
98
+ authenticationInfo,
101
99
  };
102
100
  if (platform === eas_build_job_1.Platform.ANDROID) {
103
101
  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
+ }
@@ -1,3 +1,4 @@
1
+ import { ExpoConfig } from '@expo/config';
1
2
  import { Env } from '@expo/eas-build-job';
2
3
  import { ResourceClass } from '@expo/eas-json';
3
4
  import { LoggerLevel } from '@expo/logger';
@@ -6,6 +7,7 @@ import { Analytics } from '../analytics/AnalyticsManager';
6
7
  import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectConfigContextField';
7
8
  import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
8
9
  import { LazyExperimentationClient } from '../experimentation/LazyExperimentationClient';
10
+ import { LoggedInAuthenticationInfo } from '../user/SessionManager';
9
11
  import { BuildFragment } from '../graphql/generated';
10
12
  import { RequestedPlatform } from '../platform';
11
13
  import { SimulatorRunTarget } from '../run/ios/run';
@@ -31,7 +33,7 @@ export interface BuildFlags {
31
33
  whatToTest?: string;
32
34
  simulator?: SimulatorRunTarget;
33
35
  }
34
- export declare function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, projectDir, flags, actor, getDynamicPrivateProjectConfigAsync, downloadSimBuildAutoConfirm, envOverride, experimentation, }: {
36
+ export declare function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, projectDir, flags, actor, getDynamicPrivateProjectConfigAsync, downloadSimBuildAutoConfirm, evaluatedConfig, experimentation, authenticationInfo, }: {
35
37
  graphqlClient: ExpoGraphqlClient;
36
38
  analytics: Analytics;
37
39
  vcsClient: Client;
@@ -40,9 +42,15 @@ export declare function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsCl
40
42
  actor: Actor;
41
43
  getDynamicPrivateProjectConfigAsync: DynamicConfigContextFn;
42
44
  downloadSimBuildAutoConfirm?: boolean;
43
- envOverride?: Env;
44
- /** Enables the Free plan limit guidance experiment for builds driven by a coding agent. */
45
+ evaluatedConfig?: {
46
+ env: Env;
47
+ exp: ExpoConfig;
48
+ projectId: string;
49
+ };
50
+ /** Enables the Free plan limit experiments on the build request error path. */
45
51
  experimentation?: LazyExperimentationClient;
52
+ /** Lets the Free plan limit checkout experiment create a checkout session. */
53
+ authenticationInfo?: LoggedInAuthenticationInfo;
46
54
  }): Promise<{
47
55
  buildIds: string[];
48
56
  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, experimentation, }) {
52
+ async function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, projectDir, flags, actor, getDynamicPrivateProjectConfigAsync, downloadSimBuildAutoConfirm, evaluatedConfig, experimentation, authenticationInfo, }) {
53
53
  await vcsClient.ensureRepoExistsAsync();
54
54
  await (0, repository_1.ensureRepoIsCleanAsync)(vcsClient, flags.nonInteractive);
55
55
  await (0, configure_1.ensureProjectConfiguredAsync)({
@@ -106,15 +106,14 @@ async function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, pro
106
106
  const buildCtxByPlatform = {};
107
107
  for (const buildProfile of buildProfiles) {
108
108
  const platform = (0, AppPlatform_1.toAppPlatform)(buildProfile.platform);
109
- const { env } = !envOverride
110
- ? await (0, evaluateConfigWithEnvVarsAsync_1.evaluateConfigWithEnvVarsAsync)({
109
+ const { env, exp, projectId } = evaluatedConfig ??
110
+ (await (0, evaluateConfigWithEnvVarsAsync_1.evaluateConfigWithEnvVarsAsync)({
111
111
  buildProfile: buildProfile.profile,
112
112
  buildProfileName: buildProfile.profileName,
113
113
  graphqlClient,
114
114
  getProjectConfig: getDynamicPrivateProjectConfigAsync,
115
115
  opts: { env: buildProfile.profile.env },
116
- })
117
- : { env: envOverride };
116
+ }));
118
117
  const { build: maybeBuild, buildCtx } = await prepareAndStartBuildAsync({
119
118
  projectDir,
120
119
  flags,
@@ -125,11 +124,13 @@ async function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, pro
125
124
  graphqlClient,
126
125
  analytics,
127
126
  vcsClient,
128
- getDynamicPrivateProjectConfigAsync,
127
+ exp,
128
+ projectId,
129
129
  customBuildConfigMetadata: customBuildConfigMetadataByPlatform[platform],
130
130
  env,
131
131
  easJsonAccessor,
132
132
  experimentation,
133
+ authenticationInfo,
133
134
  });
134
135
  if (maybeBuild) {
135
136
  startedBuilds.push({ build: maybeBuild, buildProfile });
@@ -223,7 +224,7 @@ async function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, pro
223
224
  buildProfiles,
224
225
  };
225
226
  }
226
- async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildProfile, easJsonCliConfig, actor, graphqlClient, analytics, vcsClient, getDynamicPrivateProjectConfigAsync, customBuildConfigMetadata, env, easJsonAccessor, experimentation, }) {
227
+ async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildProfile, easJsonCliConfig, actor, graphqlClient, analytics, vcsClient, exp, projectId, customBuildConfigMetadata, env, easJsonAccessor, experimentation, authenticationInfo, }) {
227
228
  const buildCtx = await (0, createContext_1.createBuildContextAsync)({
228
229
  buildProfileName: buildProfile.profileName,
229
230
  resourceClassFlag: flags.resourceClass,
@@ -240,7 +241,8 @@ async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildP
240
241
  graphqlClient,
241
242
  analytics,
242
243
  vcsClient,
243
- getDynamicPrivateProjectConfigAsync,
244
+ exp,
245
+ projectId,
244
246
  customBuildConfigMetadata,
245
247
  buildLoggerLevel: flags.buildLoggerLevel ?? (log_1.default.isDebug ? logger_1.LoggerLevel.DEBUG : undefined),
246
248
  freezeCredentials: flags.freezeCredentials,
@@ -249,6 +251,7 @@ async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildP
249
251
  whatToTest: flags.whatToTest,
250
252
  env,
251
253
  experimentation,
254
+ authenticationInfo,
252
255
  });
253
256
  if (!lockfileChecked && !flags.localBuildOptions.localBuildMode) {
254
257
  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}` : ''}`;
@@ -195,7 +195,9 @@ class EasCommand extends core_1.Command {
195
195
  const commandId = this.id ?? 'unknown';
196
196
  let baseMessage = `${commandId} command failed.`;
197
197
  if (err instanceof errors_1.EasCommandError) {
198
- log_1.default.error(err.message);
198
+ if (!err.messageAlreadyPrinted) {
199
+ log_1.default.error(err.message);
200
+ }
199
201
  }
200
202
  else if (err instanceof core_2.CombinedError && err?.graphQLErrors) {
201
203
  const cleanGQLErrorsMessage = err?.graphQLErrors
@@ -7,8 +7,8 @@ export type DynamicConfigContextFn = (options?: ExpoConfigOptions) => Promise<{
7
7
  projectDir: string;
8
8
  }>;
9
9
  export declare class DynamicPublicProjectConfigContextField extends ContextField<DynamicConfigContextFn> {
10
- getValueAsync({ nonInteractive, sessionManager, withServerSideEnvironment, }: ContextOptions): Promise<DynamicConfigContextFn>;
10
+ getValueAsync(options: ContextOptions): Promise<DynamicConfigContextFn>;
11
11
  }
12
12
  export declare class DynamicPrivateProjectConfigContextField extends ContextField<DynamicConfigContextFn> {
13
- getValueAsync({ nonInteractive, sessionManager, withServerSideEnvironment, }: ContextOptions): Promise<DynamicConfigContextFn>;
13
+ getValueAsync(options: ContextOptions): Promise<DynamicConfigContextFn>;
14
14
  }