react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

Add setup-module-windows command for automated Windows module scaffolding with comprehensive TurboModule stub generation

Open anupriya13 opened this issue 4 months ago • 0 comments

Description

Type of Change

  • New feature (non-breaking change which adds functionality)

Why

React Native Windows developers need an automated way to set up Windows support for community modules. The current manual process involves multiple steps (running init-windows, codegen-windows, creating stub files) and is error-prone. This automation reduces setup time from hours to minutes and prevents common configuration mistakes.

Resolves #15078

What

This PR introduces the setup-module-windows command that automates the entire Windows module setup process:

Automated Setup Pipeline:

  • Validates environment and finds TurboModule spec files
  • Updates package.json with codegen configuration
  • Runs init-windows with proper template selection
  • Executes codegen-windows to generate native specs
  • Creates comprehensive C++ stub files based on actual method signatures

Smart TurboModule Integration:

  • Parses codegen-generated nativemodulespec.g.h files
  • Extracts real method signatures including complex callback types
  • Generates accurate REACT_METHOD declarations
  • Creates implementation stubs with TODO comments and usage examples
  • Includes a generic "Hello World" method for immediate testing

Key Features:

  • Template support for both cpp-lib (default) and cpp-app via --template flag
  • Robust directory detection across multiple codegen locations
  • Accurate path reporting using actual Windows project names
  • Seamless spinner integration preventing UI conflicts
  • Comprehensive error handling and validation

Screenshots

https://github.com/user-attachments/assets/99c3bce6-9fd8-4e81-a538-09f812a1625e

Testing

  • Added complete test suite covering validation, configuration updates, directory detection, and stub generation
  • Tested with real-world modules like react-native-webview
  • Verified spinner behavior and logging consistency
  • All existing tests pass without issues

Changelog

Should this change be included in the release notes: yes

Add a brief summary of your change New setup-module-windows CLI command for automated Windows module scaffolding with comprehensive TurboModule stub generation

Microsoft Reviewers: Open in CodeFlow
Microsoft Reviewers: Open in CodeFlow

anupriya13 avatar Sep 06 '25 02:09 anupriya13