Skip to content

Commit 27ff5f3

Browse files
author
Christopher J. Brody
committed
Add exampleReactNativeVersion option
defaults to [email protected] for now (use exampleReactNativeVersion="react-native@latest" to generate example with the most current react-native release)
1 parent b150523 commit 27ff5f3

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Options:
8686
--use-cocoapods Generate a library with a sample podspec and third party pod usage example
8787
--generate-example Generate an example project and links the library module to it, requires both react-native-cli and yarn to be installed globally
8888
--example-name <exampleName> Name for the example project (default: `example`)
89+
--example-react-native-version <version> React Native version for the generated example project (default: `[email protected]`)
8990
-h, --help output usage information
9091
```
9192

@@ -119,6 +120,7 @@ createLibraryModule({
119120
view: Boolean, /* Generate the module as a very simple native view component (Default: false) */
120121
generateExample: Boolean, /* Generate an example project and links the library module to it, requires both react-native-cli and yarn to be installed globally (Default: false) */
121122
exampleName: String, /* Name for the example project (Default: `example`) */
123+
exampleReactNativeVersion: String, /* React Native version for the generated example project (Default: `[email protected]`) */
122124
}
123125
```
124126

command.js

+4
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,9 @@ ${postCreateInstructions(createOptions)}`);
109109
command: '--example-name [exampleName]',
110110
description: 'Name for the example project',
111111
default: 'example',
112+
}, {
113+
command: '--example-react-native-version [exampleReactNativeVersion]',
114+
description: 'React Native version for the generated example project',
115+
default: '[email protected]',
112116
}]
113117
};

lib.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const DEFAULT_LICENSE = 'Apache-2.0';
1616
const DEFAULT_USE_COCOAPODS = false;
1717
const DEFAULT_GENERATE_EXAMPLE = false;
1818
const DEFAULT_EXAMPLE_NAME = 'example';
19+
const DEFAULT_EXAMPLE_REACT_NATIVE_VERSION = '[email protected]';
1920

2021
const renderTemplateIfValid = (root, template, templateArgs) => {
2122
const name = template.name(templateArgs);
@@ -49,6 +50,7 @@ const generateWithOptions = ({
4950
useCocoapods = DEFAULT_USE_COCOAPODS,
5051
generateExample = DEFAULT_GENERATE_EXAMPLE,
5152
exampleName = DEFAULT_EXAMPLE_NAME,
53+
exampleReactNativeVersion = DEFAULT_EXAMPLE_REACT_NATIVE_VERSION,
5254
}) => {
5355
if (packageIdentifier === DEFAULT_PACKAGE_IDENTIFIER) {
5456
console.warn(`While \`{DEFAULT_PACKAGE_IDENTIFIER}\` is the default package
@@ -145,7 +147,7 @@ const generateWithOptions = ({
145147
const generateExampleWithName =
146148
(exampleName) => {
147149
const exampleReactNativeInitCommand =
148-
`react-native init ${exampleName}`;
150+
`react-native init ${exampleName} --version ${exampleReactNativeVersion}`;
149151

150152
console.info(
151153
`CREATE example app with the following command: ${exampleReactNativeInitCommand}`);

0 commit comments

Comments
 (0)