eas-cli 27.4.1 → 27.6.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 (61) hide show
  1. package/README.md +373 -200
  2. package/build/build/simulatorsLaunchHint.js +1 -1
  3. package/build/commands/observe/events.d.ts +2 -0
  4. package/build/commands/observe/events.js +42 -4
  5. package/build/commands/simulator/availability.d.ts +1 -0
  6. package/build/commands/simulator/availability.js +3 -1
  7. package/build/commands/simulator/control/connection.d.ts +19 -0
  8. package/build/commands/simulator/control/connection.js +93 -0
  9. package/build/commands/simulator/control.d.ts +7 -0
  10. package/build/commands/simulator/control.js +249 -110
  11. package/build/commands/simulator/egress.d.ts +1 -0
  12. package/build/commands/simulator/egress.js +3 -1
  13. package/build/commands/simulator/events.d.ts +1 -0
  14. package/build/commands/simulator/events.js +3 -1
  15. package/build/commands/simulator/exec.d.ts +1 -0
  16. package/build/commands/simulator/exec.js +3 -1
  17. package/build/commands/simulator/get.d.ts +1 -0
  18. package/build/commands/simulator/get.js +3 -1
  19. package/build/commands/simulator/index.d.ts +2 -0
  20. package/build/commands/simulator/index.js +286 -76
  21. package/build/commands/simulator/list.d.ts +1 -0
  22. package/build/commands/simulator/list.js +3 -1
  23. package/build/commands/simulator/logs.d.ts +1 -0
  24. package/build/commands/simulator/logs.js +3 -1
  25. package/build/commands/simulator/stop.d.ts +1 -0
  26. package/build/commands/simulator/stop.js +3 -1
  27. package/build/commands/workflow/ssh.d.ts +0 -1
  28. package/build/commands/workflow/ssh.js +0 -1
  29. package/build/graphql/generated.d.ts +8 -0
  30. package/build/graphql/types/Actor.js +3 -0
  31. package/build/help.js +2 -1
  32. package/build/observe/fetchCustomEvents.d.ts +2 -1
  33. package/build/observe/fetchCustomEvents.js +1 -0
  34. package/build/project/accountSelection.js +5 -8
  35. package/build/simulator/commandAliases.d.ts +10 -0
  36. package/build/simulator/commandAliases.js +24 -0
  37. package/build/simulator/controlActions.d.ts +32 -0
  38. package/build/simulator/controlActions.js +128 -0
  39. package/build/simulator/controlConfig.d.ts +43 -0
  40. package/build/simulator/controlConfig.js +156 -0
  41. package/build/simulator/controlConnection.d.ts +28 -0
  42. package/build/simulator/controlConnection.js +337 -0
  43. package/build/simulator/controlConnectionProtocol.d.ts +64 -0
  44. package/build/simulator/controlConnectionProtocol.js +155 -0
  45. package/build/simulator/controlConnectionWorker.d.ts +7 -0
  46. package/build/simulator/controlConnectionWorker.js +278 -0
  47. package/build/simulator/controlSession.d.ts +3 -0
  48. package/build/simulator/controlSession.js +28 -0
  49. package/build/simulator/hostActions.d.ts +22 -3
  50. package/build/simulator/hostActions.js +78 -19
  51. package/build/simulator/sessionConfig.d.ts +16 -0
  52. package/build/simulator/sessionConfig.js +36 -0
  53. package/build/simulator/startConfig.d.ts +7 -0
  54. package/build/simulator/startConfig.js +89 -0
  55. package/build/simulator/startSetup.d.ts +7 -0
  56. package/build/simulator/startSetup.js +17 -0
  57. package/build/user/User.d.ts +9 -1
  58. package/build/user/User.js +25 -3
  59. package/build/user/accountPermissions.js +3 -1
  60. package/oclif.manifest.json +1194 -996
  61. package/package.json +8 -6
@@ -3,27 +3,52 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
5
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
- const fs = tslib_1.__importStar(require("fs-extra"));
7
- const path_1 = tslib_1.__importDefault(require("path"));
6
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
7
+ const node_util_1 = require("node:util");
8
8
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
9
9
  const flags_1 = require("../../commandUtils/flags");
10
- const generated_1 = require("../../graphql/generated");
11
- const DeviceRunSessionQuery_1 = require("../../graphql/queries/DeviceRunSessionQuery");
12
10
  const log_1 = tslib_1.__importDefault(require("../../log"));
13
11
  const ora_1 = require("../../ora");
12
+ const controlConnection_1 = require("../../simulator/controlConnection");
13
+ const controlSession_1 = require("../../simulator/controlSession");
14
+ const controlActions_1 = require("../../simulator/controlActions");
15
+ const controlConfig_1 = require("../../simulator/controlConfig");
14
16
  const env_1 = require("../../simulator/env");
15
17
  const hostActions_1 = require("../../simulator/hostActions");
16
- const utils_1 = require("../../simulator/utils");
17
18
  const json_1 = require("../../utils/json");
19
+ const commandAliases_1 = require("../../simulator/commandAliases");
20
+ const formatFields_1 = tslib_1.__importDefault(require("../../utils/formatFields"));
21
+ const terminalText_1 = require("../../utils/terminalText");
22
+ const timer_1 = require("../../utils/timer");
18
23
  class SimulatorControl extends EasCommand_1.default {
19
- static aliases = ['sim:control'];
20
- static description = '[EXPERIMENTAL] run a serve-sim action on a remote iOS simulator session on EAS. Run without an action to list the actions the session supports. To save a screenshot locally, run `eas simulator:control screenshot.capture --output ./screenshot.png`';
24
+ static aliases = (0, commandAliases_1.getSimulatorCommandAliases)('control');
25
+ static hiddenAliases = (0, commandAliases_1.getSimulatorCommandHiddenAliases)('control');
26
+ static description = `[EXPERIMENTAL] control a remote iOS simulator session on EAS
27
+
28
+ Run without an action to list available actions. Use <action> --help for usage.
29
+
30
+ Use --keep-alive to reuse the connection across commands, or prepare it with simulator:control:connection open. Connections close after 120 seconds idle by default; use --idle-timeout to change the timeout in seconds.
31
+
32
+ To save a screenshot locally, run \`eas simulator:control screenshot.capture --output ./screenshot.png\`.
33
+
34
+ Use --import to run the actions from a JSON file. The start section is used only by simulator:start:
35
+
36
+ {
37
+ "version": 1,
38
+ "start": {"device": "iPhone 17 Pro", "type": "web-preview-only"},
39
+ "actions": [{"action": "appearance.set", "params": {"value": "dark"}}]
40
+ }
41
+
42
+ The file is checked before any actions run. Actions run in order and stop on the first failure. Local paths are relative to the JSON file; paths in params refer to the simulator host.
43
+
44
+ Existing output files are overwritten. When saving to a directory, an existing file with the generated name causes the action to fail.`;
21
45
  static strict = false;
22
46
  static examples = [
23
47
  '$ eas simulator:control',
24
48
  '$ eas simulator:control --id <session-id>',
25
49
  '$ eas simulator:control screenshot.capture --help',
26
50
  '$ eas simulator:control clipboard.write -- --some-text',
51
+ '$ eas simulator:control --import ./simulator-control.json',
27
52
  '$ eas simulator:control hardwareKeyboard.set off',
28
53
  '$ eas simulator:control permissions.set grant camera com.example.app',
29
54
  '$ eas simulator:control app.install ./MyApp.ipa',
@@ -32,22 +57,34 @@ class SimulatorControl extends EasCommand_1.default {
32
57
  ];
33
58
  static args = {
34
59
  action: core_1.Args.string({
35
- description: 'Action to run, followed by its values in order or as name=value. Omit to list the actions. Put -- before values that start with --.',
60
+ description: 'Action name, followed by values or name=value pairs. Omit to list actions. Use -- before values starting with --.',
36
61
  }),
37
62
  };
38
63
  static flags = {
39
64
  help: core_1.Flags.boolean({
40
65
  char: 'h',
41
- description: 'Show command help, or usage for the selected action from the session.',
66
+ description: 'Show help for this command or the selected action',
42
67
  }),
43
68
  id: core_1.Flags.string({
44
69
  description: `Simulator session ID. Defaults to ${env_1.SIMULATOR_DOTENV_FILE_NAME}.`,
45
70
  }),
46
71
  list: core_1.Flags.boolean({
47
- description: 'List the actions the session supports.',
72
+ description: 'List available actions',
48
73
  }),
49
74
  output: core_1.Flags.string({
50
- description: 'Local path to save a returned file. For screenshots, --output ./screenshot.png sets the local filename; omit it to save with a generated filename in the current directory.',
75
+ description: 'Local file or existing directory for saved output',
76
+ }),
77
+ import: core_1.Flags.string({
78
+ description: 'Run saved actions from a JSON file',
79
+ }),
80
+ 'keep-alive': core_1.Flags.boolean({
81
+ description: 'Keep the control connection available for subsequent commands (macOS and Linux)',
82
+ }),
83
+ 'idle-timeout': core_1.Flags.integer({
84
+ min: 1,
85
+ max: 86_400,
86
+ description: 'Seconds of idle time before closing the kept-alive connection (default: 120)',
87
+ dependsOn: ['keep-alive'],
51
88
  }),
52
89
  ...flags_1.EasNonInteractiveAndJsonFlags,
53
90
  };
@@ -64,8 +101,19 @@ class SimulatorControl extends EasCommand_1.default {
64
101
  if (flags.id === '') {
65
102
  throw new Error('--id needs a simulator session ID.');
66
103
  }
104
+ const idleTimeoutMs = flags['idle-timeout'] !== undefined ? flags['idle-timeout'] * 1_000 : undefined;
105
+ if (flags['keep-alive']) {
106
+ (0, controlConnection_1.assertControlKeepAliveSupported)();
107
+ }
67
108
  const action = flags.list && !flags.help ? undefined : args.action;
68
- const { projectDir, loggedIn: { graphqlClient }, } = await this.getContextAsync(SimulatorControl, {
109
+ const importing = flags.import !== undefined;
110
+ if (importing && (args.action || flags.list || flags.output !== undefined)) {
111
+ throw new Error('--import cannot be combined with an action, --list, or --output.');
112
+ }
113
+ if (!action && flags.output) {
114
+ throw new Error('--output requires an action.');
115
+ }
116
+ const { projectDir, loggedIn: { graphqlClient, authenticationInfo }, } = await this.getContextAsync(SimulatorControl, {
69
117
  nonInteractive,
70
118
  });
71
119
  await (0, env_1.loadSimulatorEnvAsync)(projectDir);
@@ -77,40 +125,176 @@ class SimulatorControl extends EasCommand_1.default {
77
125
  let connection;
78
126
  try {
79
127
  let catalog;
128
+ let controlSession;
80
129
  try {
81
- const session = await DeviceRunSessionQuery_1.DeviceRunSessionQuery.byIdAsync(graphqlClient, sessionId);
82
- connection = await (0, hostActions_1.connectHostActionsAsync)(assertControllableSession(session));
83
- catalog = await (0, hostActions_1.fetchHostActionCatalogAsync)(connection);
84
- spinner.succeed(`Connected to simulator session ${sessionId}`);
130
+ const identity = await (0, controlConnection_1.createControlConnectionIdentityAsync)(sessionId, projectDir, authenticationInfo);
131
+ if (flags['keep-alive']) {
132
+ await (0, controlConnection_1.openControlConnectionAsync)(identity, () => (0, controlSession_1.loadControlSessionAsync)(graphqlClient, sessionId), idleTimeoutMs);
133
+ }
134
+ const borrowed = await (0, controlConnection_1.borrowControlConnectionAsync)(identity);
135
+ if (flags['keep-alive'] && !borrowed) {
136
+ throw new Error('The control helper closed before it could be used. Open the connection again.');
137
+ }
138
+ if (borrowed) {
139
+ connection = borrowed.connection;
140
+ catalog = borrowed.catalog;
141
+ controlSession = borrowed.info.session;
142
+ spinner.stop();
143
+ if (flags['keep-alive'] && !action && !importing && !flags.list && !flags.help) {
144
+ if (jsonFlag) {
145
+ (0, json_1.printJsonOnlyOutput)({ connected: true, id: sessionId, connection: borrowed.info });
146
+ }
147
+ else {
148
+ log_1.default.succeed(`Control connection ready · idle timeout: ${(0, timer_1.formatMilliseconds)(borrowed.info.idleTimeoutMs)}`);
149
+ }
150
+ return;
151
+ }
152
+ }
153
+ else {
154
+ const { access, session } = await (0, controlSession_1.loadControlSessionAsync)(graphqlClient, sessionId);
155
+ connection = await (0, hostActions_1.connectHostActionsAsync)(access);
156
+ catalog = await (0, hostActions_1.fetchHostActionCatalogAsync)(connection);
157
+ controlSession = {
158
+ ...session,
159
+ device: importing || (jsonFlag && Boolean(action) && !flags.list && !flags.help)
160
+ ? await (0, hostActions_1.fetchHostActionDeviceAsync)(access, connection.udid)
161
+ : { udid: connection.udid },
162
+ };
163
+ spinner.succeed(`Connected to simulator session ${sessionId}`);
164
+ }
85
165
  }
86
166
  catch (err) {
87
167
  spinner.fail(`Failed to connect to simulator session ${sessionId}`);
88
168
  throw err;
89
169
  }
90
- if (!action) {
170
+ if (!action && !importing) {
91
171
  this.printCatalog(catalog, jsonFlag);
92
172
  return;
93
173
  }
94
- const entry = Object.hasOwn(catalog, action) ? catalog[action] : undefined;
95
- if (!entry) {
96
- throw new Error(`Unknown simulator action "${action}". Run \`eas simulator:control\` to see the actions.`);
97
- }
98
- if (flags.help) {
174
+ if (flags.help && action) {
175
+ const entry = Object.hasOwn(catalog, action) ? catalog[action] : undefined;
176
+ if (!entry) {
177
+ throw new Error(`Unknown simulator action "${action}". Run \`eas simulator:control --list\` to see the actions.`);
178
+ }
99
179
  this.printActionHelp(action, entry, jsonFlag);
100
180
  return;
101
181
  }
102
- await this.runActionAsync(connection, entry, {
103
- sessionId,
104
- action,
105
- values: argv.slice(1).map(String),
106
- outputPath: flags.output,
107
- jsonFlag,
108
- });
182
+ if (importing) {
183
+ await this.importConfigAsync(connection, catalog, flags.import, {
184
+ session: controlSession,
185
+ jsonFlag,
186
+ });
187
+ }
188
+ else {
189
+ const entry = Object.hasOwn(catalog, action) ? catalog[action] : undefined;
190
+ await this.runActionAsync(connection, catalog, {
191
+ action: action,
192
+ params: entry ? (0, hostActions_1.buildHostActionParams)(action, entry, argv.slice(1).map(String)) : {},
193
+ outputPath: flags.output,
194
+ }, { session: controlSession, jsonFlag });
195
+ }
109
196
  }
110
197
  finally {
111
198
  connection?.close();
112
199
  }
113
200
  }
201
+ async importConfigAsync(connection, catalog, filePath, { session, jsonFlag }) {
202
+ const spinner = jsonFlag ? undefined : (0, ora_1.ora)(`Validating ${node_path_1.default.basename(filePath)}`).start();
203
+ const startedAt = Date.now();
204
+ let stepStartedAt = startedAt;
205
+ let config;
206
+ let results;
207
+ try {
208
+ config = await (0, controlConfig_1.prepareControlConfigAsync)(catalog, filePath, connection.udid);
209
+ if (spinner) {
210
+ spinner.succeed(`Validated ${formatActionCount(config.actions.length)}`);
211
+ this.printSessionHeader(session);
212
+ log_1.default.log(chalk_1.default.bold(node_path_1.default.basename(config.path)));
213
+ log_1.default.gray(config.path);
214
+ for (const { plan } of config.actions) {
215
+ if (plan.localFile) {
216
+ log_1.default.gray(` Read: ${plan.localFile.path}`);
217
+ }
218
+ if (plan.outputPath) {
219
+ log_1.default.gray(` Output: ${plan.outputPath}`);
220
+ }
221
+ }
222
+ if (config.actions.some(({ plan }) => plan.outputPath)) {
223
+ log_1.default.gray('Explicit output files are overwritten; directory outputs use simulator filenames and fail if the file exists.');
224
+ }
225
+ log_1.default.newLine();
226
+ }
227
+ const prepared = config;
228
+ results = await (0, controlConfig_1.executeControlConfigAsync)(connection, prepared, {
229
+ onProgress: spinner
230
+ ? progress => {
231
+ const label = `[${progress.step}/${progress.total}] ${progress.action}`;
232
+ if (progress.status === 'running') {
233
+ stepStartedAt = Date.now();
234
+ spinner.start(label);
235
+ }
236
+ else {
237
+ spinner.succeed(`${label} ${chalk_1.default.dim(formatElapsed(stepStartedAt))}`);
238
+ this.printConfigResult(progress.result);
239
+ }
240
+ }
241
+ : undefined,
242
+ });
243
+ }
244
+ catch (error) {
245
+ if (error instanceof controlConfig_1.ControlConfigExecutionError && config) {
246
+ spinner?.fail(`[${error.step}/${config.actions.length}] ${error.action} ${chalk_1.default.dim(formatElapsed(stepStartedAt))}`);
247
+ if (jsonFlag) {
248
+ (0, json_1.printJsonOnlyOutput)({
249
+ id: session.id,
250
+ session,
251
+ config: config.path,
252
+ results: (0, controlConfig_1.serializeControlConfigResults)(error.completed),
253
+ error: { step: error.step, action: error.action, message: error.message },
254
+ });
255
+ process.exitCode = 1;
256
+ return;
257
+ }
258
+ const skipped = config.actions.length - error.step;
259
+ log_1.default.newLine();
260
+ log_1.default.log(`${error.completed.length} completed · 1 failed · ${skipped} skipped`);
261
+ for (const [index, { plan }] of config.actions.entries()) {
262
+ if (index >= error.step) {
263
+ log_1.default.gray(` [${index + 1}/${config.actions.length}] ${plan.action} skipped`);
264
+ }
265
+ }
266
+ }
267
+ else {
268
+ spinner?.fail(config ? 'Import failed' : 'Validation failed. No actions were run.');
269
+ }
270
+ throw error;
271
+ }
272
+ if (jsonFlag) {
273
+ (0, json_1.printJsonOnlyOutput)({
274
+ id: session.id,
275
+ session,
276
+ config: config.path,
277
+ results: (0, controlConfig_1.serializeControlConfigResults)(results),
278
+ });
279
+ }
280
+ else {
281
+ log_1.default.newLine();
282
+ log_1.default.succeed(`Import complete · ${formatActionCount(results.length)} · ${formatElapsed(startedAt)}`);
283
+ }
284
+ }
285
+ printConfigResult(result) {
286
+ if (result.file) {
287
+ log_1.default.log(` Saved: ${result.file}`);
288
+ }
289
+ else if (result.output) {
290
+ const output = (0, controlActions_1.parseControlActionOutput)(result.output);
291
+ const text = typeof output === 'string' ? output : JSON.stringify(output, null, 2);
292
+ log_1.default.log(text
293
+ .split('\n')
294
+ .map(line => ` ${line}`)
295
+ .join('\n'));
296
+ }
297
+ }
114
298
  printCatalog(catalog, jsonFlag) {
115
299
  if (jsonFlag) {
116
300
  (0, json_1.printJsonOnlyOutput)(Object.fromEntries(Object.entries(catalog).map(([name, entry]) => [name, withUploadPathHelp(entry)])));
@@ -163,47 +347,48 @@ class SimulatorControl extends EasCommand_1.default {
163
347
  }
164
348
  log_1.default.newLine();
165
349
  }
166
- async runActionAsync(connection, entry, { sessionId, action, values, outputPath, jsonFlag, }) {
167
- const params = (0, hostActions_1.buildHostActionParams)(action, entry, values);
168
- await (0, hostActions_1.assertHostActionOutputAsync)(action, entry, outputPath);
169
- const localFile = await findLocalUploadAsync(entry, params);
170
- const spinner = (0, ora_1.ora)(`Running ${action} on simulator session ${sessionId}`).start();
171
- let uploadId;
172
- let succeeded = false;
350
+ printSessionHeader(session) {
351
+ const clean = (value) => (0, terminalText_1.sanitizeTerminalText)((0, node_util_1.stripVTControlCharacters)(value).replace(/[\u202A-\u202E\u2066-\u2069]/g, ''));
352
+ const runtime = clean(session.device.runtime ?? '')
353
+ .replace(/^([A-Za-z]+)-/, '$1 ')
354
+ .replaceAll('-', '.');
355
+ log_1.default.newLine();
356
+ log_1.default.log(chalk_1.default.bold('Simulator controls'));
357
+ log_1.default.log((0, formatFields_1.default)([
358
+ { label: 'Session', value: (0, terminalText_1.truncate)(clean(session.name ?? '') || 'Unnamed session', 80) },
359
+ { label: 'Project', value: clean(session.project) },
360
+ {
361
+ label: 'Device',
362
+ value: [(0, terminalText_1.truncate)(clean(session.device.name ?? '') || 'Unavailable', 80), runtime]
363
+ .filter(Boolean)
364
+ .join(' · '),
365
+ },
366
+ { label: 'State', value: session.status.toLowerCase().replaceAll('_', ' ') },
367
+ { label: 'Session ID', value: clean(session.id) },
368
+ { label: 'Device ID', value: clean(session.device.udid) },
369
+ ]));
370
+ log_1.default.newLine();
371
+ }
372
+ async runActionAsync(connection, catalog, selection, { session, jsonFlag }) {
373
+ const { action } = selection;
374
+ const plan = await (0, controlActions_1.prepareControlActionAsync)(catalog, selection);
375
+ const spinner = (0, ora_1.ora)(`Running ${action} on simulator session ${session.id}`).start();
173
376
  let output;
174
377
  let savedFile;
175
378
  try {
176
- if (localFile) {
177
- spinner.text = `Uploading ${localFile.path}`;
178
- const upload = await (0, hostActions_1.uploadFileAsync)(connection, localFile.path);
179
- uploadId = upload.uploadId;
180
- params[localFile.param] = entry.uploadAs === 'id' ? upload.uploadId : upload.path;
181
- spinner.text = `Running ${action} on simulator session ${sessionId}`;
182
- }
183
- const result = await connection.requestAsync(action, params);
184
- if (result.exitCode !== 0) {
185
- const detail = (result.stderr || result.stdout).trim() || `exit code ${result.exitCode}`;
186
- throw new Error(`The simulator could not run ${action}: ${detail}`);
187
- }
188
- succeeded = true;
189
- savedFile = await (0, hostActions_1.saveHostActionOutputAsync)(connection, entry, result.stdout, outputPath);
190
- output = savedFile ? '' : result.stdout.trim();
191
- spinner.succeed(`Ran ${action} on simulator session ${sessionId}`);
379
+ ({ output, file: savedFile } = await (0, controlActions_1.executeControlActionAsync)(connection, plan));
380
+ spinner.succeed(`Ran ${action} on simulator session ${session.id}`);
192
381
  }
193
382
  catch (err) {
194
- spinner.fail(`Failed to run ${action} on simulator session ${sessionId}`);
383
+ spinner.fail(`Failed to run ${action} on simulator session ${session.id}`);
195
384
  throw err;
196
385
  }
197
- finally {
198
- if (uploadId && (!entry.keepUpload || !succeeded)) {
199
- await connection.requestAsync('upload.remove', { uploadId }).catch(() => { });
200
- }
201
- }
202
386
  if (jsonFlag) {
203
387
  (0, json_1.printJsonOnlyOutput)({
204
- id: sessionId,
388
+ id: session.id,
389
+ session,
205
390
  action,
206
- output: parseJsonOutput(output),
391
+ output: (0, controlActions_1.parseControlActionOutput)(output),
207
392
  file: savedFile,
208
393
  });
209
394
  return;
@@ -231,55 +416,9 @@ function withUploadPathHelp(entry) {
231
416
  ? { ...entry, description: [entry.description, help].filter(Boolean).join('\n\n') }
232
417
  : entry;
233
418
  }
234
- async function findLocalUploadAsync({ upload: param, uploadWhen = {}, uploadAs }, params) {
235
- const value = param ? params[param] : undefined;
236
- const applies = Object.entries(uploadWhen).every(([name, expected]) => params[name] === expected);
237
- if (!param || typeof value !== 'string' || !applies) {
238
- return null;
239
- }
240
- if (value.startsWith('host:')) {
241
- if (uploadAs === 'id') {
242
- throw new Error('This action requires a local file to upload; host: paths are not supported.');
243
- }
244
- const hostPath = value.slice('host:'.length);
245
- if (!path_1.default.posix.isAbsolute(hostPath)) {
246
- throw new Error(`A host: path must be absolute, for example host:/tmp/app.tar.gz. For a local filename beginning with host:, use ./${value}.`);
247
- }
248
- params[param] = hostPath;
249
- return null;
250
- }
251
- const stat = await fs.stat(value).catch((error) => {
252
- if (error.code === 'ENOENT' || error.code === 'ENOTDIR') {
253
- return null;
254
- }
255
- throw error;
256
- });
257
- if (stat?.isDirectory()) {
258
- throw new Error(`${value} is a folder. Pass the path of a file.`);
259
- }
260
- if (!stat) {
261
- throw new Error(`${value} does not exist on this computer. Pass a local file, or prefix an absolute simulator-host path with host:.`);
262
- }
263
- return stat ? { param, path: value } : null;
419
+ function formatElapsed(startedAt) {
420
+ return (0, timer_1.formatMilliseconds)(Date.now() - startedAt) || '<1s';
264
421
  }
265
- function assertControllableSession(session) {
266
- if (session.status !== generated_1.DeviceRunSessionStatus.InProgress) {
267
- throw new Error(`Simulator session ${session.id} is ${session.status.toLowerCase()}. Simulator actions need a running session. Start one with \`eas simulator:start\`.`);
268
- }
269
- if (session.platform !== generated_1.AppPlatform.Ios) {
270
- throw new Error(`Simulator session ${session.id} runs on ${session.platform.toLowerCase()}. Simulator actions are available only for iOS sessions.`);
271
- }
272
- const access = session.remoteConfig ? (0, utils_1.getPreviewApiAccess)(session.remoteConfig) : null;
273
- if (!access) {
274
- throw new Error(`Simulator session ${session.id} does not expose a preview server with a token. Simulator actions use that server. Start a new session with \`eas simulator:start\`.`);
275
- }
276
- return access;
277
- }
278
- function parseJsonOutput(output) {
279
- try {
280
- return JSON.parse(output);
281
- }
282
- catch {
283
- return output;
284
- }
422
+ function formatActionCount(count) {
423
+ return `${count} action${count === 1 ? '' : 's'}`;
285
424
  }
@@ -1,6 +1,7 @@
1
1
  import EasCommand from '../../commandUtils/EasCommand';
2
2
  export default class SimulatorEgress extends EasCommand {
3
3
  static aliases: string[];
4
+ static hiddenAliases: string[];
4
5
  static description: string;
5
6
  static flags: {
6
7
  'config-type': import("@oclif/core/lib/interfaces").OptionFlag<"env" | "dotenv", import("@oclif/core/lib/interfaces").CustomOptions>;
@@ -6,8 +6,10 @@ const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasComm
6
6
  const log_1 = tslib_1.__importDefault(require("../../log"));
7
7
  const egress_1 = require("../../simulator/egress");
8
8
  const env_1 = require("../../simulator/env");
9
+ const commandAliases_1 = require("../../simulator/commandAliases");
9
10
  class SimulatorEgress extends EasCommand_1.default {
10
- static aliases = ['sim:egress'];
11
+ static aliases = (0, commandAliases_1.getSimulatorCommandAliases)('egress');
12
+ static hiddenAliases = (0, commandAliases_1.getSimulatorCommandHiddenAliases)('egress');
11
13
  static description = `[EXPERIMENTAL] run the local egress client for a simulator session to route proxied HTTP(S) requests through this machine`;
12
14
  static flags = {
13
15
  'config-type': core_1.Flags.option({
@@ -1,6 +1,7 @@
1
1
  import EasCommand from '../../commandUtils/EasCommand';
2
2
  export default class SimulatorEvents extends EasCommand {
3
3
  static aliases: string[];
4
+ static hiddenAliases: string[];
4
5
  static description: string;
5
6
  static flags: {
6
7
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -11,10 +11,12 @@ const env_1 = require("../../simulator/env");
11
11
  const events_1 = require("../../simulator/events");
12
12
  const json_1 = require("../../utils/json");
13
13
  const promise_1 = require("../../utils/promise");
14
+ const commandAliases_1 = require("../../simulator/commandAliases");
14
15
  const POLL_INTERVAL_MS = 5_000;
15
16
  const POST_STOP_REFRESH_COUNT = 2;
16
17
  class SimulatorEvents extends EasCommand_1.default {
17
- static aliases = ['sim:events'];
18
+ static aliases = (0, commandAliases_1.getSimulatorCommandAliases)('events');
19
+ static hiddenAliases = (0, commandAliases_1.getSimulatorCommandHiddenAliases)('events');
18
20
  static description = '[EXPERIMENTAL] show activity events from a remote simulator session';
19
21
  static flags = {
20
22
  id: core_1.Flags.string({
@@ -1,6 +1,7 @@
1
1
  import EasCommand from '../../commandUtils/EasCommand';
2
2
  export default class SimulatorExec extends EasCommand {
3
3
  static aliases: string[];
4
+ static hiddenAliases: string[];
4
5
  static description: string;
5
6
  static strict: boolean;
6
7
  static contextDefinition: {
@@ -4,8 +4,10 @@ const tslib_1 = require("tslib");
4
4
  const spawn_async_1 = tslib_1.__importDefault(require("@expo/spawn-async"));
5
5
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
6
6
  const env_1 = require("../../simulator/env");
7
+ const commandAliases_1 = require("../../simulator/commandAliases");
7
8
  class SimulatorExec extends EasCommand_1.default {
8
- static aliases = ['sim:exec'];
9
+ static aliases = (0, commandAliases_1.getSimulatorCommandAliases)('exec');
10
+ static hiddenAliases = (0, commandAliases_1.getSimulatorCommandHiddenAliases)('exec');
9
11
  static description = `[EXPERIMENTAL] execute a simulator command with ${env_1.SIMULATOR_DOTENV_FILE_NAME} environment loaded`;
10
12
  static strict = false;
11
13
  static contextDefinition = {
@@ -1,6 +1,7 @@
1
1
  import EasCommand from '../../commandUtils/EasCommand';
2
2
  export default class SimulatorGet extends EasCommand {
3
3
  static aliases: string[];
4
+ static hiddenAliases: string[];
4
5
  static description: string;
5
6
  static flags: {
6
7
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -15,8 +15,10 @@ const utils_1 = require("../../simulator/utils");
15
15
  const files_1 = require("../../utils/files");
16
16
  const formatFields_1 = tslib_1.__importDefault(require("../../utils/formatFields"));
17
17
  const json_1 = require("../../utils/json");
18
+ const commandAliases_1 = require("../../simulator/commandAliases");
18
19
  class SimulatorGet extends EasCommand_1.default {
19
- static aliases = ['sim:get'];
20
+ static aliases = (0, commandAliases_1.getSimulatorCommandAliases)('get');
21
+ static hiddenAliases = (0, commandAliases_1.getSimulatorCommandHiddenAliases)('get');
20
22
  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";
21
23
  static flags = {
22
24
  id: core_1.Flags.string({
@@ -3,9 +3,11 @@ export default class Simulator extends EasCommand {
3
3
  static aliases: string[];
4
4
  static hiddenAliases: string[];
5
5
  static description: string;
6
+ static examples: string[];
6
7
  static flags: {
7
8
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
9
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ import: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
11
  platform: import("@oclif/core/lib/interfaces").OptionFlag<"android" | "ios" | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
12
  name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
13
  tag: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;