-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use react-native-init-func to generate example app (#421)
* chore: add react-native-init-func to package dependencies * refactor(prep): resolve *absolute* paths before generating example * test: replace absolute process cwd in output paths before taking snapshots * feat: use react-native-init-func to generate example app * refactor: make reactNativeInit overridable (for testing purposes) * test: update tests to use injected / mocked reactNativeInit function * test: remove test for react-native CLI tool no longer needed * test: remove test of missing react-native CLI (no longer relevant) * test: update test of missing Yarn CLI * refactor: update help text for --example-react-native-version * refactor: update help text for --generate-example * test: update test snapshots * doc: update option text in README.md * doc: update some more documentation in README.md BREAKING CHANGE: this may change how the React Native template version is used to generate the example app.
- Loading branch information
Chris Brody
authored
Mar 11, 2021
1 parent
51f8666
commit 56e7dbf
Showing
31 changed files
with
2,744 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,13 +57,12 @@ __Outdated alternatives:__ see [acknowledgements](#acknowledgements) below | |
|
||
## Installation | ||
|
||
Packages required to be installed globally if the recommended example app is generated: | ||
Package required to be installed globally if the recommended example app is generated: | ||
|
||
- [`react-native-cli`](https://www.npmjs.com/package/react-native-cli) | ||
- [`yarn`](https://www.npmjs.com/package/yarn) | ||
|
||
``` | ||
$ npm install -g react-native-cli yarn | ||
$ npm install -g yarn | ||
``` | ||
|
||
To install this package: | ||
|
@@ -105,10 +104,10 @@ Options: | |
--author-email <authorEmail> The author's email (Default: `[email protected]`) | ||
--license <license> The license type (Default: `MIT`) | ||
--use-apple-networking [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code - see issue #426 | ||
--generate-example Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires both react-native-cli and yarn to be installed globally | ||
--generate-example Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires Yarn to be installed globally | ||
--example-file-linkage DEPRECATED: do `yarn add file:../` instead of `yarn add link:../` in a generated example project, and add a postinstall workaround script, with no overwrite of example metro.config.js | ||
--example-name <exampleName> Name for the example project (default: `example`) | ||
--example-react-native-version <version> React Native version for the generated example project (default: `react-native@latest`) | ||
--example-react-native-version <version> React Native template version for the generated example project, for example: react-native-tvos or [email protected] (requires --tvos-enabled option); [email protected] (default: `react-native@latest`) | ||
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile | ||
-h, --help output usage information | ||
``` | ||
|
@@ -143,10 +142,10 @@ createLibraryModule({ | |
authorEmail: String, /* The author's email (Default: `[email protected]`) */ | ||
license: String, /* The license type of this library (Default: `MIT`) */ | ||
useAppleNetworking: Boolean, /* [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code - see issue #426 (Default: false) */ | ||
generateExample: Boolean, /* Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires both react-native-cli and yarn to be installed globally (Default: false) */ | ||
generateExample: Boolean, /* Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires Yarn to be installed globally (Default: false) */ | ||
exampleFileLinkage: Boolean, /* DEPRECATED: do `yarn add file:../` instead of `yarn add link:../` in a generated example project, and add a postinstall workaround script, with no overwrite of example metro.config.js (Default: false) */ | ||
exampleName: String, /* Name for the example project (Default: `example`) */ | ||
exampleReactNativeVersion: String, /* React Native version for the generated example project (Default: `react-native@latest`) */ | ||
exampleReactNativeVersion: String, /* React Native template version for the generated example project, for example: react-native-tvos or [email protected] (requires --tvos-enabled option); [email protected] (Default: `react-native@latest`) */ | ||
writeExamplePodfile: Boolean, /* [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile (Default: false) */ | ||
} | ||
``` | ||
|
@@ -188,13 +187,15 @@ Otherwise, React Native will open its own window to run the Metro Bundler. | |
To run on Android, do the following command (within `react-native-alice-helper/example`): | ||
|
||
``` | ||
react-native run-android | ||
npx react-native run-android | ||
``` | ||
|
||
(or `yarn android` on React Native starting with 0.61) | ||
|
||
This assumes that the `ANDROID_HOME` environmental variable is set properly. Here is a sample command that does not make such an assumption on a mac: | ||
|
||
``` | ||
ANDROID_HOME=~/Library/Android/sdk react-native run-android | ||
ANDROID_HOME=~/Library/Android/sdk npx react-native run-android | ||
``` | ||
|
||
For iOS: | ||
|
@@ -208,9 +209,11 @@ cd ios && pod install && cd .. | |
Then to run on iOS: | ||
|
||
``` | ||
react-native run-ios | ||
npx react-native run-ios | ||
``` | ||
|
||
(or `yarn ios` on React Native starting with 0.61) | ||
|
||
or do the following command to open the iOS project in Xcode: | ||
|
||
``` | ||
|
@@ -254,12 +257,12 @@ It is *recommended* to start the Metro Bundler manually as described above (with | |
yarn start | ||
``` | ||
|
||
To run on Android: do `react-native run-android` as described for the other example above. | ||
To run on Android: do `npx react-native run-android` as described for the other example above. | ||
|
||
To run on iOS (as described above): | ||
|
||
- _in case of clean checkout **only**_: do `pod install` in `ios` subdirectory | ||
- do `react-native run-ios` or `open ios/example.xcodeproj` | ||
- do `npx react-native run-ios` or `open ios/example.xcodeproj` | ||
|
||
__Expected result:__ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,7 +132,7 @@ ${postCreateInstructions(createOptions)}`); | |
description: '[iOS] Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code', | ||
}, { | ||
command: '--generate-example', | ||
description: 'Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires both react-native-cli and yarn to be installed globally', | ||
description: 'Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires Yarn to be installed globally', | ||
}, { | ||
command: '--example-file-linkage', | ||
description: "DEPRECATED: do `yarn add file:../` instead of `yarn add link:../` in a generated example project, and add a postinstall workaround script, with no overwrite of example metro.config.js", | ||
|
@@ -142,7 +142,7 @@ ${postCreateInstructions(createOptions)}`); | |
default: 'example', | ||
}, { | ||
command: '--example-react-native-version [exampleReactNativeVersion]', | ||
description: 'React Native version for the generated example project', | ||
description: 'React Native template version for the generated example project, for example: react-native-tvos or [email protected] (requires --tvos-enabled option); [email protected]', | ||
default: 'react-native@latest', | ||
}, { | ||
command: '--write-example-podfile', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,10 @@ Options: | |
--author-email [authorEmail] The author's email (default: \\"[email protected]\\") | ||
--license [license] The license type (default: \\"MIT\\") | ||
--use-apple-networking [iOS] Use \`AFNetworking\` dependency as a sample in the podspec & use it from the iOS code | ||
--generate-example Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires both react-native-cli and yarn to be installed globally | ||
--generate-example Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires Yarn to be installed globally | ||
--example-file-linkage DEPRECATED: do \`yarn add file:../\` instead of \`yarn add link:../\` in a generated example project, and add a postinstall workaround script, with no overwrite of example metro.config.js | ||
--example-name [exampleName] Name for the example project (default: \\"example\\") | ||
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@latest\\") | ||
--example-react-native-version [exampleReactNativeVersion] React Native template version for the generated example project, for example: react-native-tvos or [email protected] (requires --tvos-enabled option); [email protected] (default: \\"react-native@latest\\") | ||
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile | ||
-h, --help display help for command" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,10 @@ Options: | |
--author-email [authorEmail] The author's email (default: \\"[email protected]\\") | ||
--license [license] The license type (default: \\"MIT\\") | ||
--use-apple-networking [iOS] Use \`AFNetworking\` dependency as a sample in the podspec & use it from the iOS code | ||
--generate-example Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires both react-native-cli and yarn to be installed globally | ||
--generate-example Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires Yarn to be installed globally | ||
--example-file-linkage DEPRECATED: do \`yarn add file:../\` instead of \`yarn add link:../\` in a generated example project, and add a postinstall workaround script, with no overwrite of example metro.config.js | ||
--example-name [exampleName] Name for the example project (default: \\"example\\") | ||
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@latest\\") | ||
--example-react-native-version [exampleReactNativeVersion] React Native template version for the generated example project, for example: react-native-tvos or [email protected] (requires --tvos-enabled option); [email protected] (default: \\"react-native@latest\\") | ||
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile | ||
-h, --help display help for command" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,7 @@ Object { | |
}, | ||
Object { | ||
"command": "--generate-example", | ||
"description": "Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires both react-native-cli and yarn to be installed globally", | ||
"description": "Generate an example project and add the library module to it with symlink by defult, with overwrite of example metro.config.js to add workaround for Metro symlink issue - requires Yarn to be installed globally", | ||
}, | ||
Object { | ||
"command": "--example-file-linkage", | ||
|
@@ -82,7 +82,7 @@ Object { | |
Object { | ||
"command": "--example-react-native-version [exampleReactNativeVersion]", | ||
"default": "react-native@latest", | ||
"description": "React Native version for the generated example project", | ||
"description": "React Native template version for the generated example project, for example: react-native-tvos or [email protected] (requires --tvos-enabled option); [email protected]", | ||
}, | ||
Object { | ||
"command": "--write-example-podfile", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.