eas-cli 22.3.0 → 22.5.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 (34) hide show
  1. package/README.md +205 -130
  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/simulator/index.d.ts +4 -0
  26. package/build/commands/simulator/index.js +36 -7
  27. package/build/graphql/generated.d.ts +47 -2
  28. package/build/graphql/queries/AccountQuery.d.ts +4 -5
  29. package/build/graphql/queries/AccountQuery.js +23 -0
  30. package/build/simulator/expoGo.d.ts +2 -3
  31. package/build/simulator/expoGo.js +7 -42
  32. package/build/utils/usage/checkForOverages.js +6 -2
  33. package/oclif.manifest.json +1289 -1066
  34. package/package.json +7 -3
@@ -58,6 +58,16 @@ class Simulator extends EasCommand_1.default {
58
58
  description: "Install and launch Expo Go matching the current project's Expo SDK before the simulator session is ready.",
59
59
  exclusive: ['build-id', 'application-archive-url'],
60
60
  }),
61
+ 'sdk-version': core_1.Flags.string({
62
+ description: 'Expo SDK version used to select Expo Go when --expo-go is passed. Defaults to the current project SDK.',
63
+ }),
64
+ 'launch-arg': core_1.Flags.string({
65
+ description: 'Argument passed to the installed application when it launches. Repeat for multiple arguments.',
66
+ multiple: true,
67
+ }),
68
+ 'open-url': core_1.Flags.string({
69
+ description: 'Expo or development-client URL to open in the installed application after it launches.',
70
+ }),
61
71
  type: core_1.Flags.option({
62
72
  description: 'Type of simulator session to create',
63
73
  options: Object.values(utils_1.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES),
@@ -70,6 +80,10 @@ class Simulator extends EasCommand_1.default {
70
80
  description: 'Maximum duration of the simulator session in minutes before it is automatically stopped. Only customizable on paid plans. Defaults to a value derived from the job run priority when omitted.',
71
81
  min: 0,
72
82
  }),
83
+ 'max-idle-time-minutes': core_1.Flags.integer({
84
+ description: 'Stop the simulator session automatically after this many minutes without session activity. When omitted, the session has no idle timeout and runs until its maximum duration.',
85
+ min: 0,
86
+ }),
73
87
  force: core_1.Flags.boolean({
74
88
  description: '[default: true] Create a new simulator session even when an existing simulator session is present in the environment.',
75
89
  default: true,
@@ -111,18 +125,27 @@ class Simulator extends EasCommand_1.default {
111
125
  const deviceIdentifier = flags.device?.trim() || undefined;
112
126
  const buildId = flags['build-id']?.trim() || undefined;
113
127
  const applicationArchiveUrlFromFlag = flags['application-archive-url']?.trim() || undefined;
128
+ const sdkVersionFromFlag = flags['sdk-version']?.trim() || undefined;
129
+ const launchArgs = flags['launch-arg'];
130
+ const openUrl = flags['open-url']?.trim() || undefined;
131
+ if (sdkVersionFromFlag && !flags['expo-go']) {
132
+ throw new errors_1.EasCommandError('The --sdk-version flag can only be used with --expo-go.');
133
+ }
134
+ if ((launchArgs?.length || openUrl) &&
135
+ !buildId &&
136
+ !applicationArchiveUrlFromFlag &&
137
+ !flags['expo-go']) {
138
+ throw new errors_1.EasCommandError('Launch options require an application source. Pass --build-id, --application-archive-url, or --expo-go.');
139
+ }
114
140
  await (0, env_1.loadSimulatorEnvAsync)(projectDir);
115
141
  const existingDeviceRunSessionId = process.env[env_1.EAS_SIMULATOR_SESSION_ID];
116
142
  if (existingDeviceRunSessionId && !flags.force) {
117
143
  throw new Error(`Existing simulator session in environment. Use --force to create a new simulator session.`);
118
144
  }
119
145
  const platform = await resolvePlatformAsync(flags.platform, nonInteractive);
120
- const applicationArchiveUrl = flags['expo-go']
121
- ? await (0, expoGo_1.resolveExpoGoApplicationArchiveUrlAsync)({
122
- platform: platform === generated_1.AppPlatform.Ios ? 'ios' : 'android',
123
- projectDir,
124
- })
125
- : applicationArchiveUrlFromFlag;
146
+ const expoGoSdkVersion = flags['expo-go']
147
+ ? await (0, expoGo_1.resolveExpoGoSdkVersionAsync)({ projectDir, sdkVersion: sdkVersionFromFlag })
148
+ : undefined;
126
149
  if (existingDeviceRunSessionId) {
127
150
  log_1.default.warn(` Overwriting previous simulator session (id: ${existingDeviceRunSessionId}). ` +
128
151
  `The previous remote session will continue running until stopped. ` +
@@ -142,8 +165,14 @@ class Simulator extends EasCommand_1.default {
142
165
  packageVersion: flags['package-version'],
143
166
  deviceIdentifier,
144
167
  ...(buildId ? { buildId } : {}),
145
- ...(applicationArchiveUrl ? { applicationArchiveUrl } : {}),
168
+ ...(applicationArchiveUrlFromFlag
169
+ ? { applicationArchiveUrl: applicationArchiveUrlFromFlag }
170
+ : {}),
171
+ ...(expoGoSdkVersion ? { expoGo: true, sdkVersion: expoGoSdkVersion } : {}),
172
+ ...(launchArgs?.length ? { launchArgs } : {}),
173
+ ...(openUrl ? { openUrl } : {}),
146
174
  maxRunTimeMinutes: flags['max-duration-minutes'],
175
+ maxIdleTimeMinutes: flags['max-idle-time-minutes'],
147
176
  });
148
177
  deviceRunSessionId = session.id;
149
178
  (0, nullthrows_1.default)(session.turtleJobRun?.id, 'Expected simulator session to start');
@@ -4472,12 +4472,12 @@ export type CreateDeviceRunSessionInput = {
4472
4472
  appId: Scalars['ID']['input'];
4473
4473
  /**
4474
4474
  * Application archive URL to download, install, and launch before the simulator session
4475
- * becomes available. Mutually exclusive with buildId.
4475
+ * becomes available. Mutually exclusive with buildId and expoGo.
4476
4476
  */
4477
4477
  applicationArchiveUrl?: InputMaybe<Scalars['String']['input']>;
4478
4478
  /**
4479
4479
  * EAS Build to install and launch before the simulator session becomes available.
4480
- * Mutually exclusive with applicationArchiveUrl.
4480
+ * Mutually exclusive with applicationArchiveUrl and expoGo.
4481
4481
  */
4482
4482
  buildId?: InputMaybe<Scalars['ID']['input']>;
4483
4483
  /**
@@ -4487,6 +4487,17 @@ export type CreateDeviceRunSessionInput = {
4487
4487
  * default device.
4488
4488
  */
4489
4489
  deviceIdentifier?: InputMaybe<Scalars['String']['input']>;
4490
+ /**
4491
+ * Install and launch Expo Go before the simulator session becomes available. The server resolves
4492
+ * the platform-specific application archive. Mutually exclusive with buildId and
4493
+ * applicationArchiveUrl.
4494
+ */
4495
+ expoGo?: InputMaybe<Scalars['Boolean']['input']>;
4496
+ /**
4497
+ * Arguments passed to the installed application when it is launched. Requires buildId,
4498
+ * applicationArchiveUrl, or expoGo.
4499
+ */
4500
+ launchArgs?: InputMaybe<Array<Scalars['String']['input']>>;
4490
4501
  /**
4491
4502
  * Stop the session automatically after this many minutes without observed
4492
4503
  * session activity. Must be positive and smaller than the session's maximum
@@ -4507,12 +4518,22 @@ export type CreateDeviceRunSessionInput = {
4507
4518
  * session is unnamed and clients fall back to identifying it by id.
4508
4519
  */
4509
4520
  name?: InputMaybe<Scalars['String']['input']>;
4521
+ /**
4522
+ * Expo or development-client URL to open after launching the installed application. Requires
4523
+ * buildId, applicationArchiveUrl, or expoGo.
4524
+ */
4525
+ openUrl?: InputMaybe<Scalars['String']['input']>;
4510
4526
  /**
4511
4527
  * The version of the package backing the device run session (e.g. "0.1.3-alpha.3").
4512
4528
  * If omitted, consumers treat the session as pinned to "latest".
4513
4529
  */
4514
4530
  packageVersion?: InputMaybe<Scalars['String']['input']>;
4515
4531
  platform: AppPlatform;
4532
+ /**
4533
+ * Expo SDK version used to select an Expo Go application archive. Only supported when expoGo is
4534
+ * true. If omitted, the current Expo Go archive for the platform is used.
4535
+ */
4536
+ sdkVersion?: InputMaybe<Scalars['String']['input']>;
4516
4537
  type: DeviceRunSessionType;
4517
4538
  };
4518
4539
  export type CreateEchoChatInput = {
@@ -16701,6 +16722,11 @@ export type AccountByNameQuery = {
16701
16722
  __typename?: 'Account';
16702
16723
  id: string;
16703
16724
  name: string;
16725
+ viewerUserPermission: {
16726
+ __typename?: 'UserPermission';
16727
+ id: string;
16728
+ permissions: Array<Permission>;
16729
+ };
16704
16730
  };
16705
16731
  };
16706
16732
  };
@@ -16962,6 +16988,25 @@ export type AccountBillingPeriodQuery = {
16962
16988
  };
16963
16989
  };
16964
16990
  };
16991
+ export type AccountSubscriptionQueryVariables = Exact<{
16992
+ accountId: Scalars['String']['input'];
16993
+ }>;
16994
+ export type AccountSubscriptionQuery = {
16995
+ __typename?: 'RootQuery';
16996
+ account: {
16997
+ __typename?: 'AccountQuery';
16998
+ byId: {
16999
+ __typename?: 'Account';
17000
+ id: string;
17001
+ subscription?: {
17002
+ __typename?: 'SubscriptionDetails';
17003
+ id: string;
17004
+ name?: string | null;
17005
+ planId?: string | null;
17006
+ } | null;
17007
+ };
17008
+ };
17009
+ };
16965
17010
  export type AppByIdQueryVariables = Exact<{
16966
17011
  appId: Scalars['String']['input'];
16967
17012
  }>;
@@ -1,15 +1,14 @@
1
1
  import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
2
- import { AccountFullUsageQuery as AccountFullUsageQueryType, AccountUsageForOverageWarningQuery } from '../generated';
2
+ import { AccountByNameQuery as AccountByNameQueryType, AccountFullUsageQuery as AccountFullUsageQueryType, AccountSubscriptionQuery as AccountSubscriptionQueryType, AccountUsageForOverageWarningQuery } from '../generated';
3
3
  export type AccountFullUsageData = NonNullable<AccountFullUsageQueryType['account']['byId']>;
4
+ export type AccountSubscriptionInfo = NonNullable<NonNullable<AccountSubscriptionQueryType['account']['byId']>['subscription']>;
4
5
  export declare const AccountQuery: {
5
- getByNameAsync(graphqlClient: ExpoGraphqlClient, accountName: string): Promise<{
6
- id: string;
7
- name: string;
8
- } | null>;
6
+ getByNameAsync(graphqlClient: ExpoGraphqlClient, accountName: string): Promise<AccountByNameQueryType["account"]["byName"] | null>;
9
7
  getFullUsageAsync(graphqlClient: ExpoGraphqlClient, accountId: string, currentDate: Date, startDate: Date, endDate: Date): Promise<AccountFullUsageData>;
10
8
  getUsageForOverageWarningAsync(graphqlClient: ExpoGraphqlClient, accountId: string, currentDate: Date): Promise<AccountUsageForOverageWarningQuery["account"]["byId"]>;
11
9
  getBillingPeriodAsync(graphqlClient: ExpoGraphqlClient, accountId: string, currentDate: Date): Promise<{
12
10
  start: Date;
13
11
  end: Date;
14
12
  }>;
13
+ getSubscriptionAsync(graphqlClient: ExpoGraphqlClient, accountId: string): Promise<AccountSubscriptionInfo | null>;
15
14
  };
@@ -15,6 +15,10 @@ exports.AccountQuery = {
15
15
  byName(accountName: $accountName) {
16
16
  id
17
17
  name
18
+ viewerUserPermission {
19
+ id
20
+ permissions
21
+ }
18
22
  }
19
23
  }
20
24
  }
@@ -205,4 +209,23 @@ exports.AccountQuery = {
205
209
  end: new Date(end),
206
210
  };
207
211
  },
212
+ async getSubscriptionAsync(graphqlClient, accountId) {
213
+ const data = await (0, client_1.withErrorHandlingAsync)(graphqlClient
214
+ .query((0, graphql_tag_1.default) `
215
+ query AccountSubscription($accountId: String!) {
216
+ account {
217
+ byId(accountId: $accountId) {
218
+ id
219
+ subscription {
220
+ id
221
+ name
222
+ planId
223
+ }
224
+ }
225
+ }
226
+ }
227
+ `, { accountId }, { additionalTypenames: ['Account', 'SubscriptionDetails'] })
228
+ .toPromise());
229
+ return data.account.byId?.subscription ?? null;
230
+ },
208
231
  };
@@ -1,5 +1,4 @@
1
- export type ExpoGoPlatform = 'android' | 'ios';
2
- export declare function resolveExpoGoApplicationArchiveUrlAsync({ platform, projectDir, }: {
3
- platform: ExpoGoPlatform;
1
+ export declare function resolveExpoGoSdkVersionAsync({ projectDir, sdkVersion: sdkVersionFromFlag, }: {
4
2
  projectDir: string;
3
+ sdkVersion?: string;
5
4
  }): Promise<string>;
@@ -1,54 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveExpoGoApplicationArchiveUrlAsync = resolveExpoGoApplicationArchiveUrlAsync;
3
+ exports.resolveExpoGoSdkVersionAsync = resolveExpoGoSdkVersionAsync;
4
4
  const tslib_1 = require("tslib");
5
- const util_1 = require("util");
6
- const spawn_async_1 = tslib_1.__importDefault(require("@expo/spawn-async"));
7
5
  const semver_1 = tslib_1.__importDefault(require("semver"));
8
6
  const errors_1 = require("../commandUtils/errors");
9
7
  const detectProjectSdkVersionAsync_1 = require("../project/detectProjectSdkVersionAsync");
10
- const EXPO_GO_DOWNLOAD_MESSAGE = 'Download Expo Go from';
11
- function extractApplicationArchiveUrl(stdout) {
12
- const output = (0, util_1.stripVTControlCharacters)(stdout);
13
- const outputLines = output.trim().split(/\r?\n/);
14
- const downloadMessageLine = outputLines.find(line => line.includes(EXPO_GO_DOWNLOAD_MESSAGE));
15
- const bareUrlOutput = outputLines.length === 1 ? outputLines[0] : undefined;
16
- const lineWithUrl = downloadMessageLine ?? bareUrlOutput;
17
- return lineWithUrl?.match(/https?:\/\/[^\s\])]+/)?.[0];
18
- }
19
- async function resolveExpoGoApplicationArchiveUrlAsync({ platform, projectDir, }) {
20
- const sdkVersion = await (0, detectProjectSdkVersionAsync_1.detectProjectSdkVersionAsync)(projectDir);
8
+ async function resolveExpoGoSdkVersionAsync({ projectDir, sdkVersion: sdkVersionFromFlag, }) {
9
+ const sdkVersion = sdkVersionFromFlag ?? (await (0, detectProjectSdkVersionAsync_1.detectProjectSdkVersionAsync)(projectDir));
21
10
  const sdkMajorVersion = semver_1.default.coerce(sdkVersion)?.major;
22
11
  if (!sdkMajorVersion) {
12
+ if (sdkVersionFromFlag) {
13
+ throw new errors_1.EasCommandError(`Unable to parse Expo SDK version "${sdkVersionFromFlag}". Pass a major or semantic version, such as --sdk-version 57.`);
14
+ }
23
15
  throw new errors_1.EasCommandError("Unable to determine this project's Expo SDK version, so Expo Go could not be selected. " +
24
16
  'Make sure the project has Expo installed and a valid app config, or use --build-id or --application-archive-url instead.');
25
17
  }
26
- const args = ['--yes', 'expo-go', 'url', platform, String(sdkMajorVersion)];
27
- let stdout;
28
- try {
29
- ({ stdout } = await (0, spawn_async_1.default)('npx', args, {
30
- cwd: projectDir,
31
- stdio: 'pipe',
32
- }));
33
- }
34
- catch (error) {
35
- const reason = error instanceof Error ? ` ${error.message}` : '';
36
- throw new errors_1.EasCommandError(`Failed to resolve the Expo Go download URL for SDK ${sdkMajorVersion} on ${platform}.${reason} ` +
37
- `Run "npx expo-go url ${platform} ${sdkMajorVersion}" to diagnose the problem, or use --build-id or --application-archive-url instead.`);
38
- }
39
- const applicationArchiveUrl = extractApplicationArchiveUrl(stdout);
40
- try {
41
- if (!applicationArchiveUrl) {
42
- throw new Error('Missing URL');
43
- }
44
- const parsedUrl = new URL(applicationArchiveUrl);
45
- if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
46
- throw new Error('Unsupported protocol');
47
- }
48
- }
49
- catch {
50
- throw new errors_1.EasCommandError(`expo-go returned an invalid download URL for SDK ${sdkMajorVersion} on ${platform}. ` +
51
- `Run "npx expo-go url ${platform} ${sdkMajorVersion}" to diagnose the problem, or use --build-id or --application-archive-url instead.`);
52
- }
53
- return applicationArchiveUrl;
18
+ return `${sdkMajorVersion}.0.0`;
54
19
  }
@@ -7,6 +7,7 @@ exports.createProgressBar = createProgressBar;
7
7
  exports.displayOverageWarning = displayOverageWarning;
8
8
  const tslib_1 = require("tslib");
9
9
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
10
+ const plans_1 = require("../../billing/plans");
10
11
  const AccountQuery_1 = require("../../graphql/queries/AccountQuery");
11
12
  const log_1 = tslib_1.__importStar(require("../../log"));
12
13
  const APPROACHING_THRESHOLD_PERCENT = 80;
@@ -93,6 +94,7 @@ function formatCents(cents) {
93
94
  }
94
95
  function displayOverageWarning({ tier, name, hasFreePlan, planValue, limit, overageCount, overageCostCents, }) {
95
96
  const billingUrl = `https://expo.dev/accounts/${name}/settings/billing`;
97
+ const upgradeHint = ` Run ${(0, plans_1.formatStarterSubscribeCommand)(name)} to upgrade to the Starter plan.`;
96
98
  if (tier === 'approaching') {
97
99
  const percentUsed = calculatePercentUsed(planValue, limit);
98
100
  log_1.default.warn(chalk_1.default.bold(`You've used ${percentUsed}% of your included build credits this billing period.`) +
@@ -100,7 +102,8 @@ function displayOverageWarning({ tier, name, hasFreePlan, planValue, limit, over
100
102
  createProgressBar(percentUsed));
101
103
  log_1.default.warn(hasFreePlan
102
104
  ? "You won't be able to start new builds once you reach the limit. " +
103
- (0, log_1.link)(billingUrl, { text: 'Upgrade your plan to continue service.', dim: false })
105
+ (0, log_1.link)(billingUrl, { text: 'Upgrade your plan to continue service.', dim: false }) +
106
+ upgradeHint
104
107
  : 'Additional usage beyond your limit will be charged at pay-as-you-go rates. ' +
105
108
  (0, log_1.link)(billingUrl, { text: 'See usage in billing.', dim: false }));
106
109
  return;
@@ -111,7 +114,8 @@ function displayOverageWarning({ tier, name, hasFreePlan, planValue, limit, over
111
114
  log_1.default.warn(chalk_1.default.bold("You've reached your included build credits this billing period."));
112
115
  log_1.default.warn(hasFreePlan
113
116
  ? 'New builds are blocked until your billing period resets. ' +
114
- (0, log_1.link)(billingUrl, { text: 'Upgrade your plan to continue building.', dim: false })
117
+ (0, log_1.link)(billingUrl, { text: 'Upgrade your plan to continue building.', dim: false }) +
118
+ upgradeHint
115
119
  : 'Additional builds will be charged at pay-as-you-go rates. ' +
116
120
  (0, log_1.link)(billingUrl, { text: 'See usage in billing.', dim: false }));
117
121
  return;