1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @format
8 */
9
10'use strict';
11
12const executor = require('./codegen/generate-artifacts-executor.js');
13const yargs = require('yargs');
14
15const argv = yargs
16  .option('p', {
17    alias: 'path',
18    description: 'Path to React Native application',
19  })
20  .option('o', {
21    alias: 'outputPath',
22    description: 'Path where generated artifacts will be output to',
23  })
24  .option('f', {
25    alias: 'configFilename',
26    default: 'package.json',
27    description: 'The file that contains the codegen configuration.',
28  })
29  .option('k', {
30    alias: 'configKey',
31    default: 'codegenConfig',
32    description:
33      'The key that contains the codegen configuration in the config file.',
34  })
35  .option('e', {
36    alias: 'fabricEnabled',
37    default: true,
38    description: 'A flag to control whether to generate fabric components.',
39    boolean: 'e',
40  })
41  .option('c', {
42    alias: 'configFileDir',
43    default: '',
44    description:
45      'Path where codegen config files are located (e.g. node_modules dir).',
46  })
47  .option('n', {
48    alias: 'nodeBinary',
49    default: 'node',
50    description: 'Path to the node executable.',
51  })
52  .usage('Usage: $0 -p [path to app]')
53  .demandOption(['p']).argv;
54
55const CODEGEN_CONFIG_FILENAME = argv.f;
56const CODEGEN_CONFIG_FILE_DIR = argv.c;
57const CODEGEN_CONFIG_KEY = argv.k;
58const CODEGEN_FABRIC_ENABLED = argv.e;
59const NODE = argv.n;
60
61const appRoot = argv.path;
62const outputPath = argv.outputPath;
63
64executor.execute(
65  appRoot,
66  outputPath,
67  NODE,
68  CODEGEN_CONFIG_FILENAME,
69  CODEGEN_CONFIG_KEY,
70  CODEGEN_CONFIG_FILE_DIR,
71  CODEGEN_FABRIC_ENABLED,
72);
73