Skip to content

Commit 16da725

Browse files
committed
prettier
1 parent c04d995 commit 16da725

5 files changed

Lines changed: 115 additions & 102 deletions

File tree

README.md

Lines changed: 108 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,38 @@ This library gets the latest app version by parsing google play store, apple app
1111
Parsing code is referenced from [here](http://itmir.tistory.com/524)
1212

1313
### Looking for maintainers!
14+
1415
I have almost zero experience in ios development, and I am no longer working on mobile app development(doing backend and devops works mainly and some web frontend). It makes it hard to maintain this library actively. Hope to have someone to help maintaining react-native-version-check!
1516

1617
### expo
18+
1719
react-native-version-check supports [expo](https://expo.io)! with [react-native-version-check-expo](https://www.npmjs.com/package/react-native-version-check-expo)
20+
1821
- usage
22+
1923
```js
2024
// import
21-
import VersionCheck from 'react-native-version-check-expo'
25+
import VersionCheck from 'react-native-version-check-expo';
2226

23-
VersionCheck.getCountry().then(country => console.log(country))
27+
VersionCheck.getCountry().then(country => console.log(country));
2428
```
2529

2630
## Getting started
27-
- npm
28-
```bash
29-
$ npm install react-native-version-check
30-
```
31-
- yarn
32-
```bash
33-
$ yarn add react-native-version-check
34-
```
31+
32+
- npm
33+
34+
```bash
35+
$ npm install react-native-version-check
36+
```
37+
38+
- yarn
39+
40+
```bash
41+
$ yarn add react-native-version-check
42+
```
3543

3644
### Example
45+
3746
```bash
3847
$ git clone https://github.com/kimxogus/react-native-version-check.git
3948
$ cd react-native-version-check/example
@@ -42,43 +51,53 @@ $ react-native run-android # or react-native run-ios
4251
```
4352

4453
### Automatic Installation
54+
4555
```bash
4656
$ react-native link react-native-version-check
4757
```
4858

4959
### Manual Installation
60+
5061
#### - iOS - Link Manually
51-
* Add ```.xcodeproj``` file as library to XCode project.
62+
63+
- Add `.xcodeproj` file as library to XCode project.
64+
5265
1. In project navigator, right click Libraries
53-
2. Select ```Add Files to [PROJECT_NAME]```
54-
3. Add the ```node_modules/react-native-version-check/ios/RNVersionCheck.xcodeproj``` file
66+
2. Select `Add Files to [PROJECT_NAME]`
67+
3. Add the `node_modules/react-native-version-check/ios/RNVersionCheck.xcodeproj` file
5568

56-
* Add the ```libRNVersionCheck.a``` from the ```RNVersionCheck``` project to your project's Build Phases > Link Binary With Libraries
69+
- Add the `libRNVersionCheck.a` from the `RNVersionCheck` project to your project's Build Phases > Link Binary With Libraries
5770

5871
#### iOS - CocoaPods Package Manager
59-
* Add to your `Podfile` (assuming it's in `ios/Podfile`):
72+
73+
- Add to your `Podfile` (assuming it's in `ios/Podfile`):
6074
```ruby
6175
pod 'react-native-version-check', :path => '../node_modules/react-native-version-check'
6276
```
63-
* Reinstall pod with `cd ios && pod install && cd ..`
77+
- Reinstall pod with `cd ios && pod install && cd ..`
6478

6579
#### - Android
6680

67-
* Append the following lines to `android/settings.gradle`:
81+
- Append the following lines to `android/settings.gradle`:
82+
6883
```gradle
6984
...
7085
include ':react-native-version-check'
7186
project(':react-native-version-check').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-version-check/android')
7287
```
73-
* Insert the following lines inside the dependencies block in `android/app/build.gradle`:
88+
89+
- Insert the following lines inside the dependencies block in `android/app/build.gradle`:
90+
7491
```gradle
7592
...
7693
dependencies {
7794
...
7895
compile project(':react-native-version-check')
7996
}
8097
```
81-
* Open up `android/app/src/main/java/[...]/MainApplication.java`
98+
99+
- Open up `android/app/src/main/java/[...]/MainApplication.java`
100+
82101
```java
83102
......
84103
import io.xogus.reactnative.versioncheck.RNVersionCheckPackage; // <--- HERE
@@ -94,79 +113,75 @@ protected List<ReactPackage> getPackages() {
94113
```
95114

96115
## Usage
116+
97117
```javascript
98118
import { Linking } from 'react-native';
99119
import VersionCheck from 'react-native-version-check';
100120

101-
VersionCheck.getCountry()
102-
.then(country => console.log(country)); // KR
103-
console.log(VersionCheck.getPackageName()); // com.reactnative.app
121+
VersionCheck.getCountry().then(country => console.log(country)); // KR
122+
console.log(VersionCheck.getPackageName()); // com.reactnative.app
104123
console.log(VersionCheck.getCurrentBuildNumber()); // 10
105-
console.log(VersionCheck.getCurrentVersion()); // 0.1.1
124+
console.log(VersionCheck.getCurrentVersion()); // 0.1.1
106125

107-
VersionCheck.getLatestVersion()
108-
.then(latestVersion => {
109-
console.log(latestVersion); // 0.1.2
110-
});
126+
VersionCheck.getLatestVersion().then(latestVersion => {
127+
console.log(latestVersion); // 0.1.2
128+
});
111129

112130
VersionCheck.getLatestVersion({
113-
provider: 'appStore' // for iOS
114-
})
115-
.then(latestVersion => {
116-
console.log(latestVersion); // 0.1.2
117-
});
131+
provider: 'appStore', // for iOS
132+
}).then(latestVersion => {
133+
console.log(latestVersion); // 0.1.2
134+
});
118135

119136
VersionCheck.getLatestVersion({
120-
provider: 'playStore' // for Android
121-
})
122-
.then(latestVersion => {
123-
console.log(latestVersion); // 0.1.2
124-
});
137+
provider: 'playStore', // for Android
138+
}).then(latestVersion => {
139+
console.log(latestVersion); // 0.1.2
140+
});
125141

126-
VersionCheck.getLatestVersion() // Automatically choose profer provider using `Platform.select` by device platform.
142+
VersionCheck.getLatestVersion() // Automatically choose profer provider using `Platform.select` by device platform.
127143
.then(latestVersion => {
128-
console.log(latestVersion); // 0.1.2
144+
console.log(latestVersion); // 0.1.2
129145
});
130146

131147
VersionCheck.getLatestVersion({
132148
forceUpdate: true,
133-
provider: () => fetch('http://your.own/api')
134-
.then(r => r.json())
135-
.then(({version}) => version), // You can get latest version from your own api.
136-
}).then(latestVersion =>{
149+
provider: () =>
150+
fetch('http://your.own/api')
151+
.then(r => r.json())
152+
.then(({ version }) => version), // You can get latest version from your own api.
153+
}).then(latestVersion => {
137154
console.log(latestVersion);
138155
});
139156

140-
VersionCheck.needUpdate()
141-
.then(async res => {
142-
console.log(res.isNeeded); // true
143-
if (res.isNeeded) {
144-
Linking.openURL(res.storeUrl); // open store if update is needed.
145-
}
146-
});
157+
VersionCheck.needUpdate().then(async res => {
158+
console.log(res.isNeeded); // true
159+
if (res.isNeeded) {
160+
Linking.openURL(res.storeUrl); // open store if update is needed.
161+
}
162+
});
147163

148164
VersionCheck.needUpdate({
149-
depth: 2
165+
depth: 2,
150166
}).then(res => {
151167
console.log(res.isNeeded);
152168
// false; because first two fields of current and the latest versions are the same as "0.1".
153169
});
154170

155171
VersionCheck.needUpdate({
156-
currentVersion: "1.0",
157-
latestVersion: "2.0"
172+
currentVersion: '1.0',
173+
latestVersion: '2.0',
158174
}).then(res => {
159-
console.log(res.isNeeded); // true
175+
console.log(res.isNeeded); // true
160176
});
161177

162178
VersionCheck.needUpdate({
163179
depth: 1,
164-
currentVersion: "2.1",
165-
latestVersion: "2.0",
180+
currentVersion: '2.1',
181+
latestVersion: '2.0',
166182
}).then(res => {
167-
console.log(res.isNeeded); // false
183+
console.log(res.isNeeded); // false
168184
});
169-
170185
```
171186

172187
## Methods
@@ -176,58 +191,61 @@ VersionCheck.needUpdate({
176191
- <a name="getCurrentBuildNumber" href="#getCurrentBuildNumber">#</a>**`getCurrentBuildNumber()`** _(buildNumber: Number)_ - Returns current app build number.
177192
- <a name="getStoreUrl" href="#getStoreUrl">#</a>**`getStoreUrl([option: Object])`** _(Promise<storeUrl: String>)_ - Returns url of Play Market or App Store of app.
178193
- <a name="getAppStoreUrl" href="#getAppStoreUrl">#</a>**`getAppStoreUrl([option: Object])`** _(Promise<storeUrl: String>)_ - Returns url of App Store of app.
194+
179195
- Option
180196

181-
Field | Type | Default
182-
--- | --- | ---
183-
appID | _string_ | App ID
184-
ignoreErrors | _boolean_ | true
197+
| Field | Type | Default |
198+
| ------------ | --------- | ------- |
199+
| appID | _string_ | App ID |
200+
| ignoreErrors | _boolean_ | true |
201+
185202
- <a name="getPlayStoreUrl" href="#getPlayStoreUrl">#</a>**`getPlayStoreUrl([option: Object])`** _(Promise<storeUrl: String>)_ - Returns url of Play Store of app.
203+
186204
- Option
187205

188-
Field | Type | Default
189-
--- | --- | ---
190-
packageName | _string_ | Package Name
191-
ignoreErrors | _boolean_ | true
206+
| Field | Type | Default |
207+
| ------------ | --------- | ------------ |
208+
| packageName | _string_ | Package Name |
209+
| ignoreErrors | _boolean_ | true |
192210

193211
- <a name="getCurrentVersion" href="#getCurrentVersion">#</a>**`getCurrentVersion()`** _(currentVersion: String)_ - Returns current app version.
194212
- <a name="getLatestVersion" href="#getLatestVersion">#</a>**`getLatestVersion([option: Object])`** _(Promise<latestVersion: String>)_ - Returns the latest app version parsed from url. Returns `null` when parsing error occurs.
213+
195214
- Option
196215

197-
Field | Type | Default
198-
--- | --- | ---
199-
forceUpdate | _boolean_ | ```false```
200-
provider | _string_ or _function_ | provider name or function that returns promise or value of the latest version
201-
fetchOptions | _object_ | isomorphic-fetch options (https://github.github.io/fetch/)
202-
ignoreErrors | _boolean_ | true
216+
| Field | Type | Default |
217+
| ------------ | ---------------------- | ----------------------------------------------------------------------------- |
218+
| forceUpdate | _boolean_ | `false` |
219+
| provider | _string_ or _function_ | provider name or function that returns promise or value of the latest version |
220+
| fetchOptions | _object_ | isomorphic-fetch options (https://github.github.io/fetch/) |
221+
| ignoreErrors | _boolean_ | true |
203222

204223
- <a name="needUpdate" href="#needUpdate">#</a>**`needUpdate([option: Object])`** _(Promise<result: Object>)_ - Returns an object contains with boolean value whether update needed, current version and latest version. Current and the latest app versions are first split by delimiter, and check each split numbers into depth.
224+
205225
- Option
206226

207-
Field | Type | Default
208-
--- | --- | ---
209-
currentVersion | _string_ | app's current version from [getCurrentVersion()](#getCurrentVersion)
210-
latestVersion | _string_ | app's latest version from [getLatestVersion()](#getLatestVersion)
211-
depth | _number_ | ```Infinity```
212-
forceUpdate | _boolean_ | ```false```
213-
provider | _string_ or _function_ | provider name or function that returns promise or value of the latest version
214-
fetchOptions | _object_ | isomorphic-fetch options (https://github.github.io/fetch/)
215-
ignoreErrors | _boolean_ | true
227+
| Field | Type | Default |
228+
| -------------- | ---------------------- | ----------------------------------------------------------------------------- |
229+
| currentVersion | _string_ | app's current version from [getCurrentVersion()](#getCurrentVersion) |
230+
| latestVersion | _string_ | app's latest version from [getLatestVersion()](#getLatestVersion) |
231+
| depth | _number_ | `Infinity` |
232+
| forceUpdate | _boolean_ | `false` |
233+
| provider | _string_ or _function_ | provider name or function that returns promise or value of the latest version |
234+
| fetchOptions | _object_ | isomorphic-fetch options (https://github.github.io/fetch/) |
235+
| ignoreErrors | _boolean_ | true |
216236

217237
- Result
218238

219-
Field | Type
220-
--- | ---
221-
isNeeded | _boolean_
222-
storeUrl | _string_
223-
currentVersion | _string_
224-
latestVersion | _string_
225-
226-
239+
| Field | Type |
240+
| -------------- | --------- |
241+
| isNeeded | _boolean_ |
242+
| storeUrl | _string_ |
243+
| currentVersion | _string_ |
244+
| latestVersion | _string_ |
227245

228246
## License
229-
MIT
230247

248+
MIT
231249

232250
[npm-image]: https://img.shields.io/npm/v/react-native-version-check.svg
233251
[npm-url]: https://npmjs.org/package/react-native-version-check

examples/expo/babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function(api) {
1+
module.exports = function (api) {
22
api.cache(true);
33
return {
44
presets: ['babel-preset-expo'],

examples/reactnative/App.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ const Section = ({children, title}): Node => {
3333
{
3434
color: isDarkMode ? Colors.white : Colors.black,
3535
},
36-
]}
37-
>
36+
]}>
3837
{title}
3938
</Text>
4039
<Text
@@ -43,8 +42,7 @@ const Section = ({children, title}): Node => {
4342
{
4443
color: isDarkMode ? Colors.light : Colors.dark,
4544
},
46-
]}
47-
>
45+
]}>
4846
{children}
4947
</Text>
5048
</View>
@@ -90,14 +88,12 @@ const App: () => Node = () => {
9088
/>
9189
<ScrollView
9290
contentInsetAdjustmentBehavior="automatic"
93-
style={backgroundStyle}
94-
>
91+
style={backgroundStyle}>
9592
<Header />
9693
<View
9794
style={{
9895
backgroundColor: isDarkMode ? Colors.black : Colors.white,
99-
}}
100-
>
96+
}}>
10197
<Section title="Current Version">{currentVersion}</Section>
10298
<Section title="Latest Version">{latestVersion}</Section>
10399
<Section title="Is update needed?">{String(isNeeded)}</Section>

packages/react-native-version-check-expo/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
> A version checker for expo(react-native) applications
1010
1111
### Looking for maintainers!
12+
1213
I have almost zero experience in ios development, and I am no longer working on mobile app development(doing backend and devops works mainly and some web frontend). It makes me hard to maintain this library actively. Hope to have someone to help maintaining react-native-version-check!
1314

1415
[Github](https://github.com/kimxogus/react-native-version-check)
1516

16-
1717
[npm-image]: https://img.shields.io/npm/v/react-native-version-check-expo.svg
1818
[npm-url]: https://npmjs.org/package/react-native-version-check-expo
1919
[downloads-image]: https://img.shields.io/npm/dm/react-native-version-check-expo.svg
@@ -24,4 +24,3 @@ I have almost zero experience in ios development, and I am no longer working on
2424
[dev-dependencies-url]: https://david-dm.org/kimxogus/react-native-version-check?type=dev
2525
[vulnerabilities-image]: https://snyk.io/test/github/kimxogus/react-native-version-check/badge.svg
2626
[vulnerabilities-url]: https://snyk.io/test/github/kimxogus/react-native-version-check
27-

packages/react-native-version-check/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
> A version checker for react-native applications
1010
1111
### Looking for maintainers!
12+
1213
I have almost zero experience in ios development, and I am no longer working on mobile app development(doing backend and devops works mainly and some web frontend). It makes me hard to maintain this library actively. Hope to have someone to help maintaining react-native-version-check!
1314

1415
[Github](https://github.com/kimxogus/react-native-version-check)
@@ -23,4 +24,3 @@ I have almost zero experience in ios development, and I am no longer working on
2324
[dev-dependencies-url]: https://david-dm.org/kimxogus/react-native-version-check?type=dev
2425
[vulnerabilities-image]: https://snyk.io/test/github/kimxogus/react-native-version-check/badge.svg
2526
[vulnerabilities-url]: https://snyk.io/test/github/kimxogus/react-native-version-check
26-

0 commit comments

Comments
 (0)