mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-17 18:06:10 +08:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3266f09644 | ||
![]() |
848f528625 | ||
![]() |
18d772b1bc |
3
bun.lock
3
bun.lock
@@ -10,6 +10,7 @@
|
||||
"chalk": "4",
|
||||
"cli-arguments": "^0.2.1",
|
||||
"commander": "^13",
|
||||
"compare-versions": "^6.1.1",
|
||||
"filesize-parser": "^1.5.1",
|
||||
"form-data": "^4.0.2",
|
||||
"fs-extra": "8",
|
||||
@@ -278,6 +279,8 @@
|
||||
|
||||
"commander": ["commander@13.1.0", "", {}, "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw=="],
|
||||
|
||||
"compare-versions": ["compare-versions@6.1.1", "", {}, "sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg=="],
|
||||
|
||||
"config-chain": ["config-chain@1.1.13", "", { "dependencies": { "ini": "^1.3.4", "proto-list": "~1.2.1" } }, "sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ=="],
|
||||
|
||||
"content-disposition": ["content-disposition@0.5.4", "", { "dependencies": { "safe-buffer": "5.2.1" } }, "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ=="],
|
||||
|
5
cli.json
5
cli.json
@@ -87,11 +87,14 @@
|
||||
"maxPackageVersion": {
|
||||
"hasValue": true
|
||||
},
|
||||
"semverRange": {
|
||||
"packageVersionRange": {
|
||||
"hasValue": true
|
||||
},
|
||||
"rollout": {
|
||||
"hasValue": true
|
||||
},
|
||||
"dryRun": {
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update-cli",
|
||||
"version": "1.45.1",
|
||||
"version": "1.45.4",
|
||||
"description": "command line tool for react-native-update (remote updates for react native)",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
@@ -42,6 +42,7 @@
|
||||
"chalk": "4",
|
||||
"cli-arguments": "^0.2.1",
|
||||
"commander": "^13",
|
||||
"compare-versions": "^6.1.1",
|
||||
"filesize-parser": "^1.5.1",
|
||||
"form-data": "^4.0.2",
|
||||
"fs-extra": "8",
|
||||
|
@@ -8,9 +8,9 @@ import {
|
||||
type ZipFile as YauzlZipFile,
|
||||
} from 'yauzl';
|
||||
import { question, checkPlugins } from './utils';
|
||||
import { checkPlatform, getPlatform } from './app';
|
||||
import { getPlatform } from './app';
|
||||
import { spawn, spawnSync } from 'child_process';
|
||||
import semverSatisfies from 'semver/functions/satisfies';
|
||||
import { satisfies } from 'compare-versions';
|
||||
const g2js = require('gradle-to-js/lib/parser');
|
||||
import os from 'os';
|
||||
const properties = require('properties');
|
||||
@@ -101,7 +101,7 @@ async function runReactNativeBundleCommand({
|
||||
.toString(),
|
||||
).version;
|
||||
// expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
|
||||
if (semverSatisfies(expoCliVersion, '>= 0.10.17')) {
|
||||
if (satisfies(expoCliVersion, '>= 0.10.17')) {
|
||||
usingExpo = true;
|
||||
} else {
|
||||
cliPath = undefined;
|
||||
|
@@ -129,4 +129,5 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
||||
versionMetaInfoQuestion: 'Enter custom meta info:',
|
||||
updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
|
||||
unnamed: '(Unnamed)',
|
||||
dryRun: 'Below is the dry-run result, no actual operation will be performed:',
|
||||
};
|
||||
|
@@ -122,4 +122,5 @@ export default {
|
||||
versionMetaInfoQuestion: '输入自定义的 meta info:',
|
||||
updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
|
||||
unnamed: '(未命名)',
|
||||
dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
|
||||
};
|
||||
|
@@ -3,7 +3,7 @@ import os from 'os';
|
||||
import path from 'path';
|
||||
import pkg from '../../package.json';
|
||||
import AppInfoParser from './app-info-parser';
|
||||
import semverSatisfies from 'semver/functions/satisfies';
|
||||
import { satisfies } from 'compare-versions';
|
||||
import chalk from 'chalk';
|
||||
import latestVersion from '../utils/latest-version';
|
||||
import { checkPlugins } from './check-plugin';
|
||||
@@ -189,24 +189,24 @@ export async function printVersionCommand() {
|
||||
: '';
|
||||
console.log(`react-native-update: ${rnuVersion}${latestRnuVersion}`);
|
||||
if (IS_CRESC) {
|
||||
if (semverSatisfies(rnuVersion, '<10.27.0')) {
|
||||
if (satisfies(rnuVersion, '<10.27.0')) {
|
||||
console.error(
|
||||
'Unsupported version, please update to the latest version: npm i react-native-update@latest',
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
if (semverSatisfies(rnuVersion, '<8.5.2')) {
|
||||
if (satisfies(rnuVersion, '<8.5.2')) {
|
||||
console.warn(
|
||||
`当前版本已不再支持,请至少升级到 v8 的最新小版本后重新打包(代码无需改动): npm i react-native-update@8 .
|
||||
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
|
||||
);
|
||||
} else if (semverSatisfies(rnuVersion, '9.0.0 - 9.2.1')) {
|
||||
} else if (satisfies(rnuVersion, '9.0.0 - 9.2.1')) {
|
||||
console.warn(
|
||||
`当前版本已不再支持,请至少升级到 v9 的最新小版本后重新打包(代码无需改动,可直接热更): npm i react-native-update@9 .
|
||||
如有使用安装 apk 的功能,请注意添加所需权限 https://pushy.reactnative.cn/docs/api#async-function-downloadandinstallapkurl`,
|
||||
);
|
||||
} else if (semverSatisfies(rnuVersion, '10.0.0 - 10.17.0')) {
|
||||
} else if (satisfies(rnuVersion, '10.0.0 - 10.17.0')) {
|
||||
console.warn(
|
||||
'当前版本已不再支持,请升级到 v10 的最新小版本(代码无需改动,可直接热更): npm i react-native-update@10',
|
||||
);
|
||||
|
@@ -7,7 +7,8 @@ import { choosePackage } from './package';
|
||||
import { depVersions } from './utils/dep-versions';
|
||||
import { getCommitInfo } from './utils/git';
|
||||
import type { Package, Platform, Version } from 'types';
|
||||
import semverSatisfies from 'semver/functions/satisfies';
|
||||
import { satisfies } from 'compare-versions';
|
||||
import chalk from 'chalk';
|
||||
|
||||
interface CommandOptions {
|
||||
name?: string;
|
||||
@@ -19,8 +20,9 @@ interface CommandOptions {
|
||||
packageVersion?: string;
|
||||
minPackageVersion?: string;
|
||||
maxPackageVersion?: string;
|
||||
semverRange?: string;
|
||||
packageVersionRange?: string;
|
||||
rollout?: string;
|
||||
dryRun?: boolean;
|
||||
}
|
||||
|
||||
async function showVersion(appId: string, offset: number) {
|
||||
@@ -107,22 +109,29 @@ export const bindVersionToPackages = async ({
|
||||
versionId,
|
||||
pkgs,
|
||||
rollout,
|
||||
dryRun,
|
||||
}: {
|
||||
appId: string;
|
||||
versionId: string;
|
||||
pkgs: Package[];
|
||||
rollout?: number;
|
||||
dryRun?: boolean;
|
||||
}) => {
|
||||
if (dryRun) {
|
||||
console.log(chalk.yellow(t('dryRun')));
|
||||
}
|
||||
if (rollout !== undefined) {
|
||||
const rolloutConfig: Record<string, number> = {};
|
||||
for (const pkg of pkgs) {
|
||||
rolloutConfig[pkg.name] = rollout;
|
||||
}
|
||||
if (!dryRun) {
|
||||
await put(`/app/${appId}/version/${versionId}`, {
|
||||
config: {
|
||||
rollout: rolloutConfig,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log(
|
||||
`${t('rolloutConfigSet', {
|
||||
versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
|
||||
@@ -131,9 +140,11 @@ export const bindVersionToPackages = async ({
|
||||
);
|
||||
}
|
||||
for (const pkg of pkgs) {
|
||||
if (!dryRun) {
|
||||
await put(`/app/${appId}/package/${pkg.id}`, {
|
||||
versionId,
|
||||
});
|
||||
}
|
||||
console.log(
|
||||
`${t('versionBind', {
|
||||
version: versionId,
|
||||
@@ -170,7 +181,8 @@ export const commands = {
|
||||
const { id } = await post(`/app/${appId}/version/create`, {
|
||||
name: versionName,
|
||||
hash,
|
||||
description: description || (await question(t('versionDescriptionQuestion'))),
|
||||
description:
|
||||
description || (await question(t('versionDescriptionQuestion'))),
|
||||
metaInfo: metaInfo || (await question(t('versionMetaInfoQuestion'))),
|
||||
deps: depVersions,
|
||||
commit: await getCommitInfo(),
|
||||
@@ -208,7 +220,7 @@ export const commands = {
|
||||
let pkgVersion = options.packageVersion;
|
||||
let minPkgVersion = options.minPackageVersion;
|
||||
let maxPkgVersion = options.maxPackageVersion;
|
||||
let semverRange = options.semverRange;
|
||||
let packageVersionRange = options.packageVersionRange;
|
||||
let rollout: number | undefined = undefined;
|
||||
|
||||
if (options.rollout !== undefined) {
|
||||
@@ -233,7 +245,7 @@ export const commands = {
|
||||
if (minPkgVersion) {
|
||||
minPkgVersion = String(minPkgVersion).trim();
|
||||
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
||||
semverSatisfies(pkg.name, `>=${minPkgVersion}`),
|
||||
satisfies(pkg.name, `>=${minPkgVersion}`),
|
||||
);
|
||||
if (pkgsToBind.length === 0) {
|
||||
throw new Error(
|
||||
@@ -243,7 +255,7 @@ export const commands = {
|
||||
} else if (maxPkgVersion) {
|
||||
maxPkgVersion = String(maxPkgVersion).trim();
|
||||
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
||||
semverSatisfies(pkg.name, `<=${maxPkgVersion}`),
|
||||
satisfies(pkg.name, `<=${maxPkgVersion}`),
|
||||
);
|
||||
if (pkgsToBind.length === 0) {
|
||||
throw new Error(
|
||||
@@ -260,14 +272,14 @@ export const commands = {
|
||||
t('nativeVersionNotFoundMatch', { version: pkgVersion }),
|
||||
);
|
||||
}
|
||||
} else if (semverRange) {
|
||||
semverRange = semverRange.trim();
|
||||
} else if (packageVersionRange) {
|
||||
packageVersionRange = packageVersionRange.trim();
|
||||
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
||||
semverSatisfies(pkg.name, semverRange!),
|
||||
satisfies(pkg.name, packageVersionRange!),
|
||||
);
|
||||
if (pkgsToBind.length === 0) {
|
||||
throw new Error(
|
||||
t('nativeVersionNotFoundMatch', { version: semverRange }),
|
||||
t('nativeVersionNotFoundMatch', { version: packageVersionRange }),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -293,6 +305,7 @@ export const commands = {
|
||||
versionId,
|
||||
pkgs: pkgsToBind,
|
||||
rollout,
|
||||
dryRun: options.dryRun,
|
||||
});
|
||||
console.log(t('operationSuccess'));
|
||||
},
|
||||
|
Reference in New Issue
Block a user