ronantakizawa/codereview-bench huggingface dataset:
Repository: facebook/react
File: compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts (TypeScript)

Code before:
  [
    '1',
    addFunction(
      BUILTIN_SHAPES,
      [],
      {
        positionalParams: [],
        restParam: Effect.Freeze,
        returnType: PRIMITIVE_TYPE,
        calleeEffect: Effect.Read,
        returnValueKind: ValueKind.Primitive,
      },
      BuiltInDispatchId,
    ),
  ],
]);

addObject(BUILTIN_SHAPES, BuiltInUseRefId, [
  ['current', {kind: 'Object', shapeId: BuiltInRefValueId}],
]);

addObject(BUILTIN_SHAPES, BuiltInRefValueId, [
  ['*', {kind: 'Object', shapeId: BuiltInRefValueId}],
]);

addFunction(
  BUILTIN_SHAPES,
  [],
  {
    positionalParams: [],
    restParam: Effect.ConditionallyMutate,
    returnType: {kind: 'Poly'},
    calleeEffect: Effect.ConditionallyMutate,
    returnValueKind: ValueKind.Mutable,
  },
  BuiltinEffectEventId,
);

/**
 * MixedReadOnly =
 *   | primitive
 *   | simple objects (Record<string, MixedReadOnly>)
 *   | Array<MixedReadOnly>
 *
 * APIs such as Relay — but also Flux and other data stores — often return a
 * union of types with some interesting properties in terms of analysis.
 *
 * Given this constraint, if data came from Relay, then we should be able to
 * infer things like `data.items.map(): Array`. That may seem like a leap at
 * first but remember, we assume you're not patching builtins. Thus the only way
 * data.items.map can exist and be a function, given the above set of data types

Review comment (suggestion):
Without this i got errors trying to resolve properties, because we have a shape id defined for reanimated but no shape definition. I'm not sure how we didn't run into that error before but it seems like it easily could have occurred.

Code after:
  [
    '1',
    addFunction(
      BUILTIN_SHAPES,
      [],
      {
        positionalParams: [],
        restParam: Effect.Freeze,
        returnType: PRIMITIVE_TYPE,
        calleeEffect: Effect.Read,
        returnValueKind: ValueKind.Primitive,
      },
      BuiltInDispatchId,
    ),
  ],
]);

addObject(BUILTIN_SHAPES, BuiltInUseRefId, [
  ['current', {kind: 'Object', shapeId: BuiltInRefValueId}],
]);

addObject(BUILTIN_SHAPES, BuiltInRefValueId, [
  ['*', {kind: 'Object', shapeId: BuiltInRefValueId}],
]);

addObject(BUILTIN_SHAPES, ReanimatedSharedValueId, []);

addFunction(
  BUILTIN_SHAPES,
  [],
  {
    positionalParams: [],
    restParam: Effect.ConditionallyMutate,
    returnType: {kind: 'Poly'},
    calleeEffect: Effect.ConditionallyMutate,
    returnValueKind: ValueKind.Mutable,
  },
  BuiltinEffectEventId,
);

/**
 * MixedReadOnly =
 *   | primitive
 *   | simple objects (Record<string, MixedReadOnly>)
 *   | Array<MixedReadOnly>
 *
 * APIs such as Relay — but also Flux and other data stores — often return a
 * union of types with some interesting properties in terms of analysis.
 *
 * Given this constraint, if data came from Relay, then we should be able to
 * infer things like `data.items.map(): Array`. That may seem like a leap at
Repository: facebook/react
File: packages/react-devtools-shared/src/hooks/SourceMapConsumer.js (JavaScript)

Code before:
        } else {
          if (currentColumn > targetColumnNumber) {
            if (stopIndex - index > 0) {
              stopIndex = index;
            } else {
              index = stopIndex;
              break;
            }
          } else {
            if (index - startIndex > 0) {
              startIndex = index;
            } else {
              index = startIndex;
              break;
            }
          }
        }
      } else {
        if (currentLine > lineNumber) {
          if (stopIndex - index > 0) {
            stopIndex = index;
          } else {
            index = stopIndex;
            break;
          }
        } else {
          if (index - startIndex > 0) {
            startIndex = index;
          } else {
            index = startIndex;
            break;
          }
        }
      }
    }

    if (section == null) {
      // TODO maybe fall back to the runtime source instead of throwing?
      throw Error(
        `Could not find matching section for line:${lineNumber} and column:${columnNumber}`,
      );
    }

    if (section.sourceMapConsumer === null) {
      // Lazily parse the section only when it's needed.
      // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
      section.sourceMapConsumer = new SourceMapConsumer(section.map);
    }

    return section.sourceMapConsumer.originalPositionFor({
      columnNumber,

Review comment (bug):
This is the essence of the fix. The rest is just me being extra cautious with off-by-one errors. The implementation to find the relevant section is the same we're using in Next.js: https://github.com/vercel/next.js/blob/62f9611facd13ca7720b8fcfbc609c948a0563ba/packages/next/src/server/lib/source-maps.ts#L75-L97

Code after:
          currentSection.offsetColumn0 <= column0)
      ) {
        section = currentSection;
        left = middle + 1;
      } else {
        right = middle - 1;
      }
    }

    if (section == null) {
      // TODO maybe fall back to the runtime source instead of throwing?
      throw Error(
        `Could not find matching section for line:${lineNumber} and column:${columnNumber}`,
      );
    }

    if (section.sourceMapConsumer === null) {
      // Lazily parse the section only when it's needed.
      // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
      section.sourceMapConsumer = new SourceMapConsumer(section.map);
    }

    return section.sourceMapConsumer.originalPositionFor({
      // The mappings in a Source Map section are relative to the section offset.
      columnNumber: columnNumber - section.offsetColumn0,
      lineNumber: lineNumber - section.offsetLine0,
    });
  }

  return (({
    originalPositionFor,
  }: any): SourceMapConsumerType);
}
Repository: facebook/react
File: compiler/packages/babel-plugin-react-compiler/src/index.ts (TypeScript)

Code before:
  tryFindDirectiveEnablingMemoization as findDirectiveEnablingMemoization,
  findDirectiveDisablingMemoization,
  type CompilerPipelineValue,
  type Logger,
  type LoggerEvent,
  type PluginOptions,
} from './Entrypoint';
export {
  Effect,
  ValueKind,
  ValueReason,
  printHIR,
  printFunctionWithOutlined,
  validateEnvironmentConfig,
  type EnvironmentConfig,
  type ExternalFunction,
  type Hook,
  type SourceLocation,
} from './HIR';
export {
  printReactiveFunction,
  printReactiveFunctionWithOutlined,
} from './ReactiveScopes';
export {parseConfigPragmaForTests} from './Utils/TestUtils';
declare global {
  let __DEV__: boolean | null | undefined;
}

import BabelPluginReactCompiler from './Babel/BabelPlugin';
export default BabelPluginReactCompiler;


Review comment (suggestion):
I'm not sure we want this to be a top-level export of the compiler package. Especially if this logic is specific to the playground app. Though I see `parseConfigPragmaForTests` so @mofeiZ  might have a better opinion.

Seems like how you had it before in the ConfigEditor component module would be ok.

Code after:
  tryFindDirectiveEnablingMemoization as findDirectiveEnablingMemoization,
  findDirectiveDisablingMemoization,
  type CompilerPipelineValue,
  type Logger,
  type LoggerEvent,
  type PluginOptions,
} from './Entrypoint';
export {
  Effect,
  ValueKind,
  ValueReason,
  printHIR,
  printFunctionWithOutlined,
  validateEnvironmentConfig,
  type EnvironmentConfig,
  type ExternalFunction,
  type Hook,
  type SourceLocation,
} from './HIR';
export {
  printReactiveFunction,
  printReactiveFunctionWithOutlined,
} from './ReactiveScopes';
export {
  parseConfigPragmaForTests,
  parseConfigPragmaAsString,
} from './Utils/TestUtils';
declare global {
  let __DEV__: boolean | null | undefined;
}

import BabelPluginReactCompiler from './Babel/BabelPlugin';
export default BabelPluginReactCompiler;
Repository: facebook/react
File: packages/react-devtools-extensions/src/background/dynamicallyInjectContentScripts.js (JavaScript)

Code before:
/* global chrome */

const contentScriptsToInject = [
  {
    id: '@react-devtools/proxy',
    js: ['build/proxy.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_start',
    world: chrome.scripting.ExecutionWorld.ISOLATED,
  },
  {
    id: '@react-devtools/file-fetcher',
    js: ['build/fileFetcher.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_start',
    world: chrome.scripting.ExecutionWorld.ISOLATED,
  },
  {
    id: '@react-devtools/hook',
    js: ['build/installHook.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_start',
    world: chrome.scripting.ExecutionWorld.MAIN,
  },
  {
    id: '@react-devtools/hook-settings-injector',
    js: ['build/hookSettingsInjector.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_start',
  },
];

async function dynamicallyInjectContentScripts() {
  try {
    // Using this, instead of filtering registered scrips with `chrome.scripting.getRegisteredScripts`
    // because of https://bugs.chromium.org/p/chromium/issues/detail?id=1393762
    // This fixes registering proxy content script in incognito mode
    await chrome.scripting.unregisterContentScripts();

Review comment (suggestion):
`file-fetcher` script is probably best to keep initialized at `document_end`, no real need for it this early

Code after:
/* global chrome */

const contentScriptsToInject = [
  {
    id: '@react-devtools/proxy',
    js: ['build/proxy.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_start',
    world: chrome.scripting.ExecutionWorld.ISOLATED,
  },
  {
    id: '@react-devtools/file-fetcher',
    js: ['build/fileFetcher.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_end',
    world: chrome.scripting.ExecutionWorld.ISOLATED,
  },
  {
    id: '@react-devtools/hook',
    js: ['build/installHook.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_start',
    world: chrome.scripting.ExecutionWorld.MAIN,
  },
  {
    id: '@react-devtools/hook-settings-injector',
    js: ['build/hookSettingsInjector.js'],
    matches: ['<all_urls>'],
    persistAcrossSessions: true,
    runAt: 'document_start',
  },
];

async function dynamicallyInjectContentScripts() {
  try {
    // Using this, instead of filtering registered scrips with `chrome.scripting.getRegisteredScripts`
    // because of https://bugs.chromium.org/p/chromium/issues/detail?id=1393762
    // This fixes registering proxy content script in incognito mode
    await chrome.scripting.unregisterContentScripts();
Repository: facebook/react
File: compiler/apps/playground/lib/defaultStore.ts (TypeScript)

Code before:
/**
 * 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 type {Store} from './stores';

const index = `\
export default function MyApp() {
  return <div>Hello World</div>;
}
`;

export const defaultStore: Store = {
  source: index,
  config: '',
};

export const emptyStore: Store = {
  source: '',
  config: '',
};


Review comment (bug):
This default has to be maintained as we change the config schema or defaults, right? If we can't load automatically from the plugin options themselves, we at least should have a unit test.

Basically if this default goes out of date we should fail a test so the next person who changes an option can come update this string.

Code after:
export default function MyApp() {
  return <div>Hello World</div>;
}
`;

export const defaultConfig = `\
import type { PluginOptions } from 'babel-plugin-react-compiler/dist';

({
  compilationMode: 'infer',
  panicThreshold: 'none',
  environment: {},
  logger: null,
  gating: null,
  noEmit: false,
  dynamicGating: null,
  eslintSuppressionRules: null,
  flowSuppressions: true,
  ignoreUseNoForget: false,
  sources: filename => {
    return filename.indexOf('node_modules') === -1;
  },
  enableReanimatedCheck: true,
  customOptOutDirectives: null,
  target: '19',
} satisfies Partial<PluginOptions>);`;

export const defaultStore: Store = {
  source: index,
  config: defaultConfig,
};

export const emptyStore: Store = {
  source: '',
  config: '',
};
Repository: facebook/react
File: packages/react/index.fb.js (JavaScript)

Code before:
import {captureOwnerStack as captureOwnerStackImpl} from './src/ReactClient';

export {
  __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
  __COMPILER_RUNTIME,
  act,
  cache,
  cacheSignal,
  Children,
  cloneElement,
  Component,
  createContext,
  createElement,
  createRef,
  experimental_useEffectEvent,
  forwardRef,
  Fragment,
  isValidElement,
  lazy,
  memo,
  Profiler,
  PureComponent,
  startTransition,
  StrictMode,
  Suspense,
  Activity,
  unstable_getCacheForType,
  unstable_LegacyHidden,
  unstable_Scope,
  unstable_SuspenseList,
  unstable_ViewTransition,
  unstable_TracingMarker,
  unstable_addTransitionType,
  unstable_useCacheRefresh,
  use,
  useActionState,
  useCallback,
  useContext,
  useDebugValue,
  useDeferredValue,
  useEffect,
  useId,
  useImperativeHandle,
  useInsertionEffect,
  useLayoutEffect,
  useMemo,
  useOptimistic,
  useReducer,
  useRef,
  useState,
  useSyncExternalStore,

Review comment (suggestion):
```suggestion
  Activity,
  Activity as unstable_Activity,
```

Code after:
import {captureOwnerStack as captureOwnerStackImpl} from './src/ReactClient';

export {
  __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
  __COMPILER_RUNTIME,
  act,
  cache,
  cacheSignal,
  Children,
  cloneElement,
  Component,
  createContext,
  createElement,
  createRef,
  experimental_useEffectEvent,
  forwardRef,
  Fragment,
  isValidElement,
  lazy,
  memo,
  Profiler,
  PureComponent,
  startTransition,
  StrictMode,
  Suspense,
  Activity,
  Activity as unstable_Activity,
  unstable_getCacheForType,
  unstable_LegacyHidden,
  unstable_Scope,
  unstable_SuspenseList,
  unstable_ViewTransition,
  unstable_TracingMarker,
  unstable_addTransitionType,
  unstable_useCacheRefresh,
  use,
  useActionState,
  useCallback,
  useContext,
  useDebugValue,
  useDeferredValue,
  useEffect,
  useId,
  useImperativeHandle,
  useInsertionEffect,
  useLayoutEffect,
  useMemo,
  useOptimistic,
  useReducer,
  useRef,
  useState,
Repository: facebook/react
File: packages/react/index.experimental.js (JavaScript)

Code before:
 * @flow
 */

export {
  __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
  __COMPILER_RUNTIME,
  Children,
  Component,
  Fragment,
  Profiler,
  PureComponent,
  StrictMode,
  Suspense,
  cloneElement,
  createContext,
  createElement,
  createRef,
  use,
  forwardRef,
  isValidElement,
  lazy,
  memo,
  cache,
  cacheSignal,
  startTransition,
  Activity,
  unstable_postpone,
  unstable_getCacheForType,
  unstable_SuspenseList,
  unstable_ViewTransition,
  unstable_startGestureTransition,
  unstable_addTransitionType,
  unstable_useCacheRefresh,
  useId,
  useCallback,
  useContext,
  useDebugValue,
  useDeferredValue,
  useEffect,
  experimental_useEffectEvent,
  useImperativeHandle,
  useInsertionEffect,
  useLayoutEffect,
  useMemo,
  useOptimistic,
  useReducer,
  useRef,
  useState,
  useSyncExternalStore,
  useTransition,
  useActionState,

Review comment (suggestion):
```suggestion
  Activity,
  unstable_Activity as Activity,
```

Code after:
 * @flow
 */

export {
  __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
  __COMPILER_RUNTIME,
  Children,
  Component,
  Fragment,
  Profiler,
  PureComponent,
  StrictMode,
  Suspense,
  cloneElement,
  createContext,
  createElement,
  createRef,
  use,
  forwardRef,
  isValidElement,
  lazy,
  memo,
  cache,
  cacheSignal,
  startTransition,
  Activity,
  Activity as unstable_Activity,
  unstable_postpone,
  unstable_getCacheForType,
  unstable_SuspenseList,
  unstable_ViewTransition,
  unstable_startGestureTransition,
  unstable_addTransitionType,
  unstable_useCacheRefresh,
  useId,
  useCallback,
  useContext,
  useDebugValue,
  useDeferredValue,
  useEffect,
  experimental_useEffectEvent,
  useImperativeHandle,
  useInsertionEffect,
  useLayoutEffect,
  useMemo,
  useOptimistic,
  useReducer,
  useRef,
  useState,
  useSyncExternalStore,
  useTransition,
Repository: facebook/react
File: packages/react/index.experimental.js (JavaScript)

Code before:
 */

export {
  __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
  __COMPILER_RUNTIME,
  Children,
  Component,
  Fragment,
  Profiler,
  PureComponent,
  StrictMode,
  Suspense,
  cloneElement,
  createContext,
  createElement,
  createRef,
  use,
  forwardRef,
  isValidElement,
  lazy,
  memo,
  cache,
  cacheSignal,
  startTransition,
  Activity,
  unstable_Activity as Activity,
  unstable_postpone,
  unstable_getCacheForType,
  unstable_SuspenseList,
  unstable_ViewTransition,
  unstable_startGestureTransition,
  unstable_addTransitionType,
  unstable_useCacheRefresh,
  useId,
  useCallback,
  useContext,
  useDebugValue,
  useDeferredValue,
  useEffect,
  experimental_useEffectEvent,
  useImperativeHandle,
  useInsertionEffect,
  useLayoutEffect,
  useMemo,
  useOptimistic,
  useReducer,
  useRef,
  useState,
  useSyncExternalStore,
  useTransition,
  useActionState,

Review comment (suggestion):
```suggestion
  Activity,
  Activity as unstable_Activity,
```

Code after:
 */

export {
  __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
  __COMPILER_RUNTIME,
  Children,
  Component,
  Fragment,
  Profiler,
  PureComponent,
  StrictMode,
  Suspense,
  cloneElement,
  createContext,
  createElement,
  createRef,
  use,
  forwardRef,
  isValidElement,
  lazy,
  memo,
  cache,
  cacheSignal,
  startTransition,
  Activity,
  Activity as unstable_Activity,
  unstable_postpone,
  unstable_getCacheForType,
  unstable_SuspenseList,
  unstable_ViewTransition,
  unstable_startGestureTransition,
  unstable_addTransitionType,
  unstable_useCacheRefresh,
  useId,
  useCallback,
  useContext,
  useDebugValue,
  useDeferredValue,
  useEffect,
  experimental_useEffectEvent,
  useImperativeHandle,
  useInsertionEffect,
  useLayoutEffect,
  useMemo,
  useOptimistic,
  useReducer,
  useRef,
  useState,
  useSyncExternalStore,
  useTransition,
  useActionState,
Repository: facebook/react
File: compiler/apps/playground/lib/stores/store.ts (TypeScript)

Code before:
}

/**
 * Check if @param raw is a valid Store by if
 * - it has a `source` property and is a string
 */
function isValidStore(raw: unknown): raw is Store {
  return (
    raw != null &&
    typeof raw == 'object' &&
    'source' in raw &&
    typeof raw['source'] === 'string'
  );
}

/**
 * Deserialize, decode, and initialize @param store from URL and then
 * localStorage. Throw an error if Store is malformed.
 */
export function initStoreFromUrlOrLocalStorage(): Store {
  const encodedSourceFromUrl = location.hash.slice(1);
  const encodedSourceFromLocal = localStorage.getItem('playgroundStore');
  const encodedSource = encodedSourceFromUrl || encodedSourceFromLocal;

  // Prioritize local storage for showInternals field
  const showInternals =
    localStorage.getItem('playgroundShowInternals') === 'true';

  /**
   * No data in the URL and no data in the localStorage to fallback to.
   * Initialize with the default store.
   */
  if (!encodedSource) {
    return {
      ...defaultStore,
      showInternals,
    };
  }

  const raw = decodeStore(encodedSource);

  invariant(isValidStore(raw), 'Invalid Store');

  // Make sure all properties are populated
  return {
    source: raw.source,
    config: 'config' in raw ? raw.config : defaultConfig,
    showInternals,
  };
}


Review comment (bug):
Oh I see, is the reasoning that if someone links a playground example (with `showInternals = false`), we want the localStorage to override this?

Let's keep things simple for now -- I don't mind toggling `showInternals` back when I load a URL. 

The reasoning for this is that we might eventually use `showInternals` in playground config (e.g. not logging passes unless show internals is enabled). Having URL loading be straightforward is one less thing to think about when debugging

Code after:
 * - it has a `source` property and is a string
 */
function isValidStore(raw: unknown): raw is Store {
  return (
    raw != null &&
    typeof raw == 'object' &&
    'source' in raw &&
    typeof raw['source'] === 'string'
  );
}

/**
 * Deserialize, decode, and initialize @param store from URL and then
 * localStorage. Throw an error if Store is malformed.
 */
export function initStoreFromUrlOrLocalStorage(): Store {
  const encodedSourceFromUrl = location.hash.slice(1);
  const encodedSourceFromLocal = localStorage.getItem('playgroundStore');
  const encodedSource = encodedSourceFromUrl || encodedSourceFromLocal;

  /**
   * No data in the URL and no data in the localStorage to fallback to.
   * Initialize with the default store.
   */
  if (!encodedSource) return defaultStore;

  const raw: any = decodeStore(encodedSource);

  invariant(isValidStore(raw), 'Invalid Store');

  // Make sure all properties are populated
  return {
    source: raw.source,
    config: 'config' in raw ? raw.config : defaultConfig,
    showInternals: 'showInternals' in raw ? raw.showInternals : false,
  };
}
Repository: facebook/react
File: scripts/ci/download_devtools_regression_build.js (JavaScript)

Code before:
        'node_modules',
        'scheduler'
      )} ${buildPath}`
    );
  }

  if (semver.gte(reactVersion, '18.2.0') && semver.lt(reactVersion, '19.0.0')) {
    console.log(chalk.white(`Downloading react-compiler-runtime\n`));
    await exec(
      `npm install --prefix ${REGRESSION_FOLDER} react-compiler-runtime`
    );

    console.log(
      chalk.white(
        `Moving react-compiler-runtime to react/compiler-runtime.js\n`
      )
    );
    await exec(
      `mv ${REGRESSION_FOLDER}/node_modules/react-compiler-runtime/dist/index.js ${buildPath}/react/compiler-runtime.js`
    );
  }
}

async function main() {
  try {
    if (!version) {
      console.log(chalk.red('Must specify React version to download'));
      return;
    }
    await downloadRegressionBuild();
  } finally {
    // We shouldn't remove the regression-build folder unless we're using
    // it to replace the build folder
    if (shouldReplaceBuild) {
      console.log(chalk.bold.white(`Removing regression build`));
      await exec(`rm -r ${regressionBuildPath}`);
    }
  }
}

main();


Review comment (bug):
I found it annoying that this script always exited with a zero exit code. This could make CI fail but I suspect we'd want to know about these failures. I'm actively working on fixing the regression test suite so I'll notice if this reveals some other issue.

Code after:
        'scheduler'
      )} ${buildPath}`
    );
  }

  if (semver.gte(reactVersion, '18.2.0') && semver.lt(reactVersion, '19.0.0')) {
    console.log(chalk.white(`Downloading react-compiler-runtime\n`));
    await exec(
      `npm install --prefix ${REGRESSION_FOLDER} react-compiler-runtime`
    );

    console.log(
      chalk.white(
        `Moving react-compiler-runtime to react/compiler-runtime.js\n`
      )
    );
    await exec(
      `mv ${REGRESSION_FOLDER}/node_modules/react-compiler-runtime/dist/index.js ${buildPath}/react/compiler-runtime.js`
    );
  }
}

async function main() {
  try {
    if (!version) {
      console.log(chalk.red('Must specify React version to download'));
      return;
    }
    await downloadRegressionBuild();
  } finally {
    // We shouldn't remove the regression-build folder unless we're using
    // it to replace the build folder
    if (shouldReplaceBuild) {
      console.log(chalk.bold.white(`Removing regression build`));
      await exec(`rm -r ${regressionBuildPath}`);
    }
  }
}

main();