Skip to content

Commit 838bfe1

Browse files
author
Christopher J. Brody
committed
Merge branch 'master' of https://github.com/brodybits/create-react-native-module into with-native-section
2 parents 81b6d07 + 7fefc28 commit 838bfe1

File tree

67 files changed

+3772
-3045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3772
-3045
lines changed

.github/workflows/nodejs.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ master, brodybits-* ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ${{ matrix.os }}
16+
17+
strategy:
18+
# ref:
19+
# - https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix
20+
# - https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
21+
matrix:
22+
os:
23+
- macos-latest
24+
- windows-latest
25+
node-version:
26+
- 8.x
27+
- 10.x
28+
- 12.x
29+
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: Use Node.js ${{ matrix.node-version }}
33+
uses: actions/setup-node@v1
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
- run: npm i
37+
- run: npm run build --if-present
38+
- run: npm test
39+
env:
40+
CI: true

.github/workflows/pr-merge.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# original source:
2+
# https://github.com/marketplace/actions/pull-request-merge-command#installation
3+
name: 'Merge command'
4+
5+
on: issue_comment
6+
7+
jobs:
8+
merge-command:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v1
15+
16+
- name: Merge command
17+
uses: Goobles/gh-actions-merge-command@v1
18+
with:
19+
allow_ff: false
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Temporary Items
2727

2828
node_modules
2929
npm-debug.log
30+
yarn-error.log
3031

3132
# Stryker mutator output
3233
.stryker-tmp

.travis.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

README.md

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,15 @@ This tool based on [`react-native-create-library`](https://www.npmjs.com/package
2828
### General status
2929

3030
- **React Native versions supported:**
31-
- recommended: `0.60`, `0.61-rc` (see known quirks and issues below)
32-
- outdated: `0.59`
33-
- Known quirks & issues on React Native 0.60(+):
34-
- [issue #99](https://github.com/brodybits/create-react-native-module/issues/99) - additional `pod install` step needed for RN 0.60 on iOS
35-
- [issue #29](https://github.com/brodybits/create-react-native-module/issues/29) - View does not work with RN 0.60 on Android (quick patch needed)
36-
- React Native 0.60(+) currently not supported by Expo or react-native-windows
31+
- recommended: `0.61`
32+
- minimum (outdated): `0.60`
3733
- Platform fork support
38-
- tvOS platform support
34+
- tvOS platform fork
3935
- requires use of `--tvos-enabled` option as documented below
40-
- requires the [`react-native-tvos`](https://www.npmjs.com/package/react-native-tvos) fork (see discussion in [react-native-community/react-native-tvos#11](https://github.com/react-native-community/react-native-tvos/issues/11))
36+
- requires the [`react-native-tvos`](https://www.npmjs.com/package/react-native-tvos) fork, with minimum version of 0.60 ref: [react-native-community/react-native-tvos#11](https://github.com/react-native-community/react-native-tvos/issues/11)), [issue #95](https://github.com/brodybits/create-react-native-module/issues/95)
4137
- unstable with very limited testing, with limited if any active support from the primary maintainer [@brodybits](https://github.com/brodybits) (see [issue #127](https://github.com/brodybits/create-react-native-module/issues/127))
42-
- minimum react-native-tvos version is 0.60 (see [issue #95](https://github.com/brodybits/create-react-native-module/issues/95))
43-
- Out-of-tree platform support
44-
- Windows - unstable (not tested, see [issue #23](https://github.com/brodybits/create-react-native-module/issues/23)); now deprecated and may be removed in the near future (see [issue #43](https://github.com/brodybits/create-react-native-module/issues/43))
38+
- Out-of-tree platforms
39+
- Windows - no longer supported for reasons discussed in issues [#23](https://github.com/brodybits/create-react-native-module/issues/23) and [#43](https://github.com/brodybits/create-react-native-module/issues/43) (existing Windows C# template is kept in `unsupported-platforms` for now (at least) and further discussion would be welcome in a new issue on GitHub)
4540
- for future consideration: macOS (see [issue #94](https://github.com/brodybits/create-react-native-module/issues/94))
4641
- Node.js pre-10 support is deprecated and will be removed in the near future (see [issue #38](https://github.com/brodybits/create-react-native-module/issues/38))
4742

@@ -54,8 +49,10 @@ Why not use `react-native new-library`? Unfortunately that command doesn't creat
5449

5550
### Alternatives
5651

57-
- [`react-native-create-library`](https://www.npmjs.com/package/react-native-create-library)
58-
- [`react-native-create-bridge`](https://github.com/peggyrayzis/react-native-create-bridge)
52+
- [`brodybits/react-native-module-init`](https://github.com/brodybits/react-native-module-init) - new interactive CLI that uses the templates from this utiity
53+
- [`react-native-community/bob`](https://github.com/react-native-community/bob) - opinionated, interactive library CLI that is designed to support both native libraries and libraries with web support
54+
55+
__Outdated alternatives:__ see [acknowledgements](#acknowledgements) below
5956

6057
## Installation
6158

@@ -96,9 +93,10 @@ Usage: create-react-native-module [options] <name>
9693
Options:
9794
9895
-V, --version output the version number
99-
--prefix <prefix> The prefix for the library module (Default: ``)
96+
--prefix <prefix> The prefix of the native library module, ignored if --class-name is specified (Default: ``)
10097
--module-name <moduleName> The module library package name to be used in package.json. Default: react-native-(name in param-case)
101-
--module-prefix <modulePrefix> The module prefix for the library module, ignored if --module-name is specified (Default: `react-native`)
98+
--class-name <className> The name of the native object to be exported by the JavaScript and by the native code. Default: (prefix)(name in PascalCase)
99+
--module-prefix <modulePrefix> The native module prefix for the library module package name, ignored if --module-name is specified (Default: `react-native`)
102100
--package-identifier <packageIdentifier> [Android] The Java package identifier used by the Android module (Default: `com.reactlibrary`)
103101
--platforms <platforms> Platforms the library module will be created for - comma separated (Default: `ios,android`)
104102
--tvos-enabled Generate the module with tvOS build enabled (requires react-native-tvos fork, with minimum version of 0.60, and iOS platform to be enabled)
@@ -110,7 +108,7 @@ Options:
110108
--use-apple-networking [iOS] Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code
111109
--generate-example Generate an example project and links the library module to it, requires both react-native-cli and yarn to be installed globally
112110
--example-name <exampleName> Name for the example project (default: `example`)
113-
--example-react-native-version <version> React Native version for the generated example project (default: `react-native@0.59`)
111+
--example-react-native-version <version> React Native version for the generated example project (default: `react-native@latest`)
114112
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile
115113
-h, --help output usage information
116114
```
@@ -132,9 +130,10 @@ createLibraryModule({
132130
```javascript
133131
{
134132
name: String, /* The name of the library (Default: Library) */
135-
prefix: String, /* The prefix for the library (Default: ``) */
133+
prefix: String, /* The prefix of the native library module, ignored if className is specified (Default: ``) */
136134
moduleName: String, /* The module library package name to be used in package.json. Default: react-native-(name in param-case) */
137-
modulePrefix: String, /* The module prefix for the library, ignored if moduleName is specified (Default: react-native) */
135+
className: String, /* The name of the native object to be exported by the JavaScript and by the native code. Default: (prefix)(name in PascalCase) */
136+
modulePrefix: String, /* The native module prefix for the library module package name, ignored if moduleName is specified (Default: react-native) */
138137
platforms: Array | String, /* Platforms the library will be created for. (Default: ['android', 'ios']) */
139138
packageIdentifier: String, /* [Android] The Java package identifier used by the Android module (Default: com.reactlibrary) */
140139
tvosEnabled: Boolean, /* Generate the module with tvOS build enabled (requires react-native-tvos fork, with minimum version of 0.60, and iOS platform to be enabled) */
@@ -146,15 +145,11 @@ createLibraryModule({
146145
view: Boolean, /* Generate the module as a very simple native view component (Default: false) */
147146
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) */
148147
exampleName: String, /* Name for the example project (Default: `example`) */
149-
exampleReactNativeVersion: String, /* React Native version for the generated example project (Default: `react-native@0.59`) */
148+
exampleReactNativeVersion: String, /* React Native version for the generated example project (Default: `react-native@latest`) */
150149
writeExamplePodfile: Boolean, /* [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile (Default: false) */
151150
}
152151
```
153152

154-
## Behavior not tested or supported
155-
156-
- Windows platform support
157-
158153
## Examples
159154

160155
### Example module with no view
@@ -175,12 +170,16 @@ cd react-native-alice-helper/example
175170

176171
#### Running the example app
177172

178-
__Within the example test app subdirectory:__
173+
**Recommended:** Follow the instructions shown in the end of the console log output, which are more likely to be up-to-date.
174+
175+
__Extra notes:__
176+
177+
_Within the example test app subdirectory:_
179178

180179
It is *recommended* to start the Metro Bundler manually (within `react-native-alice-helper/example`), which would run in the foreground:
181180

182181
```
183-
npm start
182+
yarn start
184183
```
185184

186185
Otherwise, React Native will open its own window to run the Metro Bundler.
@@ -199,7 +198,7 @@ ANDROID_HOME=~/Library/Android/sdk react-native run-android
199198

200199
For iOS:
201200

202-
Extra installation step needed on React Native 0.60(+) (see [issue #28](https://github.com/brodybits/create-react-native-module/issues/28)):
201+
Extra installation step needed _in case of clean checkout only_:
203202

204203
```
205204
cd ios && pod install && cd ..
@@ -217,7 +216,7 @@ or do the following command to open the iOS project in Xcode:
217216
open ios/example.xcodeproj
218217
```
219218

220-
__Expected result:__
219+
#### Expected result
221220

222221
The example app shows the following indications:
223222

@@ -242,17 +241,26 @@ Then go into the example app subdirectory:
242241
cd react-native-carol-widget/example
243242
```
244243

245-
__Within the example test app subdirectory:__
244+
#### Running the view example app
245+
246+
**Recommended:** Follow the instructions shown in the end of the console log output, which are more likely to be up-to-date.
247+
248+
__Some extra notes:__
249+
250+
_Within the example test app subdirectory:_
246251

247252
It is *recommended* to start the Metro Bundler manually as described above (within `react-native-carol-widget/example`):
248253

249254
```
250-
npm start
255+
yarn start
251256
```
252257

253258
To run on Android: do `react-native run-android` as described for the other example above.
254259

255-
To run on iOS: do `pod install` in `ios` subdirectory for React Native 0.60(+) (see above), then do `react-native run-ios` or `open ios/example.xcodeproj` as described for the other example above.
260+
To run on iOS (as described above):
261+
262+
- _in case of clean checkout **only**_: do `pod install` in `ios` subdirectory
263+
- do `react-native run-ios` or `open ios/example.xcodeproj`
256264

257265
__Expected result:__
258266

lib/cli-command.js

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
11
const emoji = require('node-emoji');
22

3+
const logSymbols = require('log-symbols');
4+
35
const normalizedOptions = require('./normalized-options');
46

57
const createLibraryModule = require('./lib');
68

7-
const postCreateInstructions = ({ moduleName, exampleName, writeExamplePodfile }) => {
8-
return `
9+
const postCreateInstructions = ({
10+
moduleName,
11+
platforms,
12+
generateExample,
13+
exampleName
14+
}) => `
915
====================================================
1016
YOU'RE ALL SET!
11-
12-
To build and run iOS example project, do:
13-
----
14-
cd ${moduleName}/${exampleName}
15-
yarn
16-
cd ios
17-
pod install # ${writeExamplePodfile ? `required` : `required starting with React Native 0.60`}
18-
cd ..
19-
react-native run-ios
20-
----
21-
`;
22-
};
17+
` + (generateExample
18+
? `
19+
${emoji.get('bulb')} check out the example app in ${moduleName}/${exampleName}
20+
${emoji.get('bulb')} recommended: run Metro Bundler in a new shell
21+
${logSymbols.info} (cd ${moduleName}/${exampleName} && yarn start)
22+
${emoji.get('bulb')} enter the following commands to run the example app:
23+
${logSymbols.info} cd ${moduleName}/${exampleName}
24+
${platforms.split(',').map(platform =>
25+
`${logSymbols.info} react-native run-${platform}`
26+
).join(`
27+
`)}
28+
${logSymbols.warning} first steps in case of a clean checkout
29+
${logSymbols.info} run Yarn in ${moduleName}/${exampleName}/ios
30+
${logSymbols.info} (cd ${moduleName}/${exampleName} && yarn)
31+
${logSymbols.info} do \`pod install\` for iOS in ${moduleName}/${exampleName}/ios
32+
${logSymbols.info} cd ${moduleName}/${exampleName}
33+
${logSymbols.info} (cd ios && pod install)
34+
`
35+
: `
36+
${emoji.get('bulb')} next time consider using \`--generate-example\` to add a generated example!
37+
`);
2338

2439
module.exports = {
2540
name: 'create-library',
2641
description: 'creates a React Native library module for one or more platforms',
2742
usage: '[options] <name>',
28-
func: (args, config, options) => {
43+
action: (args, options) => {
2944
const name = args[0];
3045

3146
const beforeCreation = Date.now();
@@ -57,14 +72,17 @@ ${postCreateInstructions(createOptions)}`);
5772
},
5873
options: [{
5974
command: '--prefix [prefix]',
60-
description: 'The prefix for the library module',
75+
description: 'The prefix of the native library module, ignored if --class-name is specified',
6176
default: '',
6277
}, {
6378
command: '--module-name [moduleName]',
6479
description: 'The module library package name to be used in package.json. Default: react-native-(name in param-case)',
80+
}, {
81+
command: '--class-name [className]',
82+
description: 'The name of the native object to be exported by the JavaScript and by the native code. Default: (prefix)(name in PascalCase)',
6583
}, {
6684
command: '--module-prefix [modulePrefix]',
67-
description: 'The module prefix for the library module, ignored if --module-name is specified',
85+
description: 'The native module prefix for the library module package name, ignored if --module-name is specified',
6886
default: 'react-native',
6987
}, {
7088
command: '--package-identifier [packageIdentifier]',
@@ -109,7 +127,7 @@ ${postCreateInstructions(createOptions)}`);
109127
}, {
110128
command: '--example-react-native-version [exampleReactNativeVersion]',
111129
description: 'React Native version for the generated example project',
112-
default: 'react-native@0.59',
130+
default: 'react-native@latest',
113131
}, {
114132
command: '--write-example-podfile',
115133
description: '[iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile',

lib/cli-program.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
const pkg = require('./../package.json');
2+
require('please-upgrade-node')(pkg);
3+
14
const program = require('commander');
5+
26
const updateNotifier = require('update-notifier');
37

48
const command = require('./cli-command');
5-
const pkg = require('./../package.json');
69

710
updateNotifier({ pkg }).notify();
811

912
program
1013
.version(pkg.version)
1114
.usage(command.usage)
1215
.description(command.description)
13-
.action(function runAction () {
14-
command.func(arguments, {}, this.opts());
16+
.action(function programAction (_, args) {
17+
command.action(args, this.opts());
1518
});
1619

1720
(command.options || [])

0 commit comments

Comments
 (0)