Skip to content

Commit 1f78dc4

Browse files
author
Chris Brody
authored
[...] make tvOS support optional (#126)
* make tvOS support optional (tvOS not enabled by default) with the requirements included in the --tvos-enabled option description
1 parent a7ec673 commit 1f78dc4

File tree

35 files changed

+69
-19
lines changed

35 files changed

+69
-19
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ This tool based on [`react-native-create-library`](https://www.npmjs.com/package
3636
- React Native 0.60(+) currently not supported by Expo or react-native-windows
3737
- Platform fork support
3838
- tvOS platform support
39+
- requires use of `--tvos-enabled` option as documented below
3940
- 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))
4041
- 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))
4142
- minimum react-native-tvos version is 0.60 (see [issue #95](https://github.com/brodybits/create-react-native-module/issues/95))
@@ -100,6 +101,7 @@ Options:
100101
--module-prefix <modulePrefix> The module prefix for the library module, ignored if --module-name is specified (Default: `react-native`)
101102
--package-identifier <packageIdentifier> [Android] The Java package identifier used by the Android module (Default: `com.reactlibrary`)
102103
--platforms <platforms> Platforms the library module will be created for - comma separated (Default: `ios,android`)
104+
--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)
103105
--github-account <githubAccount> The github account where the library module is hosted (Default: `github_account`)
104106
--author-name <authorName> The author's name (Default: `Your Name`)
105107
--author-email <authorEmail> The author's email (Default: `[email protected]`)
@@ -134,6 +136,7 @@ createLibraryModule({
134136
modulePrefix: String, /* The module prefix for the library, 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) */
139+
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) */
137140
githubAccount: String, /* The github account where the library is hosted (Default: `github_account`) */
138141
authorName: String, /* The author's name (Default: `Your Name`) */
139142
authorEmail: String, /* The author's email (Default: `[email protected]`) */

lib/cli-command.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ ${postCreateInstructions(createOptions)}`);
7575
command: '--platforms <platforms>',
7676
description: 'Platforms the library module will be created for - comma separated',
7777
default: 'ios,android',
78+
}, {
79+
command: '--tvos-enabled',
80+
description: 'Generate the module with tvOS build enabled (requires react-native-tvos fork, with minimum version of 0.60, and iOS platform to be enabled)',
7881
}, {
7982
command: '--github-account [githubAccount]',
8083
description: 'The github account where the library module is hosted',

lib/lib.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const generateWithNormalizedOptions = ({
7070
packageIdentifier = DEFAULT_PACKAGE_IDENTIFIER,
7171
namespace,
7272
platforms = DEFAULT_PLATFORMS,
73+
tvosEnabled = false,
7374
githubAccount = DEFAULT_GITHUB_ACCOUNT,
7475
authorName = DEFAULT_AUTHOR_NAME,
7576
authorEmail = DEFAULT_AUTHOR_EMAIL,
@@ -101,6 +102,7 @@ const generateWithNormalizedOptions = ({
101102
modulePrefix: ${modulePrefix}
102103
packageIdentifier: ${packageIdentifier}
103104
platforms: ${platforms}
105+
tvosEnabled: ${tvosEnabled}
104106
githubAccount: ${githubAccount}
105107
authorName: ${authorName}
106108
authorEmail: ${authorEmail}
@@ -158,6 +160,7 @@ const generateWithNormalizedOptions = ({
158160
packageIdentifier,
159161
namespace,
160162
platforms,
163+
tvosEnabled,
161164
githubAccount,
162165
authorName,
163166
authorEmail,

templates/ios.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = platform => [{
22
name: ({ moduleName }) => `${moduleName}.podspec`,
3-
content: ({ moduleName, githubAccount, authorName, authorEmail, useCocoapods }) => `require "json"
3+
content: ({ moduleName, tvosEnabled, githubAccount, authorName, authorEmail, useCocoapods }) => `require "json"
44
55
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
66
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
1515
s.license = "MIT"
1616
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
1717
s.authors = { "${authorName}" => "${authorEmail}" }
18-
s.platforms = { :ios => "9.0", :tvos => "10.0" }
18+
s.platforms = { :ios => "9.0"${tvosEnabled ? `, :tvos => "10.0"` : ``} }
1919
s.source = { :git => "https://github.com/${githubAccount}/${moduleName}.git", :tag => "#{s.version}" }
2020
2121
s.source_files = "ios/**/*.{h,m,swift}"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ Pod::Spec.new do |s|
686686
s.license = \\"MIT\\"
687687
# s.license = { :type => \\"MIT\\", :file => \\"FILE_LICENSE\\" }
688688
s.authors = { \\"Your Name\\" => \\"[email protected]\\" }
689-
s.platforms = { :ios => \\"9.0\\", :tvos => \\"10.0\\" }
689+
s.platforms = { :ios => \\"9.0\\" }
690690
s.source = { :git => \\"https://github.com/github_account/react-native-integration-view-test-package.git\\", :tag => \\"#{s.version}\\" }
691691
692692
s.source_files = \\"ios/**/*.{h,m,swift}\\"

tests/integration/cli/create/with-defaults/__snapshots__/cli-create-with-defaults.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ Pod::Spec.new do |s|
679679
s.license = \\"MIT\\"
680680
# s.license = { :type => \\"MIT\\", :file => \\"FILE_LICENSE\\" }
681681
s.authors = { \\"Your Name\\" => \\"[email protected]\\" }
682-
s.platforms = { :ios => \\"9.0\\", :tvos => \\"10.0\\" }
682+
s.platforms = { :ios => \\"9.0\\" }
683683
s.source = { :git => \\"https://github.com/github_account/react-native-integration-test-package.git\\", :tag => \\"#{s.version}\\" }
684684
685685
s.source_files = \\"ios/**/*.{h,m,swift}\\"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Options:
1212
--module-prefix [modulePrefix] The module prefix for the library module, ignored if --module-name is specified (default: \\"react-native\\")
1313
--package-identifier [packageIdentifier] [Android] The Java package identifier used by the Android module (default: \\"com.reactlibrary\\")
1414
--platforms <platforms> Platforms the library module will be created for - comma separated (default: \\"ios,android\\")
15+
--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)
1516
--github-account [githubAccount] The github account where the library module is hosted (default: \\"github_account\\")
1617
--author-name [authorName] The author's name (default: \\"Your Name\\")
1718
--author-email [authorEmail] The author's email (default: \\"[email protected]\\")

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Options:
1212
--module-prefix [modulePrefix] The module prefix for the library module, ignored if --module-name is specified (default: \\"react-native\\")
1313
--package-identifier [packageIdentifier] [Android] The Java package identifier used by the Android module (default: \\"com.reactlibrary\\")
1414
--platforms <platforms> Platforms the library module will be created for - comma separated (default: \\"ios,android\\")
15+
--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)
1516
--github-account [githubAccount] The github account where the library module is hosted (default: \\"github_account\\")
1617
--author-name [authorName] The author's name (default: \\"Your Name\\")
1718
--author-email [authorEmail] The author's email (default: \\"[email protected]\\")

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Object {
3030
"default": "ios,android",
3131
"description": "Platforms the library module will be created for - comma separated",
3232
},
33+
Object {
34+
"command": "--tvos-enabled",
35+
"description": "Generate the module with tvOS build enabled (requires react-native-tvos fork, with minimum version of 0.60, and iOS platform to be enabled)",
36+
},
3337
Object {
3438
"command": "--github-account [githubAccount]",
3539
"default": "github_account",

tests/with-injection/create/view/with-defaults/__snapshots__/create-view-with-defaults.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ Pod::Spec.new do |s|
425425
s.license = \\"MIT\\"
426426
# s.license = { :type => \\"MIT\\", :file => \\"FILE_LICENSE\\" }
427427
s.authors = { \\"Your Name\\" => \\"[email protected]\\" }
428-
s.platforms = { :ios => \\"9.0\\", :tvos => \\"10.0\\" }
428+
s.platforms = { :ios => \\"9.0\\" }
429429
s.source = { :git => \\"https://github.com/github_account/react-native-alice-bobbi.git\\", :tag => \\"#{s.version}\\" }
430430
431431
s.source_files = \\"ios/**/*.{h,m,swift}\\"

0 commit comments

Comments
 (0)