Skip to content

Commit

Permalink
support React Native 0.61; drop React Native 0.59 (#244)
Browse files Browse the repository at this point in the history
* generate example with React Native 0.61 by default
* remove `react-native link` step (not needed since React Native 0.60)
* prep: test with generate example for Android only
  (needed to help ensure `pod install` is not run on example,
   in case the module is for Android only)
* do `pod install` in generated example for iOS
* remove `pod install` step from manual post-create instructions
* update generated Android view for React Native 0.60(+)
* update template `devDependencies` for React Native 0.61
* minimum React Native 0.60 in template `peerDependencies`
* documentation updates
* update documentation for out-of-tree platforms
  (not supported by the generated example)
  • Loading branch information
brodycj authored Feb 13, 2020
1 parent 77f14cd commit 1f105df
Show file tree
Hide file tree
Showing 44 changed files with 875 additions and 182 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,15 @@ This tool based on [`react-native-create-library`](https://www.npmjs.com/package
### General status

- **React Native versions supported:**
- recommended: `0.61`, `0.60` (see known quirks and issues below)
- outdated: `0.59`
- Known quirks & issues on React Native 0.60(+):
- [issue #99](https://github.com/brodybits/create-react-native-module/issues/99) - additional `pod install` step needed for RN 0.60 on iOS
- [issue #29](https://github.com/brodybits/create-react-native-module/issues/29) - View does not work with RN 0.60 on Android (quick patch needed)
- React Native 0.60(+) currently not supported by Expo or react-native-windows
- recommended: `0.61`
- minimum (outdated): `0.60`
- 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
- Out-of-tree platforms
- not supported by generated example
- 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))
- for future consideration: macOS (see [issue #94](https://github.com/brodybits/create-react-native-module/issues/94))
- Node.js pre-10 support is deprecated and will be removed in the near future (see [issue #38](https://github.com/brodybits/create-react-native-module/issues/38))
Expand Down Expand Up @@ -109,7 +106,7 @@ Options:
--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`)
--example-react-native-version <version> React Native version for the generated example project (default: `react-native@0.61`)
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile
-h, --help output usage information
```
Expand Down
7 changes: 2 additions & 5 deletions lib/cli-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const normalizedOptions = require('./normalized-options');

const createLibraryModule = require('./lib');

const postCreateInstructions = ({ moduleName, exampleName, writeExamplePodfile }) => {
const postCreateInstructions = ({ moduleName, exampleName }) => {
return `
====================================================
YOU'RE ALL SET!
Expand All @@ -13,9 +13,6 @@ To build and run iOS example project, do:
----
cd ${moduleName}/${exampleName}
yarn
cd ios
pod install # ${writeExamplePodfile ? `required` : `required starting with React Native 0.60`}
cd ..
react-native run-ios
----
`;
Expand Down Expand Up @@ -109,7 +106,7 @@ ${postCreateInstructions(createOptions)}`);
}, {
command: '--example-react-native-version [exampleReactNativeVersion]',
description: 'React Native version for the generated example project',
default: 'react-native@0.59',
default: 'react-native@0.61',
}, {
command: '--write-example-podfile',
description: '[iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile',
Expand Down
38 changes: 36 additions & 2 deletions lib/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const DEFAULT_AUTHOR_EMAIL = 'yourname@email.com';
const DEFAULT_LICENSE = 'MIT';
const DEFAULT_GENERATE_EXAMPLE = false;
const DEFAULT_EXAMPLE_NAME = 'example';
const DEFAULT_EXAMPLE_REACT_NATIVE_VERSION = 'react-native@0.59';
const DEFAULT_EXAMPLE_REACT_NATIVE_VERSION = 'react-native@0.61';

const renderTemplateIfValid = (fs, root, template, templateArgs) => {
// avoid throwing an exception in case there is no valid template.name member
Expand Down Expand Up @@ -142,6 +142,9 @@ const generateWithNormalizedOptions = ({
throw new Error(
`${yarnVersionCommand} failed; ${errorRemedyMessage}`);
}

// NOTE: While the pod tool is also required for example on iOS,
// react-native CLI will help the user install this tool if needed.
}

console.info('CREATE: Generating the React Native library module');
Expand Down Expand Up @@ -235,8 +238,39 @@ const generateWithNormalizedOptions = ({
console.error('Yarn failure for example, aborting');
throw (e);
}
commandSync('react-native link', addLinkLibraryOptions);

// Since React Native 0.60, pod install must be done (again)
// after adding the native library to the generated example.
if (platforms.indexOf('ios') !== -1) {
const iosExampleAppProjectPath =
`${pathExampleApp}/ios`;

const podCommandOptions = {
cwd: iosExampleAppProjectPath,
stdio: 'inherit'
};

// pod tool is needed at this point for iOS
try {
console.log(
`check for valid pod version in ${iosExampleAppProjectPath}`);

commandSync('pod --version', podCommandOptions);
} catch (e) {
console.error('pod --version failure, aborting with broken example app');
throw (e);
}

console.log(
`running pod install in ${iosExampleAppProjectPath}`);

try {
commandSync('pod install', podCommandOptions);
} catch (e) {
console.error('pod install failure, aborting with broken example app');
throw (e);
}
}
return resolve();
});
});
Expand Down
5 changes: 1 addition & 4 deletions templates/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,7 @@ public class ${name}Module extends ReactContextBaseJavaModule {
import android.view.View;
// AppCompatCheckBox import for React Native pre-0.60:
import android.support.v7.widget.AppCompatCheckBox;
// AppCompatCheckBox import for React Native 0.60(+):
// import androidx.appcompat.widget.AppCompatCheckBox;
import androidx.appcompat.widget.AppCompatCheckBox;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
Expand Down
10 changes: 5 additions & 5 deletions templates/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ ${name};
const peerDependencies =
`{
"react": "^16.8.1",
"react-native": ">=0.59.0-rc.0 <1.0.x"` +
"react-native": ">=0.60.0-rc.0 <1.0.x"` +
(withWindows
? `,
"react-native-windows": ">=0.59.0-rc.0 <1.0.x"`
"react-native-windows": ">=0.60.0-0 <1.0.x"`
: ``) + `
}`;

const devDependencies =
`{
"react": "^16.8.3",
"react-native": "^0.59.10"` +
"react": "^16.9.0",
"react-native": "^0.61.5"` +
(withWindows
? `,
"react-native-windows": "^0.59.0-rc.1"`
"react-native-windows": "^0.61.0-beta.5"`
: ``) + `
}`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,7 @@ afterEvaluate { project ->
import android.view.View;
// AppCompatCheckBox import for React Native pre-0.60:
import android.support.v7.widget.AppCompatCheckBox;
// AppCompatCheckBox import for React Native 0.60(+):
// import androidx.appcompat.widget.AppCompatCheckBox;
import androidx.appcompat.widget.AppCompatCheckBox;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
Expand Down Expand Up @@ -672,11 +669,11 @@ RCT_EXPORT_MODULE()
\\"readmeFilename\\": \\"README.md\\",
\\"peerDependencies\\": {
\\"react\\": \\"^16.8.1\\",
\\"react-native\\": \\">=0.59.0-rc.0 <1.0.x\\"
\\"react-native\\": \\">=0.60.0-rc.0 <1.0.x\\"
},
\\"devDependencies\\": {
\\"react\\": \\"^16.8.3\\",
\\"react-native\\": \\"^0.59.10\\"
\\"react\\": \\"^16.9.0\\",
\\"react-native\\": \\"^0.61.5\\"
}
}
",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,11 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
\\"readmeFilename\\": \\"README.md\\",
\\"peerDependencies\\": {
\\"react\\": \\"^16.8.1\\",
\\"react-native\\": \\">=0.59.0-rc.0 <1.0.x\\"
\\"react-native\\": \\">=0.60.0-rc.0 <1.0.x\\"
},
\\"devDependencies\\": {
\\"react\\": \\"^16.8.3\\",
\\"react-native\\": \\"^0.59.10\\"
\\"react\\": \\"^16.9.0\\",
\\"react-native\\": \\"^0.61.5\\"
}
}
",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Options:
--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 [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@0.59\\")
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@0.61\\")
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile
-h, --help output usage information"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Options:
--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 [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@0.59\\")
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@0.61\\")
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile
-h, --help output usage information"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Object {
},
Object {
"command": "--example-react-native-version [exampleReactNativeVersion]",
"default": "react-native@0.59",
"default": "react-native@0.61",
"description": "React Native version for the generated example project",
},
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ content:
\\"readmeFilename\\": \\"README.md\\",
\\"peerDependencies\\": {
\\"react\\": \\"^16.8.1\\",
\\"react-native\\": \\">=0.59.0-rc.0 <1.0.x\\"
\\"react-native\\": \\">=0.60.0-rc.0 <1.0.x\\"
},
\\"devDependencies\\": {
\\"react\\": \\"^16.8.3\\",
\\"react-native\\": \\"^0.59.10\\"
\\"react\\": \\"^16.9.0\\",
\\"react-native\\": \\"^0.61.5\\"
}
}
Expand Down Expand Up @@ -342,10 +342,7 @@ package com.reactlibrary;
import android.view.View;
// AppCompatCheckBox import for React Native pre-0.60:
import android.support.v7.widget.AppCompatCheckBox;
// AppCompatCheckBox import for React Native 0.60(+):
// import androidx.appcompat.widget.AppCompatCheckBox;
import androidx.appcompat.widget.AppCompatCheckBox;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ content:
\\"readmeFilename\\": \\"README.md\\",
\\"peerDependencies\\": {
\\"react\\": \\"^16.8.1\\",
\\"react-native\\": \\">=0.59.0-rc.0 <1.0.x\\"
\\"react-native\\": \\">=0.60.0-rc.0 <1.0.x\\"
},
\\"devDependencies\\": {
\\"react\\": \\"^16.8.3\\",
\\"react-native\\": \\"^0.59.10\\"
\\"react\\": \\"^16.9.0\\",
\\"react-native\\": \\"^0.61.5\\"
}
}
Expand Down Expand Up @@ -347,10 +347,7 @@ package com.reactlibrary;
import android.view.View;
// AppCompatCheckBox import for React Native pre-0.60:
import android.support.v7.widget.AppCompatCheckBox;
// AppCompatCheckBox import for React Native 0.60(+):
// import androidx.appcompat.widget.AppCompatCheckBox;
import androidx.appcompat.widget.AppCompatCheckBox;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
Expand Down Expand Up @@ -782,7 +779,7 @@ content:
<<<<<<<< ======== >>>>>>>>
",
"* execa.commandSync command: react-native init example --version react-native@0.59 options: {\\"cwd\\":\\"./react-native-alice-bobbi\\",\\"stdio\\":\\"inherit\\"}
"* execa.commandSync command: react-native init example --version react-native@0.61 options: {\\"cwd\\":\\"./react-native-alice-bobbi\\",\\"stdio\\":\\"inherit\\"}
",
"* ensureDir dir: react-native-alice-bobbi/scripts/
",
Expand Down Expand Up @@ -983,7 +980,9 @@ const styles = StyleSheet.create({
},
"* execa.commandSync command: yarn add file:../ options: {\\"cwd\\":\\"./react-native-alice-bobbi/example\\",\\"stdio\\":\\"inherit\\"}
",
"* execa.commandSync command: react-native link options: {\\"cwd\\":\\"./react-native-alice-bobbi/example\\",\\"stdio\\":\\"inherit\\"}
"* execa.commandSync command: pod --version options: {\\"cwd\\":\\"./react-native-alice-bobbi/example/ios\\",\\"stdio\\":\\"inherit\\"}
",
"* execa.commandSync command: pod install options: {\\"cwd\\":\\"./react-native-alice-bobbi/example/ios\\",\\"stdio\\":\\"inherit\\"}
",
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ content:
\\"readmeFilename\\": \\"README.md\\",
\\"peerDependencies\\": {
\\"react\\": \\"^16.8.1\\",
\\"react-native\\": \\">=0.59.0-rc.0 <1.0.x\\"
\\"react-native\\": \\">=0.60.0-rc.0 <1.0.x\\"
},
\\"devDependencies\\": {
\\"react\\": \\"^16.8.3\\",
\\"react-native\\": \\"^0.59.10\\"
\\"react\\": \\"^16.9.0\\",
\\"react-native\\": \\"^0.61.5\\"
}
}
Expand Down Expand Up @@ -347,10 +347,7 @@ package com.reactlibrary;
import android.view.View;
// AppCompatCheckBox import for React Native pre-0.60:
import android.support.v7.widget.AppCompatCheckBox;
// AppCompatCheckBox import for React Native 0.60(+):
// import androidx.appcompat.widget.AppCompatCheckBox;
import androidx.appcompat.widget.AppCompatCheckBox;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
Expand Down Expand Up @@ -983,7 +980,9 @@ const styles = StyleSheet.create({
},
"* execa.commandSync command: yarn add file:../ options: {\\"cwd\\":\\"./react-native-alice-bobbi/test-demo\\",\\"stdio\\":\\"inherit\\"}
",
"* execa.commandSync command: react-native link options: {\\"cwd\\":\\"./react-native-alice-bobbi/test-demo\\",\\"stdio\\":\\"inherit\\"}
"* execa.commandSync command: pod --version options: {\\"cwd\\":\\"./react-native-alice-bobbi/test-demo/ios\\",\\"stdio\\":\\"inherit\\"}
",
"* execa.commandSync command: pod install options: {\\"cwd\\":\\"./react-native-alice-bobbi/test-demo/ios\\",\\"stdio\\":\\"inherit\\"}
",
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ content:
\\"readmeFilename\\": \\"README.md\\",
\\"peerDependencies\\": {
\\"react\\": \\"^16.8.1\\",
\\"react-native\\": \\">=0.59.0-rc.0 <1.0.x\\"
\\"react-native\\": \\">=0.60.0-rc.0 <1.0.x\\"
},
\\"devDependencies\\": {
\\"react\\": \\"^16.8.3\\",
\\"react-native\\": \\"^0.59.10\\"
\\"react\\": \\"^16.9.0\\",
\\"react-native\\": \\"^0.61.5\\"
}
}
Expand Down Expand Up @@ -311,10 +311,7 @@ package com.reactlibrary;
import android.view.View;
// AppCompatCheckBox import for React Native pre-0.60:
import android.support.v7.widget.AppCompatCheckBox;
// AppCompatCheckBox import for React Native 0.60(+):
// import androidx.appcompat.widget.AppCompatCheckBox;
import androidx.appcompat.widget.AppCompatCheckBox;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ content:
\\"readmeFilename\\": \\"README.md\\",
\\"peerDependencies\\": {
\\"react\\": \\"^16.8.1\\",
\\"react-native\\": \\">=0.59.0-rc.0 <1.0.x\\"
\\"react-native\\": \\">=0.60.0-rc.0 <1.0.x\\"
},
\\"devDependencies\\": {
\\"react\\": \\"^16.8.3\\",
\\"react-native\\": \\"^0.59.10\\"
\\"react\\": \\"^16.9.0\\",
\\"react-native\\": \\"^0.61.5\\"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ content:
\\"readmeFilename\\": \\"README.md\\",
\\"peerDependencies\\": {
\\"react\\": \\"^16.8.1\\",
\\"react-native\\": \\">=0.59.0-rc.0 <1.0.x\\"
\\"react-native\\": \\">=0.60.0-rc.0 <1.0.x\\"
},
\\"devDependencies\\": {
\\"react\\": \\"^16.8.3\\",
\\"react-native\\": \\"^0.59.10\\"
\\"react\\": \\"^16.9.0\\",
\\"react-native\\": \\"^0.61.5\\"
}
}
Expand Down
Loading

0 comments on commit 1f105df

Please sign in to comment.