Skip to content

Commit 8c31ee5

Browse files
committed
semver range
1 parent 002e866 commit 8c31ee5

File tree

10 files changed

+173
-195
lines changed

10 files changed

+173
-195
lines changed

bun.lock

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"chalk": "4",
1111
"cli-arguments": "^0.2.1",
1212
"commander": "^13",
13-
"compare-versions": "^6.1.1",
1413
"filesize-parser": "^1.5.1",
1514
"form-data": "^4.0.2",
1615
"fs-extra": "8",
@@ -25,19 +24,19 @@
2524
"properties": "^1.2.1",
2625
"read": "^4.1.0",
2726
"registry-auth-token": "^5.1.0",
28-
"semver": "^7.7.1",
27+
"semver": "^7.7.2",
2928
"tcp-ping": "^0.1.1",
3029
"tty-table": "4.2",
3130
"yauzl": "^3.2.0",
3231
"yazl": "3.3.1",
3332
},
3433
"devDependencies": {
3534
"@biomejs/biome": "^1.9.4",
36-
"@swc/cli": "0.7.3",
35+
"@swc/cli": "0.7.7",
3736
"@swc/core": "^1.11.24",
3837
"@types/filesize-parser": "^1.5.3",
3938
"@types/fs-extra": "^11.0.4",
40-
"@types/node": "^22.14.1",
39+
"@types/node": "^22.15.18",
4140
"@types/node-fetch": "^2.6.12",
4241
"@types/progress": "^2.0.7",
4342
"@types/semver": "^7.7.0",
@@ -125,7 +124,7 @@
125124

126125
"@sindresorhus/is": ["@sindresorhus/[email protected]", "", {}, "sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g=="],
127126

128-
"@swc/cli": ["@swc/[email protected].3", "", { "dependencies": { "@swc/counter": "^0.1.3", "@xhmikosr/bin-wrapper": "^13.0.5", "commander": "^8.3.0", "fast-glob": "^3.2.5", "minimatch": "^9.0.3", "piscina": "^4.3.1", "semver": "^7.3.8", "slash": "3.0.0", "source-map": "^0.7.3" }, "peerDependencies": { "@swc/core": "^1.2.66", "chokidar": "^4.0.1" }, "optionalPeers": ["chokidar"], "bin": { "swc": "bin/swc.js", "swcx": "bin/swcx.js", "spack": "bin/spack.js" } }, "sha512-rnVXNnlURjdOuPaBIwZ3TmBA44BF/eP0j154LanlgPEYfau74ige7cpKlKkZr1IBqMOG99lAnYNxQipDWA3hdg=="],
127+
"@swc/cli": ["@swc/[email protected].7", "", { "dependencies": { "@swc/counter": "^0.1.3", "@xhmikosr/bin-wrapper": "^13.0.5", "commander": "^8.3.0", "fast-glob": "^3.2.5", "minimatch": "^9.0.3", "piscina": "^4.3.1", "semver": "^7.3.8", "slash": "3.0.0", "source-map": "^0.7.3" }, "peerDependencies": { "@swc/core": "^1.2.66", "chokidar": "^4.0.1" }, "optionalPeers": ["chokidar"], "bin": { "swc": "bin/swc.js", "swcx": "bin/swcx.js", "spack": "bin/spack.js" } }, "sha512-j4yYm9bx3pxWofaJKX1BFwj/3ngUDynN4UIQ2Xd2h0h/7Gt7zkReBTpDN7g5S13mgAYxacaTHTOUsz18097E8w=="],
129128

130129
"@swc/core": ["@swc/[email protected]", "", { "dependencies": { "@swc/counter": "^0.1.3", "@swc/types": "^0.1.21" }, "optionalDependencies": { "@swc/core-darwin-arm64": "1.11.24", "@swc/core-darwin-x64": "1.11.24", "@swc/core-linux-arm-gnueabihf": "1.11.24", "@swc/core-linux-arm64-gnu": "1.11.24", "@swc/core-linux-arm64-musl": "1.11.24", "@swc/core-linux-x64-gnu": "1.11.24", "@swc/core-linux-x64-musl": "1.11.24", "@swc/core-win32-arm64-msvc": "1.11.24", "@swc/core-win32-ia32-msvc": "1.11.24", "@swc/core-win32-x64-msvc": "1.11.24" }, "peerDependencies": { "@swc/helpers": ">=0.5.17" }, "optionalPeers": ["@swc/helpers"] }, "sha512-MaQEIpfcEMzx3VWWopbofKJvaraqmL6HbLlw2bFZ7qYqYw3rkhM0cQVEgyzbHtTWwCwPMFZSC2DUbhlZgrMfLg=="],
131130

@@ -165,7 +164,7 @@
165164

166165
"@types/jsonfile": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ=="],
167166

168-
"@types/node": ["@types/node@22.14.1", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw=="],
167+
"@types/node": ["@types/node@22.15.18", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-v1DKRfUdyW+jJhZNEI1PYy29S2YRxMV5AOO/x/SjKmW0acCIOqmbj6Haf9eHAhsPmrhlHSxEhv/1WszcLWV4cg=="],
169168

170169
"@types/node-fetch": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*", "form-data": "^4.0.0" } }, "sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA=="],
171170

@@ -279,8 +278,6 @@
279278

280279
"commander": ["[email protected]", "", {}, "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw=="],
281280

282-
"compare-versions": ["[email protected]", "", {}, "sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg=="],
283-
284281
"config-chain": ["[email protected]", "", { "dependencies": { "ini": "^1.3.4", "proto-list": "~1.2.1" } }, "sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ=="],
285282

286283
"content-disposition": ["[email protected]", "", { "dependencies": { "safe-buffer": "5.2.1" } }, "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ=="],
@@ -625,7 +622,7 @@
625622

626623
"seek-bzip": ["[email protected]", "", { "dependencies": { "commander": "^6.0.0" }, "bin": { "seek-bunzip": "bin/seek-bunzip", "seek-table": "bin/seek-bzip-table" } }, "sha512-SMguiTnYrhpLdk3PwfzHeotrcwi8bNV4iemL9tx9poR/yeaMYwB9VzR1w7b57DuWpuqR8n6oZboi0hj3AxZxQg=="],
627624

628-
"semver": ["[email protected].1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA=="],
625+
"semver": ["[email protected].2", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA=="],
629626

630627
"semver-regex": ["[email protected]", "", {}, "sha512-hunMQrEy1T6Jr2uEVjrAIqjwWcQTgOAcIM52C8MY1EZSD3DDNft04XzvYKPqjED65bNVVko0YI38nYeEHCX3yw=="],
631628

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update-cli",
3-
"version": "1.44.7",
3+
"version": "1.45.0",
44
"description": "command line tool for react-native-update (remote updates for react native)",
55
"main": "index.js",
66
"bin": {
@@ -42,7 +42,6 @@
4242
"chalk": "4",
4343
"cli-arguments": "^0.2.1",
4444
"commander": "^13",
45-
"compare-versions": "^6.1.1",
4645
"filesize-parser": "^1.5.1",
4746
"form-data": "^4.0.2",
4847
"fs-extra": "8",
@@ -57,7 +56,7 @@
5756
"properties": "^1.2.1",
5857
"read": "^4.1.0",
5958
"registry-auth-token": "^5.1.0",
60-
"semver": "^7.7.1",
59+
"semver": "^7.7.2",
6160
"tcp-ping": "^0.1.1",
6261
"tty-table": "4.2",
6362
"yauzl": "^3.2.0",
@@ -68,11 +67,11 @@
6867
},
6968
"devDependencies": {
7069
"@biomejs/biome": "^1.9.4",
71-
"@swc/cli": "0.7.3",
70+
"@swc/cli": "0.7.7",
7271
"@swc/core": "^1.11.24",
7372
"@types/filesize-parser": "^1.5.3",
7473
"@types/fs-extra": "^11.0.4",
75-
"@types/node": "^22.14.1",
74+
"@types/node": "^22.15.18",
7675
"@types/node-fetch": "^2.6.12",
7776
"@types/progress": "^2.0.7",
7877
"@types/semver": "^7.7.0",

src/api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
credentialFile,
1212
defaultEndpoint,
1313
} from './utils/constants';
14-
import type { Session } from 'types';
14+
import type { Session, Package } from 'types';
1515
import FormData from 'form-data';
1616
import { t } from './utils/i18n';
1717

@@ -177,3 +177,8 @@ export async function uploadFile(fn: string, key?: string) {
177177
// const body = await response.json();
178178
return { hash: key || formData.key };
179179
}
180+
181+
export const getAllPackages = async (appId: string) => {
182+
const { data } = await get(`/app/${appId}/package/list?limit=1000`);
183+
return data as Package[] | undefined | null;
184+
};

src/app.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,21 @@ import { t } from './utils/i18n';
88

99
const validPlatforms = ['ios', 'android', 'harmony'];
1010

11-
export function checkPlatform(platform: Platform) {
11+
export async function getPlatform(platform?: string) {
12+
return assertPlatform(
13+
platform || (await question(t('platformQuestion'))),
14+
) as Platform;
15+
}
16+
17+
export function assertPlatform(platform: string) {
1218
if (!validPlatforms.includes(platform)) {
1319
throw new Error(t('unsupportedPlatform', { platform }));
1420
}
1521
return platform;
1622
}
1723

1824
export function getSelectedApp(platform: Platform) {
19-
checkPlatform(platform);
25+
assertPlatform(platform);
2026

2127
if (!fs.existsSync('update.json')) {
2228
throw new Error(t('appNotSelected', { platform }));
@@ -68,9 +74,7 @@ export const commands = {
6874
}) {
6975
const name = options.name || (await question(t('appNameQuestion')));
7076
const { downloadUrl } = options;
71-
const platform = checkPlatform(
72-
options.platform || (await question(t('platformQuestion'))),
73-
);
77+
const platform = await getPlatform(options.platform);
7478
const { id } = await post('/app/create', { name, platform, downloadUrl });
7579
console.log(t('createAppSuccess', { id }));
7680
await this.selectApp({
@@ -104,9 +108,7 @@ export const commands = {
104108
args: string[];
105109
options: { platform: Platform };
106110
}) => {
107-
const platform = checkPlatform(
108-
options.platform || (await question(t('platformQuestion'))),
109-
);
111+
const platform = await getPlatform(options.platform);
110112
const id = args[0]
111113
? Number.parseInt(args[0])
112114
: (await chooseApp(platform)).id;

src/bundle.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
type ZipFile as YauzlZipFile,
99
} from 'yauzl';
1010
import { question, checkPlugins } from './utils';
11-
import { checkPlatform } from './app';
11+
import { checkPlatform, getPlatform } from './app';
1212
import { spawn, spawnSync } from 'child_process';
1313
import semverSatisfies from 'semver/functions/satisfies';
1414
const g2js = require('gradle-to-js/lib/parser');
@@ -902,9 +902,7 @@ function diffArgsCheck(args: string[], options: any, diffFn: string) {
902902

903903
export const commands = {
904904
bundle: async ({ options }) => {
905-
const platform = checkPlatform(
906-
options.platform || (await question(t('platformPrompt'))),
907-
);
905+
const platform = await getPlatform(options.platform);
908906

909907
const {
910908
bundleName,

src/locales/en.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
7373
'Multiple lock files detected ({{- lockFiles}}), which may cause inconsistent dependencies and hot-updating issues.',
7474
nativePackageId: 'Native Package ID',
7575
nativeVersion: 'Native Version',
76-
nativeVersionNotFound: 'No native version found >= {{version}}',
77-
nativeVersionNotFoundLess: 'No native version found <= {{version}}',
76+
nativeVersionNotFoundGte: 'No native version found >= {{version}}',
77+
nativeVersionNotFoundLte: 'No native version found <= {{version}}',
7878
nativeVersionNotFoundMatch: 'No matching native version found: {{version}}',
79+
nativePackageIdNotFound: 'No native package id found: {{id}}',
80+
noPackagesFound: 'No packages found. (appId: {{appId}})',
7981
offset: 'Offset {{offset}}',
8082
operationComplete: 'Operation complete, bound to {{count}} native versions',
8183
operationSuccess: 'Operation successful',
@@ -122,4 +124,9 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
122124
versionBind:
123125
'Bound version {{version}} to native version {{nativeVersion}} (id: {{id}})',
124126
welcomeMessage: 'Welcome to Cresc hot update service, {{name}}.',
127+
versionNameQuestion: 'Enter version name:',
128+
versionDescriptionQuestion: 'Enter version description:',
129+
versionMetaInfoQuestion: 'Enter custom meta info:',
130+
updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
131+
unnamed: '(Unnamed)',
125132
};

src/locales/zh.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ export default {
6969
'检测到多种不同格式的锁文件({{- lockFiles}}),这可能导致依赖关系不一致而使热更异常。',
7070
nativePackageId: '原生包 Id',
7171
nativeVersion: '原生版本',
72-
nativeVersionNotFound: '未查询到 >= {{version}} 的原生版本',
73-
nativeVersionNotFoundLess: '未查询到 <= {{version}} 的原生版本',
72+
nativeVersionNotFoundGte: '未查询到 >= {{version}} 的原生版本',
73+
nativeVersionNotFoundLte: '未查询到 <= {{version}} 的原生版本',
7474
nativeVersionNotFoundMatch: '未查询到匹配原生版本:{{version}}',
75+
nativePackageIdNotFound: '未查询到原生包 id: {{id}}',
76+
noPackagesFound: '未查询到任何原生包(appId: {{appId}})',
7577
offset: '偏移量 {{offset}}',
7678
operationComplete: '操作完成,共已绑定 {{count}} 个原生版本',
7779
operationSuccess: '操作成功',
@@ -115,4 +117,9 @@ export default {
115117
versionBind:
116118
'已将热更版本 {{version}} 绑定到原生版本 {{nativeVersion}} (id: {{id}})',
117119
welcomeMessage: '欢迎使用 pushy 热更新服务,{{name}}。',
120+
versionNameQuestion: '输入版本名称:',
121+
versionDescriptionQuestion: '输入版本描述:',
122+
versionMetaInfoQuestion: '输入自定义的 meta info:',
123+
updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
124+
unnamed: '(未命名)',
118125
};

src/package.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { get, post, uploadFile } from './api';
1+
import { get, getAllPackages, post, uploadFile } from './api';
22
import { question, saveToLocal } from './utils';
33
import { t } from './utils/i18n';
44

5-
import { checkPlatform, getSelectedApp } from './app';
5+
import { checkPlatform, getPlatform, getSelectedApp } from './app';
66

77
import { getApkInfo, getIpaInfo, getAppInfo } from './utils';
88
import Table from 'tty-table';
@@ -11,14 +11,14 @@ import { getCommitInfo } from './utils/git';
1111
import type { Platform } from 'types';
1212

1313
export async function listPackage(appId: string) {
14-
const { data } = await get(`/app/${appId}/package/list?limit=1000`);
14+
const allPkgs = await getAllPackages(appId);
1515

1616
const header = [
1717
{ value: t('nativePackageId') },
1818
{ value: t('nativeVersion') },
1919
];
2020
const rows = [];
21-
for (const pkg of data) {
21+
for (const pkg of allPkgs) {
2222
const { version } = pkg;
2323
let versionInfo = '';
2424
if (version) {
@@ -36,8 +36,8 @@ export async function listPackage(appId: string) {
3636
}
3737

3838
console.log(Table(header, rows).render());
39-
console.log(t('totalPackages', { count: data.length }));
40-
return data;
39+
console.log(t('totalPackages', { count: allPkgs.length }));
40+
return allPkgs;
4141
}
4242

4343
export async function choosePackage(appId: string) {
@@ -174,9 +174,7 @@ export const commands = {
174174
console.log(await getApkInfo(fn));
175175
},
176176
packages: async ({ options }: { options: { platform: Platform } }) => {
177-
const platform = checkPlatform(
178-
options.platform || (await question(t('platformPrompt'))),
179-
);
177+
const platform = await getPlatform(options.platform);
180178
const { appId } = await getSelectedApp(platform);
181179
await listPackage(appId);
182180
},

src/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@ export interface Session {
88
}
99

1010
export type Platform = 'ios' | 'android' | 'harmony';
11+
12+
export interface Package {
13+
id: string;
14+
name: string;
15+
}
16+
17+
export interface Version {
18+
id: string;
19+
hash: string;
20+
name: string;
21+
packages?: Package[];
22+
}

0 commit comments

Comments
 (0)