1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-10-30 14:23:10 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Update version to 1.45.4, add dryRun option in cli.json and versions.ts, and enhance localization for dryRun messages

This commit is contained in:
sunnylqm
2025-05-16 09:32:46 +08:00
parent 848f528625
commit 3266f09644
5 changed files with 26 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ import { depVersions } from './utils/dep-versions';
import { getCommitInfo } from './utils/git';
import type { Package, Platform, Version } from 'types';
import { satisfies } from 'compare-versions';
import chalk from 'chalk';
interface CommandOptions {
name?: string;
@@ -21,6 +22,7 @@ interface CommandOptions {
maxPackageVersion?: 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;
}
await put(`/app/${appId}/version/${versionId}`, {
config: {
rollout: rolloutConfig,
},
});
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) {
await put(`/app/${appId}/package/${pkg.id}`, {
versionId,
});
if (!dryRun) {
await put(`/app/${appId}/package/${pkg.id}`, {
versionId,
});
}
console.log(
`${t('versionBind', {
version: versionId,
@@ -294,6 +305,7 @@ export const commands = {
versionId,
pkgs: pkgsToBind,
rollout,
dryRun: options.dryRun,
});
console.log(t('operationSuccess'));
},