eas-cli 27.9.0 → 27.10.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.
@@ -96,4 +96,4 @@ export declare function isAnalyticsOptedOutAsync(): Promise<boolean>;
96
96
  /**
97
97
  * Create an instance of Analytics based on the user's analytics enabled preferences.
98
98
  */
99
- export declare function createAnalyticsAsync(): Promise<AnalyticsWithOrchestration>;
99
+ export declare function createAnalyticsAsync(parentCommand?: string | null): Promise<AnalyticsWithOrchestration>;
@@ -120,7 +120,7 @@ async function isAnalyticsOptedOutAsync() {
120
120
  /**
121
121
  * Create an instance of Analytics based on the user's analytics enabled preferences.
122
122
  */
123
- async function createAnalyticsAsync() {
123
+ async function createAnalyticsAsync(parentCommand = null) {
124
124
  // TODO: remove after some time
125
125
  const amplitudeEnabled = await UserSettings_1.default.getAsync(USER_SETTINGS_KEY_AMPLITUDE_ENABLED, null);
126
126
  if (amplitudeEnabled !== null) {
@@ -145,7 +145,7 @@ async function createAnalyticsAsync() {
145
145
  if (!persistedDeviceId) {
146
146
  await UserSettings_1.default.setAsync(USER_SETTINGS_KEY_ANALYTICS_DEVICE_ID, deviceId);
147
147
  }
148
- return new RudderstackAnalytics(deviceId);
148
+ return new RudderstackAnalytics(deviceId, parentCommand);
149
149
  }
150
150
  class NoOpAnalytics {
151
151
  logEvent() { }
@@ -168,12 +168,14 @@ const RudderstackAnalyticsConfig = process.env.EXPO_STAGING || process.env.EXPO_
168
168
  };
169
169
  class RudderstackAnalytics {
170
170
  persistentDeviceId;
171
+ parentCommand;
171
172
  rudderstackClient = new rudder_sdk_node_1.default(RudderstackAnalyticsConfig.rudderstackWriteKey, new url_1.URL('/v1/batch', RudderstackAnalyticsConfig.rudderstackDataPlaneURL).toString(), {
172
173
  flushInterval: 300,
173
174
  });
174
175
  identifiedActor = null;
175
- constructor(persistentDeviceId) {
176
+ constructor(persistentDeviceId, parentCommand) {
176
177
  this.persistentDeviceId = persistentDeviceId;
178
+ this.parentCommand = parentCommand;
177
179
  // identify once with just anonymous ID. Once the actor is fetched, re-indentify with
178
180
  // both so that they can be associated
179
181
  this.rudderstackClient.identify({
@@ -221,6 +223,7 @@ class RudderstackAnalytics {
221
223
  os: { name: platform, version: os_1.default.release() },
222
224
  device: { type: platform, model: platform },
223
225
  app: { name: 'eas cli', version: easCli_1.easCliVersion ?? undefined },
226
+ ...(this.parentCommand ? { parent_command: this.parentCommand } : {}),
224
227
  ...(sandboxProvider ? { sandbox_provider: sandboxProvider } : {}),
225
228
  ...(agent ? { agent } : {}),
226
229
  };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Makes child processes and nested EAS commands report `command` as their parent command.
3
+ * Expo CLI uses the same variable name and the same `<cli> <command>` value. Do not change them.
4
+ *
5
+ * `parentCommand` is the Expo CLI or EAS CLI command that started the current one.
6
+ * `restoreParentCommand` puts the inherited value back.
7
+ */
8
+ export declare function markAsParentCommand(command: string): {
9
+ parentCommand: string | null;
10
+ restoreParentCommand: () => void;
11
+ };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.markAsParentCommand = markAsParentCommand;
4
+ /**
5
+ * Makes child processes and nested EAS commands report `command` as their parent command.
6
+ * Expo CLI uses the same variable name and the same `<cli> <command>` value. Do not change them.
7
+ *
8
+ * `parentCommand` is the Expo CLI or EAS CLI command that started the current one.
9
+ * `restoreParentCommand` puts the inherited value back.
10
+ */
11
+ function markAsParentCommand(command) {
12
+ const inheritedCommand = process.env.__EXPO_PARENT_COMMAND;
13
+ process.env.__EXPO_PARENT_COMMAND = command;
14
+ return {
15
+ parentCommand: inheritedCommand || null,
16
+ restoreParentCommand: () => {
17
+ if (inheritedCommand === undefined) {
18
+ delete process.env.__EXPO_PARENT_COMMAND;
19
+ }
20
+ else {
21
+ process.env.__EXPO_PARENT_COMMAND = inheritedCommand;
22
+ }
23
+ },
24
+ };
25
+ }
@@ -20,6 +20,7 @@ const SessionManagementContextField_1 = tslib_1.__importDefault(require("./conte
20
20
  const VcsClientContextField_1 = tslib_1.__importDefault(require("./context/VcsClientContextField"));
21
21
  const errors_1 = require("./errors");
22
22
  const AnalyticsManager_1 = require("../analytics/AnalyticsManager");
23
+ const parentCommand_1 = require("../analytics/parentCommand");
23
24
  const log_1 = tslib_1.__importStar(require("../log"));
24
25
  const sentry_1 = tslib_1.__importDefault(require("../sentry"));
25
26
  const SessionManager_1 = tslib_1.__importDefault(require("../user/SessionManager"));
@@ -167,23 +168,30 @@ class EasCommand extends core_1.Command {
167
168
  }
168
169
  // eslint-disable-next-line async-protect/async-suffix
169
170
  async run() {
170
- this.analyticsInternal = await (0, AnalyticsManager_1.createAnalyticsAsync)();
171
- this.sessionManagerInternal = new SessionManager_1.default(this.analytics);
172
- // this is needed for logEvent call below as it identifies the user in the analytics system
173
- // if possible
174
- const actor = await this.sessionManager.getUserAsync();
175
- if (actor) {
176
- sentry_1.default.setUser({
177
- id: actor.id,
178
- username: (0, User_1.getActorDisplayName)(actor),
179
- });
171
+ // id is assigned by oclif in constructor based on the filepath:
172
+ // commands/submit === submit, commands/build/list === build:list
173
+ const command = `eas ${this.id}`;
174
+ const { parentCommand, restoreParentCommand } = (0, parentCommand_1.markAsParentCommand)(command);
175
+ try {
176
+ this.analyticsInternal = await (0, AnalyticsManager_1.createAnalyticsAsync)(parentCommand);
177
+ this.sessionManagerInternal = new SessionManager_1.default(this.analytics);
178
+ // this is needed for logEvent call below as it identifies the user in the analytics system
179
+ // if possible
180
+ const actor = await this.sessionManager.getUserAsync();
181
+ if (actor) {
182
+ sentry_1.default.setUser({
183
+ id: actor.id,
184
+ username: (0, User_1.getActorDisplayName)(actor),
185
+ });
186
+ }
187
+ this.analytics.logEvent(AnalyticsManager_1.CommandEvent.ACTION, { action: command });
188
+ return await this.runAsync();
189
+ }
190
+ finally {
191
+ // Commands can run inside each other, for example `eas open` runs `eas browse`.
192
+ // The outer command is the parent command again after the inner one ends.
193
+ restoreParentCommand();
180
194
  }
181
- this.analytics.logEvent(AnalyticsManager_1.CommandEvent.ACTION, {
182
- // id is assigned by oclif in constructor based on the filepath:
183
- // commands/submit === submit, commands/build/list === build:list
184
- action: `eas ${this.id}`,
185
- });
186
- return await this.runAsync();
187
195
  }
188
196
  // eslint-disable-next-line async-protect/async-suffix
189
197
  async finally(err) {
@@ -0,0 +1,15 @@
1
+ import EasCommand from '../../commandUtils/EasCommand';
2
+ export default class SimulatorDevices extends EasCommand {
3
+ static aliases: string[];
4
+ static hiddenAliases: string[];
5
+ static description: string;
6
+ static flags: {
7
+ json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
+ 'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ platform: import("@oclif/core/lib/interfaces").OptionFlag<"android" | "ios" | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ };
11
+ static contextDefinition: {
12
+ loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
13
+ };
14
+ runAsync(): Promise<void>;
15
+ }
@@ -0,0 +1,89 @@
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 chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
7
+ const flags_1 = require("../../commandUtils/flags");
8
+ const DeviceRunSessionQuery_1 = require("../../graphql/queries/DeviceRunSessionQuery");
9
+ const log_1 = tslib_1.__importDefault(require("../../log"));
10
+ const ora_1 = require("../../ora");
11
+ const platform_1 = require("../../platform");
12
+ const json_1 = require("../../utils/json");
13
+ const commandAliases_1 = require("../../simulator/commandAliases");
14
+ const utils_1 = require("../../simulator/utils");
15
+ const PLATFORM_ORDER = ['ios', 'android'];
16
+ function formatDeviceFlagValue(identifier) {
17
+ return /^[\w-]+$/.test(identifier) ? identifier : JSON.stringify(identifier);
18
+ }
19
+ class SimulatorDevices extends EasCommand_1.default {
20
+ static aliases = (0, commandAliases_1.getSimulatorCommandAliases)('devices');
21
+ static hiddenAliases = (0, commandAliases_1.getSimulatorCommandHiddenAliases)('devices');
22
+ static description = 'list the devices Expo suggests for a remote simulator session';
23
+ static flags = {
24
+ platform: core_1.Flags.option({
25
+ char: 'p',
26
+ description: 'Show the devices of one platform',
27
+ options: utils_1.DEVICE_RUN_SESSION_PLATFORM_FLAG_VALUES,
28
+ })(),
29
+ ...flags_1.EasNonInteractiveAndJsonFlags,
30
+ };
31
+ static contextDefinition = {
32
+ ...this.ContextOptions.LoggedIn,
33
+ };
34
+ async runAsync() {
35
+ const { flags } = await this.parse(SimulatorDevices);
36
+ const { json: jsonFlag, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
37
+ if (jsonFlag) {
38
+ (0, json_1.enableJsonOutput)();
39
+ }
40
+ const { loggedIn: { graphqlClient }, } = await this.getContextAsync(SimulatorDevices, {
41
+ nonInteractive,
42
+ });
43
+ const fetchSpinner = jsonFlag ? null : (0, ora_1.ora)('Fetching simulator devices').start();
44
+ let profiles;
45
+ try {
46
+ profiles = await DeviceRunSessionQuery_1.DeviceRunSessionQuery.profilesAsync(graphqlClient);
47
+ fetchSpinner?.stop();
48
+ }
49
+ catch (err) {
50
+ fetchSpinner?.fail('Failed to fetch simulator devices');
51
+ throw err;
52
+ }
53
+ const platforms = PLATFORM_ORDER.filter(platform => !flags.platform || flags.platform === platform);
54
+ if (jsonFlag) {
55
+ (0, json_1.printJsonOnlyOutput)(Object.fromEntries(platforms.map(platform => [
56
+ platform,
57
+ profiles[platform].devices.map(({ identifier, displayName }) => ({
58
+ identifier,
59
+ displayName,
60
+ })),
61
+ ])));
62
+ return;
63
+ }
64
+ const devices = platforms.flatMap(platform => profiles[platform].devices.map(({ identifier, displayName }) => ({
65
+ platform,
66
+ displayName,
67
+ flagValue: formatDeviceFlagValue(identifier),
68
+ })));
69
+ if (devices.length === 0) {
70
+ log_1.default.log('No simulator devices found.');
71
+ return;
72
+ }
73
+ const header = ['Platform', 'Device', '--device value'];
74
+ const rows = devices.map(({ platform, displayName, flagValue }) => [
75
+ platform_1.appPlatformDisplayNames[utils_1.DEVICE_RUN_SESSION_PLATFORM_BY_FLAG_VALUE[platform]],
76
+ displayName,
77
+ flagValue,
78
+ ]);
79
+ const widths = header.map((title, column) => Math.max(title.length, ...rows.map(row => row[column].length)));
80
+ const formatRow = (row) => row
81
+ .map((cell, column) => cell.padEnd(widths[column]))
82
+ .join(' ')
83
+ .trimEnd();
84
+ log_1.default.log([chalk_1.default.dim(formatRow(header)), ...rows.map(formatRow)].join('\n'));
85
+ log_1.default.newLine();
86
+ log_1.default.log(`Start a session with: eas simulator:start --platform ${devices[0].platform} --device ${devices[0].flagValue}`);
87
+ }
88
+ }
89
+ exports.default = SimulatorDevices;
@@ -39,12 +39,7 @@ const OUT_CONFIG_TYPE_VALUES = {
39
39
  Env: 'env',
40
40
  Dotenv: 'dotenv',
41
41
  };
42
- const PLATFORM_FLAG_VALUES = ['android', 'ios'];
43
42
  const EGRESS_FLAG_VALUES = ['local'];
44
- const APP_PLATFORM_BY_FLAG_VALUE = {
45
- android: generated_1.AppPlatform.Android,
46
- ios: generated_1.AppPlatform.Ios,
47
- };
48
43
  class Simulator extends EasCommand_1.default {
49
44
  static aliases = ['simulator:start', ...(0, commandAliases_1.getSimulatorCommandAliases)('start')];
50
45
  static hiddenAliases = [
@@ -78,7 +73,7 @@ With local egress, actions wait for the connection and require interactive mode.
78
73
  platform: core_1.Flags.option({
79
74
  char: 'p',
80
75
  description: 'Device platform',
81
- options: PLATFORM_FLAG_VALUES,
76
+ options: utils_1.DEVICE_RUN_SESSION_PLATFORM_FLAG_VALUES,
82
77
  })(),
83
78
  name: core_1.Flags.string({
84
79
  description: 'Human-readable name for the simulator session, shown in eas simulator:list and on expo.dev. Defaults to unnamed.',
@@ -88,7 +83,7 @@ With local egress, actions wait for the connection and require interactive mode.
88
83
  multiple: true,
89
84
  }),
90
85
  device: core_1.Flags.string({
91
- 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.',
86
+ description: 'Virtual device to start for the session. On iOS, a Simulator device name or UDID (e.g. "iPhone 17 Pro"). On Android, an AVD hardware profile id (e.g. "pixel_9"). Defaults to a device chosen by the runner. eas simulator:devices lists the devices Expo suggests.',
92
87
  }),
93
88
  'system-image': core_1.Flags.string({
94
89
  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.',
@@ -711,7 +706,7 @@ async function formatJobRunErrorsAsync(graphqlClient, deviceRunSessionId, signal
711
706
  }
712
707
  async function resolvePlatformAsync(platform, nonInteractive) {
713
708
  if (platform) {
714
- return APP_PLATFORM_BY_FLAG_VALUE[platform];
709
+ return utils_1.DEVICE_RUN_SESSION_PLATFORM_BY_FLAG_VALUE[platform];
715
710
  }
716
711
  if (nonInteractive) {
717
712
  throw new Error('The --platform flag must be set when running in non-interactive mode.');
@@ -20196,6 +20196,34 @@ export type DeviceRunSessionByIdQuery = {
20196
20196
  };
20197
20197
  };
20198
20198
  };
20199
+ export type DeviceRunSessionProfilesQueryVariables = Exact<{
20200
+ [key: string]: never;
20201
+ }>;
20202
+ export type DeviceRunSessionProfilesQuery = {
20203
+ __typename?: 'RootQuery';
20204
+ deviceRunSessions: {
20205
+ __typename?: 'DeviceRunSessionQuery';
20206
+ profiles: {
20207
+ __typename?: 'DeviceRunSessionProfiles';
20208
+ ios: {
20209
+ __typename?: 'IosDeviceRunSessionProfiles';
20210
+ devices: Array<{
20211
+ __typename?: 'IosDeviceRunSessionDevice';
20212
+ identifier: string;
20213
+ displayName: string;
20214
+ }>;
20215
+ };
20216
+ android: {
20217
+ __typename?: 'AndroidDeviceRunSessionProfiles';
20218
+ devices: Array<{
20219
+ __typename?: 'AndroidDeviceRunSessionDevice';
20220
+ identifier: string;
20221
+ displayName: string;
20222
+ }>;
20223
+ };
20224
+ };
20225
+ };
20226
+ };
20199
20227
  export type DeviceRunSessionsByAppIdQueryVariables = Exact<{
20200
20228
  appId: Scalars['String']['input'];
20201
20229
  first?: InputMaybe<Scalars['Int']['input']>;
@@ -1,5 +1,5 @@
1
1
  import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
2
- import { DeviceRunSessionByIdQuery, DeviceRunSessionEventsByIdQuery, DeviceRunSessionFilterInput, DeviceRunSessionJobRunErrorsByIdQuery, DeviceRunSessionsByAppIdQuery } from '../generated';
2
+ import { DeviceRunSessionByIdQuery, DeviceRunSessionEventsByIdQuery, DeviceRunSessionFilterInput, DeviceRunSessionJobRunErrorsByIdQuery, DeviceRunSessionProfilesQuery, DeviceRunSessionsByAppIdQuery } from '../generated';
3
3
  export declare const DeviceRunSessionQuery: {
4
4
  eventsByIdAsync(graphqlClient: ExpoGraphqlClient, deviceRunSessionId: string): Promise<DeviceRunSessionEventsByIdQuery["deviceRunSessions"]["byId"]>;
5
5
  /**
@@ -10,6 +10,7 @@ export declare const DeviceRunSessionQuery: {
10
10
  signal: AbortSignal;
11
11
  }): Promise<DeviceRunSessionJobRunErrorsByIdQuery["deviceRunSessions"]["byId"]["turtleJobRun"]>;
12
12
  byIdAsync(graphqlClient: ExpoGraphqlClient, deviceRunSessionId: string): Promise<DeviceRunSessionByIdQuery["deviceRunSessions"]["byId"]>;
13
+ profilesAsync(graphqlClient: ExpoGraphqlClient): Promise<DeviceRunSessionProfilesQuery["deviceRunSessions"]["profiles"]>;
13
14
  listByAppIdAsync(graphqlClient: ExpoGraphqlClient, { appId, first, after, filter, }: {
14
15
  appId: string;
15
16
  first?: number;
@@ -158,6 +158,31 @@ exports.DeviceRunSessionQuery = {
158
158
  .toPromise());
159
159
  return data.deviceRunSessions.byId;
160
160
  },
161
+ async profilesAsync(graphqlClient) {
162
+ const data = await (0, client_1.withErrorHandlingAsync)(graphqlClient
163
+ .query((0, graphql_tag_1.default) `
164
+ query DeviceRunSessionProfilesQuery {
165
+ deviceRunSessions {
166
+ profiles {
167
+ ios {
168
+ devices {
169
+ identifier
170
+ displayName
171
+ }
172
+ }
173
+ android {
174
+ devices {
175
+ identifier
176
+ displayName
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
182
+ `, {}, { requestPolicy: 'network-only' })
183
+ .toPromise());
184
+ return data.deviceRunSessions.profiles;
185
+ },
161
186
  async listByAppIdAsync(graphqlClient, { appId, first, after, filter, }) {
162
187
  const data = await (0, client_1.withErrorHandlingAsync)(graphqlClient
163
188
  .query((0, graphql_tag_1.default) `
@@ -11,6 +11,9 @@ export declare function formatSimulatorUnavailableMessage(accountName: string):
11
11
  export declare const DEVICE_RUN_SESSION_TYPE_FLAG_VALUES: Record<DeviceRunSessionType, string>;
12
12
  export declare const DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE: Record<string, DeviceRunSessionType>;
13
13
  export declare const DEVICE_RUN_SESSION_TYPE_FLAG_OPTIONS: string[];
14
+ export declare const DEVICE_RUN_SESSION_PLATFORM_FLAG_VALUES: readonly ["android", "ios"];
15
+ export type DeviceRunSessionPlatformFlagValue = (typeof DEVICE_RUN_SESSION_PLATFORM_FLAG_VALUES)[number];
16
+ export declare const DEVICE_RUN_SESSION_PLATFORM_BY_FLAG_VALUE: Record<DeviceRunSessionPlatformFlagValue, AppPlatform>;
14
17
  export declare function deviceRunSessionTypesForFlagValue(value: string): DeviceRunSessionType[];
15
18
  export declare function deviceRunSessionTypeToFlagValue(type: DeviceRunSessionType): string;
16
19
  export declare const DEVICE_RUN_SESSION_RESOURCE_CLASS_FLAG_VALUES: Record<DeviceRunSessionResourceClass, string>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ANDROID_EMULATOR_EGRESS_RELAY_PORT = exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_FLAG_VALUES = exports.DEVICE_RUN_SESSION_TYPE_FLAG_OPTIONS = exports.DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES = void 0;
3
+ exports.ANDROID_EMULATOR_EGRESS_RELAY_PORT = exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_RESOURCE_CLASS_FLAG_VALUES = exports.DEVICE_RUN_SESSION_PLATFORM_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_PLATFORM_FLAG_VALUES = exports.DEVICE_RUN_SESSION_TYPE_FLAG_OPTIONS = exports.DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE = exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES = void 0;
4
4
  exports.formatSimulatorUnavailableMessage = formatSimulatorUnavailableMessage;
5
5
  exports.deviceRunSessionTypesForFlagValue = deviceRunSessionTypesForFlagValue;
6
6
  exports.deviceRunSessionTypeToFlagValue = deviceRunSessionTypeToFlagValue;
@@ -51,6 +51,11 @@ exports.DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE = Object.fromEntries(Object.entrie
51
51
  exports.DEVICE_RUN_SESSION_TYPE_FLAG_OPTIONS = [
52
52
  ...new Set(Object.values(exports.DEVICE_RUN_SESSION_TYPE_FLAG_VALUES)),
53
53
  ];
54
+ exports.DEVICE_RUN_SESSION_PLATFORM_FLAG_VALUES = ['android', 'ios'];
55
+ exports.DEVICE_RUN_SESSION_PLATFORM_BY_FLAG_VALUE = {
56
+ android: generated_1.AppPlatform.Android,
57
+ ios: generated_1.AppPlatform.Ios,
58
+ };
54
59
  // Every enum value behind a flag value, so filtering by web-preview-only also
55
60
  // matches sessions created with the legacy ServeSim type.
56
61
  function deviceRunSessionTypesForFlagValue(value) {