eas-cli 24.14.0 → 25.1.1

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 (39) hide show
  1. package/README.md +208 -158
  2. package/build/billing/resolveAccount.js +38 -14
  3. package/build/build/utils/url.d.ts +1 -0
  4. package/build/build/utils/url.js +4 -0
  5. package/build/commandUtils/EasCommand.js +11 -5
  6. package/build/commandUtils/context/contextUtils/getProjectIdAsync.js +1 -1
  7. package/build/commandUtils/new/configs.d.ts +2 -2
  8. package/build/commandUtils/new/configs.js +8 -20
  9. package/build/commandUtils/usageUtils.d.ts +14 -0
  10. package/build/commandUtils/usageUtils.js +40 -2
  11. package/build/commands/account/usage.js +55 -2
  12. package/build/commands/account/view.d.ts +6 -1
  13. package/build/commands/account/view.js +38 -8
  14. package/build/commands/simulator/get.js +5 -2
  15. package/build/commands/simulator/index.d.ts +3 -0
  16. package/build/commands/simulator/index.js +37 -2
  17. package/build/easSelect.d.ts +30 -0
  18. package/build/easSelect.js +57 -0
  19. package/build/graphql/generated.d.ts +370 -946
  20. package/build/graphql/generated.js +5 -74
  21. package/build/graphql/queries/AccountQuery.js +27 -1
  22. package/build/graphql/queries/DeviceRunSessionQuery.js +1 -0
  23. package/build/graphql/types/Account.js +8 -2
  24. package/build/project/accountSelection.d.ts +2 -3
  25. package/build/project/accountSelection.js +12 -15
  26. package/build/project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync.js +4 -4
  27. package/build/project/projectInitialization.js +7 -6
  28. package/build/prompts.d.ts +2 -1
  29. package/build/prompts.js +2 -0
  30. package/build/simulator/frameAncestors.d.ts +9 -0
  31. package/build/simulator/frameAncestors.js +66 -0
  32. package/build/simulator/utils.d.ts +20 -5
  33. package/build/simulator/utils.js +105 -20
  34. package/build/user/User.d.ts +17 -1
  35. package/build/user/User.js +37 -2
  36. package/build/user/roles.d.ts +6 -0
  37. package/build/user/roles.js +35 -0
  38. package/oclif.manifest.json +23 -3
  39. package/package.json +6 -6
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveBillingAccountAsync = resolveBillingAccountAsync;
4
+ const tslib_1 = require("tslib");
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
4
6
  const generated_1 = require("../graphql/generated");
5
7
  const AccountQuery_1 = require("../graphql/queries/AccountQuery");
6
8
  const plans_1 = require("./plans");
@@ -8,12 +10,36 @@ const prompts_1 = require("../prompts");
8
10
  function billingPermissionError(accountName) {
9
11
  return new Error(`You must be an Owner or Admin of account "${accountName}" to manage billing.`);
10
12
  }
11
- function hasBillingRole(actor, account) {
12
- if (account.ownerUserActor?.id === actor.id) {
13
- return true;
13
+ /**
14
+ * @param accounts which accounts the viewer is an Owner or Admin of, e.g. `account "name"`
15
+ */
16
+ function scopedCredentialBillingPermissionError(accounts) {
17
+ return new Error(`You are an Owner or Admin of ${accounts}, but the permissions granted during authentication do not allow you to manage billing. Run ${chalk_1.default.bold('eas whoami')} to check your permission grant, and ${chalk_1.default.bold('eas login')} to change it.`);
18
+ }
19
+ function hasBillingPermission(permissions) {
20
+ return permissions.includes(generated_1.Permission.Admin) || permissions.includes(generated_1.Permission.Own);
21
+ }
22
+ /**
23
+ * Whether the viewer can manage billing on the account with the credential used for this command.
24
+ * The scopes of a scoped credential cap `effectivePermissions`.
25
+ */
26
+ function canManageBilling(account) {
27
+ return hasBillingPermission(account.viewerUserPermission2.effectivePermissions);
28
+ }
29
+ /**
30
+ * Whether the viewer's role on the account allows billing, regardless of the scopes of the
31
+ * credential used for this command.
32
+ */
33
+ function hasBillingRole(account) {
34
+ return hasBillingPermission(account.viewerUserPermission2.permissions);
35
+ }
36
+ function assertCanManageBilling(account) {
37
+ if (canManageBilling(account)) {
38
+ return;
14
39
  }
15
- const { role } = account.viewerUserPermission;
16
- return role === generated_1.Role.Admin || role === generated_1.Role.Owner || role === generated_1.Role.HasAdmin;
40
+ throw hasBillingRole(account)
41
+ ? scopedCredentialBillingPermissionError(`account "${account.name}"`)
42
+ : billingPermissionError(account.name);
17
43
  }
18
44
  async function getAccountWithSubscriptionAsync(graphqlClient, account) {
19
45
  const subscription = await AccountQuery_1.AccountQuery.getSubscriptionAsync(graphqlClient, account.id);
@@ -31,23 +57,18 @@ function toAccountChoice(account, disabled) {
31
57
  async function resolveNamedAccountAsync(graphqlClient, actor, accountName) {
32
58
  const ownAccount = actor.accounts.find(account => account.name === accountName);
33
59
  if (ownAccount) {
34
- if (!hasBillingRole(actor, ownAccount)) {
35
- throw billingPermissionError(ownAccount.name);
36
- }
60
+ assertCanManageBilling(ownAccount);
37
61
  return ownAccount;
38
62
  }
39
63
  const account = await AccountQuery_1.AccountQuery.getByNameAsync(graphqlClient, accountName).catch(() => null);
40
64
  if (!account) {
41
65
  const availableAccounts = actor.accounts
42
- .filter(candidate => hasBillingRole(actor, candidate))
66
+ .filter(canManageBilling)
43
67
  .map(candidate => candidate.name)
44
68
  .join(', ');
45
69
  throw new Error(`Account "${accountName}" not found or you don't have access. Available accounts: ${availableAccounts}`);
46
70
  }
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
- }
71
+ assertCanManageBilling(account);
51
72
  return account;
52
73
  }
53
74
  async function resolveBillingAccountAsync({ graphqlClient, actor, accountName, nonInteractive, subscriptionFilter, }) {
@@ -59,8 +80,11 @@ async function resolveBillingAccountAsync({ graphqlClient, actor, accountName, n
59
80
  }
60
81
  return account;
61
82
  }
62
- const billingAccounts = actor.accounts.filter(account => hasBillingRole(actor, account));
83
+ const billingAccounts = actor.accounts.filter(canManageBilling);
63
84
  if (billingAccounts.length === 0) {
85
+ if (actor.accounts.some(hasBillingRole)) {
86
+ throw scopedCredentialBillingPermissionError('at least one account');
87
+ }
64
88
  throw new Error('You must be an Owner or Admin of at least one account to manage billing.');
65
89
  }
66
90
  const accounts = await Promise.all(billingAccounts.map(account => getAccountWithSubscriptionAsync(graphqlClient, account)));
@@ -8,6 +8,7 @@ export declare function getUpdateGroupUrl(accountName: string, projectName: stri
8
8
  export declare function getSubmissionUrl(accountName: string, projectName: string, submissionId: string): string;
9
9
  export declare function getWorkflowRunUrl(accountName: string, projectName: string, workflowRunId: string): string;
10
10
  export declare function getDeviceRunSessionUrl(accountName: string, projectName: string, deviceRunSessionId: string): string;
11
+ export declare function getDeviceRunSessionPreviewUrl(accountName: string, projectName: string, deviceRunSessionId: string): string;
11
12
  /**
12
13
  * @deprecated Links to the raw job-run page; prefer a higher-level URL (e.g. the workflow run
13
14
  * or the feature-specific dashboard) that gives users more context. Use this only for internal
@@ -9,6 +9,7 @@ exports.getUpdateGroupUrl = getUpdateGroupUrl;
9
9
  exports.getSubmissionUrl = getSubmissionUrl;
10
10
  exports.getWorkflowRunUrl = getWorkflowRunUrl;
11
11
  exports.getDeviceRunSessionUrl = getDeviceRunSessionUrl;
12
+ exports.getDeviceRunSessionPreviewUrl = getDeviceRunSessionPreviewUrl;
12
13
  exports.getBareJobRunUrl = getBareJobRunUrl;
13
14
  exports.getProjectGitHubSettingsUrl = getProjectGitHubSettingsUrl;
14
15
  exports.getHostingDeploymentsUrl = getHostingDeploymentsUrl;
@@ -50,6 +51,9 @@ function getWorkflowRunUrl(accountName, projectName, workflowRunId) {
50
51
  function getDeviceRunSessionUrl(accountName, projectName, deviceRunSessionId) {
51
52
  return new URL(`/accounts/${encodeURIComponent(accountName)}/projects/${encodeURIComponent(projectName)}/simulator-sessions/${encodeURIComponent(deviceRunSessionId)}`, (0, api_1.getExpoWebsiteBaseUrl)()).toString();
52
53
  }
54
+ function getDeviceRunSessionPreviewUrl(accountName, projectName, deviceRunSessionId) {
55
+ return `${getDeviceRunSessionUrl(accountName, projectName, deviceRunSessionId)}/preview`;
56
+ }
53
57
  /**
54
58
  * @deprecated Links to the raw job-run page; prefer a higher-level URL (e.g. the workflow run
55
59
  * or the feature-specific dashboard) that gives users more context. Use this only for internal
@@ -197,12 +197,18 @@ class EasCommand extends core_1.Command {
197
197
  : '';
198
198
  const defaultMsg = `${messageLine}${requestIdLine}`;
199
199
  if (graphQLError.extensions?.errorCode === 'UNAUTHORIZED_ERROR') {
200
- if (defaultMsg.includes('ScopedAccountActorViewerContext') && process.env.EAS_BUILD) {
201
- // We're in EAS, authenticated with a scoped account actor access token.
202
- // We may have not added the scoped actor privacy rule to the right place yet.
203
- return `${chalk_1.default.bold(`You don't have the required permissions to perform this operation.`)}\n\nWe are in the process of migrating EAS to a more granular permissioning system. If you believe what you're doing is a legitimate operation you should be able to perform, report this to us at ${(0, log_1.link)('https://expo.dev/contact')}\n\nOriginal error message: ${defaultMsg}`;
200
+ if (defaultMsg.includes('ScopedAccountActorViewerContext')) {
201
+ if (process.env.EAS_BUILD) {
202
+ // We're within an EAS job, authenticated with our minted scoped account actor access token.
203
+ // There's a chance that this operation should be allowed, so we want to provide a way for the user to report this to us.
204
+ return `${chalk_1.default.bold(`You don't have the required permissions to perform this operation.`)}\n\nWe are in the process of migrating EAS to a more granular permissioning system. If you believe what you're doing is a legitimate operation you should be able to perform, report this to us at ${(0, log_1.link)('https://expo.dev/contact')}\n\nOriginal error message: ${defaultMsg}`;
205
+ }
206
+ else {
207
+ // We're not in EAS, authenticated with a scoped account actor access token.
208
+ return `${chalk_1.default.bold(`You don't have the required permissions to perform this operation.`)}\n\nThis can sometimes happen if you are logged in as incorrect user or if the permissions granted during authentication are insufficient to perform the operation.\nRun ${chalk_1.default.bold('eas whoami')} to check the user you are logged in as and your permission grant.\nRun ${chalk_1.default.bold('eas login')} to change the user or permission grant.\n\nOriginal error message: ${defaultMsg}`;
209
+ }
204
210
  }
205
- return `${chalk_1.default.bold(`You don't have the required permissions to perform this operation.`)}\n\nThis can sometimes happen if you are logged in as incorrect user.\nRun ${chalk_1.default.bold('eas whoami')} to check the username you are logged in as.\nRun ${chalk_1.default.bold('eas login')} to change the account.\n\nOriginal error message: ${defaultMsg}`;
211
+ return `${chalk_1.default.bold(`You don't have the required permissions to perform this operation.`)}\n\nThis can sometimes happen if you are logged in as incorrect user.\nRun ${chalk_1.default.bold('eas whoami')} to check the user you are logged in as.\nRun ${chalk_1.default.bold('eas login')} to change users.\n\nOriginal error message: ${defaultMsg}`;
206
212
  }
207
213
  return defaultMsg;
208
214
  })
@@ -151,7 +151,7 @@ async function chooseAccountNameForEASProjectAsync(exp, actor, options) {
151
151
  if (options.nonInteractive) {
152
152
  throw (0, projectNotConfiguredError_1.getUnconfiguredProjectError)({ actor });
153
153
  }
154
- const choices = (0, accountSelection_1.getAccountChoices)(actor, (0, accountSelection_1.getAccountNamesWhereUserHasSufficientPermissionsToCreateApp)(actor));
154
+ const choices = (0, accountSelection_1.getAccountChoices)(actor);
155
155
  return (await (0, prompts_1.promptAsync)({
156
156
  type: 'select',
157
157
  name: 'account',
@@ -1,4 +1,4 @@
1
- import { Choice } from '../../prompts';
1
+ import { SelectChoice } from '../../prompts';
2
2
  import { Actor } from '../../user/User';
3
3
  import { ExpoGraphqlClient } from '../context/contextUtils/createGraphqlClient';
4
4
  export declare function generateProjectConfigAsync(pathArg: string | undefined, options: {
@@ -9,7 +9,7 @@ export declare function generateProjectConfigAsync(pathArg: string | undefined,
9
9
  projectDirectory: string;
10
10
  }>;
11
11
  export declare function promptForProjectAccountAsync(actor: Actor): Promise<string>;
12
- export declare function getAccountChoices(actor: Actor, permissionsMap?: Map<string, boolean>): Choice[];
12
+ export declare function getAccountChoices(actor: Actor): SelectChoice[];
13
13
  /**
14
14
  * Finds an available project name that doesn't conflict with either:
15
15
  * Local filesystem (directory already exists)
@@ -9,10 +9,10 @@ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
9
9
  const nanoid_1 = require("nanoid");
10
10
  const path_1 = tslib_1.__importDefault(require("path"));
11
11
  const utils_1 = require("./utils");
12
- const generated_1 = require("../../graphql/generated");
13
12
  const log_1 = tslib_1.__importDefault(require("../../log"));
14
13
  const fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync_1 = require("../../project/fetchOrCreateProjectIDForWriteToConfigWithConfirmationAsync");
15
14
  const prompts_1 = require("../../prompts");
15
+ const User_1 = require("../../user/User");
16
16
  function validateProjectPath(resolvedPath) {
17
17
  const normalizedPath = path_1.default.normalize(resolvedPath);
18
18
  // Check for path traversal attempts
@@ -52,34 +52,25 @@ async function generateProjectConfigAsync(pathArg, options) {
52
52
  projectDirectory,
53
53
  };
54
54
  }
55
- function getAccountPermissionsMap(actor) {
56
- const permissionsMap = new Map();
57
- for (const account of actor.accounts) {
58
- const hasPermission = account.viewerUserPermission.role !== generated_1.Role.ViewOnly;
59
- permissionsMap.set(account.name, hasPermission);
60
- }
61
- return permissionsMap;
62
- }
63
55
  async function promptForProjectAccountAsync(actor) {
64
- const permissionsMap = getAccountPermissionsMap(actor);
65
56
  // If only one account, use it (if has permissions)
66
57
  if (actor.accounts.length === 1) {
67
58
  const account = actor.accounts[0];
68
- if (permissionsMap.get(account.name)) {
59
+ const reason = (0, User_1.getCannotCreateProjectsOnAccountReason)(account);
60
+ if (!reason) {
69
61
  return account.name;
70
62
  }
71
- throw new Error(`You don't have permission to create projects on your only available account (${account.name}).`);
63
+ throw new Error(`You can't create projects on your only available account (${account.name}). ${reason}`);
72
64
  }
73
65
  // Multiple accounts - prompt user to select one with permissions
74
66
  return (await (0, prompts_1.promptAsync)({
75
67
  type: 'select',
76
68
  name: 'account',
77
69
  message: 'Which account should own this project?',
78
- choices: getAccountChoices(actor, permissionsMap),
70
+ choices: getAccountChoices(actor),
79
71
  })).account.name;
80
72
  }
81
- function getAccountChoices(actor, permissionsMap) {
82
- const permissions = permissionsMap ?? getAccountPermissionsMap(actor);
73
+ function getAccountChoices(actor) {
83
74
  const sortedAccounts = [...actor.accounts].sort((a, _b) => (a.ownerUserActor ? 1 : -1));
84
75
  return sortedAccounts.map(account => {
85
76
  const isPersonalAccount = !!account.ownerUserActor && account.ownerUserActor.id === actor.id;
@@ -89,14 +80,11 @@ function getAccountChoices(actor, permissionsMap) {
89
80
  : isTeamAccount
90
81
  ? `${account.name} (Limited - Team Account)`
91
82
  : account.name;
92
- const disabled = !permissions.get(account.name);
83
+ const disabledReason = (0, User_1.getCannotCreateProjectsOnAccountReason)(account);
93
84
  return {
94
85
  title: accountDisplayName,
95
86
  value: { name: account.name },
96
- ...(disabled && {
97
- disabled: true,
98
- description: 'You do not have the required permissions to create projects on this account.',
99
- }),
87
+ ...(disabledReason && { disabled: true, disabledReason }),
100
88
  };
101
89
  });
102
90
  }
@@ -8,6 +8,19 @@ export interface UsageMetricDisplay {
8
8
  overageValue: number;
9
9
  overageCost: number;
10
10
  unit?: string;
11
+ maxDecimals?: number;
12
+ }
13
+ export interface SimulatorJobTypeBreakdown {
14
+ workflows: number;
15
+ simulator: number;
16
+ other: number;
17
+ }
18
+ export interface SimulatorUsageDisplay {
19
+ minutes: UsageMetricDisplay;
20
+ iosMinutes: number;
21
+ androidMinutes: number;
22
+ jobTypeBreakdown?: SimulatorJobTypeBreakdown;
23
+ overageCostCents: number;
11
24
  }
12
25
  export interface BuildOverageByWorkerSize {
13
26
  platform: AppPlatform;
@@ -40,6 +53,7 @@ export interface UsageDisplayData {
40
53
  bandwidth: UsageMetricDisplay;
41
54
  overageCostCents: number;
42
55
  };
56
+ simulator?: SimulatorUsageDisplay;
43
57
  totalOverageCostCents: number;
44
58
  estimatedBillCents: number;
45
59
  recurringCents: number | null;
@@ -50,7 +50,7 @@ function calculateBillingPeriodDays(startDate, endDate) {
50
50
  }
51
51
  function extractUsageData(data) {
52
52
  const { name, subscription, billingPeriod, usageMetrics } = data;
53
- const { EAS_BUILD, EAS_UPDATE, MEDIUM_ANDROID_BUILDS, LARGE_ANDROID_BUILDS, MEDIUM_IOS_BUILDS, LARGE_IOS_BUILDS, } = usageMetrics;
53
+ const { EAS_BUILD, EAS_UPDATE, MEDIUM_ANDROID_BUILDS, LARGE_ANDROID_BUILDS, MEDIUM_IOS_BUILDS, LARGE_IOS_BUILDS, EAS_SIMULATOR, IOS_SIMULATOR_MINUTES, ANDROID_SIMULATOR_MINUTES, } = usageMetrics;
54
54
  // Find build metrics
55
55
  const buildMetric = EAS_BUILD.planMetrics.find(m => m.serviceMetric === generated_1.EasServiceMetric.Builds && m.metricType === generated_1.UsageMetricType.Build);
56
56
  // Extract build counts by platform and worker size
@@ -118,9 +118,11 @@ function extractUsageData(data) {
118
118
  const bandwidthPlanValue = bandwidthMetric?.value ?? 0;
119
119
  const bandwidthOverageValue = bandwidthOverage?.value ?? 0;
120
120
  const bandwidthLimit = bandwidthMetric?.limit ?? 0;
121
+ const simulator = extractSimulatorUsage(EAS_SIMULATOR, IOS_SIMULATOR_MINUTES?.[0]?.value ?? 0, ANDROID_SIMULATOR_MINUTES?.[0]?.value ?? 0);
121
122
  const buildOverageCostCents = EAS_BUILD.totalCost;
122
123
  const updateOverageCostCents = EAS_UPDATE.totalCost;
123
- const totalOverageCostCents = buildOverageCostCents + updateOverageCostCents;
124
+ const simulatorOverageCostCents = simulator?.overageCostCents ?? 0;
125
+ const totalOverageCostCents = buildOverageCostCents + updateOverageCostCents + simulatorOverageCostCents;
124
126
  // Calculate total overage count for display
125
127
  const totalOverageBuilds = overagesByWorkerSize.reduce((sum, o) => sum + o.count, 0);
126
128
  return {
@@ -187,11 +189,47 @@ function extractUsageData(data) {
187
189
  },
188
190
  overageCostCents: updateOverageCostCents,
189
191
  },
192
+ simulator,
190
193
  totalOverageCostCents,
191
194
  estimatedBillCents: (subscription?.recurringCents ?? 0) + totalOverageCostCents,
192
195
  recurringCents: subscription?.recurringCents ?? null,
193
196
  };
194
197
  }
198
+ // Accounts without EAS Simulator get no SIMULATOR_USAGE plan metric, so the section is hidden.
199
+ // On the Free plan the metric is the minute pool shared with Workflows, split by jobTypeBreakdown.
200
+ function extractSimulatorUsage(simulatorTotal, iosMinutes, androidMinutes) {
201
+ if (simulatorTotal.unavailableServiceUsageMetrics.some(metric => metric.service === generated_1.EasService.Simulator)) {
202
+ throw new Error('Simulator usage is temporarily unavailable, so the bill cannot be estimated. Try again in a few minutes.');
203
+ }
204
+ const planMetric = simulatorTotal.planMetrics.find(m => m.serviceMetric === generated_1.EasServiceMetric.SimulatorUsage);
205
+ if (!planMetric) {
206
+ return undefined;
207
+ }
208
+ const overage = simulatorTotal.overageMetrics.find(m => m.serviceMetric === generated_1.EasServiceMetric.SimulatorUsage);
209
+ const jobTypeBreakdown = planMetric.jobTypeBreakdown
210
+ ? {
211
+ workflows: planMetric.jobTypeBreakdown.workflows,
212
+ simulator: planMetric.jobTypeBreakdown.simulator,
213
+ other: planMetric.jobTypeBreakdown.other,
214
+ }
215
+ : undefined;
216
+ return {
217
+ minutes: {
218
+ name: jobTypeBreakdown ? 'CI/CD and Simulator minutes' : 'Simulator minutes',
219
+ planValue: planMetric.value,
220
+ limit: planMetric.limit,
221
+ percentUsed: (0, checkForOverages_1.calculatePercentUsed)(planMetric.value, planMetric.limit),
222
+ overageValue: overage?.value ?? 0,
223
+ overageCost: overage?.totalCost ?? 0,
224
+ unit: 'minutes',
225
+ maxDecimals: 1,
226
+ },
227
+ iosMinutes,
228
+ androidMinutes,
229
+ jobTypeBreakdown,
230
+ overageCostCents: simulatorTotal.totalCost,
231
+ };
232
+ }
195
233
  function calculateBillingPeriodInfo(data) {
196
234
  const daysElapsed = calculateDaysElapsed(data.billingPeriod.start);
197
235
  const totalDays = calculateBillingPeriodDays(data.billingPeriod.start, data.billingPeriod.end);
@@ -49,10 +49,17 @@ function displayBandwidthMetric(metric, indent = ' ') {
49
49
  log_1.default.log(`${indent}${metric.name} (additional usage): ${chalk_1.default.red(formatBytesDisplay(metric.overageValue))} (${(0, usageUtils_1.formatCurrency)(metric.overageCost)})`);
50
50
  }
51
51
  }
52
+ function formatMetricValue(value, maxDecimals) {
53
+ return value.toLocaleString(undefined, { maximumFractionDigits: maxDecimals });
54
+ }
55
+ function formatMinutes(minutes) {
56
+ return `${formatMetricValue(minutes, 1)} minutes`;
57
+ }
52
58
  function displayMetric(metric, indent = ' ') {
53
59
  const progressBar = (0, checkForOverages_1.createProgressBar)(metric.percentUsed, 20);
54
60
  const percentStr = `${metric.percentUsed}%`;
55
- const planUsageStr = `${(0, usageUtils_1.formatNumber)(metric.planValue)}/${(0, usageUtils_1.formatNumber)(metric.limit)} ${metric.unit ?? ''}`;
61
+ const maxDecimals = metric.maxDecimals ?? 0;
62
+ const planUsageStr = `${formatMetricValue(metric.planValue, maxDecimals)}/${formatMetricValue(metric.limit, maxDecimals)} ${metric.unit ?? ''}`;
56
63
  let color = chalk_1.default.green;
57
64
  if (metric.percentUsed >= 100) {
58
65
  color = chalk_1.default.red;
@@ -63,7 +70,26 @@ function displayMetric(metric, indent = ' ') {
63
70
  log_1.default.log(`${indent}${metric.name} (plan): ${color(planUsageStr)}`);
64
71
  log_1.default.log(`${indent}${progressBar} ${color(percentStr)}`);
65
72
  if (metric.overageValue > 0) {
66
- log_1.default.log(`${indent}${metric.name} (additional usage): ${chalk_1.default.red(`${(0, usageUtils_1.formatNumber)(metric.overageValue)} ${metric.unit ?? ''}`)} (${(0, usageUtils_1.formatCurrency)(metric.overageCost)})`);
73
+ log_1.default.log(`${indent}${metric.name} (additional usage): ${chalk_1.default.red(`${formatMetricValue(metric.overageValue, maxDecimals)} ${metric.unit ?? ''}`)} (${(0, usageUtils_1.formatCurrency)(metric.overageCost)})`);
74
+ }
75
+ }
76
+ function displaySimulatorUsage(simulator) {
77
+ log_1.default.newLine();
78
+ log_1.default.log(chalk_1.default.bold.underline('EAS Simulator'));
79
+ displayMetric(simulator.minutes);
80
+ if (simulator.jobTypeBreakdown) {
81
+ const { workflows, simulator: simulatorMinutes, other } = simulator.jobTypeBreakdown;
82
+ log_1.default.log(' Breakdown by job type:');
83
+ log_1.default.log(` Workflows: ${formatMinutes(workflows)}`);
84
+ log_1.default.log(` Simulator: ${formatMinutes(simulatorMinutes)}`);
85
+ if (other > 0) {
86
+ log_1.default.log(` Other jobs: ${formatMinutes(other)}`);
87
+ }
88
+ }
89
+ if (simulator.iosMinutes > 0 || simulator.androidMinutes > 0) {
90
+ log_1.default.log(' Simulator minutes by platform:');
91
+ log_1.default.log(` iOS: ${formatMinutes(simulator.iosMinutes)}`);
92
+ log_1.default.log(` Android: ${formatMinutes(simulator.androidMinutes)}`);
67
93
  }
68
94
  }
69
95
  function billingUrl(accountName) {
@@ -101,6 +127,9 @@ function displayUsage(data, usageData) {
101
127
  log_1.default.log(chalk_1.default.bold.underline('EAS Update'));
102
128
  displayMetric(data.updates.mau);
103
129
  displayBandwidthMetric(data.updates.bandwidth);
130
+ if (data.simulator) {
131
+ displaySimulatorUsage(data.simulator);
132
+ }
104
133
  log_1.default.newLine();
105
134
  log_1.default.log(chalk_1.default.bold.underline('Billing'));
106
135
  const upcomingInvoice = subscription?.upcomingInvoice;
@@ -142,6 +171,9 @@ function displayUsage(data, usageData) {
142
171
  if (data.updates.overageCostCents > 0) {
143
172
  log_1.default.log(` Updates: ${(0, usageUtils_1.formatCurrency)(data.updates.overageCostCents)}`);
144
173
  }
174
+ if (data.simulator && data.simulator.overageCostCents > 0) {
175
+ log_1.default.log(` Simulator: ${(0, usageUtils_1.formatCurrency)(data.simulator.overageCostCents)}`);
176
+ }
145
177
  }
146
178
  log_1.default.log(` Estimated bill: ${chalk_1.default.bold((0, usageUtils_1.formatCurrency)(data.estimatedBillCents))}`);
147
179
  }
@@ -302,6 +334,27 @@ class AccountUsage extends EasCommand_1.default {
302
334
  },
303
335
  overageCostCents: displayData.updates.overageCostCents,
304
336
  },
337
+ simulator: displayData.simulator
338
+ ? {
339
+ minutes: {
340
+ plan: {
341
+ used: displayData.simulator.minutes.planValue,
342
+ limit: displayData.simulator.minutes.limit,
343
+ percentUsed: displayData.simulator.minutes.percentUsed,
344
+ },
345
+ overage: {
346
+ count: displayData.simulator.minutes.overageValue,
347
+ costCents: displayData.simulator.minutes.overageCost,
348
+ },
349
+ },
350
+ byPlatform: {
351
+ ios: displayData.simulator.iosMinutes,
352
+ android: displayData.simulator.androidMinutes,
353
+ },
354
+ byJobType: displayData.simulator.jobTypeBreakdown ?? null,
355
+ overageCostCents: displayData.simulator.overageCostCents,
356
+ }
357
+ : null,
305
358
  billing: {
306
359
  addons: subscription?.addons ?? [],
307
360
  upcomingInvoice: subscription?.upcomingInvoice ?? null,
@@ -6,6 +6,11 @@ export default class AccountView extends EasCommand {
6
6
  maybeLoggedIn: import("../../commandUtils/context/MaybeLoggedInContextField").default;
7
7
  };
8
8
  runAsync(): Promise<void>;
9
- private static getRoleOnAccount;
9
+ /**
10
+ * Whether the scopes of the credential used for this command remove any of the permissions that
11
+ * the viewer's role grants on the account.
12
+ */
13
+ private static isLimitedByCredentials;
14
+ private static getLabelForPermissions;
10
15
  private static getLabelForRole;
11
16
  }
@@ -6,6 +6,7 @@ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasComm
6
6
  const generated_1 = require("../../graphql/generated");
7
7
  const log_1 = tslib_1.__importDefault(require("../../log"));
8
8
  const User_1 = require("../../user/User");
9
+ const roles_1 = require("../../user/roles");
9
10
  class AccountView extends EasCommand_1.default {
10
11
  static description = 'show the username you are logged in as';
11
12
  static aliases = ['whoami'];
@@ -24,15 +25,28 @@ class AccountView extends EasCommand_1.default {
24
25
  log_1.default.log(actor.email);
25
26
  }
26
27
  // personal account is included, only show if more accounts that personal account
27
- // but do show personal account in list if there are more
28
+ // but do show personal account in list if there are more, or if the credentials used for
29
+ // this command limit the permissions on it
28
30
  const accountExcludingPersonalAccount = actor.accounts.filter(account => !('username' in actor) || account.name !== actor.username);
29
- if (accountExcludingPersonalAccount.length > 0) {
31
+ const hasLimitedAccount = actor.accounts.some(AccountView.isLimitedByCredentials);
32
+ if (accountExcludingPersonalAccount.length > 0 || hasLimitedAccount) {
30
33
  log_1.default.newLine();
31
34
  log_1.default.log('Accounts:');
32
35
  actor.accounts.forEach(account => {
33
- const roleOnAccount = AccountView.getRoleOnAccount(actor, account);
34
- log_1.default.log(`• ${account.name} (Role: ${AccountView.getLabelForRole(roleOnAccount)})`);
36
+ const { permissions, effectivePermissions } = account.viewerUserPermission2;
37
+ const roleLabel = AccountView.getLabelForPermissions(permissions);
38
+ if (AccountView.isLimitedByCredentials(account)) {
39
+ const effectiveRoleLabel = AccountView.getLabelForPermissions(effectivePermissions);
40
+ log_1.default.log(`• ${account.name} (Role: ${roleLabel}, ${chalk_1.default.yellow(`limited to ${effectiveRoleLabel} by the current credentials`)})`);
41
+ }
42
+ else {
43
+ log_1.default.log(`• ${account.name} (Role: ${roleLabel})`);
44
+ }
35
45
  });
46
+ if (hasLimitedAccount) {
47
+ log_1.default.newLine();
48
+ log_1.default.log(`The permissions granted during authentication limit your access to some accounts. Run ${chalk_1.default.bold('eas login')} to change the permission grant.`);
49
+ }
36
50
  }
37
51
  }
38
52
  else {
@@ -40,11 +54,25 @@ class AccountView extends EasCommand_1.default {
40
54
  process.exit(1);
41
55
  }
42
56
  }
43
- static getRoleOnAccount(actor, account) {
44
- if ('username' in actor && account.name === actor.username) {
45
- return generated_1.Role.Owner;
57
+ /**
58
+ * Whether the scopes of the credential used for this command remove any of the permissions that
59
+ * the viewer's role grants on the account.
60
+ */
61
+ static isLimitedByCredentials(account) {
62
+ const { permissions, effectivePermissions } = account.viewerUserPermission2;
63
+ return permissions.some(permission => !effectivePermissions.includes(permission));
64
+ }
65
+ static getLabelForPermissions(permissions) {
66
+ const role = (0, roles_1.getRoleForPermissions)(permissions);
67
+ if (role !== generated_1.Role.Custom) {
68
+ return AccountView.getLabelForRole(role);
69
+ }
70
+ if (permissions.length === 0) {
71
+ return 'No permissions';
46
72
  }
47
- return account.viewerUserPermission.role;
73
+ return `Custom: ${permissions
74
+ .map(permission => permission.toLowerCase().replaceAll('_', ' '))
75
+ .join(', ')}`;
48
76
  }
49
77
  static getLabelForRole(role) {
50
78
  switch (role) {
@@ -56,6 +84,8 @@ class AccountView extends EasCommand_1.default {
56
84
  return 'Developer';
57
85
  case generated_1.Role.ReleaseManager:
58
86
  return 'Release Manager';
87
+ case generated_1.Role.Runner:
88
+ return 'Runner';
59
89
  case generated_1.Role.ViewOnly:
60
90
  return 'Viewer';
61
91
  case generated_1.Role.Custom:
@@ -16,7 +16,7 @@ const formatFields_1 = tslib_1.__importDefault(require("../../utils/formatFields
16
16
  const json_1 = require("../../utils/json");
17
17
  class SimulatorGet extends EasCommand_1.default {
18
18
  static aliases = ['sim:get'];
19
- static description = '[EXPERIMENTAL] get info about a remote simulator session on EAS by its simulator session ID';
19
+ static description = "[EXPERIMENTAL] get info about a remote simulator session on EAS by its simulator session ID. Preview links follow the session's saved sharing preference.";
20
20
  static flags = {
21
21
  id: core_1.Flags.string({
22
22
  description: `Simulator session ID. Defaults to ${env_1.SIMULATOR_DOTENV_FILE_NAME}.`,
@@ -52,6 +52,7 @@ class SimulatorGet extends EasCommand_1.default {
52
52
  throw err;
53
53
  }
54
54
  const deviceRunSessionUrl = (0, url_1.getDeviceRunSessionUrl)(session.app.ownerAccount.name, session.app.slug, session.id);
55
+ const deviceRunSessionPreviewUrl = (0, url_1.getDeviceRunSessionPreviewUrl)(session.app.ownerAccount.name, session.app.slug, session.id);
55
56
  if (jsonFlag) {
56
57
  (0, json_1.printJsonOnlyOutput)({
57
58
  id: session.id,
@@ -66,7 +67,7 @@ class SimulatorGet extends EasCommand_1.default {
66
67
  updatedAt: session.updatedAt,
67
68
  deviceRunSessionUrl,
68
69
  remoteConfig: session.remoteConfig
69
- ? (0, utils_1.sanitizeRemoteConfigForJson)(session.remoteConfig)
70
+ ? (0, utils_1.sanitizeRemoteConfigForJson)(session.remoteConfig, deviceRunSessionPreviewUrl, session.publicPreview)
70
71
  : session.remoteConfig,
71
72
  artifacts: session.artifacts,
72
73
  });
@@ -79,6 +80,8 @@ class SimulatorGet extends EasCommand_1.default {
79
80
  if (session.remoteConfig) {
80
81
  log_1.default.log((0, utils_1.formatRemoteSessionInstructions)(session.remoteConfig, 'env', {
81
82
  sessionUrl: deviceRunSessionUrl,
83
+ privatePreviewUrl: deviceRunSessionPreviewUrl,
84
+ publicLink: session.publicPreview,
82
85
  platform: session.platform,
83
86
  }));
84
87
  }
@@ -26,8 +26,11 @@ export default class Simulator extends EasCommand {
26
26
  'resource-class': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
27
27
  egress: import("@oclif/core/lib/interfaces").OptionFlag<"local" | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
28
28
  'egress-allow': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
29
+ 'cors-origin': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
30
+ 'frame-ancestor': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
29
31
  force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
30
32
  'out-config-type': import("@oclif/core/lib/interfaces").OptionFlag<"env" | "dotenv", import("@oclif/core/lib/interfaces").CustomOptions>;
33
+ 'public-link': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
31
34
  };
32
35
  static contextDefinition: {
33
36
  analytics: import("../../commandUtils/context/AnalyticsContextField").default;