create-react-native-module
Advanced tools
Comparing version 0.11.1 to 0.12.0
@@ -7,3 +7,3 @@ const emoji = require('node-emoji'); | ||
const postCreateInstructions = ({ moduleName, useCocoapods, exampleName }) => { | ||
const postCreateInstructions = ({ moduleName, exampleName, writeExamplePodfile }) => { | ||
return ` | ||
@@ -17,7 +17,6 @@ ==================================================== | ||
yarn | ||
${useCocoapods ? `cd ios | ||
pod install | ||
cd ios | ||
pod install # ${writeExamplePodfile ? `required` : `required starting with React Native 0.60`} | ||
cd .. | ||
` | ||
: ``}react-native run-ios | ||
react-native run-ios | ||
---- | ||
@@ -81,2 +80,5 @@ `; | ||
}, { | ||
command: '--tvos-enabled', | ||
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)', | ||
}, { | ||
command: '--github-account [githubAccount]', | ||
@@ -101,4 +103,4 @@ description: 'The github account where the library module is hosted', | ||
}, { | ||
command: '--use-cocoapods', | ||
description: '[iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: Use `AFNetworking` dependency as a sample in the podspec; use it from the iOS code & add `ios/Podfile` to generated example', | ||
command: '--use-apple-networking', | ||
description: '[iOS] Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code', | ||
}, { | ||
@@ -115,3 +117,6 @@ command: '--generate-example', | ||
default: 'react-native@0.59', | ||
}, { | ||
command: '--write-example-podfile', | ||
description: '[iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile', | ||
}] | ||
}; |
@@ -30,3 +30,2 @@ // Node.js built-in: | ||
const DEFAULT_LICENSE = 'MIT'; | ||
const DEFAULT_USE_COCOAPODS = false; | ||
const DEFAULT_GENERATE_EXAMPLE = false; | ||
@@ -74,2 +73,3 @@ const DEFAULT_EXAMPLE_NAME = 'example'; | ||
platforms = DEFAULT_PLATFORMS, | ||
tvosEnabled = false, | ||
githubAccount = DEFAULT_GITHUB_ACCOUNT, | ||
@@ -80,6 +80,7 @@ authorName = DEFAULT_AUTHOR_NAME, | ||
view = false, | ||
useCocoapods = DEFAULT_USE_COCOAPODS, | ||
useAppleNetworking = false, | ||
generateExample = DEFAULT_GENERATE_EXAMPLE, | ||
exampleName = DEFAULT_EXAMPLE_NAME, | ||
exampleReactNativeVersion = DEFAULT_EXAMPLE_REACT_NATIVE_VERSION, | ||
writeExamplePodfile = false, | ||
}, { | ||
@@ -107,2 +108,3 @@ fs = fsExtra, // (this can be mocked out for testing purposes) | ||
platforms: ${platforms} | ||
tvosEnabled: ${tvosEnabled} | ||
githubAccount: ${githubAccount} | ||
@@ -113,5 +115,6 @@ authorName: ${authorName} | ||
view: ${view} | ||
useCocoapods: ${useCocoapods} | ||
useAppleNetworking: ${useAppleNetworking} | ||
generateExample: ${generateExample} | ||
exampleName: ${exampleName} | ||
writeExamplePodfile: ${writeExamplePodfile} | ||
`); | ||
@@ -166,2 +169,3 @@ | ||
platforms, | ||
tvosEnabled, | ||
githubAccount, | ||
@@ -172,3 +176,3 @@ authorName, | ||
view, | ||
useCocoapods, | ||
useAppleNetworking, | ||
generateExample, | ||
@@ -210,4 +214,5 @@ exampleName, | ||
view, | ||
useCocoapods, | ||
useAppleNetworking, | ||
exampleName, | ||
writeExamplePodfile, | ||
}; | ||
@@ -214,0 +219,0 @@ |
{ | ||
"name": "create-react-native-module", | ||
"version": "0.11.1", | ||
"version": "0.12.0", | ||
"description": "Tool to create a React Native library module or view module with a single command", | ||
@@ -44,3 +44,3 @@ "bin": "bin/cli.js", | ||
"commander": "^3.0.1", | ||
"execa": "^2.0.4", | ||
"execa": "^3.3.0", | ||
"fs-extra": "^8.1.0", | ||
@@ -47,0 +47,0 @@ "jsonfile": "^5.0.0", |
@@ -31,3 +31,3 @@ # create-react-native-module | ||
- **React Native versions supported:** | ||
- recommended: `0.60`, `0.61-rc` (see known quirks and issues below) | ||
- recommended: `0.61`, `0.60` (see known quirks and issues below) | ||
- outdated: `0.59` | ||
@@ -38,4 +38,8 @@ - Known quirks & issues on React Native 0.60(+): | ||
- React Native 0.60(+) currently not supported by Expo or react-native-windows | ||
- Platform fork support | ||
- tvOS platform fork | ||
- requires use of `--tvos-enabled` option as documented below | ||
- requires the [`react-native-tvos`](https://www.npmjs.com/package/react-native-tvos) fork, with minimum version of 0.60 ref: [react-native-community/react-native-tvos#11](https://github.com/react-native-community/react-native-tvos/issues/11)), [issue #95](https://github.com/brodybits/create-react-native-module/issues/95) | ||
- 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)) | ||
- Out-of-tree platform support | ||
- tvOS platform support - unstable with very limited testing, minimum react-native-tvos version is 0.60 (see [issue #95](https://github.com/brodybits/create-react-native-module/issues/95)) | ||
- Windows - unstable (not tested, see [issue #23](https://github.com/brodybits/create-react-native-module/issues/23)); now deprecated and may be removed in the near future (see [issue #43](https://github.com/brodybits/create-react-native-module/issues/43)) | ||
@@ -101,2 +105,3 @@ - for future consideration: macOS (see [issue #94](https://github.com/brodybits/create-react-native-module/issues/94)) | ||
--platforms <platforms> Platforms the library module will be created for - comma separated (Default: `ios,android`) | ||
--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) | ||
--github-account <githubAccount> The github account where the library module is hosted (Default: `github_account`) | ||
@@ -107,6 +112,7 @@ --author-name <authorName> The author's name (Default: `Your Name`) | ||
--view Generate the module as a very simple native view component | ||
--use-cocoapods [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: Use `AFNetworking` dependency as a sample in the podspec; use it from the iOS code & add `ios/Podfile` to generated example | ||
--use-apple-networking [iOS] Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code | ||
--generate-example Generate an example project and links the library module to it, requires both react-native-cli and yarn to be installed globally | ||
--example-name <exampleName> Name for the example project (default: `example`) | ||
--example-react-native-version <version> React Native version for the generated example project (default: `react-native@0.59`) | ||
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile | ||
-h, --help output usage information | ||
@@ -137,2 +143,3 @@ ``` | ||
packageIdentifier: String, /* [Android] The Java package identifier used by the Android module (Default: com.reactlibrary) */ | ||
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) */ | ||
githubAccount: String, /* The github account where the library is hosted (Default: `github_account`) */ | ||
@@ -142,3 +149,3 @@ authorName: String, /* The author's name (Default: `Your Name`) */ | ||
license: String, /* The license type of this library (Default: `MIT`) */ | ||
useCocoapods: Boolean, /* [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: Use `AFNetworking` dependency as a sample in the podspec; use it from the iOS code & add `ios/Podfile` to generated example (Default: false) */ | ||
useAppleNetworking: Boolean, /* [iOS] Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code (Default: false) */ | ||
view: Boolean, /* Generate the module as a very simple native view component (Default: false) */ | ||
@@ -148,2 +155,3 @@ generateExample: Boolean, /* Generate an example project and links the library module to it, requires both react-native-cli and yarn to be installed globally (Default: false) */ | ||
exampleReactNativeVersion: String, /* React Native version for the generated example project (Default: `react-native@0.59`) */ | ||
writeExamplePodfile: Boolean, /* [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile (Default: false) */ | ||
} | ||
@@ -150,0 +158,0 @@ ``` |
@@ -5,2 +5,17 @@ module.exports = platform => [{ | ||
// based on: | ||
// | ||
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle | ||
// original location: | ||
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle | ||
// | ||
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle | ||
// original location: | ||
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle | ||
def DEFAULT_COMPILE_SDK_VERSION = 28 | ||
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3' | ||
def DEFAULT_MIN_SDK_VERSION = 16 | ||
def DEFAULT_TARGET_SDK_VERSION = 28 | ||
def safeExtGet(prop, fallback) { | ||
@@ -10,2 +25,5 @@ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'maven' | ||
buildscript { | ||
@@ -15,2 +33,3 @@ // The Android Gradle plugin is only required when opening the android folder stand-alone. | ||
// module dependency in an application project. | ||
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies | ||
if (project == rootProject) { | ||
@@ -30,10 +49,2 @@ repositories { | ||
// Matches values in recent template from React Native 0.59 / 0.60 | ||
// https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L5-L9 | ||
// https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L5-L9 | ||
def DEFAULT_COMPILE_SDK_VERSION = 28 | ||
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3" | ||
def DEFAULT_MIN_SDK_VERSION = 16 | ||
def DEFAULT_TARGET_SDK_VERSION = 28 | ||
android { | ||
@@ -54,2 +65,3 @@ compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) | ||
repositories { | ||
// ref: https://www.baeldung.com/maven-local-repository | ||
mavenLocal() | ||
@@ -69,4 +81,2 @@ maven { | ||
dependencies { | ||
// ref: | ||
// https://github.com/facebook/react-native/blob/0.61-stable/template/android/app/build.gradle#L192 | ||
//noinspection GradleDynamicVersion | ||
@@ -73,0 +83,0 @@ implementation 'com.facebook.react:react-native:+' // From node_modules |
@@ -117,4 +117,4 @@ module.exports = [{ | ||
}, { | ||
name: ({ useCocoapods, exampleName }) => | ||
useCocoapods ? `${exampleName}/ios/Podfile` : undefined, | ||
name: ({ exampleName, writeExamplePodfile }) => | ||
writeExamplePodfile ? `${exampleName}/ios/Podfile` : undefined, | ||
content: ({ moduleName, exampleName }) => `platform :ios, '10.0' | ||
@@ -124,3 +124,3 @@ | ||
rn_path = '../node_modules/react-native' | ||
pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec" | ||
@@ -149,3 +149,3 @@ pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec" | ||
] | ||
pod '${moduleName}', :path => '../../${moduleName}.podspec' | ||
@@ -152,0 +152,0 @@ end |
module.exports = [{ | ||
name: () => 'README.md', | ||
content: ({ moduleName, packageIdentifier, name, namespace, platforms }) => { | ||
let manualInstallation = ''; | ||
content: ({ moduleName, name }) => | ||
`# ${moduleName} | ||
if (platforms.indexOf('ios') >= 0) { | ||
manualInstallation += ` | ||
#### iOS | ||
1. In XCode, in the project navigator, right click \`Libraries\` ➜ \`Add Files to [your project's name]\` | ||
2. Go to \`node_modules\` ➜ \`${moduleName}\` and add \`${name}.xcodeproj\` | ||
3. In XCode, in the project navigator, select your project. Add \`lib${name}.a\` to your project's \`Build Phases\` ➜ \`Link Binary With Libraries\` | ||
4. Run your project (\`Cmd+R\`)< | ||
`; | ||
} | ||
if (platforms.indexOf('android') >= 0) { | ||
manualInstallation += ` | ||
#### Android | ||
1. Open up \`android/app/src/main/java/[...]/MainApplication.java\` | ||
- Add \`import ${packageIdentifier}.${name}Package;\` to the imports at the top of the file | ||
- Add \`new ${name}Package()\` to the list returned by the \`getPackages()\` method | ||
2. Append the following lines to \`android/settings.gradle\`: | ||
\`\`\` | ||
include ':${moduleName}' | ||
project(':${moduleName}').projectDir = new File(rootProject.projectDir, '../node_modules/${moduleName}/android') | ||
\`\`\` | ||
3. Insert the following lines inside the dependencies block in \`android/app/build.gradle\`: | ||
\`\`\` | ||
compile project(':${moduleName}') | ||
\`\`\` | ||
`; | ||
} | ||
if (platforms.indexOf('windows') >= 0) { | ||
manualInstallation += ` | ||
#### Windows | ||
[Read it! :D](https://github.com/ReactWindows/react-native) | ||
1. In Visual Studio add the \`${name}.sln\` in \`node_modules/${moduleName}/windows/${name}.sln\` folder to their solution, reference from their app. | ||
2. Open up your \`MainPage.cs\` app | ||
- Add \`using ${namespace}.${name};\` to the usings at the top of the file | ||
- Add \`new ${name}Package()\` to the \`List<IReactPackage>\` returned by the \`Packages\` method | ||
`; | ||
} | ||
return `# ${moduleName} | ||
## Getting started | ||
@@ -58,6 +14,2 @@ | ||
### Manual installation | ||
${manualInstallation} | ||
## Usage | ||
@@ -70,4 +22,3 @@ \`\`\`javascript | ||
\`\`\` | ||
`; | ||
}, | ||
`, | ||
}, { | ||
@@ -74,0 +25,0 @@ name: () => 'package.json', |
module.exports = platform => [{ | ||
name: ({ moduleName }) => `${moduleName}.podspec`, | ||
content: ({ moduleName, githubAccount, authorName, authorEmail, useCocoapods }) => `require "json" | ||
content: ({ moduleName, tvosEnabled, githubAccount, authorName, authorEmail, useAppleNetworking }) => `require "json" | ||
@@ -18,3 +18,3 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json"))) | ||
s.authors = { "${authorName}" => "${authorEmail}" } | ||
s.platforms = { :ios => "9.0", :tvos => "10.0" } | ||
s.platforms = { :ios => "9.0"${tvosEnabled ? `, :tvos => "10.0"` : ``} } | ||
s.source = { :git => "https://github.com/${githubAccount}/${moduleName}.git", :tag => "#{s.version}" } | ||
@@ -26,3 +26,3 @@ | ||
s.dependency "React" | ||
${useCocoapods ? `s.dependency 'AFNetworking', '~> 3.0'` : ``} | ||
${useAppleNetworking ? `s.dependency 'AFNetworking', '~> 3.0'` : `# ...`} | ||
# s.dependency "..." | ||
@@ -44,5 +44,5 @@ end | ||
name: ({ name, view }) => !view && `${platform}/${name}.m`, | ||
content: ({ name, useCocoapods }) => `#import "${name}.h" | ||
content: ({ name, useAppleNetworking }) => `#import "${name}.h" | ||
${useCocoapods ? `#import <AFNetworking/AFNetworking.h> | ||
${useAppleNetworking ? `#import <AFNetworking/AFNetworking.h> | ||
` : ``} | ||
@@ -54,6 +54,7 @@ @implementation ${name} | ||
RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnull NSNumber *)numberArgument callback:(RCTResponseSenderBlock)callback) | ||
{ | ||
// TODO: Implement some actually useful functionality | ||
${useCocoapods | ||
? `AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; | ||
` + | ||
// sample method body with tabs for truthy useAppleNetworking *only*: | ||
(useAppleNetworking | ||
? `{ | ||
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; | ||
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"]; | ||
@@ -64,5 +65,8 @@ [manager GET:@"https://httpstat.us/200" parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) { | ||
callback(@[[NSString stringWithFormat: @"numberArgument: %@ stringArgument: %@ err: %@", numberArgument, stringArgument, error]]); | ||
}];` | ||
: `callback(@[[NSString stringWithFormat: @"numberArgument: %@ stringArgument: %@", numberArgument, stringArgument]]);`} | ||
} | ||
}]; | ||
}` | ||
: `{ | ||
// TODO: Implement some actually useful functionality | ||
callback(@[[NSString stringWithFormat: @"numberArgument: %@ stringArgument: %@", numberArgument, stringArgument]]); | ||
}`) + ` | ||
@@ -69,0 +73,0 @@ @end |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85174
269
1885
+ Addedexeca@3.4.0(transitive)
+ Addedhuman-signals@1.1.1(transitive)
+ Addednpm-run-path@4.0.1(transitive)
- Removedexeca@2.1.0(transitive)
- Removednpm-run-path@3.1.0(transitive)
Updatedexeca@^3.3.0