eas-cli 21.3.0 → 21.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ import { type DeviceRunSessionEvent } from '@expo/eas-build-job';
2
+ export type { DeviceRunSessionEvent };
3
+ export declare function downloadDeviceRunSessionEventsAsync(eventLogUrl: string): Promise<DeviceRunSessionEvent[]>;
4
+ export declare function projectDeviceRunSessionEventsForDisplay(events: DeviceRunSessionEvent[], { includeIncompleteOperations }?: {
5
+ includeIncompleteOperations?: boolean;
6
+ }): DeviceRunSessionEvent[];
7
+ export declare function formatDeviceRunSessionEvent(event: DeviceRunSessionEvent): string;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.downloadDeviceRunSessionEventsAsync = downloadDeviceRunSessionEventsAsync;
4
+ exports.projectDeviceRunSessionEventsForDisplay = projectDeviceRunSessionEventsForDisplay;
5
+ exports.formatDeviceRunSessionEvent = formatDeviceRunSessionEvent;
6
+ const tslib_1 = require("tslib");
7
+ const util_1 = require("util");
8
+ const eas_build_job_1 = require("@expo/eas-build-job");
9
+ const fetch_1 = tslib_1.__importStar(require("../fetch"));
10
+ const timer_1 = require("../utils/timer");
11
+ async function downloadDeviceRunSessionEventsAsync(eventLogUrl) {
12
+ try {
13
+ const response = await (0, fetch_1.default)(eventLogUrl);
14
+ return (0, eas_build_job_1.parseDeviceRunSessionEvents)(await response.text());
15
+ }
16
+ catch (error) {
17
+ if (error instanceof fetch_1.RequestError && error.response.status === 404) {
18
+ return [];
19
+ }
20
+ throw error;
21
+ }
22
+ }
23
+ function projectDeviceRunSessionEventsForDisplay(events, { includeIncompleteOperations = true } = {}) {
24
+ const operations = new Map();
25
+ for (const event of events) {
26
+ if (!event.operationId) {
27
+ continue;
28
+ }
29
+ const operationKey = getOperationKey(event);
30
+ const operation = operations.get(operationKey) ?? { interactions: [] };
31
+ if (event.type === 'operation.completed') {
32
+ operation.completed = event;
33
+ }
34
+ else if (event.type === 'interaction.recorded') {
35
+ operation.interactions.push(event);
36
+ }
37
+ operations.set(operationKey, operation);
38
+ }
39
+ return events.flatMap(event => {
40
+ if (!event.operationId) {
41
+ return [event];
42
+ }
43
+ const operation = operations.get(getOperationKey(event));
44
+ const completed = operation?.completed;
45
+ const interactions = operation?.interactions ?? [];
46
+ if (!includeIncompleteOperations &&
47
+ !completed &&
48
+ (event.type === 'operation.started' || event.type === 'interaction.recorded')) {
49
+ return [];
50
+ }
51
+ if (event.type === 'operation.started' && (completed || interactions.length > 0)) {
52
+ return [];
53
+ }
54
+ if (event.type === 'interaction.recorded' && completed?.outcome === 'failure') {
55
+ return [];
56
+ }
57
+ if (event.type === 'operation.completed' && completed?.outcome !== 'failure') {
58
+ return interactions.length > 0 ? [] : [event];
59
+ }
60
+ if (event.type === 'interaction.recorded' &&
61
+ completed &&
62
+ interactions.at(-1)?.eventId === event.eventId) {
63
+ return [{ ...event, durationMs: completed.durationMs, outcome: completed.outcome }];
64
+ }
65
+ return [event];
66
+ });
67
+ }
68
+ function formatDeviceRunSessionEvent(event) {
69
+ const screenshotFilename = getScreenshotFilename(event);
70
+ const summary = screenshotFilename && !event.summary.includes(screenshotFilename)
71
+ ? `${event.summary} ${screenshotFilename}`
72
+ : event.summary;
73
+ const duration = event.durationMs === undefined ? '' : ` (${formatEventDuration(event.durationMs)})`;
74
+ return stripTerminalControlCharacters(`${event.ts} [${event.producer}] ${summary}${duration}`);
75
+ }
76
+ function getOperationKey(event) {
77
+ return JSON.stringify([event.producer, event.operationId]);
78
+ }
79
+ function formatEventDuration(durationMs) {
80
+ return durationMs < 1000 ? `${Math.round(durationMs)}ms` : (0, timer_1.formatMilliseconds)(durationMs);
81
+ }
82
+ function getScreenshotFilename(event) {
83
+ if (event.data?.command !== 'screenshot' || typeof event.data.path !== 'string') {
84
+ return undefined;
85
+ }
86
+ return event.data.path.split(/[\\/]/).at(-1);
87
+ }
88
+ function stripTerminalControlCharacters(value) {
89
+ return [...(0, util_1.stripVTControlCharacters)(value)]
90
+ .filter(character => {
91
+ const codePoint = character.codePointAt(0) ?? 0;
92
+ return codePoint >= 0x20 && !(codePoint >= 0x7f && codePoint <= 0x9f);
93
+ })
94
+ .join('');
95
+ }
@@ -40,7 +40,7 @@ function formatRemoteSessionInstructions(remoteConfig, configType) {
40
40
  ? [
41
41
  '🔑 Run the following to use agent-device with the simulator:',
42
42
  '',
43
- 'eas simulator:exec agent-device <command>',
43
+ 'eas simulator:exec npx agent-device <command>',
44
44
  ]
45
45
  : [
46
46
  '🔑 Run the following in your shell to attach to the agent-device daemon:',