Skip to content

Commit 254ab07

Browse files
author
Chris Brody
authored
refactor!: remove prefix options (#432)
* refactor!: remove --prefix option * refactor!: remove --module-prefix option * test: remove tests with null prefix * test: remove test with custom module prefix * test: remove prefix option from 2 test cases * test: update test snapshots * docs: remove --prefix option from command-line examples * refactor: rename internal package prefix constant (and remove extra const) BREAKING CHANGE: affects anyone using the removed options
1 parent 8bfc561 commit 254ab07

File tree

25 files changed

+87
-2975
lines changed

25 files changed

+87
-2975
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ Options:
9696
--package-name <packageName> The full package name to be used in package.json. Default: react-native-(name in param-case)
9797
--view Generate the package as a very simple native view component
9898
--object-class-name The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase)
99-
--prefix <prefix> DEPRECATED: The prefix of the name of the object class to be exported by both JavaScript and native code, ignored if --object-class-name is specified (Default: ``)
100-
--module-prefix <modulePrefix> The prefix of the generated module package name, ignored if --module-name is specified (Default: `react-native`)
10199
--native-package-id <nativePackageId> [Android] The native Java package identifier used for Android (Default: `com.reactlibrary`)
102100
--platforms <platforms> Platforms the library module will be created for - comma separated (Default: `ios,android`)
103101
--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)
@@ -134,8 +132,6 @@ createLibraryModule({
134132
packageName: String, /* The full package name to be used in package.json. Default: react-native-(name in param-case) */
135133
view: Boolean, /* Generate the package as a very simple native view component (Default: false) */
136134
objectClassName: String, /* The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase) */
137-
prefix: String, /* DEPRECATED: The prefix of the name of the object class to be exported by both JavaScript and native code, ignored if objectClassName is specified (Default: ``) */
138-
modulePrefix: String, /* The prefix of the generated module package name, ignored if moduleName is specified (Default: `react-native`) */
139135
platforms: Array | String, /* Platforms the library will be created for. (Default: ['android', 'ios']) */
140136
nativePackageId: String, /* [Android] The native Java package identifier used for Android (Default: `com.reactlibrary`) */
141137
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) */
@@ -159,7 +155,7 @@ createLibraryModule({
159155
__Create the module with no view:__
160156

161157
```console
162-
create-react-native-module --prefix CB --native-package-id io.mylibrary --generate-example AliceHelper
158+
create-react-native-module --package-identifier io.mylibrary --generate-example AliceHelper
163159
```
164160

165161
The module would be generated in the `react-native-alice-helper` subdirectory, and the example test app would be in `react-native-alice-helper/example`.
@@ -234,7 +230,7 @@ The example app shows the following indications:
234230
__Create the module with an extremely simple view:__
235231

236232
```console
237-
create-react-native-module --prefix CB --native-package-id io.mylibrary --view --generate-example CarolWidget
233+
create-react-native-module --package-identifier io.mylibrary --view --generate-example CarolWidget
238234
```
239235

240236
The module would be generated in the `react-native-carol-widget` subdirectory, and the example test app would be in `react-native-carol-widget/example`.

lib/cli-command.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,6 @@ ${postCreateInstructions(createOptions)}`);
9292
}, {
9393
command: '--object-class-name [objectClassName]',
9494
description: 'The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase)',
95-
}, {
96-
command: '--prefix [prefix]',
97-
description: 'DEPRECATED: The prefix of the name of the object class to be exported by both JavaScript and native code, ignored if --object-class-name is specified',
98-
default: '',
99-
}, {
100-
command: '--module-prefix [modulePrefix]',
101-
description: 'The prefix of the generated module package name, ignored if --module-name is specified',
102-
default: 'react-native',
10395
}, {
10496
command: '--native-package-id [nativePackageId]',
10597
description: '[Android] The native Java package identifier used for Android',

lib/lib.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ const npmAddScriptSync = (packageJsonPath, script, fs) => {
6767

6868
const generateWithNormalizedOptions = ({
6969
name,
70-
prefix, // (only needed for logging purposes in this function)
7170
packageName,
7271
objectClassName,
73-
modulePrefix,
7472
nativePackageId = DEFAULT_NATIVE_PACKAGE_ID,
7573
// namespace - library API member removed since Windows platform
7674
// is now removed (may be added back someday in the future)
@@ -108,9 +106,7 @@ const generateWithNormalizedOptions = ({
108106
name: ${name}
109107
full package name: ${packageName}
110108
is view: ${view}
111-
object class name prefix: ${prefix}
112109
object class name: ${objectClassName}
113-
library modulePrefix: ${modulePrefix}
114110
Android nativePackageId: ${nativePackageId}
115111
platforms: ${platforms}
116112
Apple tvosEnabled: ${tvosEnabled}

lib/normalized-options.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@ const { paramCase } = require('param-case');
22

33
const { pascalCase } = require('pascal-case');
44

5-
// TODO: refactor all defaults from here & lib.js into a new module
6-
const DEFAULT_MODULE_PREFIX = 'react-native';
5+
const PACKAGE_PREFIX = 'react-native';
76

87
module.exports = (options) => {
98
const { name, packageName, objectClassName } = options;
109

11-
const prefix = options.prefix || '';
12-
13-
const modulePrefix = options.modulePrefix || DEFAULT_MODULE_PREFIX;
14-
1510
if (typeof name !== 'string') {
1611
throw new TypeError("Please write your library's name");
1712
}
@@ -21,14 +16,17 @@ module.exports = (options) => {
2116
// const namespace = options.namespace;
2217

2318
return Object.assign(
24-
{ name, prefix, modulePrefix },
19+
{ name },
2520
options,
2621
packageName
2722
? {}
28-
: { packageName: `${modulePrefix}-${paramCase(name)}` },
23+
: {
24+
// TODO: do not add PACKAGE_PREFIX if it is not needed
25+
packageName: `${PACKAGE_PREFIX}-${paramCase(name)}`
26+
},
2927
objectClassName
3028
? {}
31-
: { objectClassName: `${prefix}${pascalCase(name)}` },
29+
: { objectClassName: `${pascalCase(name)}` },
3230
// namespace - library API member removed since Windows platform
3331
// is now removed (may be added back someday in the future)
3432
// namespace

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ Options:
1010
--package-name [packageName] The full package name to be used in package.json. Default: react-native-(name in param-case)
1111
--view Generate the package as a very simple native view component
1212
--object-class-name [objectClassName] The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase)
13-
--prefix [prefix] DEPRECATED: The prefix of the name of the object class to be exported by both JavaScript and native code, ignored if --object-class-name is specified (default: \\"\\")
14-
--module-prefix [modulePrefix] The prefix of the generated module package name, ignored if --module-name is specified (default: \\"react-native\\")
1513
--native-package-id [nativePackageId] [Android] The native Java package identifier used for Android (default: \\"com.reactlibrary\\")
1614
--platforms <platforms> Platforms the library module will be created for - comma separated (default: \\"ios,android\\")
1715
--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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ Options:
1010
--package-name [packageName] The full package name to be used in package.json. Default: react-native-(name in param-case)
1111
--view Generate the package as a very simple native view component
1212
--object-class-name [objectClassName] The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase)
13-
--prefix [prefix] DEPRECATED: The prefix of the name of the object class to be exported by both JavaScript and native code, ignored if --object-class-name is specified (default: \\"\\")
14-
--module-prefix [modulePrefix] The prefix of the generated module package name, ignored if --module-name is specified (default: \\"react-native\\")
1513
--native-package-id [nativePackageId] [Android] The native Java package identifier used for Android (default: \\"com.reactlibrary\\")
1614
--platforms <platforms> Platforms the library module will be created for - comma separated (default: \\"ios,android\\")
1715
--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: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ Object {
1818
"command": "--object-class-name [objectClassName]",
1919
"description": "The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase)",
2020
},
21-
Object {
22-
"command": "--prefix [prefix]",
23-
"default": "",
24-
"description": "DEPRECATED: The prefix of the name of the object class to be exported by both JavaScript and native code, ignored if --object-class-name is specified",
25-
},
26-
Object {
27-
"command": "--module-prefix [modulePrefix]",
28-
"default": "react-native",
29-
"description": "The prefix of the generated module package name, ignored if --module-name is specified",
30-
},
3121
Object {
3222
"command": "--native-package-id [nativePackageId]",
3323
"default": "com.reactlibrary",

0 commit comments

Comments
 (0)