Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 29, 2025

This PR introduces a new --no-example flag for the yarn react-native init-windows CLI command that prevents the creation of example app directories during project initialization.

Problem

When using the cpp-lib template with init-windows, an example directory is automatically created to demonstrate usage of the library. However, there are cases where developers don't want this example directory to be created, such as when:

  • Creating libraries for internal use where examples aren't needed
  • Following specific project structures that don't include examples
  • Minimizing the initial project scaffolding

Solution

Added a new --no-example boolean flag that:

  1. Skips example directory creation when specified with the cpp-lib template
  2. Maintains backward compatibility - default behavior unchanged when flag is not used
  3. Only affects relevant templates - other templates like cpp-app are unaffected

Usage

# Create a library without example directory
npx @react-native-community/cli init-windows --template cpp-lib --no-example

# Default behavior (creates example directory)
npx @react-native-community/cli init-windows --template cpp-lib

Implementation Details

The implementation uses minimal, surgical changes:

  • Added example?: boolean to the InitOptions interface
  • Added the --no-example command line option definition
  • Modified the cpp-lib template logic to check options.example !== false before processing example files
  • Updated test validation and documentation

Testing

Comprehensive testing confirms:

  • ✅ Default behavior: Example directory created when flag not specified
  • ✅ With --no-example: Example directory skipped
  • ✅ Other templates unaffected by the new flag
  • ✅ All existing functionality preserved

Fixes #15091.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Microsoft Reviewers: Open in CodeFlow

@Copilot Copilot AI changed the title [WIP] Introduce a new flag --no-example in init-windows cli command that ignores the creation of example file directory Add --no-example flag to init-windows CLI command Aug 29, 2025
@Copilot Copilot AI requested a review from anupriya13 August 29, 2025 06:51
Copilot finished work on behalf of anupriya13 August 29, 2025 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce a new flag --no-example in init-windows cli command that ignores the creation of example file directory
2 participants