Skip to content

Commit 32d0613

Browse files
committed
feat: add countryCode option to VersionCheck for region-specific updates
- Introduced a new `countryCode` parameter in the `needsUpdate`. - Updated documentation to reflect the new option and its usage.
1 parent 35af70a commit 32d0613

6 files changed

Lines changed: 78 additions & 5 deletions

File tree

docs/docs/api-reference.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,19 @@ if (await VersionCheck.needsUpdate()) {
8585
if (await VersionCheck.needsUpdate({ level: 'major' })) {
8686
// ...
8787
}
88+
89+
// Check against a specific App Store region
90+
if (await VersionCheck.needsUpdate({ countryCode: 'US' })) {
91+
// ...
92+
}
8893
```
8994

9095
#### Options
9196

9297
| Option | Type | Default | Description |
9398
|--------|------|---------|-------------|
9499
| `level` | `"major" \| "minor" \| "patch"` | `"patch"` | Minimum version bump to trigger `true` |
100+
| `countryCode` | `string` | device country | 2-letter ISO country code (iOS only, ignored on Android) |
95101

96102
- `"major"` — only returns `true` for major bumps (1.x → 2.x)
97103
- `"minor"` — returns `true` for major or minor bumps

docs/docs/compatibility.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
sidebar_position: 3
3+
title: Compatibility
4+
---
5+
6+
# Compatibility
7+
8+
This page documents the compatibility between different versions of `react-native-nitro-version-check` and the Nitro ecosystem.
9+
10+
## Version Matrix
11+
12+
| `react-native-nitro-version-check` Version | `react-native-nitro-modules` | Status |
13+
|---|---|---|
14+
| v1.x | 0.32.0 - 0.34.x | Stable |
15+
| v2.0.0+ | 0.35.0+ | Current |
16+
17+
## Nitro 0.35.0 and Later
18+
19+
**Version 2.x and newer is fully built around Nitro 0.35+ support.** All v1.x versions work with Nitro 0.32.0 - 0.34.x.
20+
21+
22+
### Upgrading from v1.x to v2.0.0+
23+
24+
When you're ready to upgrade to v2.0.0, ensure you have `react-native-nitro-modules` 0.35.0+:
25+
26+
```sh
27+
bun add react-native-nitro-modules@0.35.0
28+
bun add react-native-nitro-version-check@2.0.0
29+
```
30+
31+
Then rebuild your app:
32+
33+
```sh
34+
# For Expo
35+
bunx expo prebuild --clean
36+
37+
# For bare React Native
38+
cd ios && pod install
39+
```
40+
41+
### Staying on v1.x
42+
43+
All v1.x versions work with Nitro 0.32.0 - 0.34.x. When you upgrade to Nitro 0.35.0+, you'll need to upgrade to v2.0.0+.

docs/docs/usage-examples.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ const hasMinorUpdate = await VersionCheck.needsUpdate({ level: 'minor' })
6767

6868
// Returns true for any version increase (default)
6969
const hasAnyUpdate = await VersionCheck.needsUpdate({ level: 'patch' })
70+
71+
// Check against a specific App Store region (iOS only)
72+
const needsUpdateUS = await VersionCheck.needsUpdate({ countryCode: 'US' })
7073
```
7174

7275
## Detect Install Source

package/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@
8989
"npm": {
9090
"publish": true,
9191
"skipChecks": true,
92-
"publishArgs": [
93-
"--provenance --access public"
94-
]
92+
"publishArgs": ["--provenance --access public"]
9593
},
9694
"github": {
9795
"release": true

package/src/__tests__/index.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,20 @@ describe("VersionCheck API", () => {
105105
}
106106
});
107107

108+
it("should accept options with countryCode parameter", async () => {
109+
const result = VersionCheck.needsUpdate({ countryCode: "US" });
110+
expect(result).toBeInstanceOf(Promise);
111+
const resolved = await result;
112+
expect(typeof resolved).toBe("boolean");
113+
});
114+
115+
it("should accept both level and countryCode options together", async () => {
116+
const result = VersionCheck.needsUpdate({ level: "major", countryCode: "GB" });
117+
expect(result).toBeInstanceOf(Promise);
118+
const resolved = await result;
119+
expect(typeof resolved).toBe("boolean");
120+
});
121+
108122
it("should default to patch level when no options provided", async () => {
109123
const result = await VersionCheck.needsUpdate();
110124
expect(typeof result).toBe("boolean");

package/src/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ export const VersionCheck = {
143143
* - `"minor"` — returns `true` for major or minor bumps
144144
* - `"patch"` — returns `true` for any version increase (default)
145145
*
146+
* @param options - Optional configuration
147+
* @param options.level - Update granularity to check for. Defaults to `"patch"`.
148+
* @param options.countryCode - 2-letter ISO country code (e.g., "US", "GB")
149+
* Defaults to the device's current country from `getCountry()`.
150+
* Only used on iOS; ignored on Android.
151+
*
146152
* @example
147153
* ```ts
148154
* if (await VersionCheck.needsUpdate()) {
@@ -152,10 +158,13 @@ export const VersionCheck = {
152158
*
153159
* // Only prompt for major updates
154160
* const majorUpdate = await VersionCheck.needsUpdate({ level: "major" });
161+
*
162+
* // Check against a specific App Store region
163+
* const needsUpdateUS = await VersionCheck.needsUpdate({ countryCode: "US" });
155164
* ```
156165
*/
157-
needsUpdate: async (options?: { level?: UpdateLevel }): Promise<boolean> => {
158-
const latest = await HybridVersionCheck.getLatestVersion();
166+
needsUpdate: async (options?: { level?: UpdateLevel; countryCode?: string }): Promise<boolean> => {
167+
const latest = await HybridVersionCheck.getLatestVersion(options?.countryCode);
159168
return isNewerVersion(version, latest, options?.level ?? "patch");
160169
},
161170
/**

0 commit comments

Comments
 (0)