Compare commits

...
Author SHA1 Message Date
Expo CI 5409c03d58 v24.0.0 2026-09-09 20:07:38 +00:00
Gabe Debes a941930ea7 [eas-cli] adds serve-sim session token in simulator preview links (#4312)
* [eas-cli] carry the serve-sim session token in simulator preview links

* [eas-cli] sanitize the preview config in json output
2026-09-09 12:52:08 -07:00
Szymon Świerk 74572101ac [eas-cli] Make ASC API key issuer identifier optional in types (#4248)
* [eas-cli] Make ASC API key issuer identifier optional in types

* [eas-cli] Bump @expo/apple-utils to 2.2.0

* [eas-cli] Pass optional issuer identifier through to TestFlight app lookup
2026-09-09 21:22:32 +02:00
Stanisław Chmiela 7b050cae3f [worker] Add MCP server URL to build context (#4335)
# Why

Worker has config for API server URL. I now need MCP server URL too.

# How

Added `mcpServerUrl` in `config` and in contexts.

# Test Plan

CI should pass.
2026-09-09 16:56:49 +02:00
Douglas LowderandClaude Opus 4.8 d193860668 [eas-cli] Add observe:event command to fetch a single event by ID (#4252)
* [eas-cli] Add observe:event command to fetch a single event by ID

Add `eas observe:event <id>` to display one Observe event (either metric or userEvent) by its ID. Also, ensure event IDs are propagated to the results of `eas observe:session <sessionId>` so that they appear in JSON output.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-09-09 06:07:57 -07:00
Krystof WoldrichandCodex 1da0be8529 [build-tools] Use bun x to start Argent remote sessions (#4366)
Co-authored-by: Codex (GPT-6) <[email protected]>
2026-09-08 15:22:47 +02:00
Douglas LowderandClaude Opus 4.8 08b4346620 [eas-cli] Add observe:errors command (#4339)
* [eas-cli] Add observe:errors command

Add `eas observe:errors` to display error and exception issue groups grouped by
fingerprint, using the new observe.errors.groups GraphQL namespace. Exceptions
are excluded from observe:events (userEvents.list) and surfaced here instead.
Supports --platform, --severity (fatal|error), time-range, --app-version,
--build-number, --update-id, and --environment filters, with table and --json
output.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* [eas-cli] Add --fingerprint drill-down to observe:errors

Add `eas observe:errors --fingerprint <fingerprint>` to list an error group's
individual occurrences with stack traces, instead of only the grouped summary.
Occurrences are fetched via observe.errors.occurrences (newest first) with
--limit and --after paging, and rendered as per-occurrence detail (fields,
stack trace, body, properties) or as --json. The grouped table now shows a
Fingerprint column and a hint pointing to the flag.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* Respond to review comments

* Regenerate GraphQL from server

* Fix errors from nullability change in issuerIdentifier

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
2026-09-07 20:29:56 -07:00
4d6d9b1fc4 [build-tools] Allow configuring Android emulator display (#4349)
Co-authored-by: Krystof Woldrich <[email protected]>
Co-authored-by: Codex (GPT-6) <[email protected]>
2026-09-07 15:39:56 +02:00
56 changed files with 4673 additions and 2349 deletions

No files matched your search

+7
View File
@@ -10,15 +10,22 @@ This is the log of notable changes to EAS CLI and related packages.
### 🎉 New features
- [build-tools] Add `lcd_width`, `lcd_height`, and `lcd_density` inputs to configure the Android emulator display. ([#4349](https://github.com/expo/eas-cli/pull/4349) by [@krystofwoldrich-agent](https://github.com/krystofwoldrich-agent))
- [eas-cli] Add `eas channel:protect` and `eas channel:unprotect` to manage EAS Update channel protection, and show protection in channel list and view output. ([#4319](https://github.com/expo/eas-cli/pull/4319) by [@sjkim-expo](https://github.com/sjkim-expo))
- [eas-cli] Add `eas observe:errors` to display error and exception issue groups (grouped by fingerprint), with `--fingerprint <fingerprint>` to drill into a group's individual occurrences and stack traces. ([#4339](https://github.com/expo/eas-cli/pull/4339) by [@douglowder](https://github.com/douglowder))
- [eas-cli] Add `eas observe:event` to display a single Observe event (metric, log, or error) by its ID. ([#4252](https://github.com/expo/eas-cli/pull/4252) by [@douglowder](https://github.com/douglowder))
### 🐛 Bug fixes
- [build-tools] Start Argent remote sessions with `bun x` so they work when the `bunx` symlink is missing. ([491b372a](https://github.com/expo/eas-cli/commit/491b372a) by [@krystofwoldrich](https://github.com/krystofwoldrich))
- [build-tools] Reduce `expo-device-hub` preview resolution from 1280 px to 960 px to match `serve-sim` and lower streaming bandwidth. ([#4326](https://github.com/expo/eas-cli/pull/4326) by [@krystofwoldrich-agent](https://github.com/krystofwoldrich-agent))
- [build-tools] Install FFmpeg before launching `expo-device-hub` in Android device sessions. ([#4332](https://github.com/expo/eas-cli/pull/4332) by [@krystofwoldrich-agent](https://github.com/krystofwoldrich-agent))
- [eas-cli] Print the session token in simulator preview links, so they still open once the preview is gated. ([#4312](https://github.com/expo/eas-cli/pull/4312) by [@gwdp](https://github.com/gwdp))
### 🧹 Chores
- [eas-cli] Make ASC API key issuer identifier optional in GraphQL and credentials types. ([#4248](https://github.com/expo/eas-cli/pull/4248) by [@sswrk](https://github.com/sswrk))
## [23.2.0](https://github.com/expo/eas-cli/releases/tag/v23.2.0) - 2026-08-31
### 🎉 New features
+1 -1
View File
@@ -1,5 +1,5 @@
{
"npmClient": "yarn",
"version": "23.2.0",
"version": "24.0.0",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/build-tools",
"version": "23.2.0",
"version": "24.0.0",
"bugs": "https://github.com/expo/eas-cli/issues",
"license": "BUSL-1.1",
"author": "Expo <[email protected]>",
@@ -39,17 +39,17 @@
"dependencies": {
"@expo/config": "55.0.10",
"@expo/config-plugins": "55.0.7",
"@expo/downloader": "23.0.0",
"@expo/eas-build-job": "23.1.0",
"@expo/downloader": "24.0.0",
"@expo/eas-build-job": "24.0.0",
"@expo/env": "^0.4.0",
"@expo/logger": "23.1.0",
"@expo/logger": "24.0.0",
"@expo/package-manager": "1.9.10",
"@expo/plist": "^0.3.5",
"@expo/results": "^1.0.0",
"@expo/spawn-async": "1.7.2",
"@expo/steps": "23.1.0",
"@expo/template-file": "23.0.0",
"@expo/turtle-spawn": "23.1.0",
"@expo/steps": "24.0.0",
"@expo/template-file": "24.0.0",
"@expo/turtle-spawn": "24.0.0",
"@expo/xcpretty": "^4.3.1",
"@ngrok/ngrok": "1.7.0",
"@sentry/node": "7.77.0",
@@ -11,6 +11,19 @@ jest.mock('../utils/stepMetrics');
const mockUploadStepMetricsToWwwAsync = jest.mocked(uploadStepMetricsToWwwAsync);
describe(CustomBuildContext, () => {
it('copies the MCP server URL from the build context', () => {
const ctx = new BuildContext(createTestIosJob(), {
env: { __API_SERVER_URL: 'http://api.expo.test' },
logBuffer: { getLogs: () => [], getPhaseLogs: () => [] },
logger: createMockLogger(),
uploadArtifact: jest.fn(),
workingdir: '',
mcpServerUrl: 'ws://localhost:8787',
});
expect(new CustomBuildContext(ctx).mcpServerUrl).toBe('ws://localhost:8787');
});
it('should not lose workflowInterpolationContext', () => {
const contextUploadArtifact = jest.fn();
const ctx = new BuildContext(
+3
View File
@@ -68,6 +68,7 @@ export interface BuildContextOptions {
skipNativeBuild?: boolean;
metadata?: Metadata;
expoApiV2BaseUrl?: string;
mcpServerUrl?: string;
}
export class SkipNativeBuildError extends Error {}
@@ -84,6 +85,7 @@ export class BuildContext<TJob extends Job = Job> {
) => void;
public readonly skipNativeBuild?: boolean;
public readonly expoApiV2BaseUrl?: string;
public readonly mcpServerUrl?: string;
public artifacts: Artifacts = {};
private readonly _isLocal: boolean;
@@ -112,6 +114,7 @@ export class BuildContext<TJob extends Job = Job> {
this._metadata = options.metadata;
this.skipNativeBuild = options.skipNativeBuild;
this.expoApiV2BaseUrl = options.expoApiV2BaseUrl;
this.mcpServerUrl = options.mcpServerUrl;
const environmentSecrets = this.getEnvironmentSecrets(job);
this._env = {
@@ -63,6 +63,7 @@ export class CustomBuildContext<TJob extends Job = Job> implements ExternalBuild
public readonly logger: bunyan;
public readonly graphqlClient: Client;
public readonly runtimeApi: BuilderRuntimeApi;
public readonly mcpServerUrl?: string;
public job: TJob;
public metadata?: Metadata;
@@ -84,6 +85,7 @@ export class CustomBuildContext<TJob extends Job = Job> implements ExternalBuild
this.runtimeApi = {
uploadArtifact: (...args) => buildCtx['uploadArtifact'](...args),
};
this.mcpServerUrl = buildCtx.mcpServerUrl;
this.expoApiV2BaseUrl = buildCtx.expoApiV2BaseUrl;
this.startTime = new Date();
}
@@ -83,6 +83,31 @@ describe(createStartAndroidEmulatorBuildFunction, () => {
mockedMkdtemp.mockRestore();
});
it('passes profile and LCD inputs to emulator creation', async () => {
const systemImagePackage = 'system-images;android-35;default;x86_64';
await createStep({
device_identifier: 'medium_phone',
system_image_package: systemImagePackage,
lcd_width: 720,
lcd_height: 1600,
lcd_density: 262,
}).executeAsync();
expect(mockedSpawn).toHaveBeenCalledWith('sdkmanager', [systemImagePackage], expect.anything());
expect(mockedAndroidUtils.createAsync).toHaveBeenCalledWith(
expect.objectContaining({
deviceIdentifier: 'medium_phone',
systemImagePackage,
lcdWidth: 720,
lcdHeight: 1600,
lcdDensity: 262,
})
);
expect(mockedAndroidUtils.createAsync.mock.invocationCallOrder[0]).toBeLessThan(
mockedAndroidUtils.startAsync.mock.invocationCallOrder[0]
);
});
it('retries base emulator startup with increasing readiness timeouts', async () => {
mockedAndroidUtils.startAsync
.mockResolvedValueOnce(createStartResult('emulator-1111'))
@@ -142,7 +142,10 @@ describe('createStartArgentRemoteSessionBuildFunction orchestration', () => {
const spawnCalls = jest.mocked(spawn).mock.calls;
const enableEventLogIndex = spawnCalls.findIndex(
([command, args]) =>
command === 'bunx' && Array.isArray(args) && args.includes('tool-server-event-log')
command === 'bun' &&
Array.isArray(args) &&
args[0] === 'x' &&
args.includes('tool-server-event-log')
);
expect(enableEventLogIndex).toBeGreaterThanOrEqual(0);
expect(jest.mocked(spawn).mock.invocationCallOrder[enableEventLogIndex]).toBeLessThan(
@@ -74,7 +74,7 @@ describe(warnIfArgentPackageVersionCannotBeVerified, () => {
).not.toThrow();
expect(warn).toHaveBeenCalledTimes(2);
expect(warn).toHaveBeenCalledWith(
expect.stringContaining('Continuing and letting bunx resolve it.')
expect.stringContaining('Continuing and letting bun x resolve it.')
);
});
});
@@ -46,6 +46,21 @@ export function createStartAndroidEmulatorBuildFunction(): BuildFunction {
defaultValue: AndroidEmulatorUtils.defaultSystemImagePackage,
allowedValueTypeName: BuildStepInputValueTypeName.STRING,
}),
BuildStepInput.createProvider({
id: 'lcd_width',
required: false,
allowedValueTypeName: BuildStepInputValueTypeName.NUMBER,
}),
BuildStepInput.createProvider({
id: 'lcd_height',
required: false,
allowedValueTypeName: BuildStepInputValueTypeName.NUMBER,
}),
BuildStepInput.createProvider({
id: 'lcd_density',
required: false,
allowedValueTypeName: BuildStepInputValueTypeName.NUMBER,
}),
BuildStepInput.createProvider({
id: 'count',
required: false,
@@ -86,6 +101,9 @@ export function createStartAndroidEmulatorBuildFunction(): BuildFunction {
const systemImagePackage = `${inputs.system_image_package.value}`;
// We can cast because allowedValueTypeName validated this is a string.
const deviceIdentifier = inputs.device_identifier.value as AndroidDeviceName | undefined;
const lcdWidth = inputs.lcd_width.value as number | undefined;
const lcdHeight = inputs.lcd_height.value as number | undefined;
const lcdDensity = inputs.lcd_density.value as number | undefined;
const shouldAdjustAnimationScale =
env.ANDROID_EMULATOR_ADJUST_ANIMATION_SCALE !== 'false' &&
env.ANDROID_EMULATOR_ADJUST_ANIMATION_SCALE !== '0';
@@ -129,6 +147,9 @@ export function createStartAndroidEmulatorBuildFunction(): BuildFunction {
deviceName,
systemImagePackage,
deviceIdentifier: deviceIdentifier ?? null,
lcdWidth: lcdWidth ?? null,
lcdHeight: lcdHeight ?? null,
lcdDensity: lcdDensity ?? null,
env,
logger,
});
@@ -112,24 +112,30 @@ export function createStartArgentRemoteSessionBuildFunction(
logger.info('Enabling the Argent artifacts list endpoint flag.');
await spawn(
'bunx',
[`${ARGENT_PACKAGE_NAME}@${versionSpec}`, 'enable', ARGENT_ARTIFACTS_LIST_ENDPOINT_FLAG],
'bun',
[
'x',
`${ARGENT_PACKAGE_NAME}@${versionSpec}`,
'enable',
ARGENT_ARTIFACTS_LIST_ENDPOINT_FLAG,
],
{ env, logger }
);
logger.info('Enabling the Argent tool-server event log flag.');
await spawn(
'bunx',
[`${ARGENT_PACKAGE_NAME}@${versionSpec}`, 'enable', ARGENT_EVENT_LOG_FLAG],
'bun',
['x', `${ARGENT_PACKAGE_NAME}@${versionSpec}`, 'enable', ARGENT_EVENT_LOG_FLAG],
{ env, logger }
);
logger.info(`Launching ${ARGENT_PACKAGE_NAME}@${versionSpec} tool-server via bunx.`);
// Keep Argent itself in foreground mode under the detached bunx process. This preserves
// the bunx -> Argent CLI -> tool-server ancestry used to identify the matching state file.
logger.info(`Launching ${ARGENT_PACKAGE_NAME}@${versionSpec} tool-server via bun x.`);
// Keep Argent itself in foreground mode under the detached bun process. This preserves
// the bun -> Argent CLI -> tool-server ancestry used to identify the matching state file.
const argentServer = spawnDetached({
command: 'bunx',
command: 'bun',
args: [
'x',
`${ARGENT_PACKAGE_NAME}@${versionSpec}`,
'server',
'start',
@@ -294,7 +300,7 @@ export function warnIfArgentPackageVersionCannotBeVerified({
logger.warn(
`Argent remote simulator sessions require ${ARGENT_PACKAGE_NAME}@${MIN_ARGENT_REMOTE_SESSION_VERSION} or newer, ` +
`but package_version "${packageVersion}" is not an exact semver version that EAS can verify. ` +
`Continuing and letting bunx resolve it.`
`Continuing and letting bun x resolve it.`
);
return;
}
@@ -99,12 +99,18 @@ export namespace AndroidEmulatorUtils {
deviceName,
systemImagePackage,
deviceIdentifier,
lcdWidth,
lcdHeight,
lcdDensity,
env,
logger,
}: {
deviceName: AndroidVirtualDeviceName;
systemImagePackage: string;
deviceIdentifier: AndroidDeviceName | null;
lcdWidth: number | null;
lcdHeight: number | null;
lcdDensity: number | null;
env: NodeJS.ProcessEnv;
logger: bunyan;
}): Promise<void> {
@@ -176,6 +182,13 @@ export namespace AndroidEmulatorUtils {
}
}
if (lcdWidth !== null && lcdHeight !== null && lcdDensity !== null) {
logger.info(
`Setting screen resolution to ${lcdWidth}x${lcdHeight} and density to ${lcdDensity} ppi.`
);
configIniFileContent = `${configIniFileContent}\nhw.lcd.height=${lcdHeight}\nhw.lcd.width=${lcdWidth}\nhw.lcd.density=${lcdDensity}\n`;
}
const shouldAdjustHeapSize =
env.ANDROID_EMULATOR_ADJUST_HEAP_SIZE !== 'false' &&
env.ANDROID_EMULATOR_ADJUST_HEAP_SIZE !== '0';
@@ -71,6 +71,9 @@ describe('AndroidEmulatorUtils', () => {
deviceName,
systemImagePackage: AndroidEmulatorUtils.defaultSystemImagePackage,
deviceIdentifier: null,
lcdWidth: null,
lcdHeight: null,
lcdDensity: null,
env: process.env,
logger: createMockLogger({ logToConsole: true }),
});
@@ -95,6 +98,9 @@ describe('AndroidEmulatorUtils', () => {
deviceName,
systemImagePackage: AndroidEmulatorUtils.defaultSystemImagePackage,
deviceIdentifier: null,
lcdWidth: null,
lcdHeight: null,
lcdDensity: null,
env: process.env,
logger: createMockLogger({ logToConsole: true }),
});
@@ -158,6 +164,9 @@ describe('AndroidEmulatorUtils', () => {
deviceName,
systemImagePackage: AndroidEmulatorUtils.defaultSystemImagePackage,
deviceIdentifier: null,
lcdWidth: null,
lcdHeight: null,
lcdDensity: null,
env: process.env,
logger: createMockLogger({ logToConsole: true }),
});
@@ -209,6 +218,9 @@ describe('AndroidEmulatorUtils', () => {
deviceName,
systemImagePackage: AndroidEmulatorUtils.defaultSystemImagePackage,
deviceIdentifier: null,
lcdWidth: null,
lcdHeight: null,
lcdDensity: null,
env: envForAttempt,
logger: createMockLogger({ logToConsole: true }),
});
@@ -290,6 +302,9 @@ describe('AndroidEmulatorUtils', () => {
deviceName,
systemImagePackage: AndroidEmulatorUtils.defaultSystemImagePackage,
deviceIdentifier: null,
lcdWidth: null,
lcdHeight: null,
lcdDensity: null,
env: process.env,
logger,
});
@@ -361,6 +376,9 @@ describe('AndroidEmulatorUtils', () => {
deviceName,
systemImagePackage: AndroidEmulatorUtils.defaultSystemImagePackage,
deviceIdentifier: null,
lcdWidth: null,
lcdHeight: null,
lcdDensity: null,
env: process.env,
logger: createMockLogger({ logToConsole: true }),
});
@@ -8,7 +8,11 @@ import path from 'node:path';
import { createMockLogger } from '../../__tests__/utils/logger';
import { Sentry } from '../../sentry';
import { AndroidEmulatorUtils, AndroidVirtualDeviceName } from '../AndroidEmulatorUtils';
import {
AndroidDeviceName,
AndroidEmulatorUtils,
AndroidVirtualDeviceName,
} from '../AndroidEmulatorUtils';
import { retryAsync } from '../retry';
jest.mock('@expo/turtle-spawn', () => ({
@@ -48,6 +52,120 @@ describe('AndroidEmulatorUtils', () => {
);
});
describe(AndroidEmulatorUtils.createAsync, () => {
it('applies an explicit LCD configuration after screen scaling', async () => {
const deviceName = 'eas-simulator' as AndroidVirtualDeviceName;
const avdDirectory = `/home/expo/.android/avd/${deviceName}.avd`;
await fs.promises.mkdir(avdDirectory, { recursive: true });
await fs.promises.writeFile(
`${avdDirectory}/config.ini`,
[
'hw.ramSize=1536',
'hw.lcd.height=2424',
'hw.lcd.width=1080',
'hw.lcd.density=420',
'skin.path=pixel_9',
'showDeviceFrame=yes',
].join('\n')
);
const avdManagerPromise = Promise.resolve({ stdout: '', stderr: '' }) as any;
const write = jest.fn();
const end = jest.fn();
avdManagerPromise.child = { stdin: { write, end } };
mockedSpawn.mockReturnValue(avdManagerPromise);
const logger = createMockLogger();
await AndroidEmulatorUtils.createAsync({
deviceName,
systemImagePackage: 'system-images;android-35;default;x86_64',
deviceIdentifier: 'medium_phone' as AndroidDeviceName,
lcdWidth: 720,
lcdHeight: 1600,
lcdDensity: 262,
env: {
HOME: '/home/expo',
ANDROID_EMULATOR_ADJUST_SCREEN: '1',
ANDROID_EMULATOR_ADJUST_HEAP_SIZE: '0',
},
logger,
});
expect(mockedSpawn).toHaveBeenCalledWith(
'avdmanager',
[
'create',
'avd',
'--name',
deviceName,
'--package',
'system-images;android-35;default;x86_64',
'--force',
'--device',
'medium_phone',
],
{ env: expect.any(Object), stdio: 'pipe' }
);
expect(write).toHaveBeenCalledWith('no');
expect(end).toHaveBeenCalled();
expect(logger.info).toHaveBeenCalledWith(
'Setting scaled screen resolution: hw.lcd.height to 1270 and hw.lcd.width to 566.'
);
expect(logger.info).toHaveBeenCalledWith(
'Setting screen resolution to 720x1600 and density to 262 ppi.'
);
await expect(fs.promises.readFile(`${avdDirectory}/config.ini`, 'utf8')).resolves.toBe(
[
'hw.ramSize=1536',
'hw.lcd.height=2424',
'hw.lcd.width=1080',
'hw.lcd.density=420',
'skin.path=pixel_9',
'showDeviceFrame=yes',
'hw.ramSize=2048',
'',
'hw.lcd.density=220',
'',
'hw.lcd.height=1270',
'hw.lcd.width=566',
'',
'hw.lcd.height=1600',
'hw.lcd.width=720',
'hw.lcd.density=262',
'',
].join('\n')
);
});
it('does not apply an LCD configuration when it is omitted', async () => {
const deviceName = 'generic-emulator' as AndroidVirtualDeviceName;
const avdDirectory = `/home/expo/.android/avd/${deviceName}.avd`;
const initialConfig = ['skin.path=pixel_9', 'showDeviceFrame=yes'].join('\n');
await fs.promises.mkdir(avdDirectory, { recursive: true });
await fs.promises.writeFile(`${avdDirectory}/config.ini`, initialConfig);
const avdManagerPromise = Promise.resolve({ stdout: '', stderr: '' }) as any;
avdManagerPromise.child = { stdin: { write: jest.fn(), end: jest.fn() } };
mockedSpawn.mockReturnValue(avdManagerPromise);
await AndroidEmulatorUtils.createAsync({
deviceName,
systemImagePackage: AndroidEmulatorUtils.defaultSystemImagePackage,
deviceIdentifier: null,
lcdWidth: null,
lcdHeight: null,
lcdDensity: null,
env: {
HOME: '/home/expo',
ANDROID_EMULATOR_ADJUST_HEAP_SIZE: '0',
},
logger: createMockLogger(),
});
const config = await fs.promises.readFile(`${avdDirectory}/config.ini`, 'utf8');
expect(config).toContain(initialConfig);
expect(config).not.toContain('hw.lcd.');
});
});
describe(AndroidEmulatorUtils.startAsync, () => {
function mockSuccessfulStart(deviceName: AndroidVirtualDeviceName) {
// Under `stdio: 'pipe'` these are net.Sockets, which is what startAsync
@@ -1,6 +1,6 @@
{
"name": "create-eas-build-function",
"version": "23.1.0",
"version": "24.0.0",
"description": "Create functions for use in EAS Build custom builds.",
"keywords": [
"expo",
@@ -35,7 +35,7 @@
"clean": "rimraf ./build/ \"*.tsbuildinfo\""
},
"dependencies": {
"@expo/steps": "23.1.0"
"@expo/steps": "24.0.0"
},
"devDependencies": {
"@expo/package-manager": "1.9.10",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/downloader",
"version": "23.0.0",
"version": "24.0.0",
"bugs": "https://github.com/expo/eas-cli/issues",
"license": "BUSL-1.1",
"author": "Expo <[email protected]>",
@@ -1,6 +1,6 @@
{
"name": "eas-build-cache-provider",
"version": "23.0.0",
"version": "24.0.0",
"description": "A build cache provider plugin for the Expo CLI",
"homepage": "https://github.com/expo/eas-cli",
"bugs": "https://github.com/expo/eas-cli/issues",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/eas-build-job",
"version": "23.1.0",
"version": "24.0.0",
"bugs": "https://github.com/expo/eas-cli/issues",
"license": "MIT",
"author": "Expo <[email protected]>",
@@ -25,9 +25,9 @@
"clean": "rimraf node_modules dist coverage \"*.tsbuildinfo\""
},
"dependencies": {
"@expo/logger": "23.1.0",
"@expo/logger": "24.0.0",
"@expo/results": "1.0.0",
"@expo/turtle-spawn": "23.1.0",
"@expo/turtle-spawn": "24.0.0",
"joi": "^17.13.1",
"semver": "^7.6.2",
"zod": "^4.3.5"
+323 -206
View File
File diff suppressed because it is too large. Load diff
+1758 -1723
View File
File diff suppressed because it is too large. Load diff
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "eas-cli",
"version": "23.2.0",
"version": "24.0.0",
"description": "EAS command line tool",
"keywords": [
"cli",
@@ -44,15 +44,15 @@
"copy-new-templates": "rimraf build/commandUtils/new/templates && mkdir -p build/commandUtils/new && cp -r src/commandUtils/new/templates build/commandUtils/new"
},
"dependencies": {
"@expo/apple-utils": "2.1.22",
"@expo/apple-utils": "2.2.0",
"@expo/code-signing-certificates": "0.0.5",
"@expo/config": "55.0.10",
"@expo/config-plugins": "55.0.7",
"@expo/eas-build-job": "23.1.0",
"@expo/eas-json": "23.1.0",
"@expo/eas-build-job": "24.0.0",
"@expo/eas-json": "24.0.0",
"@expo/env": "^1.0.0",
"@expo/json-file": "8.3.3",
"@expo/logger": "23.1.0",
"@expo/logger": "24.0.0",
"@expo/multipart-body-parser": "2.0.0",
"@expo/osascript": "2.1.4",
"@expo/package-manager": "1.9.10",
@@ -64,7 +64,7 @@
"@expo/results": "1.0.0",
"@expo/rudder-sdk-node": "1.1.1",
"@expo/spawn-async": "1.7.2",
"@expo/steps": "23.1.0",
"@expo/steps": "24.0.0",
"@expo/timeago.js": "1.0.0",
"@oclif/core": "^4.8.3",
"@oclif/plugin-autocomplete": "^3.2.40",
@@ -0,0 +1,148 @@
import { CombinedError } from '@urql/core';
import { GraphQLError } from 'graphql';
import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient';
import { getMockOclifConfig } from '../../../__tests__/commands/utils';
import { AppObserveErrorSeverity } from '../../../graphql/generated';
import {
fetchObserveErrorGroupsAsync,
fetchObserveErrorOccurrencesAsync,
} from '../../../observe/fetchErrors';
import {
buildObserveErrorGroupsJson,
buildObserveErrorGroupsTable,
buildObserveErrorOccurrencesJson,
buildObserveErrorOccurrencesTable,
} from '../../../observe/formatErrors';
import { EAS_OBSERVE_FEATURE_NOT_AVAILABLE_IN_FREE_TIER_ERROR_CODE } from '../../../observe/planGating';
import { enableJsonOutput, printJsonOnlyOutput } from '../../../utils/json';
import ObserveErrors from '../errors';
jest.mock('../../../observe/fetchErrors');
jest.mock('../../../observe/formatErrors', () => ({
buildObserveErrorGroupsTable: jest.fn().mockReturnValue('errors-table'),
buildObserveErrorGroupsJson: jest.fn().mockReturnValue({ errors: [], isTruncated: false }),
buildObserveErrorOccurrencesTable: jest.fn().mockReturnValue('occurrences-table'),
buildObserveErrorOccurrencesJson: jest
.fn()
.mockReturnValue({ occurrences: [], pageInfo: { hasNextPage: false, endCursor: null } }),
}));
jest.mock('../../../log');
jest.mock('../../../utils/json');
const mockFetchErrorGroupsAsync = jest.mocked(fetchObserveErrorGroupsAsync);
const mockFetchErrorOccurrencesAsync = jest.mocked(fetchObserveErrorOccurrencesAsync);
const mockBuildTable = jest.mocked(buildObserveErrorGroupsTable);
const mockBuildJson = jest.mocked(buildObserveErrorGroupsJson);
const mockBuildOccurrencesTable = jest.mocked(buildObserveErrorOccurrencesTable);
const mockBuildOccurrencesJson = jest.mocked(buildObserveErrorOccurrencesJson);
const mockEnableJsonOutput = jest.mocked(enableJsonOutput);
const mockPrintJsonOnlyOutput = jest.mocked(printJsonOnlyOutput);
describe(ObserveErrors, () => {
const graphqlClient = {} as any as ExpoGraphqlClient;
const mockConfig = getMockOclifConfig();
const projectId = 'test-project-id';
beforeEach(() => {
jest.clearAllMocks();
mockFetchErrorGroupsAsync.mockResolvedValue({ groups: [], isTruncated: false });
mockFetchErrorOccurrencesAsync.mockResolvedValue({
occurrences: [],
pageInfo: { hasNextPage: false, hasPreviousPage: false, endCursor: null } as any,
});
});
function createCommand(argv: string[]): ObserveErrors {
const command = new ObserveErrors(argv, mockConfig);
// @ts-expect-error
jest.spyOn(command, 'getContextAsync').mockReturnValue({
projectId,
loggedIn: { graphqlClient },
});
return command;
}
it('fetches error groups and renders a table by default', async () => {
await createCommand([]).runAsync();
expect(mockFetchErrorGroupsAsync).toHaveBeenCalledTimes(1);
expect(mockBuildTable).toHaveBeenCalledTimes(1);
expect(mockEnableJsonOutput).not.toHaveBeenCalled();
});
it('emits JSON with --json', async () => {
await createCommand(['--json', '--non-interactive']).runAsync();
expect(mockEnableJsonOutput).toHaveBeenCalledTimes(1);
expect(mockBuildJson).toHaveBeenCalledTimes(1);
expect(mockPrintJsonOnlyOutput).toHaveBeenCalledWith({ errors: [], isTruncated: false });
});
it('maps the --severity flag to the AppObserveErrorSeverity enum', async () => {
await createCommand(['--severity', 'fatal']).runAsync();
const options = mockFetchErrorGroupsAsync.mock.calls[0][2];
expect(options.severity).toBe(AppObserveErrorSeverity.Fatal);
});
it('fetches occurrences (not groups) and renders their table when --fingerprint is set', async () => {
await createCommand(['--fingerprint', 'fp-1']).runAsync();
expect(mockFetchErrorGroupsAsync).not.toHaveBeenCalled();
expect(mockFetchErrorOccurrencesAsync).toHaveBeenCalledTimes(1);
expect(mockFetchErrorOccurrencesAsync.mock.calls[0][2]).toMatchObject({ fingerprint: 'fp-1' });
expect(mockBuildOccurrencesTable).toHaveBeenCalledTimes(1);
expect(mockBuildTable).not.toHaveBeenCalled();
});
it('emits occurrences JSON with --fingerprint --json', async () => {
await createCommand(['--fingerprint', 'fp-1', '--json', '--non-interactive']).runAsync();
expect(mockEnableJsonOutput).toHaveBeenCalledTimes(1);
expect(mockBuildOccurrencesJson).toHaveBeenCalledTimes(1);
expect(mockPrintJsonOnlyOutput).toHaveBeenCalledWith({
occurrences: [],
pageInfo: { hasNextPage: false, endCursor: null },
});
});
it('forwards --limit to the occurrences fetch when --fingerprint is set', async () => {
await createCommand(['--fingerprint', 'fp-1', '--limit', '20']).runAsync();
expect(mockFetchErrorOccurrencesAsync.mock.calls[0][2]).toMatchObject({
fingerprint: 'fp-1',
limit: 20,
});
});
it('rejects --limit without --fingerprint', async () => {
await expect(createCommand(['--limit', '20']).runAsync()).rejects.toThrow(
/--after or --limit can only be used in combination with the --fingerprint flag/
);
expect(mockFetchErrorGroupsAsync).not.toHaveBeenCalled();
expect(mockFetchErrorOccurrencesAsync).not.toHaveBeenCalled();
});
it('rejects --after without --fingerprint', async () => {
await expect(createCommand(['--after', 'cursor-1']).runAsync()).rejects.toThrow(
/--after or --limit can only be used in combination with the --fingerprint flag/
);
expect(mockFetchErrorGroupsAsync).not.toHaveBeenCalled();
});
it('surfaces the plan-gate message when errors are not available on the plan', async () => {
mockFetchErrorGroupsAsync.mockRejectedValueOnce(
new CombinedError({
graphQLErrors: [
new GraphQLError(
'Subscription to EAS is required for this feature.',
null,
null,
null,
null,
null,
{
errorCode: EAS_OBSERVE_FEATURE_NOT_AVAILABLE_IN_FREE_TIER_ERROR_CODE,
}
),
],
})
);
await expect(createCommand([]).runAsync()).rejects.toThrow(/Subscription to EAS is required/);
});
});
@@ -0,0 +1,190 @@
import { CombinedError } from '@urql/core';
import { GraphQLError } from 'graphql';
import { ExpoGraphqlClient } from '../../../commandUtils/context/contextUtils/createGraphqlClient';
import { getMockOclifConfig } from '../../../__tests__/commands/utils';
import { ObserveQuery } from '../../../graphql/queries/ObserveQuery';
import {
buildObserveCustomEventDetail,
buildObserveCustomEventJson,
} from '../../../observe/formatCustomEvents';
import { buildObserveErrorDetail, buildObserveErrorJson } from '../../../observe/formatErrors';
import { buildObserveEventDetail, buildObserveEventJson } from '../../../observe/formatEvents';
import { EAS_OBSERVE_FEATURE_NOT_AVAILABLE_IN_FREE_TIER_ERROR_CODE } from '../../../observe/planGating';
import { enableJsonOutput, printJsonOnlyOutput } from '../../../utils/json';
import ObserveEvent from '../event';
jest.mock('../../../observe/formatEvents', () => ({
buildObserveEventDetail: jest.fn().mockReturnValue('metric-detail'),
buildObserveEventJson: jest.fn().mockReturnValue({ id: 'metric-json' }),
}));
jest.mock('../../../observe/formatCustomEvents', () => ({
buildObserveCustomEventDetail: jest.fn().mockReturnValue('log-detail'),
buildObserveCustomEventJson: jest.fn().mockReturnValue({ id: 'log-json' }),
}));
jest.mock('../../../observe/formatErrors', () => ({
buildObserveErrorDetail: jest.fn().mockReturnValue('error-detail'),
buildObserveErrorJson: jest.fn().mockReturnValue({ id: 'error-json' }),
}));
jest.mock('../../../graphql/queries/ObserveQuery', () => ({
ObserveQuery: {
logByIdAsync: jest.fn(),
metricByIdAsync: jest.fn(),
},
}));
jest.mock('../../../log');
jest.mock('../../../utils/json');
const mockLogByIdAsync = jest.mocked(ObserveQuery.logByIdAsync);
const mockMetricByIdAsync = jest.mocked(ObserveQuery.metricByIdAsync);
const mockBuildObserveEventDetail = jest.mocked(buildObserveEventDetail);
const mockBuildObserveEventJson = jest.mocked(buildObserveEventJson);
const mockBuildObserveCustomEventDetail = jest.mocked(buildObserveCustomEventDetail);
const mockBuildObserveCustomEventJson = jest.mocked(buildObserveCustomEventJson);
const mockBuildObserveErrorDetail = jest.mocked(buildObserveErrorDetail);
const mockBuildObserveErrorJson = jest.mocked(buildObserveErrorJson);
const mockEnableJsonOutput = jest.mocked(enableJsonOutput);
const mockPrintJsonOnlyOutput = jest.mocked(printJsonOnlyOutput);
// A log event ID (user event or error) is a UUID; a metric event ID is
// base64url-encoded JSON.
const UUID_ID = '123e4567-e89b-12d3-a456-426614174000';
const BASE64_ID = 'eyJhIjoxfQ';
const INVALID_ID = 'not a valid id';
const userEventLog = { id: UUID_ID, __typename: 'AppObserveUserEvent' } as any;
const errorLog = { id: UUID_ID, __typename: 'AppObserveError' } as any;
describe(ObserveEvent, () => {
const graphqlClient = {} as any as ExpoGraphqlClient;
const mockConfig = getMockOclifConfig();
const projectId = 'test-project-id';
beforeEach(() => {
jest.clearAllMocks();
mockLogByIdAsync.mockResolvedValue(null);
mockMetricByIdAsync.mockResolvedValue(null);
});
function createCommand(argv: string[]): ObserveEvent {
const command = new ObserveEvent(argv, mockConfig);
// @ts-expect-error
jest.spyOn(command, 'getContextAsync').mockReturnValue({
projectId,
loggedIn: { graphqlClient },
});
return command;
}
function planGateError(): CombinedError {
const serverMessage =
'Subscription to EAS is required for this feature. ' +
'Subscribe: https://expo.dev/accounts/acme/settings/billing';
return new CombinedError({
graphQLErrors: [
new GraphQLError(serverMessage, null, null, null, null, null, {
errorCode: EAS_OBSERVE_FEATURE_NOT_AVAILABLE_IN_FREE_TIER_ERROR_CODE,
}),
],
});
}
it('looks up a UUID id with the log query only', async () => {
mockLogByIdAsync.mockResolvedValue(userEventLog);
await createCommand([UUID_ID]).runAsync();
expect(mockLogByIdAsync).toHaveBeenCalledWith(graphqlClient, {
appId: projectId,
id: UUID_ID,
});
expect(mockMetricByIdAsync).not.toHaveBeenCalled();
expect(mockBuildObserveCustomEventDetail).toHaveBeenCalledTimes(1);
});
it('renders an error detail when a UUID id resolves to an error', async () => {
mockLogByIdAsync.mockResolvedValue(errorLog);
await createCommand([UUID_ID]).runAsync();
expect(mockBuildObserveErrorDetail).toHaveBeenCalledTimes(1);
expect(mockBuildObserveCustomEventDetail).not.toHaveBeenCalled();
});
it('looks up a base64 id with the metric query only', async () => {
mockMetricByIdAsync.mockResolvedValue({ id: BASE64_ID } as any);
await createCommand([BASE64_ID]).runAsync();
expect(mockMetricByIdAsync).toHaveBeenCalledWith(graphqlClient, {
appId: projectId,
id: BASE64_ID,
});
expect(mockLogByIdAsync).not.toHaveBeenCalled();
expect(mockBuildObserveEventDetail).toHaveBeenCalledTimes(1);
});
it('errors immediately for an ID that is neither a UUID nor base64, without querying', async () => {
await expect(createCommand([INVALID_ID]).runAsync()).rejects.toThrow(
/is not a valid Observe event ID/
);
expect(mockLogByIdAsync).not.toHaveBeenCalled();
expect(mockMetricByIdAsync).not.toHaveBeenCalled();
});
it('emits typed JSON for a metric event with --json', async () => {
mockMetricByIdAsync.mockResolvedValue({ id: BASE64_ID } as any);
await createCommand([BASE64_ID, '--json', '--non-interactive']).runAsync();
expect(mockEnableJsonOutput).toHaveBeenCalledTimes(1);
expect(mockBuildObserveEventJson).toHaveBeenCalledTimes(1);
expect(mockPrintJsonOnlyOutput).toHaveBeenCalledWith({
type: 'metric',
event: { id: 'metric-json' },
});
});
it('emits typed JSON for a log event with --json', async () => {
mockLogByIdAsync.mockResolvedValue(userEventLog);
await createCommand([UUID_ID, '--json', '--non-interactive']).runAsync();
expect(mockBuildObserveCustomEventJson).toHaveBeenCalledTimes(1);
expect(mockPrintJsonOnlyOutput).toHaveBeenCalledWith({
type: 'log',
event: { id: 'log-json' },
});
});
it('emits typed JSON for an error event with --json', async () => {
mockLogByIdAsync.mockResolvedValue(errorLog);
await createCommand([UUID_ID, '--json', '--non-interactive']).runAsync();
expect(mockBuildObserveErrorJson).toHaveBeenCalledTimes(1);
expect(mockPrintJsonOnlyOutput).toHaveBeenCalledWith({
type: 'error',
event: { id: 'error-json' },
});
});
it('throws not-found when a well-formed ID resolves to nothing', async () => {
mockLogByIdAsync.mockResolvedValue(null);
await expect(createCommand([UUID_ID]).runAsync()).rejects.toThrow(
new RegExp(`No Observe event found with ID "${UUID_ID}"`)
);
});
it('surfaces the plan-gate message when the lookup is not available on the plan', async () => {
mockLogByIdAsync.mockRejectedValueOnce(planGateError());
await expect(createCommand([UUID_ID]).runAsync()).rejects.toThrow(
/Subscription to EAS is required/
);
});
it('wraps an unexpected server error with an ID-specific message and preserves the request ID', async () => {
const serverError = new CombinedError({
graphQLErrors: [
new GraphQLError('unexpected server error', null, null, null, null, null, {
requestId: 'req-123',
}),
],
});
mockLogByIdAsync.mockRejectedValue(serverError);
await expect(createCommand([UUID_ID]).runAsync()).rejects.toThrow(
new RegExp(
`Could not retrieve Observe event with ID "${UUID_ID}"[\\s\\S]*unexpected server error \\(Request ID: req-123\\)`
)
);
});
});
@@ -0,0 +1,162 @@
import { Flags } from '@oclif/core';
import EasCommand from '../../commandUtils/EasCommand';
import {
EasNonInteractiveAndJsonFlags,
resolveNonInteractiveAndJsonFlags,
} from '../../commandUtils/flags';
import { getLimitFlagWithCustomValues } from '../../commandUtils/pagination';
import { AppObserveErrorSeverity } from '../../graphql/generated';
import Log from '../../log';
import {
fetchObserveErrorGroupsAsync,
fetchObserveErrorOccurrencesAsync,
} from '../../observe/fetchErrors';
import {
ObserveAfterFlag,
ObserveAppVersionFlag,
ObserveBuildNumberFlag,
ObserveEnvironmentFlag,
ObservePlatformFlag,
ObserveProjectIdFlag,
ObserveTimeRangeFlags,
ObserveUpdateIdFlag,
} from '../../observe/flags';
import {
buildObserveErrorGroupsJson,
buildObserveErrorGroupsTable,
buildObserveErrorOccurrencesJson,
buildObserveErrorOccurrencesTable,
} from '../../observe/formatErrors';
import { withObservePlanGateHandlingAsync } from '../../observe/planGating';
import { observePlatformsFromFlag } from '../../observe/platforms';
import { resolveObserveCommandContextAsync } from '../../observe/resolveProjectContext';
import { resolveTimeRange } from '../../observe/startAndEndTime';
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
const SEVERITY_BY_FLAG: Record<string, AppObserveErrorSeverity> = {
fatal: AppObserveErrorSeverity.Fatal,
error: AppObserveErrorSeverity.Error,
};
const DEFAULT_OCCURRENCES_LIMIT = 10;
export default class ObserveErrors extends EasCommand {
static override description =
'display error and exception issue groups (grouped by fingerprint) for the app';
static override flags = {
...ObservePlatformFlag,
fingerprint: Flags.string({
description:
'Show individual occurrences (with stack traces) for this error group fingerprint instead of the grouped summary',
required: false,
}),
severity: Flags.option({
description: 'Filter by severity (ignored when --fingerprint is set)',
options: Object.keys(SEVERITY_BY_FLAG),
required: false,
})(),
...ObserveAfterFlag,
limit: getLimitFlagWithCustomValues({
defaultTo: DEFAULT_OCCURRENCES_LIMIT,
limit: 100,
}),
...ObserveTimeRangeFlags,
...ObserveAppVersionFlag,
...ObserveBuildNumberFlag,
...ObserveUpdateIdFlag,
...ObserveEnvironmentFlag,
...ObserveProjectIdFlag,
...EasNonInteractiveAndJsonFlags,
};
static override contextDefinition = {
...this.ContextOptions.ProjectId,
...this.ContextOptions.LoggedIn,
};
private static loggedInOnlyContextDefinition = {
...this.ContextOptions.LoggedIn,
};
async runAsync(): Promise<void> {
const { flags } = await this.parse(ObserveErrors);
const { json, nonInteractive } = resolveNonInteractiveAndJsonFlags(flags);
const { projectId, graphqlClient } = await resolveObserveCommandContextAsync({
command: this,
commandClass: ObserveErrors,
loggedInOnlyContextDefinition: ObserveErrors.loggedInOnlyContextDefinition,
projectIdOverride: flags['project-id'],
nonInteractive,
});
if (!flags.fingerprint && (flags.after || flags.limit)) {
throw new Error(
'--after or --limit can only be used in combination with the --fingerprint flag.'
);
}
if (json) {
enableJsonOutput();
}
const { daysBack, startTime, endTime } = resolveTimeRange(flags);
if (flags.fingerprint) {
const { occurrences, pageInfo } = await withObservePlanGateHandlingAsync(() =>
fetchObserveErrorOccurrencesAsync(graphqlClient, projectId, {
fingerprint: flags.fingerprint as string,
startTime,
endTime,
platforms: observePlatformsFromFlag(flags.platform),
appVersion: flags['app-version'],
buildNumber: flags['build-number'],
updateId: flags['update-id'],
environment: flags.environment,
limit: flags.limit ?? DEFAULT_OCCURRENCES_LIMIT,
...(flags.after && { after: flags.after }),
})
);
if (json) {
printJsonOnlyOutput(buildObserveErrorOccurrencesJson(occurrences, pageInfo));
} else {
Log.addNewLineIfNone();
Log.log(
buildObserveErrorOccurrencesTable(occurrences, pageInfo, {
fingerprint: flags.fingerprint,
daysBack,
startTime,
endTime,
})
);
}
return;
}
const { groups, isTruncated } = await withObservePlanGateHandlingAsync(() =>
fetchObserveErrorGroupsAsync(graphqlClient, projectId, {
startTime,
endTime,
platforms: observePlatformsFromFlag(flags.platform),
appVersion: flags['app-version'],
buildNumber: flags['build-number'],
updateId: flags['update-id'],
environment: flags.environment,
...(flags.severity && { severity: SEVERITY_BY_FLAG[flags.severity] }),
})
);
if (json) {
printJsonOnlyOutput(buildObserveErrorGroupsJson(groups, isTruncated));
} else {
Log.addNewLineIfNone();
Log.log(buildObserveErrorGroupsTable(groups, { daysBack, startTime, endTime }));
if (isTruncated) {
Log.warn('Result is truncated; not all error groups are shown.');
}
}
}
}
@@ -0,0 +1,174 @@
import { Args } from '@oclif/core';
import { validate as isUuid } from 'uuid';
import EasCommand from '../../commandUtils/EasCommand';
import { EasCommandError } from '../../commandUtils/errors';
import {
EasNonInteractiveAndJsonFlags,
resolveNonInteractiveAndJsonFlags,
} from '../../commandUtils/flags';
import { GraphqlError } from '../../graphql/client';
import { ObserveQuery } from '../../graphql/queries/ObserveQuery';
import Log from '../../log';
import {
buildObserveCustomEventDetail,
buildObserveCustomEventJson,
} from '../../observe/formatCustomEvents';
import { buildObserveErrorDetail, buildObserveErrorJson } from '../../observe/formatErrors';
import { buildObserveEventDetail, buildObserveEventJson } from '../../observe/formatEvents';
import { ObserveProjectIdFlag } from '../../observe/flags';
import { withObservePlanGateHandlingAsync } from '../../observe/planGating';
import { resolveObserveCommandContextAsync } from '../../observe/resolveProjectContext';
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
export default class ObserveEvent extends EasCommand {
static override description =
'display a single Observe event (metric, log, or error) by its ID. IDs are included in event data when the `--json` flag is passed to `eas observe:session`, `eas observe:metrics`, or `eas observe:events`.';
static override args = {
id: Args.string({
description: 'ID of the event to display',
required: true,
}),
};
static override flags = {
...ObserveProjectIdFlag,
...EasNonInteractiveAndJsonFlags,
};
static override contextDefinition = {
...this.ContextOptions.ProjectId,
...this.ContextOptions.LoggedIn,
};
private static loggedInOnlyContextDefinition = {
...this.ContextOptions.LoggedIn,
};
async runAsync(): Promise<void> {
const { flags, args } = await this.parse(ObserveEvent);
const { json, nonInteractive } = resolveNonInteractiveAndJsonFlags(flags);
const { projectId, graphqlClient } = await resolveObserveCommandContextAsync({
command: this,
commandClass: ObserveEvent,
loggedInOnlyContextDefinition: ObserveEvent.loggedInOnlyContextDefinition,
projectIdOverride: flags['project-id'],
nonInteractive,
});
if (json) {
enableJsonOutput();
}
const id = args.id;
// A log event ID (user event or error) is a UUID; a metric event ID is
// base64url-encoded JSON. Route to the matching query so we never issue the
// query that is guaranteed to fail for this ID, and reject anything that is
// neither up front.
if (isUuid(id)) {
const log = await fetchObserveEventAsync(id, () =>
ObserveQuery.logByIdAsync(graphqlClient, { appId: projectId, id })
);
if (!log) {
throw eventNotFoundError(id);
}
if (log.__typename === 'AppObserveError') {
if (json) {
printJsonOnlyOutput({ type: 'error', event: buildObserveErrorJson(log) });
} else {
Log.addNewLineIfNone();
Log.log(buildObserveErrorDetail(log));
}
} else if (json) {
printJsonOnlyOutput({ type: 'log', event: buildObserveCustomEventJson(log) });
} else {
Log.addNewLineIfNone();
Log.log(buildObserveCustomEventDetail(log));
}
return;
}
if (parsesAsBase64(id)) {
const event = await fetchObserveEventAsync(id, () =>
ObserveQuery.metricByIdAsync(graphqlClient, { appId: projectId, id })
);
if (!event) {
throw eventNotFoundError(id);
}
if (json) {
printJsonOnlyOutput({ type: 'metric', event: buildObserveEventJson(event) });
} else {
Log.addNewLineIfNone();
Log.log(buildObserveEventDetail(event));
}
return;
}
throw new EasCommandError(
`"${id}" is not a valid Observe event ID. IDs come from \`eas observe:events\` or \`eas observe:session\`.`
);
}
}
/**
* A metric event ID is canonical base64url (of JSON). Round-tripping rejects
* strings that only coincidentally contain base64 characters, so a value that
* is neither a UUID nor this is treated as an invalid ID.
*/
function parsesAsBase64(id: string): boolean {
if (id.length === 0) {
return false;
}
return Buffer.from(id, 'base64url').toString('base64url') === id;
}
function eventNotFoundError(id: string): EasCommandError {
return new EasCommandError(
`No Observe event found with ID "${id}". IDs come from \`eas observe:events\` or \`eas observe:session\`, and events age out of retention.`
);
}
/**
* Runs an Observe event lookup, translating plan-gate rejections to their
* upgrade message and any other server error into an actionable message that
* preserves the underlying error and request ID for support.
*/
async function fetchObserveEventAsync<T>(id: string, fn: () => Promise<T>): Promise<T> {
try {
return await withObservePlanGateHandlingAsync(fn);
} catch (error) {
if (error instanceof EasCommandError) {
throw error;
}
throw new EasCommandError(
`Could not retrieve Observe event with ID "${id}". ` +
'The ID may be invalid or the event may not exist (events also age out of retention). ' +
'Verify it was copied in full from `eas observe:events` or `eas observe:session`.' +
`\n\n${describeObserveServerError(error)}`
);
}
}
/**
* Extract a human-readable description from a GraphQL/server error, including
* the request ID(s) so a support request can reference them. Falls back to the
* error's own message for non-GraphQL errors.
*/
function describeObserveServerError(error: unknown): string {
if (error instanceof GraphqlError && error.graphQLErrors.length > 0) {
return error.graphQLErrors
.map(graphQLError => {
const message = graphQLError.message.replace('[GraphQL] ', '');
const requestId = graphQLError.extensions?.requestId;
return requestId ? `${message} (Request ID: ${String(requestId)})` : message;
})
.join('\n');
}
if (error instanceof Error) {
return error.message;
}
return String(error);
}
@@ -18,6 +18,7 @@ import {
import {
deviceRunSessionTypeToFlagValue,
formatRemoteSessionInstructions,
sanitizeRemoteConfigForJson,
} from '../../simulator/utils';
import { formatBytes } from '../../utils/files';
import formatFields, { FormatFieldsItem } from '../../utils/formatFields';
@@ -96,7 +97,9 @@ export default class SimulatorGet extends EasCommand {
finishedAt: session.finishedAt ?? undefined,
updatedAt: session.updatedAt,
deviceRunSessionUrl,
remoteConfig: session.remoteConfig,
remoteConfig: session.remoteConfig
? sanitizeRemoteConfigForJson(session.remoteConfig)
: session.remoteConfig,
artifacts: session.artifacts,
});
return;
@@ -38,6 +38,7 @@ import {
formatRemoteSessionInstructions,
formatSimulatorUnavailableMessage,
getRemoteSessionEnvironmentVariables,
sanitizeRemoteConfigForJson,
} from '../../simulator/utils';
import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json';
import { sleepAsync } from '../../utils/promise';
@@ -385,7 +386,7 @@ export default class Simulator extends EasCommand {
name,
type: flags.type,
deviceRunSessionUrl,
remoteConfig,
remoteConfig: sanitizeRemoteConfigForJson(remoteConfig),
});
return;
}
@@ -105,7 +105,8 @@ export const distributionCertificateSchema: CredentialSchema<DistributionCertifi
export type MinimalAscApiKey = {
keyP8: string;
keyId: string;
issuerId: string;
// Absent for individual API keys, which are valid only for submissions.
issuerId?: string;
teamId?: string;
teamName?: string;
roles?: UserRole[];
@@ -115,7 +116,7 @@ export type MinimalAscApiKey = {
export interface AscApiKeyPath {
keyP8Path: string;
keyId: string;
issuerId: string;
issuerId?: string;
}
export const ascApiKeyIdSchema: CredentialSchema<Pick<MinimalAscApiKey, 'keyId'>> = {
@@ -129,7 +130,7 @@ export const ascApiKeyIdSchema: CredentialSchema<Pick<MinimalAscApiKey, 'keyId'>
],
};
export const ascApiKeyIssuerIdSchema: CredentialSchema<Pick<MinimalAscApiKey, 'issuerId'>> = {
export const ascApiKeyIssuerIdSchema: CredentialSchema<{ issuerId: string }> = {
name: 'App Store Connect API Key',
questions: [
{
@@ -246,7 +246,11 @@ function displayAscApiKey(
if (name) {
fields.push({ label: 'Name', value: name });
}
fields.push({ label: 'Issuer ID', value: issuerIdentifier });
if (issuerIdentifier) {
fields.push({ label: 'Issuer ID', value: issuerIdentifier });
} else {
fields.push({ label: 'Key Type', value: 'Individual (submissions only)' });
}
if (roles) {
fields.push({ label: 'Roles', value: roles.join(',') });
}
+336 -272
View File
File diff suppressed because it is too large. Load diff
@@ -12,7 +12,7 @@ export const AppStoreConnectApiKeyQuery = {
graphqlClient: ExpoGraphqlClient,
ascApiKeyId: string
): Promise<{
issuerIdentifier: string;
issuerIdentifier: string | undefined;
keyIdentifier: string;
keyP8: string;
}> {
@@ -42,7 +42,7 @@ export const AppStoreConnectApiKeyQuery = {
const key = data.appStoreConnectApiKey.byId;
return {
issuerIdentifier: key.issuerIdentifier,
issuerIdentifier: key.issuerIdentifier ?? undefined,
keyIdentifier: key.keyIdentifier,
keyP8: key.keyP8,
};
@@ -87,22 +87,27 @@ export const DeviceRunSessionQuery = {
agentDeviceRemoteSessionUrl
agentDeviceRemoteSessionToken
webPreviewUrl
webPreviewToken
}
... on ArgentRunSessionRemoteConfig {
toolsUrl
toolsAuthToken
webPreviewUrl
webPreviewToken
}
... on AppiumRunSessionRemoteConfig {
appiumUrl
capabilities
webPreviewUrl
webPreviewToken
}
... on ServeSimRunSessionRemoteConfig {
previewUrl
previewToken
}
... on WebPreviewOnlyRunSessionRemoteConfig {
previewUrl: webPreviewUrl
previewToken: webPreviewToken
}
}
turtleJobRun {
@@ -5,6 +5,10 @@ import { withErrorHandlingAsync } from '../client';
import {
AppObserveAppVersion,
AppObserveError,
AppObserveErrorGroup,
AppObserveErrorOccurrencesFilter,
AppObserveErrorOccurrencesOrderBy,
AppObserveErrorsGroupsInput,
AppObserveLogsOrderBy,
AppObserveMetric,
AppObserveMetricsListFilter,
@@ -24,6 +28,8 @@ import { print } from 'graphql';
import {
AppObserveAppVersionFragmentNode,
AppObserveErrorFragmentNode,
AppObserveErrorGroupFragmentNode,
AppObserveErrorOccurrenceFragmentNode,
AppObserveMetricFragmentNode,
AppObserveUserEventFragmentNode,
} from '../types/Observe';
@@ -156,6 +162,51 @@ type AppObserveNavigationRoutesQueryVariables = {
orderBy?: AppObserveNavigationOrderBy;
};
type AppObserveErrorGroupsQuery = {
app: {
byId: {
id: string;
observe: {
errors: {
groups: {
isTruncated: boolean;
groups: AppObserveErrorGroup[];
};
};
};
};
};
};
type AppObserveErrorGroupsQueryVariables = {
appId: string;
input: AppObserveErrorsGroupsInput;
};
type AppObserveErrorOccurrencesQuery = {
app: {
byId: {
id: string;
observe: {
errors: {
occurrences: {
pageInfo: PageInfo;
edges: Array<{ cursor: string; node: AppObserveError }>;
};
};
};
};
};
};
type AppObserveErrorOccurrencesQueryVariables = {
appId: string;
filter: AppObserveErrorOccurrencesFilter;
first?: number;
after?: string;
orderBy?: AppObserveErrorOccurrencesOrderBy;
};
type AppObserveSessionEventsQuery = {
app: {
byId: {
@@ -185,6 +236,35 @@ type AppObserveSessionEventsQueryVariables = {
logsOrderBy?: AppObserveLogsOrderBy;
};
type AppObserveMetricByIdQuery = {
app: {
byId: {
id: string;
observe: {
metrics: {
metric: AppObserveMetric | null;
};
};
};
};
};
type AppObserveLogByIdQuery = {
app: {
byId: {
id: string;
observe: {
log: AppObserveSessionLog | null;
};
};
};
};
type AppObserveByIdQueryVariables = {
appId: string;
id: string;
};
export const ObserveQuery = {
async appVersionsAsync(
graphqlClient: ExpoGraphqlClient,
@@ -466,6 +546,99 @@ export const ObserveQuery = {
};
},
async errorGroupsAsync(
graphqlClient: ExpoGraphqlClient,
{ appId, input }: { appId: string; input: AppObserveErrorsGroupsInput }
): Promise<{ groups: AppObserveErrorGroup[]; isTruncated: boolean }> {
const data = await withErrorHandlingAsync(
graphqlClient
.query<AppObserveErrorGroupsQuery, AppObserveErrorGroupsQueryVariables>(
gql`
query AppObserveErrorGroups($appId: String!, $input: AppObserveErrorsGroupsInput!) {
app {
byId(appId: $appId) {
id
observe {
errors {
groups(input: $input) {
isTruncated
groups {
...AppObserveErrorGroupFragment
}
}
}
}
}
}
}
${print(AppObserveErrorGroupFragmentNode)}
`,
{ appId, input }
)
.toPromise()
);
return data.app.byId.observe.errors.groups;
},
async errorOccurrencesAsync(
graphqlClient: ExpoGraphqlClient,
variables: AppObserveErrorOccurrencesQueryVariables
): Promise<{ occurrences: AppObserveError[]; pageInfo: PageInfo }> {
const data = await withErrorHandlingAsync(
graphqlClient
.query<AppObserveErrorOccurrencesQuery, AppObserveErrorOccurrencesQueryVariables>(
gql`
query AppObserveErrorOccurrences(
$appId: String!
$filter: AppObserveErrorOccurrencesFilter
$first: Int
$after: String
$orderBy: AppObserveErrorOccurrencesOrderBy
) {
app {
byId(appId: $appId) {
id
observe {
errors {
occurrences(
filter: $filter
first: $first
after: $after
orderBy: $orderBy
) {
pageInfo {
hasNextPage
hasPreviousPage
endCursor
}
edges {
cursor
node {
id
...AppObserveErrorOccurrenceFragment
}
}
}
}
}
}
}
}
${print(AppObserveErrorOccurrenceFragmentNode)}
`,
variables
)
.toPromise()
);
const { edges, pageInfo } = data.app.byId.observe.errors.occurrences;
return {
occurrences: edges.map(edge => edge.node),
pageInfo,
};
},
async sessionEventsAsync(
graphqlClient: ExpoGraphqlClient,
variables: AppObserveSessionEventsQueryVariables
@@ -546,4 +719,75 @@ export const ObserveQuery = {
logsPageInfo: logs.pageInfo,
};
},
async metricByIdAsync(
graphqlClient: ExpoGraphqlClient,
{ appId, id }: AppObserveByIdQueryVariables
): Promise<AppObserveMetric | null> {
const data = await withErrorHandlingAsync(
graphqlClient
.query<AppObserveMetricByIdQuery, AppObserveByIdQueryVariables>(
gql`
query AppObserveMetricById($appId: String!, $id: ID!) {
app {
byId(appId: $appId) {
id
observe {
metrics {
metric(id: $id) {
id
...AppObserveMetricFragment
}
}
}
}
}
}
${print(AppObserveMetricFragmentNode)}
`,
{ appId, id }
)
.toPromise()
);
return data.app.byId.observe.metrics.metric ?? null;
},
async logByIdAsync(
graphqlClient: ExpoGraphqlClient,
{ appId, id }: AppObserveByIdQueryVariables
): Promise<AppObserveSessionLog | null> {
const data = await withErrorHandlingAsync(
graphqlClient
.query<AppObserveLogByIdQuery, AppObserveByIdQueryVariables>(
gql`
query AppObserveLogById($appId: String!, $id: ID!) {
app {
byId(appId: $appId) {
id
observe {
log(id: $id) {
id
__typename
... on AppObserveUserEvent {
...AppObserveUserEventFragment
}
... on AppObserveError {
...AppObserveErrorFragment
}
}
}
}
}
}
${print(AppObserveUserEventFragmentNode)}
${print(AppObserveErrorFragmentNode)}
`,
{ appId, id }
)
.toPromise()
);
return data.app.byId.observe.log ?? null;
},
};
@@ -56,6 +56,38 @@ export const AppObserveErrorFragmentNode = gql`
}
`;
export const AppObserveErrorOccurrenceFragmentNode = gql`
fragment AppObserveErrorOccurrenceFragment on AppObserveError {
id
timestamp
sessionId
severityNumber
severityText
type
message
source
fingerprint
isFatal
stacktrace
body
properties {
key
value
type
}
appVersion
appBuildNumber
appUpdateId
appEasBuildId
deviceOs
deviceOsVersion
deviceModel
environment
easClientId
countryCode
}
`;
export const AppObserveMetricFragmentNode = gql`
fragment AppObserveMetricFragment on AppObserveMetric {
id
@@ -76,6 +108,23 @@ export const AppObserveMetricFragmentNode = gql`
}
`;
export const AppObserveErrorGroupFragmentNode = gql`
fragment AppObserveErrorGroupFragment on AppObserveErrorGroup {
fingerprint
exceptionType
exceptionMessage
errorSource
severity
isFatal
eventCount
uniqueUserCount
affectedSessionCount
firstSeenAt
lastSeenAt
platforms
}
`;
export const AppObserveAppVersionFragmentNode = gql`
fragment AppObserveAppVersionFragment on AppObserveAppVersion {
appVersion
@@ -167,6 +167,7 @@ describe('fetchObserveSessionEventsAsync', () => {
'2025-01-15T10:10:00.000Z',
]);
expect(result.entries.map(e => e.source)).toEqual(['log', 'metric', 'log']);
expect(result.entries.map(e => e.id)).toEqual(['evt-c-1', 'evt-m-1', 'evt-c-2']);
});
it('includes error logs as log entries named by their exception type, surfacing message and properties', async () => {
@@ -0,0 +1,129 @@
import { AppObserveError, AppObserveErrorGroup, PageInfo } from '../../graphql/generated';
import {
buildObserveErrorGroupsJson,
buildObserveErrorGroupsTable,
buildObserveErrorOccurrencesJson,
buildObserveErrorOccurrencesTable,
} from '../formatErrors';
function makeErrorGroup(overrides: Partial<AppObserveErrorGroup> = {}): AppObserveErrorGroup {
return {
__typename: 'AppObserveErrorGroup' as const,
fingerprint: 'fp-1',
exceptionType: 'TypeError',
exceptionMessage: 'undefined is not a function',
errorSource: 'js',
severity: 'FATAL',
isFatal: true,
eventCount: 42,
uniqueUserCount: 10,
affectedSessionCount: 8,
firstSeenAt: '2025-01-01T00:00:00.000Z',
lastSeenAt: '2025-01-15T00:00:00.000Z',
platforms: ['IOS'],
...overrides,
} as AppObserveErrorGroup;
}
function makeErrorOccurrence(overrides: Partial<AppObserveError> = {}): AppObserveError {
return {
__typename: 'AppObserveError' as const,
id: 'err-1',
type: 'TypeError',
message: 'undefined is not a function',
source: 'js',
fingerprint: 'fp-1',
severityText: 'fatal',
severityNumber: null,
isFatal: true,
stacktrace: 'at foo (app.js:1:1)\nat bar (app.js:2:2)',
body: null,
timestamp: '2025-01-15T10:00:00.000Z',
sessionId: 'session-1',
appVersion: '1.0.0',
appBuildNumber: '42',
appUpdateId: null,
appEasBuildId: null,
deviceModel: 'iPhone 15',
deviceOs: 'iOS',
deviceOsVersion: '17.0',
environment: 'production',
easClientId: 'client-1',
countryCode: 'US',
properties: [],
...overrides,
} as AppObserveError;
}
const noNextPage = {
__typename: 'PageInfo' as const,
hasNextPage: false,
hasPreviousPage: false,
endCursor: null,
} as PageInfo;
describe(buildObserveErrorGroupsTable, () => {
it('renders a placeholder when there are no error groups', () => {
expect(buildObserveErrorGroupsTable([])).toContain('No errors found');
});
it('renders the fingerprint, exception type, message, and counts', () => {
const output = buildObserveErrorGroupsTable([makeErrorGroup()]);
expect(output).toContain('fp-1');
expect(output).toContain('TypeError');
expect(output).toContain('undefined is not a function');
expect(output).toContain('42');
expect(output).toContain('--fingerprint');
});
});
describe(buildObserveErrorOccurrencesTable, () => {
it('renders a placeholder when there are no occurrences', () => {
const output = buildObserveErrorOccurrencesTable([], noNextPage, { fingerprint: 'fp-1' });
expect(output).toContain('No occurrences found');
expect(output).toContain('fp-1');
});
it('renders occurrence details including the stack trace', () => {
const output = buildObserveErrorOccurrencesTable([makeErrorOccurrence()], noNextPage, {
fingerprint: 'fp-1',
});
expect(output).toContain('Stack trace');
expect(output).toContain('at foo (app.js:1:1)');
expect(output).toContain('TypeError');
});
});
describe(buildObserveErrorOccurrencesJson, () => {
it('includes the stack trace and properties in the JSON', () => {
const result = buildObserveErrorOccurrencesJson([makeErrorOccurrence()], noNextPage);
expect(result.occurrences[0].stacktrace).toBe('at foo (app.js:1:1)\nat bar (app.js:2:2)');
expect(result.occurrences[0].id).toBe('err-1');
expect(result.pageInfo).toEqual({ hasNextPage: false, endCursor: null });
});
});
describe(buildObserveErrorGroupsJson, () => {
it('maps error-group fields into stable JSON keys', () => {
const result = buildObserveErrorGroupsJson([makeErrorGroup()], false);
expect(result).toEqual({
isTruncated: false,
errors: [
{
fingerprint: 'fp-1',
type: 'TypeError',
message: 'undefined is not a function',
source: 'js',
severity: 'FATAL',
isFatal: true,
eventCount: 42,
uniqueUserCount: 10,
affectedSessionCount: 8,
firstSeenAt: '2025-01-01T00:00:00.000Z',
lastSeenAt: '2025-01-15T00:00:00.000Z',
platforms: ['IOS'],
},
],
});
});
});
@@ -11,6 +11,7 @@ import {
function makeMetricEntry(overrides: Partial<SessionEventEntry> = {}): SessionEventEntry {
return {
source: 'metric',
id: 'evt-m-1',
timestamp: '2025-01-15T10:00:00.000Z',
sessionId: 'session-1',
appVersion: '1.0.0',
@@ -31,6 +32,7 @@ function makeMetricEntry(overrides: Partial<SessionEventEntry> = {}): SessionEve
function makeLogEntry(overrides: Partial<SessionEventEntry> = {}): SessionEventEntry {
return {
source: 'log',
id: 'evt-c-1',
timestamp: '2025-01-15T10:01:00.000Z',
sessionId: 'session-1',
appVersion: '1.0.0',
@@ -240,6 +242,7 @@ describe(buildObserveSessionEventsJson, () => {
hasMoreMetricEvents: false,
hasMoreLogEvents: true,
});
expect(result.entries[0].id).toBe('evt-m-1');
});
it('returns null metadata when there were no entries', () => {
@@ -0,0 +1,81 @@
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
import {
AppObserveError,
AppObserveErrorGroup,
AppObserveErrorOccurrencesOrderByField,
AppObserveErrorSeverity,
AppObserveOrderDirection,
AppObservePlatform,
PageInfo,
} from '../graphql/generated';
import { ObserveQuery } from '../graphql/queries/ObserveQuery';
export interface FetchObserveErrorGroupsOptions {
startTime: string;
endTime: string;
platforms?: AppObservePlatform[];
appVersion?: string;
buildNumber?: string;
updateId?: string;
environment?: string;
severity?: AppObserveErrorSeverity;
}
export async function fetchObserveErrorGroupsAsync(
graphqlClient: ExpoGraphqlClient,
appId: string,
options: FetchObserveErrorGroupsOptions
): Promise<{ groups: AppObserveErrorGroup[]; isTruncated: boolean }> {
return await ObserveQuery.errorGroupsAsync(graphqlClient, {
appId,
input: {
startTime: options.startTime,
endTime: options.endTime,
...(options.platforms?.length && { platforms: options.platforms }),
...(options.appVersion && { appVersion: options.appVersion }),
...(options.buildNumber && { appBuildNumber: options.buildNumber }),
...(options.updateId && { appUpdateId: options.updateId }),
...(options.environment && { environment: options.environment }),
...(options.severity && { severity: options.severity }),
},
});
}
export interface FetchObserveErrorOccurrencesOptions {
fingerprint: string;
startTime: string;
endTime: string;
platforms?: AppObservePlatform[];
appVersion?: string;
buildNumber?: string;
updateId?: string;
environment?: string;
limit: number;
after?: string;
}
export async function fetchObserveErrorOccurrencesAsync(
graphqlClient: ExpoGraphqlClient,
appId: string,
options: FetchObserveErrorOccurrencesOptions
): Promise<{ occurrences: AppObserveError[]; pageInfo: PageInfo }> {
return await ObserveQuery.errorOccurrencesAsync(graphqlClient, {
appId,
filter: {
fingerprint: options.fingerprint,
startTime: options.startTime,
endTime: options.endTime,
...(options.platforms?.length && { platforms: options.platforms }),
...(options.appVersion && { appVersion: options.appVersion }),
...(options.buildNumber && { appBuildNumber: options.buildNumber }),
...(options.updateId && { appUpdateId: options.updateId }),
...(options.environment && { environment: options.environment }),
},
first: options.limit,
...(options.after && { after: options.after }),
orderBy: {
field: AppObserveErrorOccurrencesOrderByField.Timestamp,
direction: AppObserveOrderDirection.Desc,
},
});
}
@@ -14,6 +14,7 @@ import { fetchObserveEventsAsync, resolveOrderBy } from './fetchEvents';
export interface SessionEventEntry {
source: 'metric' | 'log';
id: string;
timestamp: string;
sessionId: string;
// Metric name, user-event name, or error type.
@@ -40,6 +41,7 @@ export interface SessionEventEntry {
function metricEventToEntry(event: AppObserveMetric): SessionEventEntry {
return {
source: 'metric',
id: event.id,
timestamp: event.timestamp,
sessionId: event.sessionId ?? '',
name: event.name,
@@ -60,6 +62,7 @@ function metricEventToEntry(event: AppObserveMetric): SessionEventEntry {
function userEventToEntry(event: AppObserveUserEvent): SessionEventEntry {
return {
source: 'log',
id: event.id,
timestamp: event.timestamp,
sessionId: event.sessionId ?? '',
name: event.name,
@@ -85,6 +88,7 @@ function errorToEntry(event: AppObserveError): SessionEventEntry {
];
return {
source: 'log',
id: event.id,
timestamp: event.timestamp,
sessionId: event.sessionId ?? '',
name: event.type ?? 'exception',
@@ -40,6 +40,66 @@ export interface ObserveCustomEventJson {
easClientId: string;
}
export function buildObserveCustomEventJson(event: AppObserveUserEvent): ObserveCustomEventJson {
return {
id: event.id,
name: event.name,
timestamp: event.timestamp,
sessionId: event.sessionId ?? null,
severityNumber: event.severityNumber ?? null,
severityText: event.severityText ?? null,
properties: event.properties.map(p => ({
key: p.key,
value: p.value,
type: p.type,
})),
appVersion: event.appVersion,
appBuildNumber: event.appBuildNumber,
appUpdateId: event.appUpdateId ?? null,
appEasBuildId: event.appEasBuildId ?? null,
deviceModel: event.deviceModel,
deviceOs: event.deviceOs,
deviceOsVersion: event.deviceOsVersion,
countryCode: event.countryCode ?? null,
environment: event.environment ?? null,
easClientId: event.easClientId,
};
}
/**
* Render a single user-defined (log) event as a vertical Field/Value detail
* table, plus its properties, for `eas observe:event`.
*/
export function buildObserveCustomEventDetail(event: AppObserveUserEvent): string {
const rows: string[][] = [
['ID', event.id],
['Type', 'Log'],
['Event Name', event.name],
['Timestamp', formatLogTimestamp(event.timestamp)],
['Severity', formatSeverity(event)],
['Session ID', event.sessionId ?? '-'],
['App Version', `${event.appVersion} (${event.appBuildNumber})`],
['Update ID', event.appUpdateId ?? '-'],
['EAS Build ID', event.appEasBuildId ?? '-'],
['Platform', `${event.deviceOs} ${event.deviceOsVersion}`],
['Device', event.deviceModel],
['Country', event.countryCode ?? '-'],
['Environment', event.environment ?? '-'],
['EAS Client ID', event.easClientId],
];
const lines = [chalk.bold('Log event'), '', renderTextTable(['Field', 'Value'], rows)];
if (event.properties.length > 0) {
const propertyRows = event.properties.map(p => [p.key, p.type, p.value]);
lines.push(
'',
chalk.bold('Properties'),
'',
renderTextTable(['Key', 'Type', 'Value'], propertyRows)
);
}
return lines.join('\n');
}
export interface BuildCustomEventsTableOptions {
eventName?: string;
daysBack?: number;
@@ -109,29 +169,7 @@ export function buildObserveCustomEventsJson(
pageInfo: { hasNextPage: boolean; endCursor: string | null };
} {
return {
events: events.map(event => ({
id: event.id,
name: event.name,
timestamp: event.timestamp,
sessionId: event.sessionId ?? null,
severityNumber: event.severityNumber ?? null,
severityText: event.severityText ?? null,
properties: event.properties.map(p => ({
key: p.key,
value: p.value,
type: p.type,
})),
appVersion: event.appVersion,
appBuildNumber: event.appBuildNumber,
appUpdateId: event.appUpdateId ?? null,
appEasBuildId: event.appEasBuildId ?? null,
deviceModel: event.deviceModel,
deviceOs: event.deviceOs,
deviceOsVersion: event.deviceOsVersion,
countryCode: event.countryCode ?? null,
environment: event.environment ?? null,
easClientId: event.easClientId,
})),
events: events.map(buildObserveCustomEventJson),
pageInfo: {
hasNextPage: pageInfo.hasNextPage,
endCursor: pageInfo.endCursor ?? null,
@@ -0,0 +1,317 @@
import chalk from 'chalk';
import { AppObserveError, AppObserveErrorGroup, PageInfo } from '../graphql/generated';
import renderTextTable from '../utils/renderTextTable';
import { buildTimeRangeDescription, formatLogTimestamp, formatTimestamp } from './formatUtils';
export interface ObserveErrorGroupJson {
fingerprint: string | null;
type: string | null;
message: string | null;
source: string | null;
severity: string | null;
isFatal: boolean | null;
eventCount: number | null;
uniqueUserCount: number | null;
affectedSessionCount: number | null;
firstSeenAt: string | null;
lastSeenAt: string | null;
platforms: string[];
}
export interface ObserveErrorJson {
id: string;
type: string | null;
message: string | null;
source: string | null;
fingerprint: string | null;
severityNumber: number | null;
severityText: string | null;
isFatal: boolean | null;
timestamp: string;
sessionId: string | null;
appVersion: string;
appBuildNumber: string;
appUpdateId: string | null;
appEasBuildId: string | null;
deviceModel: string;
deviceOs: string;
deviceOsVersion: string;
countryCode: string | null;
environment: string | null;
easClientId: string;
}
export function buildObserveErrorJson(event: AppObserveError): ObserveErrorJson {
return {
id: event.id,
type: event.type ?? null,
message: event.message ?? null,
source: event.source ?? null,
fingerprint: event.fingerprint ?? null,
severityNumber: event.severityNumber ?? null,
severityText: event.severityText ?? null,
isFatal: event.isFatal ?? null,
timestamp: event.timestamp,
sessionId: event.sessionId ?? null,
appVersion: event.appVersion,
appBuildNumber: event.appBuildNumber,
appUpdateId: event.appUpdateId ?? null,
appEasBuildId: event.appEasBuildId ?? null,
deviceModel: event.deviceModel,
deviceOs: event.deviceOs,
deviceOsVersion: event.deviceOsVersion,
countryCode: event.countryCode ?? null,
environment: event.environment ?? null,
easClientId: event.easClientId,
};
}
/**
* Render a single error (exception) event as a vertical Field/Value detail
* table, for `eas observe:event`.
*/
export function buildObserveErrorDetail(event: AppObserveError): string {
const severity = event.isFatal ? 'fatal' : (event.severityText ?? '-');
const rows: string[][] = [
['ID', event.id],
['Type', 'Error'],
['Exception', event.type ?? '-'],
['Message', event.message ?? '-'],
['Source', event.source ?? '-'],
['Fingerprint', event.fingerprint ?? '-'],
['Severity', severity],
['Timestamp', formatLogTimestamp(event.timestamp)],
['Session ID', event.sessionId ?? '-'],
['App Version', `${event.appVersion} (${event.appBuildNumber})`],
['Update ID', event.appUpdateId ?? '-'],
['EAS Build ID', event.appEasBuildId ?? '-'],
['Platform', `${event.deviceOs} ${event.deviceOsVersion}`],
['Device', event.deviceModel],
['Country', event.countryCode ?? '-'],
['Environment', event.environment ?? '-'],
['EAS Client ID', event.easClientId],
];
return [chalk.bold('Error event'), '', renderTextTable(['Field', 'Value'], rows)].join('\n');
}
export interface BuildErrorGroupsTableOptions {
daysBack?: number;
startTime?: string;
endTime?: string;
}
function truncate(value: string, maxLength: number): string {
return value.length > maxLength ? `${value.slice(0, maxLength - 1)}…` : value;
}
export function buildObserveErrorGroupsTable(
groups: AppObserveErrorGroup[],
options?: BuildErrorGroupsTableOptions
): string {
if (groups.length === 0) {
return chalk.yellow('No errors found.');
}
const headers = [
'Fingerprint',
'Type',
'Message',
'Severity',
'Events',
'Users',
'Sessions',
'Last Seen',
];
const rows: string[][] = groups.map(group => [
group.fingerprint,
truncate(group.exceptionType ?? '-', 40),
truncate(group.exceptionMessage ?? '-', 60),
group.isFatal ? 'fatal' : (group.severity ?? '-').toString().toLowerCase(),
(group.eventCount ?? 0).toLocaleString(),
(group.uniqueUserCount ?? 0).toLocaleString(),
(group.affectedSessionCount ?? 0).toLocaleString(),
group.lastSeenAt ? formatTimestamp(group.lastSeenAt) : '-',
]);
const lines: string[] = [];
if (options) {
const timeDesc = buildTimeRangeDescription(options);
lines.push(chalk.bold(`Errors ${timeDesc}`.trim()), '');
}
lines.push(renderTextTable(headers, rows));
lines.push(
'',
'Pass --fingerprint <fingerprint> to see individual occurrences with stack traces.'
);
return lines.join('\n');
}
export function buildObserveErrorGroupsJson(
groups: AppObserveErrorGroup[],
isTruncated: boolean
): { errors: ObserveErrorGroupJson[]; isTruncated: boolean } {
return {
errors: groups.map(group => ({
fingerprint: group.fingerprint ?? null,
type: group.exceptionType ?? null,
message: group.exceptionMessage ?? null,
source: group.errorSource ?? null,
severity: group.severity ?? null,
isFatal: group.isFatal ?? null,
eventCount: group.eventCount ?? null,
uniqueUserCount: group.uniqueUserCount ?? null,
affectedSessionCount: group.affectedSessionCount ?? null,
firstSeenAt: group.firstSeenAt ?? null,
lastSeenAt: group.lastSeenAt ?? null,
platforms: group.platforms ?? [],
})),
isTruncated,
};
}
export interface ObserveErrorOccurrenceJson {
id: string;
type: string | null;
message: string | null;
source: string | null;
fingerprint: string | null;
severityNumber: number | null;
severityText: string | null;
isFatal: boolean | null;
stacktrace: string | null;
body: string | null;
timestamp: string;
sessionId: string | null;
appVersion: string;
appBuildNumber: string;
appUpdateId: string | null;
appEasBuildId: string | null;
deviceModel: string;
deviceOs: string;
deviceOsVersion: string;
countryCode: string | null;
environment: string | null;
easClientId: string;
properties: Array<{ key: string; value: string; type: string }>;
}
export function buildObserveErrorOccurrenceJson(
occurrence: AppObserveError
): ObserveErrorOccurrenceJson {
return {
id: occurrence.id,
type: occurrence.type ?? null,
message: occurrence.message ?? null,
source: occurrence.source ?? null,
fingerprint: occurrence.fingerprint ?? null,
severityNumber: occurrence.severityNumber ?? null,
severityText: occurrence.severityText ?? null,
isFatal: occurrence.isFatal ?? null,
stacktrace: occurrence.stacktrace ?? null,
body: occurrence.body ?? null,
timestamp: occurrence.timestamp,
sessionId: occurrence.sessionId ?? null,
appVersion: occurrence.appVersion,
appBuildNumber: occurrence.appBuildNumber,
appUpdateId: occurrence.appUpdateId ?? null,
appEasBuildId: occurrence.appEasBuildId ?? null,
deviceModel: occurrence.deviceModel,
deviceOs: occurrence.deviceOs,
deviceOsVersion: occurrence.deviceOsVersion,
countryCode: occurrence.countryCode ?? null,
environment: occurrence.environment ?? null,
easClientId: occurrence.easClientId,
properties: occurrence.properties.map(p => ({ key: p.key, value: p.value, type: p.type })),
};
}
export function buildObserveErrorOccurrencesJson(
occurrences: AppObserveError[],
pageInfo: PageInfo
): {
occurrences: ObserveErrorOccurrenceJson[];
pageInfo: { hasNextPage: boolean; endCursor: string | null };
} {
return {
occurrences: occurrences.map(buildObserveErrorOccurrenceJson),
pageInfo: {
hasNextPage: pageInfo.hasNextPage,
endCursor: pageInfo.endCursor ?? null,
},
};
}
/**
* Render a single error occurrence as a Field/Value detail table followed by
* its stack trace (and body, if present), for `eas observe:errors --fingerprint`.
*/
function buildObserveErrorOccurrenceDetail(occurrence: AppObserveError): string {
const severity = occurrence.isFatal ? 'fatal' : (occurrence.severityText ?? '-');
const rows: string[][] = [
['ID', occurrence.id],
['Exception', occurrence.type ?? '-'],
['Message', occurrence.message ?? '-'],
['Source', occurrence.source ?? '-'],
['Severity', severity],
['Timestamp', formatLogTimestamp(occurrence.timestamp)],
['Session ID', occurrence.sessionId ?? '-'],
['App Version', `${occurrence.appVersion} (${occurrence.appBuildNumber})`],
['Update ID', occurrence.appUpdateId ?? '-'],
['Platform', `${occurrence.deviceOs} ${occurrence.deviceOsVersion}`],
['Device', occurrence.deviceModel],
['Country', occurrence.countryCode ?? '-'],
['Environment', occurrence.environment ?? '-'],
];
const lines = [renderTextTable(['Field', 'Value'], rows)];
if (occurrence.stacktrace) {
lines.push('', chalk.bold('Stack trace'), '', occurrence.stacktrace);
}
if (occurrence.body) {
lines.push('', chalk.bold('Body'), '', occurrence.body);
}
if (occurrence.properties.length > 0) {
const propertyRows = occurrence.properties.map(p => [p.key, p.type, p.value]);
lines.push(
'',
chalk.bold('Properties'),
'',
renderTextTable(['Key', 'Type', 'Value'], propertyRows)
);
}
return lines.join('\n');
}
export interface BuildErrorOccurrencesOptions {
fingerprint: string;
daysBack?: number;
startTime?: string;
endTime?: string;
}
export function buildObserveErrorOccurrencesTable(
occurrences: AppObserveError[],
pageInfo: PageInfo,
options: BuildErrorOccurrencesOptions
): string {
if (occurrences.length === 0) {
return chalk.yellow(`No occurrences found for fingerprint "${options.fingerprint}".`);
}
const timeDesc = buildTimeRangeDescription(options);
const lines: string[] = [chalk.bold(`Occurrences of ${options.fingerprint} ${timeDesc}`.trim())];
occurrences.forEach((occurrence, index) => {
lines.push(
'',
chalk.bold(`Occurrence ${index + 1}`),
'',
buildObserveErrorOccurrenceDetail(occurrence)
);
});
if (pageInfo.hasNextPage && pageInfo.endCursor) {
lines.push('', `Next page: --after ${pageInfo.endCursor}`);
}
return lines.join('\n');
}
+46 -18
View File
@@ -2,7 +2,7 @@ import chalk from 'chalk';
import { AppObserveMetric, PageInfo } from '../graphql/generated';
import renderTextTable from '../utils/renderTextTable';
import { buildTimeRangeDescription, formatTimestamp } from './formatUtils';
import { buildTimeRangeDescription, formatLogTimestamp, formatTimestamp } from './formatUtils';
import { getMetricDisplayName } from './metricNames';
export interface ObserveEventJson {
@@ -27,6 +27,50 @@ function resolveCustomParams(event: AppObserveMetric): { [key: string]: any } |
return event.customParams ?? null;
}
export function buildObserveEventJson(event: AppObserveMetric): ObserveEventJson {
return {
id: event.id,
name: event.name,
value: event.value,
appVersion: event.appVersion,
appBuildNumber: event.appBuildNumber,
appUpdateId: event.appUpdateId ?? null,
deviceModel: event.deviceModel,
deviceOs: event.deviceOs,
deviceOsVersion: event.deviceOsVersion,
countryCode: event.countryCode ?? null,
sessionId: event.sessionId ?? null,
easClientId: event.easClientId,
timestamp: event.timestamp,
customParams: resolveCustomParams(event),
routeName: event.routeName ?? null,
};
}
/**
* Render a single metric event as a vertical Field/Value detail table, for
* `eas observe:event`.
*/
export function buildObserveEventDetail(event: AppObserveMetric): string {
const rows: string[][] = [
['ID', event.id],
['Type', 'Metric'],
['Metric', getMetricDisplayName(event.name)],
['Value', `${event.value.toFixed(2)}s`],
['Timestamp', formatLogTimestamp(event.timestamp)],
['Session ID', event.sessionId ?? '-'],
['Route', event.routeName ?? '-'],
['App Version', `${event.appVersion} (${event.appBuildNumber})`],
['Update ID', event.appUpdateId ?? '-'],
['Platform', `${event.deviceOs} ${event.deviceOsVersion}`],
['Device', event.deviceModel],
['Country', event.countryCode ?? '-'],
['EAS Client ID', event.easClientId],
['Custom Params', event.customParams ? JSON.stringify(event.customParams) : '-'],
];
return [chalk.bold('Metric event'), '', renderTextTable(['Field', 'Value'], rows)].join('\n');
}
export interface BuildEventsTableOptions {
metricName: string;
daysBack?: number;
@@ -92,23 +136,7 @@ export function buildObserveEventsJson(
pageInfo: PageInfo
): { events: ObserveEventJson[]; pageInfo: { hasNextPage: boolean; endCursor: string | null } } {
return {
events: events.map(event => ({
id: event.id,
name: event.name,
value: event.value,
appVersion: event.appVersion,
appBuildNumber: event.appBuildNumber,
appUpdateId: event.appUpdateId ?? null,
deviceModel: event.deviceModel,
deviceOs: event.deviceOs,
deviceOsVersion: event.deviceOsVersion,
countryCode: event.countryCode ?? null,
sessionId: event.sessionId ?? null,
easClientId: event.easClientId,
timestamp: event.timestamp,
customParams: resolveCustomParams(event),
routeName: event.routeName ?? null,
})),
events: events.map(buildObserveEventJson),
pageInfo: {
hasNextPage: pageInfo.hasNextPage,
endCursor: pageInfo.endCursor ?? null,
@@ -3,9 +3,13 @@ import {
DEVICE_RUN_SESSION_RESOURCE_CLASS_BY_FLAG_VALUE,
DEVICE_RUN_SESSION_TYPE_BY_FLAG_VALUE,
DEVICE_RUN_SESSION_TYPE_FLAG_VALUES,
EAS_SIMULATOR_WAITLIST_URL,
deviceRunSessionTypeToFlagValue,
formatPreviewUrl,
formatRemoteSessionInstructions,
formatSimulatorUnavailableMessage,
getRemoteSessionEnvironmentVariables,
sanitizeRemoteConfigForJson,
} from '../utils';
const iosAppiumConfig = {
@@ -73,3 +77,216 @@ describe('simulator resource class flags', () => {
);
});
});
describe(formatPreviewUrl, () => {
it('appends the session token for a gated preview', () => {
expect(formatPreviewUrl('https://preview.example.test', 'tok-1')).toBe(
'https://preview.example.test/?token=tok-1'
);
});
it('leaves the url alone when the preview is ungated', () => {
expect(formatPreviewUrl('https://preview.example.test', null)).toBe(
'https://preview.example.test'
);
expect(formatPreviewUrl('https://preview.example.test', undefined)).toBe(
'https://preview.example.test'
);
});
});
describe(sanitizeRemoteConfigForJson, () => {
const PREVIEW_URL = 'https://preview.example.test';
it('moves the token into the preview url and drops the standalone field', () => {
const sanitized = sanitizeRemoteConfigForJson({
__typename: 'ServeSimRunSessionRemoteConfig' as const,
previewUrl: PREVIEW_URL,
previewToken: 'tok-1',
});
expect(sanitized).toEqual({
__typename: 'ServeSimRunSessionRemoteConfig',
previewUrl: `${PREVIEW_URL}/?token=tok-1`,
});
expect(JSON.stringify(sanitized)).not.toContain('previewToken');
});
it('does the same for a controller session', () => {
const sanitized = sanitizeRemoteConfigForJson({
__typename: 'ArgentRunSessionRemoteConfig' as const,
toolsUrl: 'https://argent.example.test',
toolsAuthToken: 'argent-token',
webPreviewUrl: PREVIEW_URL,
webPreviewToken: 'tok-1',
});
expect(sanitized).toMatchObject({ webPreviewUrl: `${PREVIEW_URL}/?token=tok-1` });
expect(JSON.stringify(sanitized)).not.toContain('webPreviewToken');
// The controller credential is a different secret and stays: it is what simulator:exec needs.
expect(sanitized).toMatchObject({ toolsAuthToken: 'argent-token' });
});
it('leaves an ungated session untouched', () => {
const remoteConfig = {
__typename: 'ServeSimRunSessionRemoteConfig' as const,
previewUrl: PREVIEW_URL,
previewToken: null,
};
expect(sanitizeRemoteConfigForJson(remoteConfig)).toEqual({
__typename: 'ServeSimRunSessionRemoteConfig',
previewUrl: PREVIEW_URL,
});
});
it('leaves a controller session with no web preview alone', () => {
const sanitized = sanitizeRemoteConfigForJson({
__typename: 'AppiumRunSessionRemoteConfig' as const,
appiumUrl: 'https://appium.example.test',
capabilities: {},
webPreviewUrl: null,
webPreviewToken: null,
});
expect(sanitized).toMatchObject({ webPreviewUrl: null });
});
});
describe('gated preview links', () => {
const PREVIEW = 'https://preview.example.test';
const GATED = `${PREVIEW}/?token=tok-1`;
it('prints the tokenized preview for a serve-sim session', () => {
const instructions = formatRemoteSessionInstructions(
{
__typename: 'ServeSimRunSessionRemoteConfig' as const,
previewUrl: PREVIEW,
previewToken: 'tok-1',
},
'env'
);
expect(instructions).toContain(GATED);
});
it('prints the tokenized preview for a web-preview-only session', () => {
const instructions = formatRemoteSessionInstructions(
{
__typename: 'WebPreviewOnlyRunSessionRemoteConfig' as const,
previewUrl: PREVIEW,
previewToken: 'tok-1',
},
'env'
);
expect(instructions).toContain(GATED);
});
it('prints the tokenized preview for every controller session type', () => {
const controllers = [
{
__typename: 'AgentDeviceRunSessionRemoteConfig' as const,
agentDeviceRemoteSessionUrl: 'https://daemon.example.test',
agentDeviceRemoteSessionToken: 'daemon-token',
webPreviewUrl: PREVIEW,
webPreviewToken: 'tok-1',
},
{
__typename: 'ArgentRunSessionRemoteConfig' as const,
toolsUrl: 'https://argent.example.test',
toolsAuthToken: 'argent-token',
webPreviewUrl: PREVIEW,
webPreviewToken: 'tok-1',
},
{ ...iosAppiumConfig, webPreviewToken: 'tok-1' },
];
for (const remoteConfig of controllers) {
expect(formatRemoteSessionInstructions(remoteConfig, 'env')).toContain(GATED);
}
});
it('prints the plain url when the preview is ungated', () => {
const instructions = formatRemoteSessionInstructions(
{ __typename: 'ServeSimRunSessionRemoteConfig' as const, previewUrl: PREVIEW },
'env'
);
expect(instructions).toContain(PREVIEW);
expect(instructions).not.toContain('token=');
});
});
describe('preview-only session environment', () => {
it.each([
{ __typename: 'ServeSimRunSessionRemoteConfig' as const, previewUrl: 'https://p.example.test' },
{
__typename: 'WebPreviewOnlyRunSessionRemoteConfig' as const,
previewUrl: 'https://p.example.test',
},
])('has no controller variables for $__typename', remoteConfig => {
expect(getRemoteSessionEnvironmentVariables(remoteConfig)).toEqual({});
});
});
describe('Argent session without a tools token', () => {
const untokenizedArgent = {
__typename: 'ArgentRunSessionRemoteConfig' as const,
toolsUrl: 'https://argent.example.test',
webPreviewUrl: null,
};
it('omits the auth variable', () => {
expect(getRemoteSessionEnvironmentVariables(untokenizedArgent)).toEqual({
ARGENT_TOOLS_URL: 'https://argent.example.test',
});
});
it('omits the --token flag from the link command', () => {
const instructions = formatRemoteSessionInstructions(untokenizedArgent, 'dotenv');
expect(instructions).toContain("argent link 'https://argent.example.test'");
expect(instructions).not.toContain('--token');
});
});
describe('dotenv instructions', () => {
it('tells an agent-device session to use simulator:exec', () => {
const instructions = formatRemoteSessionInstructions(
{
__typename: 'AgentDeviceRunSessionRemoteConfig' as const,
agentDeviceRemoteSessionUrl: 'https://daemon.example.test',
agentDeviceRemoteSessionToken: 'daemon-token',
webPreviewUrl: null,
},
'dotenv'
);
expect(instructions).toContain('eas simulator:exec npx agent-device <command>');
});
it('tells an argent session to link its local client', () => {
const instructions = formatRemoteSessionInstructions(
{
__typename: 'ArgentRunSessionRemoteConfig' as const,
toolsUrl: 'https://argent.example.test',
toolsAuthToken: 'argent-token',
webPreviewUrl: null,
},
'dotenv'
);
expect(instructions).toContain('link your local Argent client');
expect(instructions).toContain("--token 'argent-token'");
});
});
describe(formatSimulatorUnavailableMessage, () => {
it('names the account and points at the waitlist', () => {
const message = formatSimulatorUnavailableMessage('acme');
expect(message).toContain('acme');
expect(message).toContain(EAS_SIMULATOR_WAITLIST_URL);
});
});
+51 -5
View File
@@ -86,6 +86,47 @@ export function getRemoteSessionEnvironmentVariables(
type RemoteSessionInstructionsConfigType = 'env' | 'dotenv';
/**
* Preview link for a session. A gated serve-sim needs the session token, and a browser cannot send
* a header on a page load, so it rides the query. serve-sim swaps it for a cookie on the first load.
*/
export function formatPreviewUrl(url: string, token: string | null | undefined): string {
if (!token) {
return url;
}
const withToken = new URL(url);
withToken.searchParams.set('token', token);
return withToken.toString();
}
/**
* Remote config for `--json`. The preview URL carries the token and the standalone token field is
* dropped, so a consumer gets one URL that works rather than a bare URL that 401s next to a secret
* it has to know to combine.
*/
export function sanitizeRemoteConfigForJson(
remoteConfig: DeviceRunSessionRemoteConfig
): DeviceRunSessionRemoteConfig {
switch (remoteConfig.__typename) {
case 'ServeSimRunSessionRemoteConfig':
case 'WebPreviewOnlyRunSessionRemoteConfig': {
const { previewToken, ...rest } = remoteConfig;
return { ...rest, previewUrl: formatPreviewUrl(remoteConfig.previewUrl, previewToken) };
}
case 'AgentDeviceRunSessionRemoteConfig':
case 'ArgentRunSessionRemoteConfig':
case 'AppiumRunSessionRemoteConfig': {
const { webPreviewToken, ...rest } = remoteConfig;
return {
...rest,
webPreviewUrl: remoteConfig.webPreviewUrl
? formatPreviewUrl(remoteConfig.webPreviewUrl, webPreviewToken)
: remoteConfig.webPreviewUrl,
};
}
}
}
export function formatRemoteSessionInstructions(
remoteConfig: DeviceRunSessionRemoteConfig,
configType: RemoteSessionInstructionsConfigType
@@ -112,7 +153,7 @@ export function formatRemoteSessionInstructions(
'',
'🌐 Open the following URL in your browser to preview the simulator:',
'',
remoteConfig.webPreviewUrl
formatPreviewUrl(remoteConfig.webPreviewUrl, remoteConfig.webPreviewToken)
);
}
return lines.join('\n');
@@ -150,7 +191,7 @@ export function formatRemoteSessionInstructions(
'',
'🌐 Open the following URL in your browser to preview the simulator:',
'',
remoteConfig.webPreviewUrl
formatPreviewUrl(remoteConfig.webPreviewUrl, remoteConfig.webPreviewToken)
);
}
return lines.join('\n');
@@ -174,7 +215,12 @@ export function formatRemoteSessionInstructions(
'<appium-client> [args...]',
];
if (remoteConfig.webPreviewUrl) {
lines.push('', 'Open the simulator preview:', '', remoteConfig.webPreviewUrl);
lines.push(
'',
'Open the simulator preview:',
'',
formatPreviewUrl(remoteConfig.webPreviewUrl, remoteConfig.webPreviewToken)
);
}
return lines.join('\n');
}
@@ -182,13 +228,13 @@ export function formatRemoteSessionInstructions(
return [
'🌐 Open the following URL in your browser to access the simulator:',
'',
remoteConfig.previewUrl,
formatPreviewUrl(remoteConfig.previewUrl, remoteConfig.previewToken),
].join('\n');
case 'WebPreviewOnlyRunSessionRemoteConfig':
return [
'🌐 Open the following URL in your browser to access the simulator:',
'',
remoteConfig.previewUrl,
formatPreviewUrl(remoteConfig.previewUrl, remoteConfig.previewToken),
].join('\n');
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/eas-json",
"version": "23.1.0",
"version": "24.0.0",
"description": "A library for interacting with eas.json",
"homepage": "https://github.com/expo/eas-cli",
"bugs": "https://github.com/expo/eas-cli/issues",
@@ -32,7 +32,7 @@
},
"dependencies": {
"@babel/code-frame": "7.23.5",
"@expo/eas-build-job": "23.1.0",
"@expo/eas-build-job": "24.0.0",
"chalk": "4.1.2",
"env-string": "1.0.1",
"fs-extra": "11.2.0",
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "eas-cli-local-build-plugin",
"version": "23.2.0",
"version": "24.0.0",
"description": "Tool for running EAS compatible builds on a local machine.",
"bugs": "https://github.com/expo/eas-cli/issues",
"license": "BUSL-1.1",
@@ -26,12 +26,12 @@
"clean": "rimraf node_modules dist coverage \"*.tsbuildinfo\""
},
"dependencies": {
"@expo/build-tools": "23.2.0",
"@expo/build-tools": "24.0.0",
"@expo/bunyan": "^4.0.1",
"@expo/eas-build-job": "23.1.0",
"@expo/logger": "23.1.0",
"@expo/eas-build-job": "24.0.0",
"@expo/logger": "24.0.0",
"@expo/spawn-async": "^1.7.2",
"@expo/turtle-spawn": "23.1.0",
"@expo/turtle-spawn": "24.0.0",
"chalk": "4.1.2",
"env-paths": "^2.2.1",
"fs-extra": "^11.2.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/logger",
"version": "23.1.0",
"version": "24.0.0",
"bugs": "https://github.com/expo/eas-cli/issues",
"license": "BUSL-1.1",
"author": "Expo <[email protected]>",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/steps",
"version": "23.1.0",
"version": "24.0.0",
"bugs": "https://github.com/expo/eas-cli/issues",
"license": "BUSL-1.1",
"author": "Expo <[email protected]>",
@@ -27,8 +27,8 @@
"clean": "rimraf node_modules dist coverage \"*.tsbuildinfo\""
},
"dependencies": {
"@expo/eas-build-job": "23.1.0",
"@expo/logger": "23.1.0",
"@expo/eas-build-job": "24.0.0",
"@expo/logger": "24.0.0",
"@expo/spawn-async": "^1.7.2",
"arg": "^5.0.2",
"fast-glob": "^3.3.2",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/template-file",
"version": "23.0.0",
"version": "24.0.0",
"bugs": "https://github.com/expo/eas-cli/issues",
"license": "BUSL-1.1",
"author": "Expo <[email protected]>",
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/turtle-spawn",
"version": "23.1.0",
"version": "24.0.0",
"bugs": "https://github.com/expo/eas-cli/issues",
"license": "BUSL-1.1",
"author": "Expo <[email protected]>",
@@ -25,7 +25,7 @@
"clean": "rimraf node_modules dist coverage \"*.tsbuildinfo\""
},
"dependencies": {
"@expo/logger": "23.1.0",
"@expo/logger": "24.0.0",
"@expo/spawn-async": "^1.7.2"
},
"devDependencies": {
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@expo/worker",
"version": "23.2.0",
"version": "24.0.0",
"private": true,
"scripts": {
"start": "yarn watch",
@@ -19,17 +19,17 @@
},
"dependencies": {
"@babel/core": "7.24.7",
"@expo/build-tools": "23.2.0",
"@expo/build-tools": "24.0.0",
"@expo/config-plugins": "55.0.7",
"@expo/config-types": "55.0.5",
"@expo/eas-build-job": "23.1.0",
"@expo/logger": "23.1.0",
"@expo/eas-build-job": "24.0.0",
"@expo/logger": "24.0.0",
"@expo/results": "1.0.0",
"@expo/rudder-sdk-node": "1.1.1",
"@expo/spawn-async": "1.7.2",
"@expo/steps": "23.1.0",
"@expo/template-file": "23.0.0",
"@expo/turtle-spawn": "23.1.0",
"@expo/steps": "24.0.0",
"@expo/template-file": "24.0.0",
"@expo/turtle-spawn": "24.0.0",
"@hapi/boom": "10.0.1",
"check-disk-space": "3.4.0",
"fast-glob": "3.3.2",
@@ -21,4 +21,18 @@ describe('config', () => {
expect(config.loggers.http.baseUrl).toBe(expectedBaseUrl);
});
});
it.each([
[Environment.DEVELOPMENT, 'ws://localhost:8787'],
[Environment.STAGING, 'wss://staging-mcp.expo.dev'],
[Environment.PRODUCTION, 'wss://mcp.expo.dev'],
[Environment.TEST, 'ws://localhost:8787'],
])('uses the expected MCP server URL in %s', (environment, expectedMcpServerUrl) => {
process.env.ENVIRONMENT = environment;
jest.isolateModules(() => {
const config = require('../config').default;
expect(config.mcpServerUrl).toBe(expectedMcpServerUrl);
});
});
});
@@ -91,6 +91,19 @@ describe(createBuildContext.name, () => {
);
});
it('adds the MCP server URL to the build context', async () => {
const ctx = await createBuildContext({
...baseOptions,
job: {
platform: Platform.ANDROID,
type: Workflow.GENERIC,
secrets: { environmentSecrets: [] },
} as any,
});
expect(ctx.mcpServerUrl).toBe(config.mcpServerUrl);
});
it('routes managed source maps to the source-map uploader', async () => {
const ctx = await createBuildContext({
...baseOptions,
+6
View File
@@ -86,4 +86,10 @@ export default {
: process.env.ENVIRONMENT === 'staging'
? 'https://staging-api.expo.dev/v2/'
: 'https://api.expo.dev/v2/',
mcpServerUrl:
process.env.ENVIRONMENT === 'development' || process.env.ENVIRONMENT === 'test'
? 'ws://localhost:8787'
: process.env.ENVIRONMENT === 'staging'
? 'wss://staging-mcp.expo.dev'
: 'wss://mcp.expo.dev',
};
+1
View File
@@ -103,6 +103,7 @@ export async function createBuildContext<TJob extends Job>({
cacheManager: new GCSCacheManager(),
metadata,
expoApiV2BaseUrl: config.wwwApiV2BaseUrl,
mcpServerUrl: config.mcpServerUrl,
});
return ctx;
}
Generated
+40 -40
View File
@@ -2282,33 +2282,33 @@ __metadata:
languageName: node
linkType: hard
"@expo/apple-utils@npm:2.1.22":
version: 2.1.22
resolution: "@expo/apple-utils@npm:2.1.22"
"@expo/apple-utils@npm:2.2.0":
version: 2.2.0
resolution: "@expo/apple-utils@npm:2.2.0"
bin:
apple-utils: bin.js
checksum: 10c0/19a5d21f80cde11e7502d7380b17bb4634568dcd243eb72ce741277dd71aab2b20168e44060143b10bfa01f0b03a6b8a2628b3cf3e5d697b12cf7f78a16d469a
checksum: 10c0/527bbe07536f5ff7aeb3774feaa4d9ed89e1ffec54f414125e9a85ba5048eb6471fa5ae6b4ce25f7387601383b4e34e2490c62d3778e12f79bff13167447187e
languageName: node
linkType: hard
"@expo/build-tools@npm:23.2.0, @expo/build-tools@workspace:packages/build-tools":
"@expo/build-tools@npm:24.0.0, @expo/build-tools@workspace:packages/build-tools":
version: 0.0.0-use.local
resolution: "@expo/build-tools@workspace:packages/build-tools"
dependencies:
"@expo/config": "npm:55.0.10"
"@expo/config-plugins": "npm:55.0.7"
"@expo/downloader": "npm:23.0.0"
"@expo/eas-build-job": "npm:23.1.0"
"@expo/downloader": "npm:24.0.0"
"@expo/eas-build-job": "npm:24.0.0"
"@expo/env": "npm:^0.4.0"
"@expo/logger": "npm:23.1.0"
"@expo/logger": "npm:24.0.0"
"@expo/package-manager": "npm:1.9.10"
"@expo/plist": "npm:^0.3.5"
"@expo/repack-app": "npm:~0.9.0"
"@expo/results": "npm:^1.0.0"
"@expo/spawn-async": "npm:1.7.2"
"@expo/steps": "npm:23.1.0"
"@expo/template-file": "npm:23.0.0"
"@expo/turtle-spawn": "npm:23.1.0"
"@expo/steps": "npm:24.0.0"
"@expo/template-file": "npm:24.0.0"
"@expo/turtle-spawn": "npm:24.0.0"
"@expo/xcpretty": "npm:^4.3.1"
"@ngrok/ngrok": "npm:1.7.0"
"@sentry/node": "npm:7.77.0"
@@ -2541,7 +2541,7 @@ __metadata:
languageName: node
linkType: hard
"@expo/downloader@npm:23.0.0, @expo/downloader@workspace:packages/downloader":
"@expo/downloader@npm:24.0.0, @expo/downloader@workspace:packages/downloader":
version: 0.0.0-use.local
resolution: "@expo/downloader@workspace:packages/downloader"
dependencies:
@@ -2557,13 +2557,13 @@ __metadata:
languageName: unknown
linkType: soft
"@expo/eas-build-job@npm:23.1.0, @expo/eas-build-job@workspace:packages/eas-build-job":
"@expo/eas-build-job@npm:24.0.0, @expo/eas-build-job@workspace:packages/eas-build-job":
version: 0.0.0-use.local
resolution: "@expo/eas-build-job@workspace:packages/eas-build-job"
dependencies:
"@expo/logger": "npm:23.1.0"
"@expo/logger": "npm:24.0.0"
"@expo/results": "npm:1.0.0"
"@expo/turtle-spawn": "npm:23.1.0"
"@expo/turtle-spawn": "npm:24.0.0"
"@types/jest": "npm:^29.5.12"
"@types/node": "npm:20.14.2"
jest: "npm:^29.7.0"
@@ -2576,12 +2576,12 @@ __metadata:
languageName: unknown
linkType: soft
"@expo/eas-json@npm:23.1.0, @expo/eas-json@workspace:packages/eas-json":
"@expo/eas-json@npm:24.0.0, @expo/eas-json@workspace:packages/eas-json":
version: 0.0.0-use.local
resolution: "@expo/eas-json@workspace:packages/eas-json"
dependencies:
"@babel/code-frame": "npm:7.23.5"
"@expo/eas-build-job": "npm:23.1.0"
"@expo/eas-build-job": "npm:24.0.0"
"@tsconfig/node20": "npm:20.1.8"
"@types/babel__code-frame": "npm:7.0.3"
"@types/fs-extra": "npm:11.0.4"
@@ -2695,7 +2695,7 @@ __metadata:
languageName: node
linkType: hard
"@expo/logger@npm:23.1.0, @expo/logger@workspace:packages/logger":
"@expo/logger@npm:24.0.0, @expo/logger@workspace:packages/logger":
version: 0.0.0-use.local
resolution: "@expo/logger@workspace:packages/logger"
dependencies:
@@ -2895,12 +2895,12 @@ __metadata:
languageName: node
linkType: hard
"@expo/steps@npm:23.1.0, @expo/steps@workspace:packages/steps":
"@expo/steps@npm:24.0.0, @expo/steps@workspace:packages/steps":
version: 0.0.0-use.local
resolution: "@expo/steps@workspace:packages/steps"
dependencies:
"@expo/eas-build-job": "npm:23.1.0"
"@expo/logger": "npm:23.1.0"
"@expo/eas-build-job": "npm:24.0.0"
"@expo/logger": "npm:24.0.0"
"@expo/spawn-async": "npm:^1.7.2"
"@jest/globals": "npm:^29.7.0"
"@types/jest": "npm:^29.5.12"
@@ -2926,7 +2926,7 @@ __metadata:
languageName: unknown
linkType: soft
"@expo/template-file@npm:23.0.0, @expo/template-file@workspace:packages/template-file":
"@expo/template-file@npm:24.0.0, @expo/template-file@workspace:packages/template-file":
version: 0.0.0-use.local
resolution: "@expo/template-file@workspace:packages/template-file"
dependencies:
@@ -2949,11 +2949,11 @@ __metadata:
languageName: node
linkType: hard
"@expo/turtle-spawn@npm:23.1.0, @expo/turtle-spawn@workspace:packages/turtle-spawn":
"@expo/turtle-spawn@npm:24.0.0, @expo/turtle-spawn@workspace:packages/turtle-spawn":
version: 0.0.0-use.local
resolution: "@expo/turtle-spawn@workspace:packages/turtle-spawn"
dependencies:
"@expo/logger": "npm:23.1.0"
"@expo/logger": "npm:24.0.0"
"@expo/spawn-async": "npm:^1.7.2"
"@types/jest": "npm:^29.5.12"
"@types/node": "npm:20.14.2"
@@ -2969,17 +2969,17 @@ __metadata:
resolution: "@expo/worker@workspace:packages/worker"
dependencies:
"@babel/core": "npm:7.24.7"
"@expo/build-tools": "npm:23.2.0"
"@expo/build-tools": "npm:24.0.0"
"@expo/config-plugins": "npm:55.0.7"
"@expo/config-types": "npm:55.0.5"
"@expo/eas-build-job": "npm:23.1.0"
"@expo/logger": "npm:23.1.0"
"@expo/eas-build-job": "npm:24.0.0"
"@expo/logger": "npm:24.0.0"
"@expo/results": "npm:1.0.0"
"@expo/rudder-sdk-node": "npm:1.1.1"
"@expo/spawn-async": "npm:1.7.2"
"@expo/steps": "npm:23.1.0"
"@expo/template-file": "npm:23.0.0"
"@expo/turtle-spawn": "npm:23.1.0"
"@expo/steps": "npm:24.0.0"
"@expo/template-file": "npm:24.0.0"
"@expo/turtle-spawn": "npm:24.0.0"
"@hapi/boom": "npm:10.0.1"
"@types/babel__core": "npm:7.20.5"
"@types/fs-extra": "npm:11.0.4"
@@ -9828,7 +9828,7 @@ __metadata:
resolution: "create-eas-build-function@workspace:packages/create-eas-build-function"
dependencies:
"@expo/package-manager": "npm:1.9.10"
"@expo/steps": "npm:23.1.0"
"@expo/steps": "npm:24.0.0"
"@jest/globals": "npm:^29.7.0"
"@types/jest": "npm:^29.5.12"
"@types/node": "npm:20.14.2"
@@ -10412,12 +10412,12 @@ __metadata:
version: 0.0.0-use.local
resolution: "eas-cli-local-build-plugin@workspace:packages/local-build-plugin"
dependencies:
"@expo/build-tools": "npm:23.2.0"
"@expo/build-tools": "npm:24.0.0"
"@expo/bunyan": "npm:^4.0.1"
"@expo/eas-build-job": "npm:23.1.0"
"@expo/logger": "npm:23.1.0"
"@expo/eas-build-job": "npm:24.0.0"
"@expo/logger": "npm:24.0.0"
"@expo/spawn-async": "npm:^1.7.2"
"@expo/turtle-spawn": "npm:23.1.0"
"@expo/turtle-spawn": "npm:24.0.0"
"@types/fs-extra": "npm:^11.0.4"
"@types/hapi__joi": "npm:^17.1.14"
"@types/lodash": "npm:^4.17.4"
@@ -10465,15 +10465,15 @@ __metadata:
version: 0.0.0-use.local
resolution: "eas-cli@workspace:packages/eas-cli"
dependencies:
"@expo/apple-utils": "npm:2.1.22"
"@expo/apple-utils": "npm:2.2.0"
"@expo/code-signing-certificates": "npm:0.0.5"
"@expo/config": "npm:55.0.10"
"@expo/config-plugins": "npm:55.0.7"
"@expo/eas-build-job": "npm:23.1.0"
"@expo/eas-json": "npm:23.1.0"
"@expo/eas-build-job": "npm:24.0.0"
"@expo/eas-json": "npm:24.0.0"
"@expo/env": "npm:^1.0.0"
"@expo/json-file": "npm:8.3.3"
"@expo/logger": "npm:23.1.0"
"@expo/logger": "npm:24.0.0"
"@expo/multipart-body-parser": "npm:2.0.0"
"@expo/osascript": "npm:2.1.4"
"@expo/package-manager": "npm:1.9.10"
@@ -10485,7 +10485,7 @@ __metadata:
"@expo/results": "npm:1.0.0"
"@expo/rudder-sdk-node": "npm:1.1.1"
"@expo/spawn-async": "npm:1.7.2"
"@expo/steps": "npm:23.1.0"
"@expo/steps": "npm:24.0.0"
"@expo/timeago.js": "npm:1.0.0"
"@graphql-codegen/cli": "npm:6.3.1"
"@graphql-codegen/introspection": "npm:5.0.2"