Skip to content

Commit 7c72990

Browse files
author
Chris Brody
authored
fix --class-name & some other options (#278)
* fix `--class-name` & some other options - export & document `--class-name` CLI option - document `className` library API option - update description of `prefix` option - fix description of `modulePrefix` - remove an "option NOT DOCUMENTED & NOT SUPPORTED" comment * update test snapshots
1 parent 88e33fa commit 7c72990

File tree

8 files changed

+47
-17
lines changed

8 files changed

+47
-17
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ Usage: create-react-native-module [options] <name>
9393
Options:
9494
9595
-V, --version output the version number
96-
--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: ``)
9797
--module-name <moduleName> The module library package name to be used in package.json. Default: react-native-(name in param-case)
98-
--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`)
99100
--package-identifier <packageIdentifier> [Android] The Java package identifier used by the Android module (Default: `com.reactlibrary`)
100101
--platforms <platforms> Platforms the library module will be created for - comma separated (Default: `ios,android`)
101102
--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)
@@ -129,9 +130,10 @@ createLibraryModule({
129130
```javascript
130131
{
131132
name: String, /* The name of the library (Default: Library) */
132-
prefix: String, /* The prefix for the library (Default: ``) */
133+
prefix: String, /* The prefix of the native library module, ignored if className is specified (Default: ``) */
133134
moduleName: String, /* The module library package name to be used in package.json. Default: react-native-(name in param-case) */
134-
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) */
135137
platforms: Array | String, /* Platforms the library will be created for. (Default: ['android', 'ios']) */
136138
packageIdentifier: String, /* [Android] The Java package identifier used by the Android module (Default: com.reactlibrary) */
137139
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) */

lib/cli-command.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,17 @@ ${postCreateInstructions(createOptions)}`);
7272
},
7373
options: [{
7474
command: '--prefix [prefix]',
75-
description: 'The prefix for the library module',
75+
description: 'The prefix of the native library module, ignored if --class-name is specified',
7676
default: '',
7777
}, {
7878
command: '--module-name [moduleName]',
7979
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)',
8083
}, {
8184
command: '--module-prefix [modulePrefix]',
82-
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',
8386
default: 'react-native',
8487
}, {
8588
command: '--package-identifier [packageIdentifier]',

lib/normalized-options.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ module.exports = (options) => {
1818

1919
const moduleName = options.moduleName;
2020

21-
// [TBD] option NOT DOCUMENTED & NOT SUPPORTED by CLI:
2221
const className = options.className;
2322

2423
// namespace - library API member removed since Windows platform

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ creates a React Native library module for one or more platforms
77
88
Options:
99
-V, --version output the version number
10-
--prefix [prefix] The prefix for the library module (default: \\"\\")
10+
--prefix [prefix] The prefix of the native library module, ignored if --class-name is specified (default: \\"\\")
1111
--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 module prefix for the library module, ignored if --module-name is specified (default: \\"react-native\\")
12+
--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)
13+
--module-prefix [modulePrefix] The native module prefix for the library 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)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ creates a React Native library module for one or more platforms
77
88
Options:
99
-V, --version output the version number
10-
--prefix [prefix] The prefix for the library module (default: \\"\\")
10+
--prefix [prefix] The prefix of the native library module, ignored if --class-name is specified (default: \\"\\")
1111
--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 module prefix for the library module, ignored if --module-name is specified (default: \\"react-native\\")
12+
--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)
13+
--module-prefix [modulePrefix] The native module prefix for the library 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)

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ Object {
99
Object {
1010
"command": "--prefix [prefix]",
1111
"default": "",
12-
"description": "The prefix for the library module",
12+
"description": "The prefix of the native library module, ignored if --class-name is specified",
1313
},
1414
Object {
1515
"command": "--module-name [moduleName]",
1616
"description": "The module library package name to be used in package.json. Default: react-native-(name in param-case)",
1717
},
18+
Object {
19+
"command": "--class-name [className]",
20+
"description": "The name of the native object to be exported by the JavaScript and by the native code. Default: (prefix)(name in PascalCase)",
21+
},
1822
Object {
1923
"command": "--module-prefix [modulePrefix]",
2024
"default": "react-native",
21-
"description": "The module prefix for the library module, ignored if --module-name is specified",
25+
"description": "The native module prefix for the library module package name, ignored if --module-name is specified",
2226
},
2327
Object {
2428
"command": "--package-identifier [packageIdentifier]",

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Array [
3131
"option": Object {
3232
"args": Array [
3333
"--prefix [prefix]",
34-
"The prefix for the library module",
34+
"The prefix of the native library module, ignored if --class-name is specified",
3535
[Function],
3636
"",
3737
],
@@ -47,11 +47,21 @@ Array [
4747
],
4848
},
4949
},
50+
Object {
51+
"option": Object {
52+
"args": Array [
53+
"--class-name [className]",
54+
"The name of the native object to be exported by the JavaScript and by the native code. Default: (prefix)(name in PascalCase)",
55+
[Function],
56+
undefined,
57+
],
58+
},
59+
},
5060
Object {
5161
"option": Object {
5262
"args": Array [
5363
"--module-prefix [modulePrefix]",
54-
"The module prefix for the library module, ignored if --module-name is specified",
64+
"The native module prefix for the library module package name, ignored if --module-name is specified",
5565
[Function],
5666
"react-native",
5767
],

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Array [
2929
"option": Object {
3030
"args": Array [
3131
"--prefix [prefix]",
32-
"The prefix for the library module",
32+
"The prefix of the native library module, ignored if --class-name is specified",
3333
[Function],
3434
"",
3535
],
@@ -45,11 +45,21 @@ Array [
4545
],
4646
},
4747
},
48+
Object {
49+
"option": Object {
50+
"args": Array [
51+
"--class-name [className]",
52+
"The name of the native object to be exported by the JavaScript and by the native code. Default: (prefix)(name in PascalCase)",
53+
[Function],
54+
undefined,
55+
],
56+
},
57+
},
4858
Object {
4959
"option": Object {
5060
"args": Array [
5161
"--module-prefix [modulePrefix]",
52-
"The module prefix for the library module, ignored if --module-name is specified",
62+
"The native module prefix for the library module package name, ignored if --module-name is specified",
5363
[Function],
5464
"react-native",
5565
],

0 commit comments

Comments
 (0)