1*753557f6STomasz Sapeta/**
2*753557f6STomasz Sapeta * Copyright (c) Meta Platforms, Inc. and affiliates.
3*753557f6STomasz Sapeta *
4*753557f6STomasz Sapeta * This source code is licensed under the MIT license found in the
5*753557f6STomasz Sapeta * LICENSE file in the root directory of this source tree.
6*753557f6STomasz Sapeta *
7*753557f6STomasz Sapeta * @format
8*753557f6STomasz Sapeta */
9*753557f6STomasz Sapeta
10*753557f6STomasz Sapeta'use strict';
11*753557f6STomasz Sapeta
12*753557f6STomasz Sapeta/**
13*753557f6STomasz Sapeta * Wrapper required to abstract away from the actual codegen.
14*753557f6STomasz Sapeta * This is needed because, when running tests in Sandcastle, not everything is setup as usually.
15*753557f6STomasz Sapeta * For example, the `react-native-codegen` lib is not present.
16*753557f6STomasz Sapeta *
17*753557f6STomasz Sapeta * Thanks to this wrapper, we are able to mock the getter for the codegen in a way that allow us to return
18*753557f6STomasz Sapeta * a custom object which mimics the Codegen interface.
19*753557f6STomasz Sapeta *
20*753557f6STomasz Sapeta * @return an object that can generate the code for the New Architecture.
21*753557f6STomasz Sapeta */
22*753557f6STomasz Sapetafunction getCodegen() {
23*753557f6STomasz Sapeta  let RNCodegen;
24*753557f6STomasz Sapeta  try {
25*753557f6STomasz Sapeta    RNCodegen = require('../../packages/react-native-codegen/lib/generators/RNCodegen.js');
26*753557f6STomasz Sapeta  } catch (e) {
27*753557f6STomasz Sapeta    RNCodegen = require('react-native-codegen/lib/generators/RNCodegen.js');
28*753557f6STomasz Sapeta  }
29*753557f6STomasz Sapeta  if (!RNCodegen) {
30*753557f6STomasz Sapeta    throw 'RNCodegen not found.';
31*753557f6STomasz Sapeta  }
32*753557f6STomasz Sapeta  return RNCodegen;
33*753557f6STomasz Sapeta}
34*753557f6STomasz Sapeta
35*753557f6STomasz Sapetamodule.exports = {
36*753557f6STomasz Sapeta  getCodegen: getCodegen,
37*753557f6STomasz Sapeta};
38