eas-cli 25.2.0 → 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.
- package/README.md +179 -161
- package/build/analytics/AnalyticsManager.d.ts +1 -0
- package/build/analytics/AnalyticsManager.js +1 -0
- package/build/billing/resolveAccount.d.ts +12 -0
- package/build/billing/resolveAccount.js +1 -0
- package/build/build/build.d.ts +2 -1
- package/build/build/build.js +12 -11
- package/build/build/context.d.ts +2 -0
- package/build/build/createContext.d.ts +3 -1
- package/build/build/createContext.js +2 -1
- package/build/build/freeTierLimitCheckout.d.ts +39 -0
- package/build/build/freeTierLimitCheckout.js +106 -0
- package/build/build/runBuildAndSubmit.d.ts +5 -2
- package/build/build/runBuildAndSubmit.js +4 -2
- package/build/build/utils/url.d.ts +1 -0
- package/build/build/utils/url.js +4 -0
- package/build/commandUtils/EasCommand.js +3 -1
- package/build/commandUtils/errors.d.ts +5 -1
- package/build/commandUtils/errors.js +4 -3
- package/build/commands/build/index.js +2 -1
- package/build/commands/simulator/index.d.ts +1 -0
- package/build/commands/simulator/index.js +18 -4
- package/oclif.manifest.json +189 -182
- package/package.json +6 -6
|
@@ -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"));
|
package/build/build/build.d.ts
CHANGED
|
@@ -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[];
|
package/build/build/build.js
CHANGED
|
@@ -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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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)(
|
|
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)(
|
|
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) {
|
package/build/build/context.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -8,9 +8,10 @@ import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectCo
|
|
|
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, getDynamicPrivateProjectConfigAsync, customBuildConfigMetadata, buildLoggerLevel, freezeCredentials, refreshAdHocProvisioningProfile: refreshAdHocProvisioningProfileFlag, isVerboseLoggingEnabled, whatToTest, env, experimentation, authenticationInfo, }: {
|
|
14
15
|
buildProfileName: string;
|
|
15
16
|
buildProfile: BuildProfile<T>;
|
|
16
17
|
easJsonCliConfig: EasJson['cli'];
|
|
@@ -35,4 +36,5 @@ export declare function createBuildContextAsync<T extends Platform>({ buildProfi
|
|
|
35
36
|
whatToTest?: string;
|
|
36
37
|
env: Env;
|
|
37
38
|
experimentation?: LazyExperimentationClient;
|
|
39
|
+
authenticationInfo?: LoggedInAuthenticationInfo;
|
|
38
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, experimentation, }) {
|
|
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
|
});
|
|
@@ -98,6 +98,7 @@ async function createBuildContextAsync({ buildProfileName, buildProfile, easJson
|
|
|
98
98
|
env,
|
|
99
99
|
whatToTest,
|
|
100
100
|
experimentation,
|
|
101
|
+
authenticationInfo,
|
|
101
102
|
};
|
|
102
103
|
if (platform === eas_build_job_1.Platform.ANDROID) {
|
|
103
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
|
+
}
|
|
@@ -6,6 +6,7 @@ import { Analytics } from '../analytics/AnalyticsManager';
|
|
|
6
6
|
import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectConfigContextField';
|
|
7
7
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
|
8
8
|
import { LazyExperimentationClient } from '../experimentation/LazyExperimentationClient';
|
|
9
|
+
import { LoggedInAuthenticationInfo } from '../user/SessionManager';
|
|
9
10
|
import { BuildFragment } from '../graphql/generated';
|
|
10
11
|
import { RequestedPlatform } from '../platform';
|
|
11
12
|
import { SimulatorRunTarget } from '../run/ios/run';
|
|
@@ -31,7 +32,7 @@ export interface BuildFlags {
|
|
|
31
32
|
whatToTest?: string;
|
|
32
33
|
simulator?: SimulatorRunTarget;
|
|
33
34
|
}
|
|
34
|
-
export declare function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, projectDir, flags, actor, getDynamicPrivateProjectConfigAsync, downloadSimBuildAutoConfirm, envOverride, experimentation, }: {
|
|
35
|
+
export declare function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, projectDir, flags, actor, getDynamicPrivateProjectConfigAsync, downloadSimBuildAutoConfirm, envOverride, experimentation, authenticationInfo, }: {
|
|
35
36
|
graphqlClient: ExpoGraphqlClient;
|
|
36
37
|
analytics: Analytics;
|
|
37
38
|
vcsClient: Client;
|
|
@@ -41,8 +42,10 @@ export declare function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsCl
|
|
|
41
42
|
getDynamicPrivateProjectConfigAsync: DynamicConfigContextFn;
|
|
42
43
|
downloadSimBuildAutoConfirm?: boolean;
|
|
43
44
|
envOverride?: Env;
|
|
44
|
-
/** Enables the Free plan limit
|
|
45
|
+
/** Enables the Free plan limit experiments on the build request error path. */
|
|
45
46
|
experimentation?: LazyExperimentationClient;
|
|
47
|
+
/** Lets the Free plan limit checkout experiment create a checkout session. */
|
|
48
|
+
authenticationInfo?: LoggedInAuthenticationInfo;
|
|
46
49
|
}): Promise<{
|
|
47
50
|
buildIds: string[];
|
|
48
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, experimentation, }) {
|
|
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)({
|
|
@@ -130,6 +130,7 @@ async function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, pro
|
|
|
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, getDynamicPrivateProjectConfigAsync, customBuildConfigMetadata, env, easJsonAccessor, experimentation, authenticationInfo, }) {
|
|
227
228
|
const buildCtx = await (0, createContext_1.createBuildContextAsync)({
|
|
228
229
|
buildProfileName: buildProfile.profileName,
|
|
229
230
|
resourceClassFlag: flags.resourceClass,
|
|
@@ -249,6 +250,7 @@ async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildP
|
|
|
249
250
|
whatToTest: flags.whatToTest,
|
|
250
251
|
env,
|
|
251
252
|
experimentation,
|
|
253
|
+
authenticationInfo,
|
|
252
254
|
});
|
|
253
255
|
if (!lockfileChecked && !flags.localBuildOptions.localBuildMode) {
|
|
254
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;
|
package/build/build/utils/url.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export declare class EasCommandError extends Error {
|
|
2
|
-
|
|
2
|
+
/** True when the command already printed the message, so `EasCommand.catch` must not print it again. */
|
|
3
|
+
readonly messageAlreadyPrinted: boolean;
|
|
4
|
+
constructor(message: string, { messageAlreadyPrinted }?: {
|
|
5
|
+
messageAlreadyPrinted?: boolean;
|
|
6
|
+
});
|
|
3
7
|
}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EasCommandError = void 0;
|
|
4
4
|
class EasCommandError extends Error {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
constructor(message) {
|
|
5
|
+
/** True when the command already printed the message, so `EasCommand.catch` must not print it again. */
|
|
6
|
+
messageAlreadyPrinted;
|
|
7
|
+
constructor(message, { messageAlreadyPrinted = false } = {}) {
|
|
8
8
|
super(message);
|
|
9
|
+
this.messageAlreadyPrinted = messageAlreadyPrinted;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
exports.EasCommandError = EasCommandError;
|
|
@@ -116,7 +116,7 @@ class Build extends EasCommand_1.default {
|
|
|
116
116
|
(0, json_1.enableJsonOutput)();
|
|
117
117
|
}
|
|
118
118
|
const flags = this.sanitizeFlags(rawFlags);
|
|
119
|
-
const { loggedIn: { actor, graphqlClient }, getDynamicPrivateProjectConfigAsync, projectDir, analytics, vcsClient, experimentation, } = await this.getContextAsync(Build, {
|
|
119
|
+
const { loggedIn: { actor, graphqlClient, authenticationInfo }, getDynamicPrivateProjectConfigAsync, projectDir, analytics, vcsClient, experimentation, } = await this.getContextAsync(Build, {
|
|
120
120
|
nonInteractive: flags.nonInteractive,
|
|
121
121
|
withServerSideEnvironment: null,
|
|
122
122
|
});
|
|
@@ -136,6 +136,7 @@ class Build extends EasCommand_1.default {
|
|
|
136
136
|
actor,
|
|
137
137
|
getDynamicPrivateProjectConfigAsync,
|
|
138
138
|
experimentation,
|
|
139
|
+
authenticationInfo,
|
|
139
140
|
});
|
|
140
141
|
this.maybeSuggestUsingEasBuildDev({
|
|
141
142
|
buildProfiles,
|
|
@@ -10,6 +10,7 @@ export default class Simulator extends EasCommand {
|
|
|
10
10
|
name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
11
|
tag: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
12
|
device: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
'system-image': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
14
|
'build-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
15
|
'build-fingerprint': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
16
|
'application-archive-url': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -57,6 +57,9 @@ class Simulator extends EasCommand_1.default {
|
|
|
57
57
|
device: core_1.Flags.string({
|
|
58
58
|
description: 'Virtual device to start for the session. On iOS, a Simulator device name or UDID (e.g. "iPhone 16 Pro"). On Android, an AVD hardware profile id (e.g. "pixel_7"). Defaults to a device chosen by the runner.',
|
|
59
59
|
}),
|
|
60
|
+
'system-image': core_1.Flags.string({
|
|
61
|
+
description: 'Android SDK system image package to use for the emulator (e.g. "system-images;android-35-ext15;google_apis_playstore;x86_64"). Defaults to a system image chosen by the runner. Only supported with --platform android.',
|
|
62
|
+
}),
|
|
60
63
|
'build-id': core_1.Flags.string({
|
|
61
64
|
description: 'EAS Build to install and launch before the simulator session is ready.',
|
|
62
65
|
exclusive: ['build-fingerprint', 'application-archive-url', 'expo-go'],
|
|
@@ -173,6 +176,7 @@ class Simulator extends EasCommand_1.default {
|
|
|
173
176
|
const name = flags.name?.trim() || undefined;
|
|
174
177
|
const tags = flags.tag?.map(tag => tag.trim()).filter(tag => tag.length > 0);
|
|
175
178
|
const deviceIdentifier = flags.device?.trim() || undefined;
|
|
179
|
+
const systemImagePackage = flags['system-image']?.trim() || undefined;
|
|
176
180
|
const buildId = flags['build-id']?.trim() || undefined;
|
|
177
181
|
const buildFingerprint = flags['build-fingerprint']?.trim() || undefined;
|
|
178
182
|
const applicationArchiveUrlFromFlag = flags['application-archive-url']?.trim() || undefined;
|
|
@@ -207,6 +211,9 @@ class Simulator extends EasCommand_1.default {
|
|
|
207
211
|
}
|
|
208
212
|
const platform = await resolvePlatformAsync(flags.platform, nonInteractive);
|
|
209
213
|
const egress = flags.egress === 'local' ? generated_1.DeviceRunSessionEgress.Local : undefined;
|
|
214
|
+
if (systemImagePackage && platform !== generated_1.AppPlatform.Android) {
|
|
215
|
+
throw new errors_1.EasCommandError('--system-image is only supported with --platform android.');
|
|
216
|
+
}
|
|
210
217
|
let egressAllow = [];
|
|
211
218
|
try {
|
|
212
219
|
egressAllow = (0, egress_1.parseEgressAllowList)(flags['egress-allow'] ?? []);
|
|
@@ -271,11 +278,18 @@ class Simulator extends EasCommand_1.default {
|
|
|
271
278
|
packageVersion: flags['package-version'],
|
|
272
279
|
networkCapture: flags['network-capture'],
|
|
273
280
|
...(networkCaptureFields.length ? { networkCaptureFields } : {}),
|
|
274
|
-
...(
|
|
275
|
-
?
|
|
281
|
+
...(platform === generated_1.AppPlatform.Ios
|
|
282
|
+
? deviceIdentifier
|
|
276
283
|
? { ios: { deviceIdentifier } }
|
|
277
|
-
: {
|
|
278
|
-
:
|
|
284
|
+
: {}
|
|
285
|
+
: deviceIdentifier || systemImagePackage
|
|
286
|
+
? {
|
|
287
|
+
android: {
|
|
288
|
+
...(deviceIdentifier ? { deviceIdentifier } : {}),
|
|
289
|
+
...(systemImagePackage ? { systemImagePackage } : {}),
|
|
290
|
+
},
|
|
291
|
+
}
|
|
292
|
+
: {}),
|
|
279
293
|
...(buildId ? { buildId } : {}),
|
|
280
294
|
...(buildFingerprint ? { buildFingerprint } : {}),
|
|
281
295
|
...(applicationArchiveUrlFromFlag
|