eas-cli 22.2.0 → 22.4.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 (38) hide show
  1. package/README.md +286 -205
  2. package/build/analytics/AnalyticsManager.d.ts +4 -1
  3. package/build/analytics/AnalyticsManager.js +5 -1
  4. package/build/billing/billingClient.d.ts +18 -0
  5. package/build/billing/billingClient.js +23 -0
  6. package/build/billing/openUrl.d.ts +4 -0
  7. package/build/billing/openUrl.js +29 -0
  8. package/build/billing/plans.d.ts +18 -0
  9. package/build/billing/plans.js +17 -0
  10. package/build/billing/resolveAccount.d.ts +17 -0
  11. package/build/billing/resolveAccount.js +92 -0
  12. package/build/build/build.d.ts +1 -1
  13. package/build/build/build.js +9 -3
  14. package/build/commandUtils/flags.d.ts +1 -1
  15. package/build/commands/billing/manage.d.ts +14 -0
  16. package/build/commands/billing/manage.js +63 -0
  17. package/build/commands/billing/subscribe.d.ts +18 -0
  18. package/build/commands/billing/subscribe.js +117 -0
  19. package/build/commands/env/create.d.ts +1 -1
  20. package/build/commands/env/delete.d.ts +1 -1
  21. package/build/commands/env/get.d.ts +1 -1
  22. package/build/commands/env/list.d.ts +1 -1
  23. package/build/commands/env/set.d.ts +1 -1
  24. package/build/commands/env/update.d.ts +1 -1
  25. package/build/commands/go.d.ts +0 -1
  26. package/build/commands/go.js +2 -16
  27. package/build/commands/simulator/index.d.ts +6 -0
  28. package/build/commands/simulator/index.js +47 -0
  29. package/build/graphql/generated.d.ts +55 -0
  30. package/build/graphql/queries/AccountQuery.d.ts +4 -5
  31. package/build/graphql/queries/AccountQuery.js +23 -0
  32. package/build/project/detectProjectSdkVersionAsync.d.ts +1 -0
  33. package/build/project/detectProjectSdkVersionAsync.js +17 -0
  34. package/build/simulator/expoGo.d.ts +4 -0
  35. package/build/simulator/expoGo.js +19 -0
  36. package/build/utils/usage/checkForOverages.js +6 -2
  37. package/oclif.manifest.json +2160 -1912
  38. package/package.json +7 -3
@@ -1,8 +1,11 @@
1
1
  import { Actor } from '../user/User';
2
- export type AnalyticsEvent = CommandEvent | BuildEvent | SubmissionEvent | MetadataEvent;
2
+ export type AnalyticsEvent = CommandEvent | BuildEvent | SubmissionEvent | MetadataEvent | BillingEvent;
3
3
  export declare enum CommandEvent {
4
4
  ACTION = "action"
5
5
  }
6
+ export declare enum BillingEvent {
7
+ SUBSCRIBE_COMMAND = "billing cli subscribe command"
8
+ }
6
9
  export declare enum SubmissionEvent {
7
10
  SUBMIT_COMMAND = "submit cli submit command",
8
11
  SUBMIT_COMMAND_ATTEMPT = "submit cli attempt",
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MetadataEvent = exports.BuildEvent = exports.SubmissionEvent = exports.CommandEvent = void 0;
3
+ exports.MetadataEvent = exports.BuildEvent = exports.SubmissionEvent = exports.BillingEvent = exports.CommandEvent = void 0;
4
4
  exports.setAnalyticsEnabledAsync = setAnalyticsEnabledAsync;
5
5
  exports.getAnalyticsEnabledAsync = getAnalyticsEnabledAsync;
6
6
  exports.createAnalyticsAsync = createAnalyticsAsync;
@@ -23,6 +23,10 @@ var CommandEvent;
23
23
  (function (CommandEvent) {
24
24
  CommandEvent["ACTION"] = "action";
25
25
  })(CommandEvent || (exports.CommandEvent = CommandEvent = {}));
26
+ var BillingEvent;
27
+ (function (BillingEvent) {
28
+ BillingEvent["SUBSCRIBE_COMMAND"] = "billing cli subscribe command";
29
+ })(BillingEvent || (exports.BillingEvent = BillingEvent = {}));
26
30
  var SubmissionEvent;
27
31
  (function (SubmissionEvent) {
28
32
  SubmissionEvent["SUBMIT_COMMAND"] = "submit cli submit command";
@@ -0,0 +1,18 @@
1
+ import type { CheckoutPlanType } from './plans';
2
+ export type CheckoutSession = {
3
+ id: string;
4
+ clientSecret: string | null;
5
+ url: string | null;
6
+ };
7
+ export type CustomerPortalSession = {
8
+ url: string;
9
+ };
10
+ export declare class BillingClient {
11
+ private readonly apiV2Client;
12
+ constructor(authInfo: {
13
+ accessToken: string | null;
14
+ sessionSecret: string | null;
15
+ });
16
+ createCheckoutSessionAsync(accountId: string, planType: CheckoutPlanType): Promise<CheckoutSession>;
17
+ createCustomerPortalSessionAsync(accountId: string): Promise<CustomerPortalSession>;
18
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BillingClient = void 0;
4
+ const api_1 = require("../api");
5
+ class BillingClient {
6
+ apiV2Client;
7
+ constructor(authInfo) {
8
+ this.apiV2Client = new api_1.ApiV2Client(authInfo);
9
+ }
10
+ async createCheckoutSessionAsync(accountId, planType) {
11
+ const { data } = await this.apiV2Client.postAsync('stripe-auth/checkout', {
12
+ body: { accountId, planType },
13
+ });
14
+ return data;
15
+ }
16
+ async createCustomerPortalSessionAsync(accountId) {
17
+ const { data } = await this.apiV2Client.postAsync('stripe-auth/customer-portal', {
18
+ body: { accountId },
19
+ });
20
+ return data.customerPortal;
21
+ }
22
+ }
23
+ exports.BillingClient = BillingClient;
@@ -0,0 +1,4 @@
1
+ export declare function openOrPrintUrlAsync(url: string, { label, open }: {
2
+ label: string;
3
+ open: boolean;
4
+ }): Promise<void>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.openOrPrintUrlAsync = openOrPrintUrlAsync;
4
+ const tslib_1 = require("tslib");
5
+ const log_1 = tslib_1.__importStar(require("../log"));
6
+ const ora_1 = require("../ora");
7
+ const openBrowser = require("open");
8
+ async function openOrPrintUrlAsync(url, { label, open }) {
9
+ if (!open) {
10
+ log_1.default.log(`${label}: ${(0, log_1.link)(url)}`);
11
+ return;
12
+ }
13
+ const spinner = (0, ora_1.ora)(`Opening ${label.toLowerCase()}`).start();
14
+ let opened = false;
15
+ try {
16
+ await openBrowser(url);
17
+ opened = true;
18
+ }
19
+ catch (error) {
20
+ log_1.default.debug(`Failed to open a web browser: ${error}`);
21
+ }
22
+ if (opened) {
23
+ spinner.succeed(`Opened ${label.toLowerCase()} in your browser`);
24
+ }
25
+ else {
26
+ spinner.fail('Unable to open a web browser automatically.');
27
+ }
28
+ log_1.default.log(`${label}: ${(0, log_1.link)(url)}`);
29
+ }
@@ -0,0 +1,18 @@
1
+ export declare const SUBSCRIBABLE_PLANS: {
2
+ readonly starter: {
3
+ readonly planType: "STARTER";
4
+ readonly label: "Starter";
5
+ };
6
+ readonly production: {
7
+ readonly planType: "PRODUCTION";
8
+ readonly label: "Production";
9
+ };
10
+ };
11
+ export type PlanSlug = keyof typeof SUBSCRIBABLE_PLANS;
12
+ export type CheckoutPlanType = (typeof SUBSCRIBABLE_PLANS)[PlanSlug]['planType'];
13
+ export declare const PLAN_SLUGS: PlanSlug[];
14
+ export declare const FREE_PLAN_PRICE_ID = "price_free";
15
+ export declare function formatStarterSubscribeCommand(accountName?: string): string;
16
+ export declare function hasPaidSubscription(subscription: {
17
+ planId?: string | null;
18
+ } | null): boolean;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FREE_PLAN_PRICE_ID = exports.PLAN_SLUGS = exports.SUBSCRIBABLE_PLANS = void 0;
4
+ exports.formatStarterSubscribeCommand = formatStarterSubscribeCommand;
5
+ exports.hasPaidSubscription = hasPaidSubscription;
6
+ exports.SUBSCRIBABLE_PLANS = {
7
+ starter: { planType: 'STARTER', label: 'Starter' },
8
+ production: { planType: 'PRODUCTION', label: 'Production' },
9
+ };
10
+ exports.PLAN_SLUGS = Object.keys(exports.SUBSCRIBABLE_PLANS);
11
+ exports.FREE_PLAN_PRICE_ID = 'price_free';
12
+ function formatStarterSubscribeCommand(accountName) {
13
+ return `eas billing:subscribe starter${accountName ? ` --account ${accountName}` : ''}`;
14
+ }
15
+ function hasPaidSubscription(subscription) {
16
+ return subscription?.planId != null && subscription.planId !== exports.FREE_PLAN_PRICE_ID;
17
+ }
@@ -0,0 +1,17 @@
1
+ import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
2
+ import { type AccountSubscriptionInfo } from '../graphql/queries/AccountQuery';
3
+ import { Actor } from '../user/User';
4
+ export type BillingAccount = {
5
+ id: string;
6
+ name: string;
7
+ subscription: AccountSubscriptionInfo | null;
8
+ };
9
+ type SubscriptionFilter = 'subscribed' | 'unsubscribed';
10
+ export declare function resolveBillingAccountAsync({ graphqlClient, actor, accountName, nonInteractive, subscriptionFilter, }: {
11
+ graphqlClient: ExpoGraphqlClient;
12
+ actor: Actor;
13
+ accountName: string | undefined;
14
+ nonInteractive: boolean;
15
+ subscriptionFilter: SubscriptionFilter;
16
+ }): Promise<BillingAccount>;
17
+ export {};
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveBillingAccountAsync = resolveBillingAccountAsync;
4
+ const generated_1 = require("../graphql/generated");
5
+ const AccountQuery_1 = require("../graphql/queries/AccountQuery");
6
+ const plans_1 = require("./plans");
7
+ const prompts_1 = require("../prompts");
8
+ function billingPermissionError(accountName) {
9
+ return new Error(`You must be an Owner or Admin of account "${accountName}" to manage billing.`);
10
+ }
11
+ function hasBillingRole(actor, account) {
12
+ if (account.ownerUserActor?.id === actor.id) {
13
+ return true;
14
+ }
15
+ const { role } = account.viewerUserPermission;
16
+ return role === generated_1.Role.Admin || role === generated_1.Role.Owner || role === generated_1.Role.HasAdmin;
17
+ }
18
+ async function getAccountWithSubscriptionAsync(graphqlClient, account) {
19
+ const subscription = await AccountQuery_1.AccountQuery.getSubscriptionAsync(graphqlClient, account.id);
20
+ return { id: account.id, name: account.name, subscription };
21
+ }
22
+ function toAccountChoice(account, disabled) {
23
+ const fallback = (0, plans_1.hasPaidSubscription)(account.subscription) ? 'Paid' : 'Free';
24
+ return {
25
+ title: account.name,
26
+ value: account,
27
+ description: `Current plan: ${account.subscription?.name ?? fallback}`,
28
+ disabled,
29
+ };
30
+ }
31
+ async function resolveNamedAccountAsync(graphqlClient, actor, accountName) {
32
+ const ownAccount = actor.accounts.find(account => account.name === accountName);
33
+ if (ownAccount) {
34
+ if (!hasBillingRole(actor, ownAccount)) {
35
+ throw billingPermissionError(ownAccount.name);
36
+ }
37
+ return ownAccount;
38
+ }
39
+ const account = await AccountQuery_1.AccountQuery.getByNameAsync(graphqlClient, accountName).catch(() => null);
40
+ if (!account) {
41
+ const availableAccounts = actor.accounts
42
+ .filter(candidate => hasBillingRole(actor, candidate))
43
+ .map(candidate => candidate.name)
44
+ .join(', ');
45
+ throw new Error(`Account "${accountName}" not found or you don't have access. Available accounts: ${availableAccounts}`);
46
+ }
47
+ const { permissions } = account.viewerUserPermission;
48
+ if (!permissions.includes(generated_1.Permission.Admin) && !permissions.includes(generated_1.Permission.Own)) {
49
+ throw billingPermissionError(account.name);
50
+ }
51
+ return account;
52
+ }
53
+ async function resolveBillingAccountAsync({ graphqlClient, actor, accountName, nonInteractive, subscriptionFilter, }) {
54
+ if (accountName) {
55
+ const namedAccount = await resolveNamedAccountAsync(graphqlClient, actor, accountName);
56
+ const account = await getAccountWithSubscriptionAsync(graphqlClient, namedAccount);
57
+ if (subscriptionFilter === 'subscribed' && !(0, plans_1.hasPaidSubscription)(account.subscription)) {
58
+ throw new Error(`Account "${account.name}" does not have an active paid plan. Run eas billing:subscribe to subscribe.`);
59
+ }
60
+ return account;
61
+ }
62
+ const billingAccounts = actor.accounts.filter(account => hasBillingRole(actor, account));
63
+ if (billingAccounts.length === 0) {
64
+ throw new Error('You must be an Owner or Admin of at least one account to manage billing.');
65
+ }
66
+ const accounts = await Promise.all(billingAccounts.map(account => getAccountWithSubscriptionAsync(graphqlClient, account)));
67
+ if (subscriptionFilter === 'unsubscribed' && accounts.length === 1) {
68
+ return accounts[0];
69
+ }
70
+ const subscribedAccounts = accounts.filter(account => (0, plans_1.hasPaidSubscription)(account.subscription));
71
+ const unsubscribedAccounts = accounts.filter(account => !(0, plans_1.hasPaidSubscription)(account.subscription));
72
+ const eligibleAccounts = subscriptionFilter === 'subscribed' ? subscribedAccounts : unsubscribedAccounts;
73
+ if (eligibleAccounts.length === 0) {
74
+ throw new Error(subscriptionFilter === 'subscribed'
75
+ ? 'No available accounts have an active paid plan. Run eas billing:subscribe to subscribe an account.'
76
+ : 'All available accounts already have a paid plan. Run eas billing:manage to change an existing subscription.');
77
+ }
78
+ if (eligibleAccounts.length === 1) {
79
+ return eligibleAccounts[0];
80
+ }
81
+ if (nonInteractive) {
82
+ throw new Error('The --account flag must be provided when running in `--non-interactive` mode and you can manage billing for more than one eligible account.');
83
+ }
84
+ const disabledAccounts = subscriptionFilter === 'unsubscribed' ? subscribedAccounts : [];
85
+ return await (0, prompts_1.selectAsync)('Select an account:', [
86
+ ...eligibleAccounts.map(account => toAccountChoice(account, false)),
87
+ ...disabledAccounts.map(account => toAccountChoice(account, true)),
88
+ ], {
89
+ initial: eligibleAccounts[0],
90
+ warningMessageForDisabledEntries: 'This account already has a paid plan. Run eas billing:manage to change it.',
91
+ });
92
+ }
@@ -21,7 +21,7 @@ interface Builder<TPlatform extends Platform, Credentials, TJob extends BuildJob
21
21
  }
22
22
  export type BuildRequestSender = () => Promise<BuildFragment | undefined>;
23
23
  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): never;
24
+ export declare function handleBuildRequestError(error: any, platform: Platform, accountName?: string): never;
25
25
  export type MaybeBuildFragment = BuildFragment | null;
26
26
  export declare function waitForBuildEndAsync(graphqlClient: ExpoGraphqlClient, { buildIds, accountName }: {
27
27
  buildIds: string[];
@@ -19,6 +19,7 @@ const repository_1 = require("./utils/repository");
19
19
  const AnalyticsManager_1 = require("../analytics/AnalyticsManager");
20
20
  const common_1 = require("../analytics/common");
21
21
  const api_1 = require("../api");
22
+ const plans_1 = require("../billing/plans");
22
23
  const cli_1 = require("../fingerprint/cli");
23
24
  const generated_1 = require("../graphql/generated");
24
25
  const BuildMutation_1 = require("../graphql/mutations/BuildMutation");
@@ -117,7 +118,7 @@ async function prepareBuildRequestForPlatformAsync(builder) {
117
118
  return await sendBuildRequestAsync(builder, job, graphqlMetadata, buildParams);
118
119
  }
119
120
  catch (error) {
120
- handleBuildRequestError(error, job.platform);
121
+ handleBuildRequestError(error, job.platform, ctx.accountName);
121
122
  }
122
123
  }
123
124
  else {
@@ -136,7 +137,7 @@ const SERVER_SIDE_DEFINED_ERRORS = {
136
137
  EAS_BUILD_LEGACY_RESOURCE_CLASS_NOT_AVAILABLE: errors_1.EasBuildLegacyResourceClassNotAvailableError,
137
138
  VALIDATION_ERROR: errors_1.RequestValidationError,
138
139
  };
139
- function handleBuildRequestError(error, platform) {
140
+ function handleBuildRequestError(error, platform, accountName) {
140
141
  logBuildRequestErrorDebugInfo(error);
141
142
  const graphQLErrors = Array.isArray(error?.graphQLErrors)
142
143
  ? error.graphQLErrors
@@ -144,7 +145,12 @@ function handleBuildRequestError(error, platform) {
144
145
  const graphQLErrorCode = graphQLErrors[0]?.extensions?.errorCode;
145
146
  if (graphQLErrorCode && graphQLErrorCode in SERVER_SIDE_DEFINED_ERRORS) {
146
147
  const ErrorClass = SERVER_SIDE_DEFINED_ERRORS[graphQLErrorCode];
147
- throw new ErrorClass(graphQLErrors[0]?.message);
148
+ const message = graphQLErrors[0]?.message;
149
+ const isFreeTierLimitError = graphQLErrorCode === 'EAS_BUILD_FREE_TIER_LIMIT_EXCEEDED' ||
150
+ graphQLErrorCode === 'EAS_BUILD_FREE_TIER_IOS_LIMIT_EXCEEDED';
151
+ throw new ErrorClass(isFreeTierLimitError
152
+ ? `${message}\nRun ${(0, plans_1.formatStarterSubscribeCommand)(accountName)} to upgrade to the Starter plan.`
153
+ : message);
148
154
  }
149
155
  else if (graphQLErrorCode === 'EAS_BUILD_DOWN_FOR_MAINTENANCE') {
150
156
  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.`);
@@ -27,7 +27,7 @@ export declare const EASVariableVisibilityFlag: {
27
27
  };
28
28
  export type EASEnvironmentVariableScopeFlagValue = 'project' | 'account';
29
29
  export declare const EASEnvironmentVariableScopeFlag: {
30
- scope: import("@oclif/core/lib/interfaces").OptionFlag<"project" | "account", import("@oclif/core/lib/interfaces").CustomOptions>;
30
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<"account" | "project", import("@oclif/core/lib/interfaces").CustomOptions>;
31
31
  };
32
32
  export declare const EASNonInteractiveFlag: {
33
33
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -0,0 +1,14 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ export default class BillingManage extends EasCommand {
3
+ static description: string;
4
+ static flags: {
5
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
6
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ account: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ 'no-open': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ };
10
+ static contextDefinition: {
11
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
12
+ };
13
+ runAsync(): Promise<void>;
14
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const billingClient_1 = require("../../billing/billingClient");
6
+ const openUrl_1 = require("../../billing/openUrl");
7
+ const resolveAccount_1 = require("../../billing/resolveAccount");
8
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
9
+ const flags_1 = require("../../commandUtils/flags");
10
+ const ora_1 = require("../../ora");
11
+ const json_1 = require("../../utils/json");
12
+ class BillingManage extends EasCommand_1.default {
13
+ static description = 'manage billing for an account with an active paid EAS plan';
14
+ static flags = {
15
+ account: core_1.Flags.string({
16
+ char: 'a',
17
+ description: 'Account with an active paid plan to manage. Defaults to your account when only one is eligible.',
18
+ }),
19
+ 'no-open': core_1.Flags.boolean({
20
+ description: 'Only print the customer portal URL instead of opening it in a browser',
21
+ }),
22
+ ...flags_1.EasNonInteractiveAndJsonFlags,
23
+ };
24
+ static contextDefinition = {
25
+ ...this.ContextOptions.LoggedIn,
26
+ };
27
+ async runAsync() {
28
+ const { flags } = await this.parse(BillingManage);
29
+ const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
30
+ if (json) {
31
+ (0, json_1.enableJsonOutput)();
32
+ }
33
+ const { loggedIn: { graphqlClient, actor, authenticationInfo }, } = await this.getContextAsync(BillingManage, { nonInteractive });
34
+ const account = await (0, resolveAccount_1.resolveBillingAccountAsync)({
35
+ graphqlClient,
36
+ actor,
37
+ accountName: flags.account,
38
+ nonInteractive,
39
+ subscriptionFilter: 'subscribed',
40
+ });
41
+ const billingClient = new billingClient_1.BillingClient(authenticationInfo);
42
+ const spinner = (0, ora_1.ora)(`Creating a customer portal session for ${account.name}`).start();
43
+ let portalUrl;
44
+ try {
45
+ const { url } = await billingClient.createCustomerPortalSessionAsync(account.id);
46
+ portalUrl = url;
47
+ spinner.succeed(`Created a customer portal session for ${account.name}`);
48
+ }
49
+ catch (error) {
50
+ spinner.fail('Failed to create a customer portal session');
51
+ throw error;
52
+ }
53
+ if (json) {
54
+ (0, json_1.printJsonOnlyOutput)({ customerPortalUrl: portalUrl });
55
+ return;
56
+ }
57
+ await (0, openUrl_1.openOrPrintUrlAsync)(portalUrl, {
58
+ label: 'Customer portal',
59
+ open: !flags['no-open'] && !nonInteractive,
60
+ });
61
+ }
62
+ }
63
+ exports.default = BillingManage;
@@ -0,0 +1,18 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ export default class BillingSubscribe extends EasCommand {
3
+ static description: string;
4
+ static args: {
5
+ PLAN: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
+ };
7
+ static flags: {
8
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ account: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
+ 'no-open': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ static contextDefinition: {
14
+ analytics: import("../../commandUtils/context/AnalyticsContextField").default;
15
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
16
+ };
17
+ runAsync(): Promise<void>;
18
+ }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const AnalyticsManager_1 = require("../../analytics/AnalyticsManager");
6
+ const billingClient_1 = require("../../billing/billingClient");
7
+ const openUrl_1 = require("../../billing/openUrl");
8
+ const plans_1 = require("../../billing/plans");
9
+ const resolveAccount_1 = require("../../billing/resolveAccount");
10
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
11
+ const flags_1 = require("../../commandUtils/flags");
12
+ const log_1 = tslib_1.__importDefault(require("../../log"));
13
+ const ora_1 = require("../../ora");
14
+ const prompts_1 = require("../../prompts");
15
+ const json_1 = require("../../utils/json");
16
+ class BillingSubscribe extends EasCommand_1.default {
17
+ static description = 'subscribe a Free account to an EAS plan';
18
+ static args = {
19
+ PLAN: core_1.Args.string({
20
+ description: 'plan to subscribe to. Required in non-interactive mode.',
21
+ required: false,
22
+ options: [...plans_1.PLAN_SLUGS],
23
+ }),
24
+ };
25
+ static flags = {
26
+ account: core_1.Flags.string({
27
+ char: 'a',
28
+ description: 'Account to subscribe. Defaults to your account when you only have one.',
29
+ }),
30
+ 'no-open': core_1.Flags.boolean({
31
+ description: 'Only print the checkout page URL instead of opening it in a browser',
32
+ }),
33
+ ...flags_1.EasNonInteractiveAndJsonFlags,
34
+ };
35
+ static contextDefinition = {
36
+ ...this.ContextOptions.LoggedIn,
37
+ ...this.ContextOptions.Analytics,
38
+ };
39
+ async runAsync() {
40
+ const { args: { PLAN }, flags, } = await this.parse(BillingSubscribe);
41
+ const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
42
+ if (json) {
43
+ (0, json_1.enableJsonOutput)();
44
+ }
45
+ let planSlug = PLAN;
46
+ const { analytics, loggedIn: { graphqlClient, actor, authenticationInfo }, } = await this.getContextAsync(BillingSubscribe, { nonInteractive });
47
+ const account = await (0, resolveAccount_1.resolveBillingAccountAsync)({
48
+ graphqlClient,
49
+ actor,
50
+ accountName: flags.account,
51
+ nonInteractive,
52
+ subscriptionFilter: 'unsubscribed',
53
+ });
54
+ const analyticsProperties = {
55
+ account_id: account.id,
56
+ json,
57
+ non_interactive: nonInteractive,
58
+ };
59
+ const { subscription } = account;
60
+ if ((0, plans_1.hasPaidSubscription)(subscription)) {
61
+ analytics.logEvent(AnalyticsManager_1.BillingEvent.SUBSCRIBE_COMMAND, {
62
+ ...analyticsProperties,
63
+ already_subscribed: true,
64
+ });
65
+ if (json) {
66
+ (0, json_1.printJsonOnlyOutput)({
67
+ alreadySubscribed: true,
68
+ currentPlan: subscription?.name ?? null,
69
+ });
70
+ return;
71
+ }
72
+ log_1.default.warn(`Account ${account.name} is already subscribed${subscription?.name ? ` to the ${subscription.name} plan` : ''}.`);
73
+ log_1.default.log('To change or cancel your plan, run eas billing:manage.');
74
+ return;
75
+ }
76
+ if (!planSlug && nonInteractive) {
77
+ throw new Error('The plan argument is required in non-interactive mode.');
78
+ }
79
+ if (!planSlug) {
80
+ planSlug = await (0, prompts_1.selectAsync)('Select a plan:', plans_1.PLAN_SLUGS.map(slug => ({
81
+ title: plans_1.SUBSCRIBABLE_PLANS[slug].label,
82
+ value: slug,
83
+ })));
84
+ }
85
+ const plan = plans_1.SUBSCRIBABLE_PLANS[planSlug];
86
+ analytics.logEvent(AnalyticsManager_1.BillingEvent.SUBSCRIBE_COMMAND, {
87
+ ...analyticsProperties,
88
+ already_subscribed: false,
89
+ plan: planSlug,
90
+ });
91
+ const billingClient = new billingClient_1.BillingClient(authenticationInfo);
92
+ const spinner = (0, ora_1.ora)(`Creating a checkout session for the ${plan.label} plan`).start();
93
+ let checkoutUrl;
94
+ try {
95
+ const session = await billingClient.createCheckoutSessionAsync(account.id, plan.planType);
96
+ if (!session.url) {
97
+ throw new Error('The checkout session did not include a URL.');
98
+ }
99
+ checkoutUrl = session.url;
100
+ spinner.succeed(`Created a checkout session for the ${plan.label} plan`);
101
+ }
102
+ catch (error) {
103
+ spinner.fail('Failed to create a checkout session');
104
+ throw error;
105
+ }
106
+ if (json) {
107
+ (0, json_1.printJsonOnlyOutput)({ checkoutUrl, alreadySubscribed: false });
108
+ return;
109
+ }
110
+ log_1.default.log(`Complete your subscription to the ${plan.label} plan for ${account.name} in Stripe checkout.`);
111
+ await (0, openUrl_1.openOrPrintUrlAsync)(checkoutUrl, {
112
+ label: 'Checkout page',
113
+ open: !flags['no-open'] && !nonInteractive,
114
+ });
115
+ }
116
+ }
117
+ exports.default = BillingSubscribe;
@@ -8,7 +8,7 @@ export default class EnvCreate extends EasCommand {
8
8
  static flags: {
9
9
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
10
  environment: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
- scope: import("@oclif/core/lib/interfaces").OptionFlag<"project" | "account", import("@oclif/core/lib/interfaces").CustomOptions>;
11
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<"account" | "project", import("@oclif/core/lib/interfaces").CustomOptions>;
12
12
  visibility: import("@oclif/core/lib/interfaces").OptionFlag<"plaintext" | "sensitive" | "secret" | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
13
  name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
14
14
  value: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
@@ -3,7 +3,7 @@ export default class EnvDelete extends EasCommand {
3
3
  static description: string;
4
4
  static flags: {
5
5
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
6
- scope: import("@oclif/core/lib/interfaces").OptionFlag<"project" | "account", import("@oclif/core/lib/interfaces").CustomOptions>;
6
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<"account" | "project", import("@oclif/core/lib/interfaces").CustomOptions>;
7
7
  'variable-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
8
  'variable-environment': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
9
  };
@@ -10,7 +10,7 @@ export default class EnvGet extends EasCommand {
10
10
  };
11
11
  static flags: {
12
12
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
- scope: import("@oclif/core/lib/interfaces").OptionFlag<"project" | "account", import("@oclif/core/lib/interfaces").CustomOptions>;
13
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<"account" | "project", import("@oclif/core/lib/interfaces").CustomOptions>;
14
14
  format: import("@oclif/core/lib/interfaces").OptionFlag<"long" | "short", import("@oclif/core/lib/interfaces").CustomOptions>;
15
15
  'variable-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
16
16
  'variable-environment': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
@@ -6,7 +6,7 @@ export default class EnvList extends EasCommand {
6
6
  projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
7
7
  };
8
8
  static flags: {
9
- scope: import("@oclif/core/lib/interfaces").OptionFlag<"project" | "account", import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<"account" | "project", import("@oclif/core/lib/interfaces").CustomOptions>;
10
10
  format: import("@oclif/core/lib/interfaces").OptionFlag<"long" | "short", import("@oclif/core/lib/interfaces").CustomOptions>;
11
11
  environment: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
12
  'include-sensitive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -8,7 +8,7 @@ export default class EnvSet extends EasCommand {
8
8
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
9
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
10
  environment: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
- scope: import("@oclif/core/lib/interfaces").OptionFlag<"project" | "account", import("@oclif/core/lib/interfaces").CustomOptions>;
11
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<"account" | "project", import("@oclif/core/lib/interfaces").CustomOptions>;
12
12
  visibility: import("@oclif/core/lib/interfaces").OptionFlag<"plaintext" | "sensitive" | "secret" | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
13
13
  name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
14
14
  value: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
@@ -5,7 +5,7 @@ export default class EnvUpdate extends EasCommand {
5
5
  static flags: {
6
6
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
7
  environment: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
- scope: import("@oclif/core/lib/interfaces").OptionFlag<"project" | "account", import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ scope: import("@oclif/core/lib/interfaces").OptionFlag<"account" | "project", import("@oclif/core/lib/interfaces").CustomOptions>;
9
9
  visibility: import("@oclif/core/lib/interfaces").OptionFlag<"plaintext" | "sensitive" | "secret" | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
10
  'variable-name': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
11
  'variable-environment': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
@@ -1,5 +1,4 @@
1
1
  import EasCommand from '../commandUtils/EasCommand';
2
- export declare function detectProjectSdkVersionAsync(projectDir: string): Promise<string | undefined>;
3
2
  export declare function toRepackTargetSdkVersion(sdkVersion: string | undefined): string | undefined;
4
3
  export default class Go extends EasCommand {
5
4
  static description: string;