From a612053510847b7c41135a88db2dcd11d44fa77f Mon Sep 17 00:00:00 2001 From: Dmitry Rykun Date: Thu, 21 Dec 2023 10:20:30 -0800 Subject: [PATCH] Introduce "npx react-native codegen" command (#41925) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41925 This diff introduces the `npx react-native codegen` command. It runs the codegen for the `package.json` file in current working directory. Changelog: [General][Added] - Introduce "npx react-native codegen" command. Reviewed By: cipolleschi Differential Revision: D51495465 fbshipit-source-id: 1fd4c3645235a12f68f9032349a443b92b4764b8 --- packages/react-native/react-native.config.js | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/react-native/react-native.config.js b/packages/react-native/react-native.config.js index 79a5f5249e2a28..6a8394e8ac1823 100644 --- a/packages/react-native/react-native.config.js +++ b/packages/react-native/react-native.config.js @@ -17,6 +17,33 @@ const { startCommand, } = require('@react-native/community-cli-plugin'); +const codegenCommand = { + name: 'codegen', + options: [ + { + name: '--path ', + description: 'Path to the React Native project root.', + default: process.cwd(), + }, + { + name: '--platform ', + description: + 'Target platform. Supported values: "android", "ios", "all".', + default: 'all', + }, + { + name: '--outputPath ', + description: 'Path where generated artifacts will be output to.', + }, + ], + func: (argv, config, args) => + require('./scripts/codegen/generate-artifacts-executor').execute( + args.path, + args.platform, + args.outputPath, + ), +}; + module.exports = { commands: [ ...ios.commands, @@ -24,6 +51,7 @@ module.exports = { bundleCommand, ramBundleCommand, startCommand, + codegenCommand, ], platforms: { ios: {