Skip to content

Commit 3266f09

Browse files
committed
Update version to 1.45.4, add dryRun option in cli.json and versions.ts, and enhance localization for dryRun messages
1 parent 848f528 commit 3266f09

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

cli.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@
9292
},
9393
"rollout": {
9494
"hasValue": true
95+
},
96+
"dryRun": {
97+
"default": false
9598
}
9699
}
97100
},

package.json

Lines changed: 1 addition & 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.3",
3+
"version": "1.45.4",
44
"description": "command line tool for react-native-update (remote updates for react native)",
55
"main": "index.js",
66
"bin": {

src/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,5 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
129129
versionMetaInfoQuestion: 'Enter custom meta info:',
130130
updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
131131
unnamed: '(Unnamed)',
132+
dryRun: 'Below is the dry-run result, no actual operation will be performed:',
132133
};

src/locales/zh.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,5 @@ export default {
122122
versionMetaInfoQuestion: '输入自定义的 meta info:',
123123
updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
124124
unnamed: '(未命名)',
125+
dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
125126
};

src/versions.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { depVersions } from './utils/dep-versions';
88
import { getCommitInfo } from './utils/git';
99
import type { Package, Platform, Version } from 'types';
1010
import { satisfies } from 'compare-versions';
11+
import chalk from 'chalk';
1112

1213
interface CommandOptions {
1314
name?: string;
@@ -21,6 +22,7 @@ interface CommandOptions {
2122
maxPackageVersion?: string;
2223
packageVersionRange?: string;
2324
rollout?: string;
25+
dryRun?: boolean;
2426
}
2527

2628
async function showVersion(appId: string, offset: number) {
@@ -107,22 +109,29 @@ export const bindVersionToPackages = async ({
107109
versionId,
108110
pkgs,
109111
rollout,
112+
dryRun,
110113
}: {
111114
appId: string;
112115
versionId: string;
113116
pkgs: Package[];
114117
rollout?: number;
118+
dryRun?: boolean;
115119
}) => {
120+
if (dryRun) {
121+
console.log(chalk.yellow(t('dryRun')));
122+
}
116123
if (rollout !== undefined) {
117124
const rolloutConfig: Record<string, number> = {};
118125
for (const pkg of pkgs) {
119126
rolloutConfig[pkg.name] = rollout;
120127
}
121-
await put(`/app/${appId}/version/${versionId}`, {
122-
config: {
123-
rollout: rolloutConfig,
124-
},
125-
});
128+
if (!dryRun) {
129+
await put(`/app/${appId}/version/${versionId}`, {
130+
config: {
131+
rollout: rolloutConfig,
132+
},
133+
});
134+
}
126135
console.log(
127136
`${t('rolloutConfigSet', {
128137
versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
@@ -131,9 +140,11 @@ export const bindVersionToPackages = async ({
131140
);
132141
}
133142
for (const pkg of pkgs) {
134-
await put(`/app/${appId}/package/${pkg.id}`, {
135-
versionId,
136-
});
143+
if (!dryRun) {
144+
await put(`/app/${appId}/package/${pkg.id}`, {
145+
versionId,
146+
});
147+
}
137148
console.log(
138149
`${t('versionBind', {
139150
version: versionId,
@@ -294,6 +305,7 @@ export const commands = {
294305
versionId,
295306
pkgs: pkgsToBind,
296307
rollout,
308+
dryRun: options.dryRun,
297309
});
298310
console.log(t('operationSuccess'));
299311
},

0 commit comments

Comments
 (0)