react-native-update-cli 2.11.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/README.zh-CN.md +4 -0
- package/cli.json +6 -0
- package/lib/api.js +10 -12
- package/lib/app.d.ts +1 -1
- package/lib/app.js +1 -1
- package/lib/bin.js +5 -2
- package/lib/bundle-runner.js +22 -12
- package/lib/install.js +3 -4
- package/lib/locales/en.d.ts +1 -0
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.d.ts +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/package.d.ts +3 -0
- package/lib/package.js +6 -2
- package/lib/provider.d.ts +2 -2
- package/lib/provider.js +23 -22
- package/lib/types.d.ts +17 -4
- package/lib/utils/app-info-parser/zip.d.ts +3 -3
- package/lib/utils/app-info-parser/zip.js +33 -19
- package/lib/utils/http-helper.js +2 -7
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +9 -1
- package/lib/utils/runtime.d.ts +28 -0
- package/lib/utils/runtime.js +185 -0
- package/lib/versions.d.ts +6 -3
- package/lib/versions.js +80 -23
- package/package.json +1 -6
- package/src/api.ts +23 -15
- package/src/app.ts +1 -1
- package/src/bin.ts +9 -2
- package/src/bundle-runner.ts +91 -50
- package/src/install.ts +3 -1
- package/src/locales/en.ts +1 -0
- package/src/locales/zh.ts +1 -0
- package/src/package.ts +11 -2
- package/src/provider.ts +47 -40
- package/src/types.ts +18 -4
- package/src/utils/app-info-parser/zip.ts +41 -24
- package/src/utils/http-helper.ts +2 -2
- package/src/utils/index.ts +8 -1
- package/src/utils/runtime.ts +190 -0
- package/src/versions.ts +105 -32
- package/lib/utils/latest-version/cli.d.ts +0 -1
- package/lib/utils/latest-version/cli.js +0 -308
- package/src/utils/latest-version/cli.ts +0 -445
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ChildProcessWithoutNullStreams,
|
|
3
|
+
type SpawnOptionsWithoutStdio,
|
|
4
|
+
type SpawnSyncOptions,
|
|
5
|
+
spawn,
|
|
6
|
+
spawnSync,
|
|
7
|
+
} from 'child_process';
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import { createConnection } from 'net';
|
|
10
|
+
import nodeFetch from 'node-fetch';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
|
|
13
|
+
export type RuntimeRequestInit = {
|
|
14
|
+
method?: string;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
body?: any;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type RuntimeResponse = {
|
|
21
|
+
status: number;
|
|
22
|
+
statusText: string;
|
|
23
|
+
text: () => Promise<string>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn';
|
|
27
|
+
export type JavaScriptRuntime = 'bun' | 'node';
|
|
28
|
+
|
|
29
|
+
export const isBunRuntime =
|
|
30
|
+
typeof (process.versions as NodeJS.ProcessVersions & { bun?: string }).bun ===
|
|
31
|
+
'string';
|
|
32
|
+
|
|
33
|
+
export function runtimeFetch(
|
|
34
|
+
url: string,
|
|
35
|
+
options?: RuntimeRequestInit,
|
|
36
|
+
): Promise<RuntimeResponse> {
|
|
37
|
+
const fetchImpl =
|
|
38
|
+
typeof globalThis.fetch === 'function'
|
|
39
|
+
? globalThis.fetch.bind(globalThis)
|
|
40
|
+
: nodeFetch;
|
|
41
|
+
|
|
42
|
+
return fetchImpl(url, options as any) as Promise<RuntimeResponse>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function resolveTcpTarget(input: string): { host: string; port: number } {
|
|
46
|
+
try {
|
|
47
|
+
const parsed = new URL(input);
|
|
48
|
+
const port = parsed.port || (parsed.protocol === 'http:' ? '80' : '443');
|
|
49
|
+
return {
|
|
50
|
+
host: parsed.hostname,
|
|
51
|
+
port: Number(port),
|
|
52
|
+
};
|
|
53
|
+
} catch {
|
|
54
|
+
const [host, port] = input.split(':');
|
|
55
|
+
return {
|
|
56
|
+
host,
|
|
57
|
+
port: port ? Number(port) : 443,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function measureTcpConnectOnce(
|
|
63
|
+
host: string,
|
|
64
|
+
port: number,
|
|
65
|
+
timeout: number,
|
|
66
|
+
): Promise<number> {
|
|
67
|
+
return new Promise((resolve) => {
|
|
68
|
+
const startedAt = Date.now();
|
|
69
|
+
const socket = createConnection({ host, port });
|
|
70
|
+
|
|
71
|
+
const finish = (latency: number) => {
|
|
72
|
+
socket.removeAllListeners();
|
|
73
|
+
socket.destroy();
|
|
74
|
+
resolve(latency);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
socket.setTimeout(timeout);
|
|
78
|
+
socket.once('connect', () => {
|
|
79
|
+
finish(Date.now() - startedAt);
|
|
80
|
+
});
|
|
81
|
+
socket.once('timeout', () => {
|
|
82
|
+
finish(Number.POSITIVE_INFINITY);
|
|
83
|
+
});
|
|
84
|
+
socket.once('error', () => {
|
|
85
|
+
finish(Number.POSITIVE_INFINITY);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export async function measureTcpLatency(
|
|
91
|
+
input: string,
|
|
92
|
+
{
|
|
93
|
+
attempts = 4,
|
|
94
|
+
timeout = 1000,
|
|
95
|
+
}: {
|
|
96
|
+
attempts?: number;
|
|
97
|
+
timeout?: number;
|
|
98
|
+
} = {},
|
|
99
|
+
): Promise<number> {
|
|
100
|
+
const { host, port } = resolveTcpTarget(input);
|
|
101
|
+
const latencies: number[] = [];
|
|
102
|
+
|
|
103
|
+
for (let i = 0; i < attempts; i++) {
|
|
104
|
+
const latency = await measureTcpConnectOnce(host, port, timeout);
|
|
105
|
+
if (Number.isFinite(latency)) {
|
|
106
|
+
latencies.push(latency);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (latencies.length === 0) {
|
|
111
|
+
return Number.POSITIVE_INFINITY;
|
|
112
|
+
}
|
|
113
|
+
return (
|
|
114
|
+
latencies.reduce((sum, latency) => sum + latency, 0) / latencies.length
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function detectPackageManager(
|
|
119
|
+
cwd = process.cwd(),
|
|
120
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
121
|
+
): PackageManager {
|
|
122
|
+
const lockFiles: Array<[string, PackageManager]> = [
|
|
123
|
+
['bun.lock', 'bun'],
|
|
124
|
+
['bun.lockb', 'bun'],
|
|
125
|
+
['pnpm-lock.yaml', 'pnpm'],
|
|
126
|
+
['yarn.lock', 'yarn'],
|
|
127
|
+
['package-lock.json', 'npm'],
|
|
128
|
+
];
|
|
129
|
+
for (const [lockFile, manager] of lockFiles) {
|
|
130
|
+
if (fs.existsSync(path.join(cwd, lockFile))) {
|
|
131
|
+
return manager;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const userAgent = env.npm_config_user_agent ?? '';
|
|
136
|
+
if (userAgent.startsWith('bun/')) {
|
|
137
|
+
return 'bun';
|
|
138
|
+
}
|
|
139
|
+
if (userAgent.startsWith('pnpm/')) {
|
|
140
|
+
return 'pnpm';
|
|
141
|
+
}
|
|
142
|
+
if (userAgent.startsWith('yarn/')) {
|
|
143
|
+
return 'yarn';
|
|
144
|
+
}
|
|
145
|
+
if (userAgent.startsWith('npm/')) {
|
|
146
|
+
return 'npm';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return isBunRuntime ? 'bun' : 'npm';
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function getInstallCommand(
|
|
153
|
+
installArgs: string[],
|
|
154
|
+
cwd = process.cwd(),
|
|
155
|
+
): { command: string; args: string[] } {
|
|
156
|
+
const packageManager = detectPackageManager(cwd);
|
|
157
|
+
if (packageManager === 'npm') {
|
|
158
|
+
return { command: 'npm', args: ['install', ...installArgs] };
|
|
159
|
+
}
|
|
160
|
+
return { command: packageManager, args: ['add', ...installArgs] };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function getJavaScriptRuntime(
|
|
164
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
165
|
+
): JavaScriptRuntime {
|
|
166
|
+
const configured = env.RNU_JS_RUNTIME?.toLowerCase();
|
|
167
|
+
if (configured === 'bun') {
|
|
168
|
+
return 'bun';
|
|
169
|
+
}
|
|
170
|
+
if (configured === 'auto') {
|
|
171
|
+
return isBunRuntime ? 'bun' : 'node';
|
|
172
|
+
}
|
|
173
|
+
return 'node';
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function spawnJavaScript(
|
|
177
|
+
args: string[],
|
|
178
|
+
options?: SpawnOptionsWithoutStdio,
|
|
179
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
180
|
+
): ChildProcessWithoutNullStreams {
|
|
181
|
+
return spawn(getJavaScriptRuntime(env), args, options ?? {});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function spawnJavaScriptSync(
|
|
185
|
+
args: string[],
|
|
186
|
+
options?: SpawnSyncOptions,
|
|
187
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
188
|
+
) {
|
|
189
|
+
return spawnSync(getJavaScriptRuntime(env), args, options ?? {});
|
|
190
|
+
}
|
package/src/versions.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { satisfies } from 'compare-versions';
|
|
2
|
+
import { compare, satisfies } from 'compare-versions';
|
|
3
3
|
import Table from 'tty-table';
|
|
4
4
|
import { doDelete, get, getAllPackages, post, put, uploadFile } from './api';
|
|
5
5
|
import { getPlatform, getSelectedApp } from './app';
|
|
6
6
|
import { choosePackage } from './package';
|
|
7
7
|
import type { Package, Platform, Version } from './types';
|
|
8
|
-
import { question } from './utils';
|
|
8
|
+
import { isNonInteractive, question } from './utils';
|
|
9
9
|
import { depVersions } from './utils/dep-versions';
|
|
10
10
|
import { getCommitInfo } from './utils/git';
|
|
11
11
|
import { t } from './utils/i18n';
|
|
12
|
+
import { getBooleanOption } from './utils/options';
|
|
12
13
|
|
|
13
14
|
interface VersionCommandOptions {
|
|
15
|
+
[key: string]: unknown;
|
|
14
16
|
appId?: string;
|
|
15
17
|
name?: string;
|
|
16
18
|
description?: string;
|
|
@@ -22,10 +24,11 @@ interface VersionCommandOptions {
|
|
|
22
24
|
minPackageVersion?: string;
|
|
23
25
|
maxPackageVersion?: string;
|
|
24
26
|
packageVersionRange?: string;
|
|
25
|
-
rollout?: string;
|
|
27
|
+
rollout?: number | string;
|
|
26
28
|
dryRun?: boolean;
|
|
27
29
|
versionDeps?: Record<string, string>;
|
|
28
30
|
warnDepsChanges?: boolean;
|
|
31
|
+
'no-interactive'?: boolean | string;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
type Deps = Record<string, string>;
|
|
@@ -280,8 +283,21 @@ async function printDepsChangesForPublish({
|
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
285
|
|
|
286
|
+
const versionPageLimit = 10;
|
|
287
|
+
|
|
288
|
+
export async function fetchVersions(
|
|
289
|
+
appId: string,
|
|
290
|
+
offset = 0,
|
|
291
|
+
limit = versionPageLimit,
|
|
292
|
+
): Promise<Version[]> {
|
|
293
|
+
const { data } = await get(
|
|
294
|
+
`/app/${appId}/version/list?offset=${offset}&limit=${limit}`,
|
|
295
|
+
);
|
|
296
|
+
return Array.isArray(data) ? data : [];
|
|
297
|
+
}
|
|
298
|
+
|
|
283
299
|
async function showVersion(appId: string, offset: number) {
|
|
284
|
-
const
|
|
300
|
+
const data = await fetchVersions(appId, offset, versionPageLimit);
|
|
285
301
|
console.log(t('offset', { offset }));
|
|
286
302
|
for (const version of data) {
|
|
287
303
|
const pkgCount = version.packages?.length || 0;
|
|
@@ -289,8 +305,8 @@ async function showVersion(appId: string, offset: number) {
|
|
|
289
305
|
if (pkgCount === 0) {
|
|
290
306
|
packageInfo = 'no package';
|
|
291
307
|
} else {
|
|
292
|
-
packageInfo = version.packages
|
|
293
|
-
|
|
308
|
+
packageInfo = (version.packages ?? [])
|
|
309
|
+
.slice(0, 3)
|
|
294
310
|
.map((pkg: Package) => pkg.name)
|
|
295
311
|
.join(', ');
|
|
296
312
|
if (pkgCount > 3) {
|
|
@@ -308,10 +324,13 @@ async function showVersion(appId: string, offset: number) {
|
|
|
308
324
|
return data;
|
|
309
325
|
}
|
|
310
326
|
|
|
311
|
-
async function listVersions(appId: string) {
|
|
327
|
+
async function listVersions(appId: string, interactive = true) {
|
|
312
328
|
let offset = 0;
|
|
313
329
|
while (true) {
|
|
314
|
-
await showVersion(appId, offset);
|
|
330
|
+
const data = await showVersion(appId, offset);
|
|
331
|
+
if (!interactive) {
|
|
332
|
+
return data;
|
|
333
|
+
}
|
|
315
334
|
const cmd = await question('page Up/page Down/Begin/Quit(U/D/B/Q)');
|
|
316
335
|
switch (cmd.toLowerCase()) {
|
|
317
336
|
case 'u':
|
|
@@ -324,7 +343,9 @@ async function listVersions(appId: string) {
|
|
|
324
343
|
offset = 0;
|
|
325
344
|
break;
|
|
326
345
|
case 'q':
|
|
327
|
-
return;
|
|
346
|
+
return data;
|
|
347
|
+
case '':
|
|
348
|
+
return data;
|
|
328
349
|
}
|
|
329
350
|
}
|
|
330
351
|
}
|
|
@@ -333,6 +354,9 @@ async function chooseVersion(appId: string) {
|
|
|
333
354
|
let offset = 0;
|
|
334
355
|
while (true) {
|
|
335
356
|
const data = await showVersion(appId, offset);
|
|
357
|
+
if (isNonInteractive()) {
|
|
358
|
+
throw new Error(t('versionIdRequired'));
|
|
359
|
+
}
|
|
336
360
|
const cmd = await question(
|
|
337
361
|
'Enter versionId or page Up/page Down/Begin(U/D/B)',
|
|
338
362
|
);
|
|
@@ -367,7 +391,7 @@ export const bindVersionToPackages = async ({
|
|
|
367
391
|
dryRun,
|
|
368
392
|
}: {
|
|
369
393
|
appId: string;
|
|
370
|
-
versionId: string;
|
|
394
|
+
versionId: string | null;
|
|
371
395
|
pkgs: Package[];
|
|
372
396
|
rollout?: number;
|
|
373
397
|
dryRun?: boolean;
|
|
@@ -419,17 +443,24 @@ export const versionCommands = {
|
|
|
419
443
|
|
|
420
444
|
const platform = await getPlatform(options.platform);
|
|
421
445
|
const { appId } = await getSelectedApp(platform);
|
|
446
|
+
const nonInteractive =
|
|
447
|
+
getBooleanOption(options, 'no-interactive', false) || isNonInteractive();
|
|
422
448
|
|
|
423
449
|
const { hash } = await uploadFile(fn);
|
|
424
450
|
|
|
425
451
|
const versionName =
|
|
426
|
-
name ||
|
|
452
|
+
name ||
|
|
453
|
+
(nonInteractive ? '' : await question(t('versionNameQuestion'))) ||
|
|
454
|
+
t('unnamed');
|
|
427
455
|
const { id } = await post(`/app/${appId}/version/create`, {
|
|
428
456
|
name: versionName,
|
|
429
457
|
hash,
|
|
430
458
|
description:
|
|
431
|
-
description
|
|
432
|
-
|
|
459
|
+
description ??
|
|
460
|
+
(nonInteractive ? '' : await question(t('versionDescriptionQuestion'))),
|
|
461
|
+
metaInfo:
|
|
462
|
+
metaInfo ??
|
|
463
|
+
(nonInteractive ? '' : await question(t('versionMetaInfoQuestion'))),
|
|
433
464
|
deps: depVersions,
|
|
434
465
|
commit: await getCommitInfo(),
|
|
435
466
|
});
|
|
@@ -467,7 +498,7 @@ export const versionCommands = {
|
|
|
467
498
|
warnDepsChanges: true,
|
|
468
499
|
},
|
|
469
500
|
});
|
|
470
|
-
} else {
|
|
501
|
+
} else if (!nonInteractive) {
|
|
471
502
|
const q = await question(t('updateNativePackageQuestion'));
|
|
472
503
|
if (q.toLowerCase() === 'y') {
|
|
473
504
|
await versionCommands.update({
|
|
@@ -483,17 +514,37 @@ export const versionCommands = {
|
|
|
483
514
|
return versionName;
|
|
484
515
|
},
|
|
485
516
|
versions: async ({ options }: { options: VersionCommandOptions }) => {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
517
|
+
let appId = options.appId;
|
|
518
|
+
if (!appId) {
|
|
519
|
+
const platform = await getPlatform(options.platform);
|
|
520
|
+
appId = (await getSelectedApp(platform)).appId;
|
|
521
|
+
}
|
|
522
|
+
const interactive = !(
|
|
523
|
+
getBooleanOption(options, 'no-interactive', false) || isNonInteractive()
|
|
524
|
+
);
|
|
525
|
+
await listVersions(String(appId), interactive);
|
|
489
526
|
},
|
|
490
527
|
update: async ({ options }: { options: VersionCommandOptions }) => {
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
let
|
|
494
|
-
|
|
528
|
+
const nonInteractive =
|
|
529
|
+
getBooleanOption(options, 'no-interactive', false) || isNonInteractive();
|
|
530
|
+
let appId = options.appId;
|
|
531
|
+
let platform = options.platform;
|
|
532
|
+
if (!appId) {
|
|
533
|
+
platform = await getPlatform(platform);
|
|
534
|
+
appId = (await getSelectedApp(platform)).appId;
|
|
535
|
+
} else if (platform) {
|
|
536
|
+
platform = await getPlatform(platform);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
let versionId: string | null | undefined = options.versionId;
|
|
540
|
+
if (!versionId) {
|
|
541
|
+
if (nonInteractive) {
|
|
542
|
+
throw new Error(t('versionIdRequired'));
|
|
543
|
+
}
|
|
544
|
+
versionId = (await chooseVersion(String(appId))).id;
|
|
545
|
+
}
|
|
495
546
|
if (versionId === 'null') {
|
|
496
|
-
versionId =
|
|
547
|
+
versionId = null;
|
|
497
548
|
}
|
|
498
549
|
|
|
499
550
|
let pkgId = options.packageId;
|
|
@@ -504,7 +555,7 @@ export const versionCommands = {
|
|
|
504
555
|
let rollout: number | undefined;
|
|
505
556
|
|
|
506
557
|
if (options.rollout !== undefined) {
|
|
507
|
-
rollout = Number.parseInt(options.rollout, 10);
|
|
558
|
+
rollout = Number.parseInt(String(options.rollout), 10);
|
|
508
559
|
if (Number.isNaN(rollout) || rollout < 1 || rollout > 100) {
|
|
509
560
|
throw new Error(t('rolloutRangeError'));
|
|
510
561
|
}
|
|
@@ -521,7 +572,7 @@ export const versionCommands = {
|
|
|
521
572
|
if (minPkgVersion) {
|
|
522
573
|
minPkgVersion = String(minPkgVersion).trim();
|
|
523
574
|
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
|
524
|
-
|
|
575
|
+
compare(pkg.name, minPkgVersion!, '>='),
|
|
525
576
|
);
|
|
526
577
|
if (pkgsToBind.length === 0) {
|
|
527
578
|
throw new Error(
|
|
@@ -530,9 +581,9 @@ export const versionCommands = {
|
|
|
530
581
|
}
|
|
531
582
|
} else if (maxPkgVersion) {
|
|
532
583
|
maxPkgVersion = String(maxPkgVersion).trim();
|
|
533
|
-
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
|
534
|
-
|
|
535
|
-
);
|
|
584
|
+
pkgsToBind = allPkgs.filter((pkg: Package) => {
|
|
585
|
+
return compare(pkg.name, maxPkgVersion!, '<=');
|
|
586
|
+
});
|
|
536
587
|
if (pkgsToBind.length === 0) {
|
|
537
588
|
throw new Error(
|
|
538
589
|
t('nativeVersionNotFoundLte', { version: maxPkgVersion }),
|
|
@@ -560,6 +611,9 @@ export const versionCommands = {
|
|
|
560
611
|
}
|
|
561
612
|
} else {
|
|
562
613
|
if (!pkgId) {
|
|
614
|
+
if (nonInteractive) {
|
|
615
|
+
throw new Error(t('packageIdRequired'));
|
|
616
|
+
}
|
|
563
617
|
pkgId = (await choosePackage(String(appId))).id;
|
|
564
618
|
}
|
|
565
619
|
|
|
@@ -576,7 +630,7 @@ export const versionCommands = {
|
|
|
576
630
|
}
|
|
577
631
|
}
|
|
578
632
|
|
|
579
|
-
if (options.warnDepsChanges) {
|
|
633
|
+
if (options.warnDepsChanges && versionId) {
|
|
580
634
|
await printDepsChangesForPublish({
|
|
581
635
|
appId: String(appId),
|
|
582
636
|
versionId: String(versionId),
|
|
@@ -598,10 +652,24 @@ export const versionCommands = {
|
|
|
598
652
|
}: {
|
|
599
653
|
options: VersionCommandOptions;
|
|
600
654
|
}) => {
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
655
|
+
const nonInteractive =
|
|
656
|
+
getBooleanOption(options, 'no-interactive', false) || isNonInteractive();
|
|
657
|
+
let appId = options.appId;
|
|
658
|
+
let platform = options.platform;
|
|
659
|
+
if (!appId) {
|
|
660
|
+
platform = await getPlatform(platform);
|
|
661
|
+
appId = (await getSelectedApp(platform)).appId;
|
|
662
|
+
} else if (platform) {
|
|
663
|
+
await getPlatform(platform);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
let versionId = options.versionId;
|
|
667
|
+
if (!versionId) {
|
|
668
|
+
if (nonInteractive) {
|
|
669
|
+
throw new Error(t('versionIdRequired'));
|
|
670
|
+
}
|
|
671
|
+
versionId = (await chooseVersion(String(appId))).id;
|
|
672
|
+
}
|
|
605
673
|
|
|
606
674
|
const updateParams: Record<string, string> = {};
|
|
607
675
|
if (options.name) updateParams.name = options.name;
|
|
@@ -612,6 +680,8 @@ export const versionCommands = {
|
|
|
612
680
|
console.log(t('operationSuccess'));
|
|
613
681
|
},
|
|
614
682
|
deleteVersion: async ({ options }: { options: VersionCommandOptions }) => {
|
|
683
|
+
const nonInteractive =
|
|
684
|
+
getBooleanOption(options, 'no-interactive', false) || isNonInteractive();
|
|
615
685
|
let appId = options.appId;
|
|
616
686
|
if (!appId) {
|
|
617
687
|
const platform = await getPlatform(options.platform);
|
|
@@ -620,6 +690,9 @@ export const versionCommands = {
|
|
|
620
690
|
|
|
621
691
|
let versionId = options.versionId;
|
|
622
692
|
if (!versionId) {
|
|
693
|
+
if (nonInteractive) {
|
|
694
|
+
throw new Error(t('versionIdRequired'));
|
|
695
|
+
}
|
|
623
696
|
versionId = (await chooseVersion(String(appId))).id;
|
|
624
697
|
}
|
|
625
698
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|