diff --git a/packages/@react-native-windows/cli/README.md b/packages/@react-native-windows/cli/README.md index 8a4685924cf..c19a8198e10 100644 --- a/packages/@react-native-windows/cli/README.md +++ b/packages/@react-native-windows/cli/README.md @@ -67,6 +67,9 @@ Here are the options that `npx @react-native-community/cli init-windows` takes: | `--namespace` | string | The native project namespace, expressed using dots as separators, i.e. `Level1.Level2.Level3`. Defaults to the same as name | | `--overwrite` | boolean | Overwrite any existing files without prompting | | `--no-telemetry` | boolean | Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI | +| `--list` | boolean | Shows a list with all available templates with their descriptions | +| `--no-prompt` | boolean | Skip any interactive prompts and use default choices | +| `--no-example` | boolean | Skip creating the example app directory | | `-h`, `--help` | boolean | Display help for command | ## `run-windows` diff --git a/packages/@react-native-windows/cli/src/commands/initWindows/initWindowsOptions.ts b/packages/@react-native-windows/cli/src/commands/initWindows/initWindowsOptions.ts index 4b10906226a..ffaaac291a7 100644 --- a/packages/@react-native-windows/cli/src/commands/initWindows/initWindowsOptions.ts +++ b/packages/@react-native-windows/cli/src/commands/initWindows/initWindowsOptions.ts @@ -15,6 +15,7 @@ export interface InitOptions { telemetry?: boolean; list?: boolean; prompt?: boolean; + example?: boolean; } export const initOptions: CommandOption[] = [ @@ -57,4 +58,8 @@ export const initOptions: CommandOption[] = [ name: '--no-prompt', description: 'Skip any interactive prompts and use default choices.', }, + { + name: '--no-example', + description: 'Skip creating the example app directory.', + }, ]; diff --git a/packages/@react-native-windows/cli/src/e2etest/initWindows.test.ts b/packages/@react-native-windows/cli/src/e2etest/initWindows.test.ts index a132ef3be1b..d3994288f9e 100644 --- a/packages/@react-native-windows/cli/src/e2etest/initWindows.test.ts +++ b/packages/@react-native-windows/cli/src/e2etest/initWindows.test.ts @@ -27,6 +27,7 @@ function validateOptionName( case 'telemetry': case 'list': case 'prompt': + case 'example': return true; } throw new Error( diff --git a/vnext/templates/cpp-lib/template.config.js b/vnext/templates/cpp-lib/template.config.js index 592005498f9..6c872153ca7 100644 --- a/vnext/templates/cpp-lib/template.config.js +++ b/vnext/templates/cpp-lib/template.config.js @@ -29,7 +29,7 @@ function resolveArgs(config = {}, options = {}) { const exampleProjectPath = path.join(projectRoot, 'example'); - const exExists = existsSync(exampleProjectPath); + const exExists = existsSync(exampleProjectPath) && options.example !== false; const exProjectConfig = exExists ? templateUtils.getWindowsProjectConfig(exampleProjectPath) : null;