Skip to content

Commit 310ec78

Browse files
author
Chris Brody
authored
refactor!: rename --view to --is-view; update help & doc (#439)
* refactor!: rename --view option to --is-view * update view tests * document --is-view as EXPERIMENTAL, with limited testing * update help text for --is-view option with Status: EXPERIMENTAL (...) * update test snapshot BREAKING CHANGE: affects any user generating a view module from either the CLI or the programmatic usage API.
1 parent eec3c84 commit 310ec78

File tree

19 files changed

+51
-49
lines changed

19 files changed

+51
-49
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Options:
9494

9595
-V, --version output the version number
9696
--package-name <packageName> The full package name to be used in package.json. Default: react-native-(name in param-case)
97-
--view Generate the package as a very simple native view component
97+
--is-view Generate the package as a very simple native view component. Status: EXPERIMENTAL, with limited testing.
9898
--object-class-name The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase)
9999
--native-package-id <nativePackageId> [Android] The native Java package identifier used for Android (Default: `com.reactlibrary`)
100100
--platforms <platforms> Platforms the library module will be created for - comma separated (Default: `ios,android`)
@@ -130,7 +130,7 @@ createLibraryModule({
130130
{
131131
name: String, /* The name of the library (mandatory) */
132132
packageName: String, /* The full package name to be used in package.json. Default: react-native-(name in param-case) */
133-
view: Boolean, /* Generate the package as a very simple native view component (Default: false) */
133+
isView: Boolean, /* Generate the package as a very simple native view component. Status: EXPERIMENTAL, with limited testing. (Default: false) */
134134
objectClassName: String, /* The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase) */
135135
platforms: Array | String, /* Platforms the library will be created for. (Default: ['android', 'ios']) */
136136
nativePackageId: String, /* [Android] The native Java package identifier used for Android (Default: `com.reactlibrary`) */
@@ -227,10 +227,12 @@ The example app shows the following indications:
227227

228228
### Example view module
229229

230+
EXPERIMENTAL feature with limited testing
231+
230232
__Create the module with an extremely simple view:__
231233

232234
```console
233-
create-react-native-module --package-identifier io.mylibrary --view --generate-example CarolWidget
235+
create-react-native-module --package-identifier io.mylibrary --is-view --generate-example CarolWidget
234236
```
235237

236238
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ ${postCreateInstructions(createOptions)}`);
8787
command: '--package-name [packageName]',
8888
description: 'The full package name to be used in package.json. Default: react-native-(name in param-case)',
8989
}, {
90-
command: '--view',
91-
description: 'Generate the package as a very simple native view component',
90+
command: '--is-view',
91+
description: 'Generate the package as a very simple native view component. Status: EXPERIMENTAL, with limited testing.',
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)',

lib/lib.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const generateWithNormalizedOptions = ({
7979
authorName = DEFAULT_AUTHOR_NAME,
8080
authorEmail = DEFAULT_AUTHOR_EMAIL,
8181
license = DEFAULT_LICENSE,
82-
view = false,
82+
isView = false,
8383
useAppleNetworking = false,
8484
generateExample = DEFAULT_GENERATE_EXAMPLE,
8585
exampleFileLinkage = false,
@@ -105,7 +105,7 @@ const generateWithNormalizedOptions = ({
105105
106106
name: ${name}
107107
full package name: ${packageName}
108-
is view: ${view}
108+
is view: ${isView}
109109
object class name: ${objectClassName}
110110
Android nativePackageId: ${nativePackageId}
111111
platforms: ${platforms}
@@ -169,7 +169,7 @@ const generateWithNormalizedOptions = ({
169169
authorName,
170170
authorEmail,
171171
license,
172-
view,
172+
isView,
173173
useAppleNetworking,
174174
};
175175

@@ -205,7 +205,7 @@ const generateWithNormalizedOptions = ({
205205
const templateArgs = {
206206
packageName,
207207
objectClassName,
208-
view,
208+
isView,
209209
useAppleNetworking,
210210
exampleFileLinkage,
211211
exampleName,

templates/android.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ afterEvaluate { project ->
160160
`,
161161
}, {
162162
// for module without view:
163-
name: ({ objectClassName, nativePackageId, view }) =>
164-
!view &&
163+
name: ({ objectClassName, nativePackageId, isView }) =>
164+
!isView &&
165165
`${platform}/src/main/java/${nativePackageId.split('.').join('/')}/${objectClassName}Module.java`,
166-
content: ({ objectClassName, nativePackageId, view }) =>
167-
!view &&
166+
content: ({ objectClassName, nativePackageId, isView }) =>
167+
!isView &&
168168
`// ${objectClassName}Module.java
169169
170170
package ${nativePackageId};
@@ -197,11 +197,11 @@ public class ${objectClassName}Module extends ReactContextBaseJavaModule {
197197
`,
198198
}, {
199199
// manager for view:
200-
name: ({ objectClassName, nativePackageId, view }) =>
201-
view &&
200+
name: ({ objectClassName, nativePackageId, isView }) =>
201+
isView &&
202202
`${platform}/src/main/java/${nativePackageId.split('.').join('/')}/${objectClassName}Manager.java`,
203-
content: ({ objectClassName, nativePackageId, view }) =>
204-
view &&
203+
content: ({ objectClassName, nativePackageId, isView }) =>
204+
isView &&
205205
`// ${objectClassName}Manager.java
206206
207207
package ${nativePackageId};
@@ -233,11 +233,11 @@ public class ${objectClassName}Manager extends SimpleViewManager<View> {
233233
`,
234234
}, {
235235
// package for module without view:
236-
name: ({ objectClassName, nativePackageId, view }) =>
237-
!view &&
236+
name: ({ objectClassName, nativePackageId, isView }) =>
237+
!isView &&
238238
`${platform}/src/main/java/${nativePackageId.split('.').join('/')}/${objectClassName}Package.java`,
239-
content: ({ objectClassName, nativePackageId, view }) =>
240-
!view &&
239+
content: ({ objectClassName, nativePackageId, isView }) =>
240+
!isView &&
241241
`// ${objectClassName}Package.java
242242
243243
package ${nativePackageId};
@@ -265,11 +265,11 @@ public class ${objectClassName}Package implements ReactPackage {
265265
`,
266266
}, {
267267
// package for manager for view:
268-
name: ({ objectClassName, nativePackageId, view }) =>
269-
view &&
268+
name: ({ objectClassName, nativePackageId, isView }) =>
269+
isView &&
270270
`${platform}/src/main/java/${nativePackageId.split('.').join('/')}/${objectClassName}Package.java`,
271-
content: ({ objectClassName, nativePackageId, view }) =>
272-
view &&
271+
content: ({ objectClassName, nativePackageId, isView }) =>
272+
isView &&
273273
`// ${objectClassName}Package.java
274274
275275
package ${nativePackageId};

templates/example.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ module.exports = {
189189
`,
190190
}, {
191191
name: ({ exampleName }) => `${exampleName}/App.js`,
192-
content: ({ packageName, objectClassName, view }) =>
192+
content: ({ packageName, objectClassName, isView }) =>
193193
`/**
194194
* Sample React Native App
195195
*
@@ -203,7 +203,7 @@ module.exports = {
203203
import React, { Component } from 'react';
204204
import { Platform, StyleSheet, Text, View } from 'react-native';
205205
import ${objectClassName} from '${packageName}';` +
206-
(!view
206+
(!isView
207207
? `
208208
209209
export default class App extends Component<{}> {

templates/general.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ${objectClassName};
7777
}
7878
}, {
7979
// for module without view:
80-
name: ({ view }) => !view && 'index.js',
80+
name: ({ isView }) => !isView && 'index.js',
8181
content: ({ objectClassName }) =>
8282
`// main index.js
8383
@@ -89,7 +89,7 @@ export default ${objectClassName};
8989
`,
9090
}, {
9191
// for module with view:
92-
name: ({ view }) => view && 'index.js',
92+
name: ({ isView }) => isView && 'index.js',
9393
content: ({ objectClassName }) =>
9494
`// main index.js
9595

templates/ios.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ end
3434
`,
3535
}, {
3636
// header for module without view:
37-
name: ({ objectClassName, view }) => !view && `${platform}/${objectClassName}.h`,
37+
name: ({ objectClassName, isView }) => !isView && `${platform}/${objectClassName}.h`,
3838
content: ({ objectClassName }) => `// ${objectClassName}.h
3939
4040
#import <React/RCTBridgeModule.h>
@@ -45,7 +45,7 @@ end
4545
`,
4646
}, {
4747
// implementation of module without view:
48-
name: ({ objectClassName, view }) => !view && `${platform}/${objectClassName}.m`,
48+
name: ({ objectClassName, isView }) => !isView && `${platform}/${objectClassName}.m`,
4949
content: ({ objectClassName, useAppleNetworking }) => `// ${objectClassName}.m
5050
5151
#import "${objectClassName}.h"
@@ -79,7 +79,7 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
7979
`,
8080
}, {
8181
// header for module with view:
82-
name: ({ objectClassName, view }) => view && `${platform}/${objectClassName}.h`,
82+
name: ({ objectClassName, isView }) => isView && `${platform}/${objectClassName}.h`,
8383
content: ({ objectClassName }) => `// ${objectClassName}.h
8484
8585
#import <React/RCTViewManager.h>
@@ -90,7 +90,7 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
9090
`,
9191
}, {
9292
// implementation of module with view:
93-
name: ({ objectClassName, view }) => view && `${platform}/${objectClassName}.m`,
93+
name: ({ objectClassName, isView }) => isView && `${platform}/${objectClassName}.m`,
9494
content: ({ objectClassName }) => `// ${objectClassName}.m
9595
9696
#import "${objectClassName}.h"

tests/integration/cli/create/view/cli-create-with-view.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test('CLI creates correct view module package artifacts on file system using `--
1515
// remove test artifacts just in case:
1616
await fs.remove(modulePackageName);
1717

18-
await execa.command(`node ${path.resolve('bin/cli.js')} --view ${name}`);
18+
await execa.command(`node ${path.resolve('bin/cli.js')} --is-view ${name}`);
1919

2020
const filesUnsorted = await readdirs(modulePackageName);
2121

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ creates a React Native library module for one or more platforms
88
Options:
99
-V, --version output the version number
1010
--package-name [packageName] The full 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
11+
--is-view Generate the package as a very simple native view component. Status: EXPERIMENTAL, with limited testing.
1212
--object-class-name [objectClassName] The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase)
1313
--native-package-id [nativePackageId] [Android] The native Java package identifier used for Android (default: \\"com.reactlibrary\\")
1414
--platforms <platforms> Platforms the library module will be created for - comma separated (default: \\"ios,android\\")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ creates a React Native library module for one or more platforms
88
Options:
99
-V, --version output the version number
1010
--package-name [packageName] The full 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
11+
--is-view Generate the package as a very simple native view component. Status: EXPERIMENTAL, with limited testing.
1212
--object-class-name [objectClassName] The name of the object class to be exported by both JavaScript and native code. Default: (name in PascalCase)
1313
--native-package-id [nativePackageId] [Android] The native Java package identifier used for Android (default: \\"com.reactlibrary\\")
1414
--platforms <platforms> Platforms the library module will be created for - comma separated (default: \\"ios,android\\")

0 commit comments

Comments
 (0)