Home / File/ reporter.ts — react Source File

reporter.ts — react Source File

Architecture documentation for reporter.ts, a typescript file in the react codebase. 5 imports, 2 dependents.

File typescript BabelCompiler Optimization 5 imports 2 dependents 4 functions

Entity Profile

Dependency Diagram

graph LR
  0e6b4c6b_7bcc_eac7_3f6d_ff9990f24223["reporter.ts"]
  178fc52d_e7f8_dce1_75f6_f388c2223069["chalk"]
  0e6b4c6b_7bcc_eac7_3f6d_ff9990f24223 --> 178fc52d_e7f8_dce1_75f6_f388c2223069
  324b23d8_44c6_f20a_4338_46cccc56566e["fs"]
  0e6b4c6b_7bcc_eac7_3f6d_ff9990f24223 --> 324b23d8_44c6_f20a_4338_46cccc56566e
  7b0f5d46_efcb_4a2d_89c1_7cee4a0f9bc8["invariant"]
  0e6b4c6b_7bcc_eac7_3f6d_ff9990f24223 --> 7b0f5d46_efcb_4a2d_89c1_7cee4a0f9bc8
  438ec5cd_e09b_6193_06b7_3753a896b547["jest-diff"]
  0e6b4c6b_7bcc_eac7_3f6d_ff9990f24223 --> 438ec5cd_e09b_6193_06b7_3753a896b547
  b402a0fc_00db_e86d_b1ea_ad4f8e9faaca["path"]
  0e6b4c6b_7bcc_eac7_3f6d_ff9990f24223 --> b402a0fc_00db_e86d_b1ea_ad4f8e9faaca
  49c99dfe_ec8f_3cb7_769b_a3b735b82b82["runner-worker.ts"]
  49c99dfe_ec8f_3cb7_769b_a3b735b82b82 --> 0e6b4c6b_7bcc_eac7_3f6d_ff9990f24223
  1fd49604_fb16_2568_4971_9eca12fd6a73["runner.ts"]
  1fd49604_fb16_2568_4971_9eca12fd6a73 --> 0e6b4c6b_7bcc_eac7_3f6d_ff9990f24223
  style 0e6b4c6b_7bcc_eac7_3f6d_ff9990f24223 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import chalk from 'chalk';
import fs from 'fs';
import invariant from 'invariant';
import {diff} from 'jest-diff';
import path from 'path';

function wrapWithTripleBackticks(s: string, ext: string | null = null): string {
  return `\`\`\`${ext ?? ''}
${s}
\`\`\``;
}
const SPROUT_SEPARATOR = '\n### Eval output\n';

export function writeOutputToString(
  input: string,
  compilerOutput: string | null,
  evaluatorOutput: string | null,
  logs: string | null,
  errorMessage: string | null,
) {
  // leading newline intentional
  let result = `
## Input

${wrapWithTripleBackticks(input, 'javascript')}
`; // trailing newline + space internional

  if (compilerOutput != null) {
    result += `
## Code

${wrapWithTripleBackticks(compilerOutput, 'javascript')}
`;
  } else {
    result += '\n';
  }

  if (logs != null) {
    result += `
## Logs

${wrapWithTripleBackticks(logs, null)}
`;
  }

  if (errorMessage != null) {
    result += `
## Error

${wrapWithTripleBackticks(errorMessage.replace(/^\/.*?:\s/, ''))}
          \n`;
  }
  result += `      `;
// ... (139 more lines)

Domain

Subdomains

Dependencies

  • chalk
  • fs
  • invariant
  • jest-diff
  • path

Frequently Asked Questions

What does reporter.ts do?
reporter.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in reporter.ts?
reporter.ts defines 4 function(s): report, update, wrapWithTripleBackticks, writeOutputToString.
What does reporter.ts depend on?
reporter.ts imports 5 module(s): chalk, fs, invariant, jest-diff, path.
What files import reporter.ts?
reporter.ts is imported by 2 file(s): runner-worker.ts, runner.ts.
Where is reporter.ts in the architecture?
reporter.ts is located at compiler/packages/snap/src/reporter.ts (domain: BabelCompiler, subdomain: Optimization, directory: compiler/packages/snap/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free