Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/szhigunov/react-native-npm-version
Example of React-Native application with version from package.json and npm version bump.
https://github.com/szhigunov/react-native-npm-version
example react-native versioning
Last synced: 8 days ago
JSON representation
Example of React-Native application with version from package.json and npm version bump.
- Host: GitHub
- URL: https://github.com/szhigunov/react-native-npm-version
- Owner: szhigunov
- License: gpl-3.0
- Created: 2017-02-21T11:17:40.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-21T13:07:07.000Z (over 7 years ago)
- Last Synced: 2024-08-15T00:20:06.342Z (4 months ago)
- Topics: example, react-native, versioning
- Language: Objective-C
- Size: 107 KB
- Stars: 24
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-react-native - Versioning React Native Application in elegant way (cross-platformely) ★10
- awesome-react-native - Versioning React Native Application in elegant way (cross-platformely) ★10
- awesome-react-native - Versioning React Native Application in elegant way (cross-platformely) ★10
- awesome-react-native - Versioning React Native Application in elegant way (cross-platformely) ★10
README
# react-native-npm-version
## Example of React-Native application with version from package.json and npm version bump.Why not to simpify cross-platform app version increase flow, with only ```npm version``` command ?
This repository provides an sample application, with integrated solution to minimize amount of monkey job with handling `react-native` applications.
-----
Realization consist of few parts:
* some script `./scripts/version.js` which increase version in iOS project file `Info.plist`.
* custom npm scripts `version`.
* extended `./android/build.gradle`
* modified `./android/app/build.gradle`:
-----### To use those solution in your project,
1. add `version` npm script to `scripts` section in your `package.json`:
```json
{
"scripts": {
"version": "node ./scripts/version.js && [[ $(git status --porcelain -z | gawk '/version.json/ && /Info.plist/' ) ]] && git add version.json ios/"
}
```
2. copy `./scripts/version.js` to your project root.
3. extend `./android/app/build.gradle` and `./android/build.gradle` with the following samples:`./android/app/build.gradle`
```gradle
/* ... */
android {
/* ... */
defaultConfig {
// Replace lines with your versionCode and versionName with two lines below
versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
/* ... */
}
/* ... */
}
````./android/build.gradle`
```gradle
subprojects {
ext {
def npmVersion = getNpmVersionArray()
versionMajor = npmVersion[0]
versionMinor = npmVersion[1]
versionPatch = npmVersion[2]
}
}def getNpmVersion() {
def inputFile = new File("../package.json")
def packageJson = new JsonSlurper().parseText(inputFile.text)
return packageJson["version"]
}def getNpmVersionArray() { // major [0], minor [1], patch [2]
def (major, minor, patch) = getNpmVersion().tokenize('.')
return [Integer.parseInt(major), Integer.parseInt(minor), Integer.parseInt(patch)] as int[]
}
```-----
Based on solution by @AndrewJack [https://github.com/AndrewJack/versioning-react-native-app](https://github.com/AndrewJack/versioning-react-native-app).
See [Medium post](https://medium.com/@andr3wjack/versioning-react-native-apps-407469707661)## Requirements
- ``` gawk ``` for macOS - used in `npm run version`
- ``` watchman ``` for macOS
- ``` node ``` higher than **4.2.0**