Skip to content

Commit a89916d

Browse files
author
Chris Brody
authored
update create options (#325)
* update create options - move --module-name & --view options to near the beginning in CLI & documentation - update help text & documentation of --module-name, --view, & --module-prefix options - document className option in library API (which is deprecated due to plans to rename the option) - update documentation of prefix option in library API only * update test snapshots
1 parent ff38b2f commit a89916d

File tree

7 files changed

+62
-61
lines changed

7 files changed

+62
-61
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,17 @@ Usage: create-react-native-module [options] <name>
9191
Options:
9292
9393
-V, --version output the version number
94+
--module-name <moduleName> The module package name to be used in package.json. Default: react-native-(name in param-case)
95+
--view Generate the package as a very simple native view component
9496
--prefix <prefix> The prefix of the library module object to be exported by both JavaScript and native code (Default: ``)
95-
--module-name <moduleName> The module library package name to be used in package.json. Default: react-native-(name in param-case)
96-
--module-prefix <modulePrefix> The prefix of the library module object, ignored if --module-name is specified (Default: `react-native`)
97+
--module-prefix <modulePrefix> The prefix of the generated module package name, ignored if --module-name is specified (Default: `react-native`)
9798
--package-identifier <packageIdentifier> [Android] The Java package identifier used by the Android module (Default: `com.reactlibrary`)
9899
--platforms <platforms> Platforms the library module will be created for - comma separated (Default: `ios,android`)
99100
--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)
100101
--github-account <githubAccount> The github account where the library module is hosted (Default: `github_account`)
101102
--author-name <authorName> The author's name (Default: `Your Name`)
102103
--author-email <authorEmail> The author's email (Default: `[email protected]`)
103104
--license <license> The license type (Default: `MIT`)
104-
--view Generate the module as a very simple native view component
105105
--use-apple-networking [iOS] Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code
106106
--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
107107
--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
@@ -128,9 +128,11 @@ createLibraryModule({
128128
```javascript
129129
{
130130
name: String, /* The name of the library (mandatory) */
131-
prefix: String, /* The prefix of the library module object to be exported by both JavaScript and native code (Default: ``) */
132-
moduleName: String, /* The module library package name to be used in package.json. Default: react-native-(name in param-case) */
133-
modulePrefix: String, /* The prefix of the library module object, ignored if moduleName is specified (Default: `react-native`) */
131+
moduleName: String, /* The module package name to be used in package.json. Default: react-native-(name in param-case) */
132+
view: Boolean, /* Generate the package as a very simple native view component (Default: false) */
133+
className: String, /* The name of the object class to be exported by both JavaScript and native code, deprecated due to plans to rename this option (Default: ``) */
134+
prefix: String, /* The prefix of the library module object to be exported by both JavaScript and native code, ignored if className is specified (Default: ``) */
135+
modulePrefix: String, /* The prefix of the generated module package name, ignored if moduleName is specified (Default: `react-native`) */
134136
platforms: Array | String, /* Platforms the library will be created for. (Default: ['android', 'ios']) */
135137
packageIdentifier: String, /* [Android] The Java package identifier used by the Android module (Default: com.reactlibrary) */
136138
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) */
@@ -139,7 +141,6 @@ createLibraryModule({
139141
authorEmail: String, /* The author's email (Default: `[email protected]`) */
140142
license: String, /* The license type of this library (Default: `MIT`) */
141143
useAppleNetworking: Boolean, /* [iOS] Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code (Default: false) */
142-
view: Boolean, /* Generate the module as a very simple native view component (Default: false) */
143144
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) */
144145
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) */
145146
exampleName: String, /* Name for the example project (Default: `example`) */

lib/cli-command.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@ ${postCreateInstructions(createOptions)}`);
8282
});
8383
},
8484
options: [{
85+
command: '--module-name [moduleName]',
86+
description: 'The module package name to be used in package.json. Default: react-native-(name in param-case)',
87+
}, {
88+
command: '--view',
89+
description: 'Generate the package as a very simple native view component',
90+
}, {
8591
command: '--prefix [prefix]',
8692
description: 'The prefix of the library module object to be exported by both JavaScript and native code',
8793
default: '',
88-
}, {
89-
command: '--module-name [moduleName]',
90-
description: 'The module library package name to be used in package.json. Default: react-native-(name in param-case)',
9194
}, {
9295
command: '--module-prefix [modulePrefix]',
93-
description: 'The prefix of the library module object, ignored if --module-name is specified',
96+
description: 'The prefix of the generated module package name, ignored if --module-name is specified',
9497
default: 'react-native',
9598
}, {
9699
command: '--package-identifier [packageIdentifier]',
@@ -119,9 +122,6 @@ ${postCreateInstructions(createOptions)}`);
119122
command: '--license [license]',
120123
description: 'The license type',
121124
default: 'MIT',
122-
}, {
123-
command: '--view',
124-
description: 'Generate the module as a very simple native view component',
125125
}, {
126126
command: '--use-apple-networking',
127127
description: '[iOS] Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code',

tests/integration/cli/help/__snapshots__/cli-help.test.js.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ creates a React Native library module for one or more platforms
77
88
Options:
99
-V, --version output the version number
10+
--module-name [moduleName] The module package name to be used in package.json. Default: react-native-(name in param-case)
11+
--view Generate the package as a very simple native view component
1012
--prefix [prefix] The prefix of the library module object to be exported by both JavaScript and native code (default: \\"\\")
11-
--module-name [moduleName] The module library package name to be used in package.json. Default: react-native-(name in param-case)
12-
--module-prefix [modulePrefix] The prefix of the library module object, ignored if --module-name is specified (default: \\"react-native\\")
13+
--module-prefix [modulePrefix] The prefix of the generated module package name, ignored if --module-name is specified (default: \\"react-native\\")
1314
--package-identifier [packageIdentifier] [Android] The Java package identifier used by the Android module (default: \\"com.reactlibrary\\")
1415
--platforms <platforms> Platforms the library module will be created for - comma separated (default: \\"ios,android\\")
1516
--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)
1617
--github-account [githubAccount] The github account where the library module is hosted (default: \\"github_account\\")
1718
--author-name [authorName] The author's name (default: \\"Your Name\\")
1819
--author-email [authorEmail] The author's email (default: \\"[email protected]\\")
1920
--license [license] The license type (default: \\"MIT\\")
20-
--view Generate the module as a very simple native view component
2121
--use-apple-networking [iOS] Use \`AFNetworking\` dependency as a sample in the podspec & use it from the iOS code
2222
--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
2323
--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

tests/integration/cli/noargs/__snapshots__/cli-noargs.test.js.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ creates a React Native library module for one or more platforms
77
88
Options:
99
-V, --version output the version number
10+
--module-name [moduleName] The module package name to be used in package.json. Default: react-native-(name in param-case)
11+
--view Generate the package as a very simple native view component
1012
--prefix [prefix] The prefix of the library module object to be exported by both JavaScript and native code (default: \\"\\")
11-
--module-name [moduleName] The module library package name to be used in package.json. Default: react-native-(name in param-case)
12-
--module-prefix [modulePrefix] The prefix of the library module object, ignored if --module-name is specified (default: \\"react-native\\")
13+
--module-prefix [modulePrefix] The prefix of the generated module package name, ignored if --module-name is specified (default: \\"react-native\\")
1314
--package-identifier [packageIdentifier] [Android] The Java package identifier used by the Android module (default: \\"com.reactlibrary\\")
1415
--platforms <platforms> Platforms the library module will be created for - comma separated (default: \\"ios,android\\")
1516
--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)
1617
--github-account [githubAccount] The github account where the library module is hosted (default: \\"github_account\\")
1718
--author-name [authorName] The author's name (default: \\"Your Name\\")
1819
--author-email [authorEmail] The author's email (default: \\"[email protected]\\")
1920
--license [license] The license type (default: \\"MIT\\")
20-
--view Generate the module as a very simple native view component
2121
--use-apple-networking [iOS] Use \`AFNetworking\` dependency as a sample in the podspec & use it from the iOS code
2222
--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
2323
--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

tests/with-injection/cli/command/object/__snapshots__/lib-cli-command-object-text.test.js.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@ Object {
66
"description": "creates a React Native library module for one or more platforms",
77
"name": "create-library",
88
"options": Array [
9+
Object {
10+
"command": "--module-name [moduleName]",
11+
"description": "The module package name to be used in package.json. Default: react-native-(name in param-case)",
12+
},
13+
Object {
14+
"command": "--view",
15+
"description": "Generate the package as a very simple native view component",
16+
},
917
Object {
1018
"command": "--prefix [prefix]",
1119
"default": "",
1220
"description": "The prefix of the library module object to be exported by both JavaScript and native code",
1321
},
14-
Object {
15-
"command": "--module-name [moduleName]",
16-
"description": "The module library package name to be used in package.json. Default: react-native-(name in param-case)",
17-
},
1822
Object {
1923
"command": "--module-prefix [modulePrefix]",
2024
"default": "react-native",
21-
"description": "The prefix of the library module object, ignored if --module-name is specified",
25+
"description": "The prefix of the generated module package name, ignored if --module-name is specified",
2226
},
2327
Object {
2428
"command": "--package-identifier [packageIdentifier]",
@@ -54,10 +58,6 @@ Object {
5458
"default": "MIT",
5559
"description": "The license type",
5660
},
57-
Object {
58-
"command": "--view",
59-
"description": "Generate the module as a very simple native view component",
60-
},
6161
Object {
6262
"command": "--use-apple-networking",
6363
"description": "[iOS] Use \`AFNetworking\` dependency as a sample in the podspec & use it from the iOS code",

tests/with-mocks/cli/program/with-defaults/for-android/__snapshots__/cli-program-with-defaults-for-android.test.js.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,38 @@ Array [
3030
Object {
3131
"option": Object {
3232
"args": Array [
33-
"--prefix [prefix]",
34-
"The prefix of the library module object to be exported by both JavaScript and native code",
33+
"--module-name [moduleName]",
34+
"The module package name to be used in package.json. Default: react-native-(name in param-case)",
3535
[Function],
36-
"",
36+
undefined,
3737
],
3838
},
3939
},
4040
Object {
4141
"option": Object {
4242
"args": Array [
43-
"--module-name [moduleName]",
44-
"The module library package name to be used in package.json. Default: react-native-(name in param-case)",
43+
"--view",
44+
"Generate the package as a very simple native view component",
4545
[Function],
4646
undefined,
4747
],
4848
},
4949
},
50+
Object {
51+
"option": Object {
52+
"args": Array [
53+
"--prefix [prefix]",
54+
"The prefix of the library module object to be exported by both JavaScript and native code",
55+
[Function],
56+
"",
57+
],
58+
},
59+
},
5060
Object {
5161
"option": Object {
5262
"args": Array [
5363
"--module-prefix [modulePrefix]",
54-
"The prefix of the library module object, ignored if --module-name is specified",
64+
"The prefix of the generated module package name, ignored if --module-name is specified",
5565
[Function],
5666
"react-native",
5767
],
@@ -127,16 +137,6 @@ Array [
127137
],
128138
},
129139
},
130-
Object {
131-
"option": Object {
132-
"args": Array [
133-
"--view",
134-
"Generate the module as a very simple native view component",
135-
[Function],
136-
undefined,
137-
],
138-
},
139-
},
140140
Object {
141141
"option": Object {
142142
"args": Array [

tests/with-mocks/cli/program/with-missing-args/__snapshots__/cli-program-with-missing-args.test.js.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,38 @@ Array [
2828
Object {
2929
"option": Object {
3030
"args": Array [
31-
"--prefix [prefix]",
32-
"The prefix of the library module object to be exported by both JavaScript and native code",
31+
"--module-name [moduleName]",
32+
"The module package name to be used in package.json. Default: react-native-(name in param-case)",
3333
[Function],
34-
"",
34+
undefined,
3535
],
3636
},
3737
},
3838
Object {
3939
"option": Object {
4040
"args": Array [
41-
"--module-name [moduleName]",
42-
"The module library package name to be used in package.json. Default: react-native-(name in param-case)",
41+
"--view",
42+
"Generate the package as a very simple native view component",
4343
[Function],
4444
undefined,
4545
],
4646
},
4747
},
48+
Object {
49+
"option": Object {
50+
"args": Array [
51+
"--prefix [prefix]",
52+
"The prefix of the library module object to be exported by both JavaScript and native code",
53+
[Function],
54+
"",
55+
],
56+
},
57+
},
4858
Object {
4959
"option": Object {
5060
"args": Array [
5161
"--module-prefix [modulePrefix]",
52-
"The prefix of the library module object, ignored if --module-name is specified",
62+
"The prefix of the generated module package name, ignored if --module-name is specified",
5363
[Function],
5464
"react-native",
5565
],
@@ -125,16 +135,6 @@ Array [
125135
],
126136
},
127137
},
128-
Object {
129-
"option": Object {
130-
"args": Array [
131-
"--view",
132-
"Generate the module as a very simple native view component",
133-
[Function],
134-
undefined,
135-
],
136-
},
137-
},
138138
Object {
139139
"option": Object {
140140
"args": Array [

0 commit comments

Comments
 (0)