MCPcopy Index your code
hub / github.com/callstack/agent-device / handleReplayExportCommand

Function handleReplayExportCommand

src/cli/commands/replay.ts:32–65  ·  view source on GitHub ↗
({
  positionals,
  flags,
}: ReplayCommandParams)

Source from the content-addressed store, hash-verified

30}
31
32async function handleReplayExportCommand({
33 positionals,
34 flags,
35}: ReplayCommandParams): Promise<true> {
36 validateReplayExportOptions(positionals, flags);
37 const inputPath = positionals[1];
38 if (!inputPath) {
39 throw new AppError('INVALID_ARGS', 'replay export requires an input path.');
40 }
41
42 const sourcePath = resolveUserPath(inputPath);
43 const script = fs.readFileSync(sourcePath, 'utf8');
44 const result = exportReplayScriptToMaestro(script);
45 const outputPath = typeof flags.out === 'string' ? resolveUserPath(flags.out) : undefined;
46 if (outputPath) {
47 fs.mkdirSync(path.dirname(outputPath), { recursive: true });
48 fs.writeFileSync(outputPath, result.yaml);
49 }
50 for (const warning of result.warnings) {
51 process.stderr.write(`Warning: line ${warning.line}: ${warning.message}\n`);
52 }
53
54 writeCommandOutput(
55 flags,
56 {
57 format: flags.replayExportFormat ?? 'maestro',
58 sourcePath,
59 ...(outputPath ? { path: outputPath } : { yaml: result.yaml }),
60 warnings: result.warnings,
61 },
62 () => outputPath ?? result.yaml,
63 );
64 return true;
65}
66
67function validateReplayExportOptions(
68 positionals: ReplayCommandParams['positionals'],

Callers 1

replayCommandFunction · 0.85

Calls 5

resolveUserPathFunction · 0.90
writeCommandOutputFunction · 0.90
writeMethod · 0.80

Tested by

no test coverage detected