Skip to content

Commit 928e50a

Browse files
committed
fix version compare
1 parent bf0cea6 commit 928e50a

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

bun.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"chalk": "4",
1111
"cli-arguments": "^0.2.1",
1212
"commander": "^13",
13+
"compare-versions": "^6.1.1",
1314
"filesize-parser": "^1.5.1",
1415
"form-data": "^4.0.2",
1516
"fs-extra": "8",
@@ -278,6 +279,8 @@
278279

279280
"commander": ["commander@13.1.0", "", {}, "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw=="],
280281

282+
"compare-versions": ["compare-versions@6.1.1", "", {}, "sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg=="],
283+
281284
"config-chain": ["config-chain@1.1.13", "", { "dependencies": { "ini": "^1.3.4", "proto-list": "~1.2.1" } }, "sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ=="],
282285

283286
"content-disposition": ["content-disposition@0.5.4", "", { "dependencies": { "safe-buffer": "5.2.1" } }, "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ=="],

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update-cli",
3-
"version": "1.45.1",
3+
"version": "1.45.3",
44
"description": "command line tool for react-native-update (remote updates for react native)",
55
"main": "index.js",
66
"bin": {
@@ -42,6 +42,7 @@
4242
"chalk": "4",
4343
"cli-arguments": "^0.2.1",
4444
"commander": "^13",
45+
"compare-versions": "^6.1.1",
4546
"filesize-parser": "^1.5.1",
4647
"form-data": "^4.0.2",
4748
"fs-extra": "8",

src/bundle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import {
88
type ZipFile as YauzlZipFile,
99
} from 'yauzl';
1010
import { question, checkPlugins } from './utils';
11-
import { checkPlatform, getPlatform } from './app';
11+
import { getPlatform } from './app';
1212
import { spawn, spawnSync } from 'child_process';
13-
import semverSatisfies from 'semver/functions/satisfies';
13+
import { satisfies } from 'compare-versions';
1414
const g2js = require('gradle-to-js/lib/parser');
1515
import os from 'os';
1616
const properties = require('properties');
@@ -101,7 +101,7 @@ async function runReactNativeBundleCommand({
101101
.toString(),
102102
).version;
103103
// expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
104-
if (semverSatisfies(expoCliVersion, '>= 0.10.17')) {
104+
if (satisfies(expoCliVersion, '>= 0.10.17')) {
105105
usingExpo = true;
106106
} else {
107107
cliPath = undefined;

src/utils/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import os from 'os';
33
import path from 'path';
44
import pkg from '../../package.json';
55
import AppInfoParser from './app-info-parser';
6-
import semverSatisfies from 'semver/functions/satisfies';
6+
import { satisfies } from 'compare-versions';
77
import chalk from 'chalk';
88
import latestVersion from '../utils/latest-version';
99
import { checkPlugins } from './check-plugin';
@@ -189,24 +189,24 @@ export async function printVersionCommand() {
189189
: '';
190190
console.log(`react-native-update: ${rnuVersion}${latestRnuVersion}`);
191191
if (IS_CRESC) {
192-
if (semverSatisfies(rnuVersion, '<10.27.0')) {
192+
if (satisfies(rnuVersion, '<10.27.0')) {
193193
console.error(
194194
'Unsupported version, please update to the latest version: npm i react-native-update@latest',
195195
);
196196
process.exit(1);
197197
}
198198
} else {
199-
if (semverSatisfies(rnuVersion, '<8.5.2')) {
199+
if (satisfies(rnuVersion, '<8.5.2')) {
200200
console.warn(
201201
`当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8 .
202202
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
203203
);
204-
} else if (semverSatisfies(rnuVersion, '9.0.0 - 9.2.1')) {
204+
} else if (satisfies(rnuVersion, '9.0.0 - 9.2.1')) {
205205
console.warn(
206206
`当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动,可直接热更): npm i react-native-update@9 .
207207
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
208208
);
209-
} else if (semverSatisfies(rnuVersion, '10.0.0 - 10.17.0')) {
209+
} else if (satisfies(rnuVersion, '10.0.0 - 10.17.0')) {
210210
console.warn(
211211
'当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10',
212212
);

src/versions.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { choosePackage } from './package';
77
import { depVersions } from './utils/dep-versions';
88
import { getCommitInfo } from './utils/git';
99
import type { Package, Platform, Version } from 'types';
10-
import semverSatisfies from 'semver/functions/satisfies';
10+
import { satisfies } from 'compare-versions';
1111

1212
interface CommandOptions {
1313
name?: string;
@@ -170,7 +170,8 @@ export const commands = {
170170
const { id } = await post(`/app/${appId}/version/create`, {
171171
name: versionName,
172172
hash,
173-
description: description || (await question(t('versionDescriptionQuestion'))),
173+
description:
174+
description || (await question(t('versionDescriptionQuestion'))),
174175
metaInfo: metaInfo || (await question(t('versionMetaInfoQuestion'))),
175176
deps: depVersions,
176177
commit: await getCommitInfo(),
@@ -233,7 +234,7 @@ export const commands = {
233234
if (minPkgVersion) {
234235
minPkgVersion = String(minPkgVersion).trim();
235236
pkgsToBind = allPkgs.filter((pkg: Package) =>
236-
semverSatisfies(pkg.name, `>=${minPkgVersion}`),
237+
satisfies(pkg.name, `>=${minPkgVersion}`),
237238
);
238239
if (pkgsToBind.length === 0) {
239240
throw new Error(
@@ -243,7 +244,7 @@ export const commands = {
243244
} else if (maxPkgVersion) {
244245
maxPkgVersion = String(maxPkgVersion).trim();
245246
pkgsToBind = allPkgs.filter((pkg: Package) =>
246-
semverSatisfies(pkg.name, `<=${maxPkgVersion}`),
247+
satisfies(pkg.name, `<=${maxPkgVersion}`),
247248
);
248249
if (pkgsToBind.length === 0) {
249250
throw new Error(
@@ -263,7 +264,7 @@ export const commands = {
263264
} else if (semverRange) {
264265
semverRange = semverRange.trim();
265266
pkgsToBind = allPkgs.filter((pkg: Package) =>
266-
semverSatisfies(pkg.name, semverRange!),
267+
satisfies(pkg.name, semverRange!),
267268
);
268269
if (pkgsToBind.length === 0) {
269270
throw new Error(

0 commit comments

Comments
 (0)