mirror of
https://github.com/morluto/rea
synced 2026-10-26 06:16:17 -04:00
fix(cli): stream large JavaScript JSON results (#1024)
* fix(javascript): report application analysis progress on the CLI * test(cli): preserve progress in filtered output checks * fix(cli): stream large JavaScript JSON results * test(cli): include streaming output in dispatcher fixture
This commit is contained in:
@@ -2,11 +2,14 @@ import { analyzeJavaScriptApplication } from "../application/javascript/JavaScri
|
||||
import { createProgressReporter } from "../application/ProgressReporter.js";
|
||||
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
import type { CliCommandOutput } from "./streamedJsonOutput.js";
|
||||
|
||||
/** Execute the shared one-shot CLI boundary for static JavaScript analysis. */
|
||||
export const runCliJavaScriptApplicationAnalysis = async (
|
||||
input: unknown,
|
||||
): Promise<JsonValue> => {
|
||||
output?: CliCommandOutput,
|
||||
): Promise<JsonValue | undefined> => {
|
||||
const started = performance.now();
|
||||
const progress = createProgressReporter(
|
||||
async (update) => {
|
||||
process.stderr.write(`${JSON.stringify({ rea_progress: update })}\n`);
|
||||
@@ -14,7 +17,17 @@ export const runCliJavaScriptApplicationAnalysis = async (
|
||||
{ minimumIntervalMs: 0 },
|
||||
);
|
||||
const result = await analyzeJavaScriptApplication(input, { progress });
|
||||
return result.ok ? result.value : cliError(result.error);
|
||||
const value = result.ok ? result.value : cliError(result.error);
|
||||
if (
|
||||
output !== undefined &&
|
||||
(await output.output.write(value, {
|
||||
command: output.command,
|
||||
format: output.format,
|
||||
duration: `${Math.round(performance.now() - started)}ms`,
|
||||
}))
|
||||
)
|
||||
return undefined;
|
||||
return value;
|
||||
};
|
||||
|
||||
const cliError = (
|
||||
|
||||
Reference in New Issue
Block a user