Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/simulator-start-import.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eas-cli': minor
---

Start simulator sessions from saved settings and apply control actions after readiness.
599 changes: 597 additions & 2 deletions packages/eas-cli/src/commands/simulator/__tests__/index.test.ts

Large diffs are not rendered by default.

24 changes: 6 additions & 18 deletions packages/eas-cli/src/commands/simulator/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ora } from '../../ora';
import {
ControlAction,
executeControlActionAsync,
parseControlActionOutput,
prepareControlActionAsync,
} from '../../simulator/controlActions';
import {
Expand All @@ -23,6 +24,7 @@ import {
PreparedControlConfig,
executeControlConfigAsync,
prepareControlConfigAsync,
serializeControlConfigResults,
} from '../../simulator/controlConfig';
import {
EAS_SIMULATOR_SESSION_ID,
Expand Down Expand Up @@ -262,7 +264,7 @@ export default class SimulatorControl extends EasCommand {
id: session.id,
session,
config: config.path,
results: configResultsJson(error.completed),
results: serializeControlConfigResults(error.completed),
error: { step: error.step, action: error.action, message: error.message },
});
process.exitCode = 1;
Expand All @@ -286,7 +288,7 @@ export default class SimulatorControl extends EasCommand {
id: session.id,
session,
config: config.path,
results: configResultsJson(results),
results: serializeControlConfigResults(results),
});
} else {
Log.newLine();
Expand All @@ -300,7 +302,7 @@ export default class SimulatorControl extends EasCommand {
if (result.file) {
Log.log(` Saved: ${result.file}`);
} else if (result.output) {
const output = parseJsonOutput(result.output);
const output = parseControlActionOutput(result.output);
const text = typeof output === 'string' ? output : JSON.stringify(output, null, 2);
Log.log(
text
Expand Down Expand Up @@ -421,7 +423,7 @@ export default class SimulatorControl extends EasCommand {
id: session.id,
session,
action,
output: parseJsonOutput(output),
output: parseControlActionOutput(output),
file: savedFile,
});
return;
Expand All @@ -442,12 +444,6 @@ function formatActionCount(count: number): string {
return `${count} action${count === 1 ? '' : 's'}`;
}

function configResultsJson(
results: readonly ControlConfigResult[]
): { action: string; output: unknown; file: string | null }[] {
return results.map(result => ({ ...result, output: parseJsonOutput(result.output) }));
}

function assertControllableSession(
session: Awaited<ReturnType<typeof DeviceRunSessionQuery.byIdAsync>>
): PreviewApiAccess {
Expand All @@ -469,11 +465,3 @@ function assertControllableSession(
}
return access;
}

function parseJsonOutput(output: string): unknown {
try {
return JSON.parse(output);
} catch {
return output;
}
}
Loading
Loading