Skip to content

Commit 5f2c45d

Browse files
authored
Merge branch 'reactnativecn:master' into master
2 parents 28e25f2 + 91a6029 commit 5f2c45d

8 files changed

Lines changed: 115 additions & 29 deletions

File tree

cli.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,27 @@
5757
},
5858
"metaInfo": {
5959
"hasValue": true
60+
},
61+
"packageId": {
62+
"hasValue": true
63+
},
64+
"packageVersion": {
65+
"hasValue": true
66+
},
67+
"minPackageVersion": {
68+
"hasValue": true
69+
},
70+
"maxPackageVersion": {
71+
"hasValue": true
72+
},
73+
"packageVersionRange": {
74+
"hasValue": true
75+
},
76+
"rollout": {
77+
"hasValue": true
78+
},
79+
"dryRun": {
80+
"default": false
6081
}
6182
}
6283
},
@@ -175,6 +196,27 @@
175196
"metaInfo": {
176197
"hasValue": true,
177198
"description": "Meta information for publishing"
199+
},
200+
"packageId": {
201+
"hasValue": true
202+
},
203+
"packageVersion": {
204+
"hasValue": true
205+
},
206+
"minPackageVersion": {
207+
"hasValue": true
208+
},
209+
"maxPackageVersion": {
210+
"hasValue": true
211+
},
212+
"packageVersionRange": {
213+
"hasValue": true
214+
},
215+
"rollout": {
216+
"hasValue": true
217+
},
218+
"dryRun": {
219+
"default": false
178220
}
179221
}
180222
},

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

src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export async function chooseApp(platform: Platform) {
6666
}
6767
}
6868

69-
export const commands = {
69+
export const appCommands = {
7070
createApp: async function ({
7171
options,
7272
}: {

src/bundle.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { t } from './utils/i18n';
1919
import { tempDir } from './utils/constants';
2020
import { checkLockFiles } from './utils/check-lockfile';
2121
import { addGitIgnore } from './utils/add-gitignore';
22-
import { commands as versionCommands } from './versions';
22+
import { versionCommands } from './versions';
2323

2424
type Diff = (oldSource?: Buffer, newSource?: Buffer) => Buffer;
2525

@@ -918,7 +918,7 @@ function diffArgsCheck(args: string[], options: any, diffFn: string) {
918918
};
919919
}
920920

921-
export const commands = {
921+
export const bundleCommands = {
922922
bundle: async ({ options }) => {
923923
const platform = await getPlatform(options.platform);
924924

@@ -936,6 +936,13 @@ export const commands = {
936936
name,
937937
description,
938938
metaInfo,
939+
packageId,
940+
packageVersion,
941+
minPackageVersion,
942+
maxPackageVersion,
943+
packageVersionRange,
944+
rollout,
945+
dryRun,
939946
} = translateOptions({
940947
...options,
941948
tempDir,
@@ -984,6 +991,13 @@ export const commands = {
984991
name,
985992
description,
986993
metaInfo,
994+
packageId,
995+
packageVersion,
996+
minPackageVersion,
997+
maxPackageVersion,
998+
packageVersionRange,
999+
rollout,
1000+
dryRun: Boolean(dryRun),
9871001
},
9881002
});
9891003

src/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
import { loadSession } from './api';
44
import { printVersionCommand } from './utils';
55
import { t } from './utils/i18n';
6+
import { bundleCommands } from './bundle';
7+
import { versionCommands } from './versions';
8+
import { userCommands } from './user';
9+
import { appCommands } from './app';
10+
import { packageCommands } from './package';
611

712
function printUsage() {
813
// const commandName = args[0];
@@ -15,11 +20,11 @@ function printUsage() {
1520
}
1621

1722
const commands = {
18-
...require('./user').commands,
19-
...require('./bundle').commands,
20-
...require('./app').commands,
21-
...require('./package').commands,
22-
...require('./versions').commands,
23+
...userCommands,
24+
...bundleCommands,
25+
...appCommands,
26+
...packageCommands,
27+
...versionCommands,
2328
help: printUsage,
2429
};
2530

src/package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export async function choosePackage(appId: string) {
5252
}
5353
}
5454

55-
export const commands = {
55+
export const packageCommands = {
5656
uploadIpa: async ({ args }: { args: string[] }) => {
5757
const fn = args[0];
5858
if (!fn || !fn.endsWith('.ipa')) {

src/user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function md5(str: string) {
77
return crypto.createHash('md5').update(str).digest('hex');
88
}
99

10-
export const commands = {
10+
export const userCommands = {
1111
login: async ({ args }: { args: string[] }) => {
1212
const email = args[0] || (await question('email:'));
1313
const pwd = args[1] || (await question('password:', true));

src/versions.ts

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import type { Package, Platform, Version } from 'types';
1010
import { satisfies } from 'compare-versions';
1111
import chalk from 'chalk';
1212

13-
interface CommandOptions {
13+
interface VersionCommandOptions {
14+
appId?: string;
1415
name?: string;
1516
description?: string;
1617
metaInfo?: string;
@@ -156,13 +157,13 @@ export const bindVersionToPackages = async ({
156157
console.log(t('operationComplete', { count: pkgs.length }));
157158
};
158159

159-
export const commands = {
160+
export const versionCommands = {
160161
publish: async function ({
161162
args,
162163
options,
163164
}: {
164165
args: string[];
165-
options: CommandOptions;
166+
options: VersionCommandOptions;
166167
}) {
167168
const fn = args[0];
168169
const { name, description, metaInfo } = options;
@@ -191,26 +192,52 @@ export const commands = {
191192
saveToLocal(fn, `${appId}/ppk/${id}.ppk`);
192193
console.log(t('packageUploadSuccess', { id }));
193194

194-
const v = await question(t('updateNativePackageQuestion'));
195-
if (v.toLowerCase() === 'y') {
196-
await this.update({ args: [], options: { versionId: id, platform } });
195+
const {
196+
packageId,
197+
packageVersion,
198+
packageVersionRange,
199+
minPackageVersion,
200+
maxPackageVersion,
201+
rollout,
202+
dryRun,
203+
} = options;
204+
205+
if (
206+
packageId ||
207+
packageVersion ||
208+
packageVersionRange ||
209+
minPackageVersion ||
210+
maxPackageVersion
211+
) {
212+
await this.update({
213+
options: {
214+
versionId: id,
215+
platform,
216+
packageId,
217+
packageVersion,
218+
packageVersionRange,
219+
minPackageVersion,
220+
maxPackageVersion,
221+
rollout,
222+
dryRun,
223+
},
224+
});
225+
} else {
226+
const q = await question(t('updateNativePackageQuestion'));
227+
if (q.toLowerCase() === 'y') {
228+
await this.update({ options: { versionId: id, platform } });
229+
}
197230
}
198231
return versionName;
199232
},
200-
versions: async ({ options }: { options: CommandOptions }) => {
233+
versions: async ({ options }: { options: VersionCommandOptions }) => {
201234
const platform = await getPlatform(options.platform);
202235
const { appId } = await getSelectedApp(platform);
203236
await listVersions(appId);
204237
},
205-
update: async ({
206-
args,
207-
options,
208-
}: {
209-
args: string[];
210-
options: CommandOptions;
211-
}) => {
238+
update: async ({ options }: { options: VersionCommandOptions }) => {
212239
const platform = await getPlatform(options.platform);
213-
const { appId } = await getSelectedApp(platform);
240+
const appId = options.appId || (await getSelectedApp(platform)).appId;
214241
let versionId = options.versionId || (await chooseVersion(appId)).id;
215242
if (versionId === 'null') {
216243
versionId = undefined;
@@ -309,11 +336,9 @@ export const commands = {
309336
});
310337
},
311338
updateVersionInfo: async ({
312-
args,
313339
options,
314340
}: {
315-
args: string[];
316-
options: CommandOptions;
341+
options: VersionCommandOptions;
317342
}) => {
318343
const platform = await getPlatform(options.platform);
319344
const { appId } = await getSelectedApp(platform);

0 commit comments

Comments
 (0)