react-native-update-cli 2.10.2 → 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 +2 -2
- package/lib/app.js +42 -45
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +73 -0
- package/lib/bundle-runner.d.ts +1 -0
- package/lib/bundle-runner.js +68 -22
- package/lib/exports.d.ts +2 -9
- package/lib/exports.js +0 -31
- package/lib/index.d.ts +1 -4
- package/lib/index.js +12 -80
- 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 +50 -6
- package/lib/provider.d.ts +2 -2
- package/lib/provider.js +26 -25
- package/lib/types.d.ts +17 -21
- package/lib/utils/app-info-parser/aab.js +45 -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 -1
- package/lib/utils/index.js +9 -14
- package/lib/utils/plugin-config.js +42 -6
- 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 -25
- package/package.json +8 -15
- package/src/api.ts +23 -15
- package/src/app.ts +40 -40
- package/src/bin.ts +93 -0
- package/src/bundle-runner.ts +161 -62
- package/src/exports.ts +1 -10
- package/src/index.ts +1 -94
- package/src/install.ts +3 -1
- package/src/locales/en.ts +1 -0
- package/src/locales/zh.ts +1 -0
- package/src/package.ts +12 -5
- package/src/provider.ts +49 -40
- package/src/types.ts +18 -26
- package/src/utils/app-info-parser/aab.ts +1 -1
- package/src/utils/app-info-parser/zip.ts +41 -24
- package/src/utils/http-helper.ts +2 -2
- package/src/utils/index.ts +9 -13
- package/src/utils/plugin-config.ts +1 -1
- package/src/utils/runtime.ts +190 -0
- package/src/versions.ts +105 -34
- package/lib/module-manager.d.ts +0 -16
- package/lib/module-manager.js +0 -90
- package/lib/modules/app-module.d.ts +0 -2
- package/lib/modules/app-module.js +0 -15
- package/lib/modules/bundle-module.d.ts +0 -2
- package/lib/modules/bundle-module.js +0 -15
- package/lib/modules/index.d.ts +0 -6
- package/lib/modules/index.js +0 -42
- package/lib/modules/package-module.d.ts +0 -2
- package/lib/modules/package-module.js +0 -15
- package/lib/modules/user-module.d.ts +0 -2
- package/lib/modules/user-module.js +0 -15
- package/lib/modules/version-module.d.ts +0 -2
- package/lib/modules/version-module.js +0 -15
- package/lib/utils/latest-version/cli.d.ts +0 -1
- package/lib/utils/latest-version/cli.js +0 -308
- package/src/module-manager.ts +0 -105
- package/src/modules/app-module.ts +0 -7
- package/src/modules/bundle-module.ts +0 -7
- package/src/modules/index.ts +0 -19
- package/src/modules/package-module.ts +0 -7
- package/src/modules/user-module.ts +0 -7
- package/src/modules/version-module.ts +0 -7
- 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 {
|
|
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,22 +443,27 @@ 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
|
});
|
|
436
|
-
// TODO local diff
|
|
437
|
-
saveToLocal(fn, `${appId}/ppk/${id}.ppk`);
|
|
438
467
|
console.log(t('packageUploadSuccess', { id }));
|
|
439
468
|
|
|
440
469
|
const {
|
|
@@ -469,7 +498,7 @@ export const versionCommands = {
|
|
|
469
498
|
warnDepsChanges: true,
|
|
470
499
|
},
|
|
471
500
|
});
|
|
472
|
-
} else {
|
|
501
|
+
} else if (!nonInteractive) {
|
|
473
502
|
const q = await question(t('updateNativePackageQuestion'));
|
|
474
503
|
if (q.toLowerCase() === 'y') {
|
|
475
504
|
await versionCommands.update({
|
|
@@ -485,17 +514,37 @@ export const versionCommands = {
|
|
|
485
514
|
return versionName;
|
|
486
515
|
},
|
|
487
516
|
versions: async ({ options }: { options: VersionCommandOptions }) => {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
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);
|
|
491
526
|
},
|
|
492
527
|
update: async ({ options }: { options: VersionCommandOptions }) => {
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
let
|
|
496
|
-
|
|
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
|
+
}
|
|
497
546
|
if (versionId === 'null') {
|
|
498
|
-
versionId =
|
|
547
|
+
versionId = null;
|
|
499
548
|
}
|
|
500
549
|
|
|
501
550
|
let pkgId = options.packageId;
|
|
@@ -506,7 +555,7 @@ export const versionCommands = {
|
|
|
506
555
|
let rollout: number | undefined;
|
|
507
556
|
|
|
508
557
|
if (options.rollout !== undefined) {
|
|
509
|
-
rollout = Number.parseInt(options.rollout, 10);
|
|
558
|
+
rollout = Number.parseInt(String(options.rollout), 10);
|
|
510
559
|
if (Number.isNaN(rollout) || rollout < 1 || rollout > 100) {
|
|
511
560
|
throw new Error(t('rolloutRangeError'));
|
|
512
561
|
}
|
|
@@ -523,7 +572,7 @@ export const versionCommands = {
|
|
|
523
572
|
if (minPkgVersion) {
|
|
524
573
|
minPkgVersion = String(minPkgVersion).trim();
|
|
525
574
|
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
|
526
|
-
|
|
575
|
+
compare(pkg.name, minPkgVersion!, '>='),
|
|
527
576
|
);
|
|
528
577
|
if (pkgsToBind.length === 0) {
|
|
529
578
|
throw new Error(
|
|
@@ -532,9 +581,9 @@ export const versionCommands = {
|
|
|
532
581
|
}
|
|
533
582
|
} else if (maxPkgVersion) {
|
|
534
583
|
maxPkgVersion = String(maxPkgVersion).trim();
|
|
535
|
-
pkgsToBind = allPkgs.filter((pkg: Package) =>
|
|
536
|
-
|
|
537
|
-
);
|
|
584
|
+
pkgsToBind = allPkgs.filter((pkg: Package) => {
|
|
585
|
+
return compare(pkg.name, maxPkgVersion!, '<=');
|
|
586
|
+
});
|
|
538
587
|
if (pkgsToBind.length === 0) {
|
|
539
588
|
throw new Error(
|
|
540
589
|
t('nativeVersionNotFoundLte', { version: maxPkgVersion }),
|
|
@@ -562,6 +611,9 @@ export const versionCommands = {
|
|
|
562
611
|
}
|
|
563
612
|
} else {
|
|
564
613
|
if (!pkgId) {
|
|
614
|
+
if (nonInteractive) {
|
|
615
|
+
throw new Error(t('packageIdRequired'));
|
|
616
|
+
}
|
|
565
617
|
pkgId = (await choosePackage(String(appId))).id;
|
|
566
618
|
}
|
|
567
619
|
|
|
@@ -578,7 +630,7 @@ export const versionCommands = {
|
|
|
578
630
|
}
|
|
579
631
|
}
|
|
580
632
|
|
|
581
|
-
if (options.warnDepsChanges) {
|
|
633
|
+
if (options.warnDepsChanges && versionId) {
|
|
582
634
|
await printDepsChangesForPublish({
|
|
583
635
|
appId: String(appId),
|
|
584
636
|
versionId: String(versionId),
|
|
@@ -600,10 +652,24 @@ export const versionCommands = {
|
|
|
600
652
|
}: {
|
|
601
653
|
options: VersionCommandOptions;
|
|
602
654
|
}) => {
|
|
603
|
-
const
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
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
|
+
}
|
|
607
673
|
|
|
608
674
|
const updateParams: Record<string, string> = {};
|
|
609
675
|
if (options.name) updateParams.name = options.name;
|
|
@@ -614,6 +680,8 @@ export const versionCommands = {
|
|
|
614
680
|
console.log(t('operationSuccess'));
|
|
615
681
|
},
|
|
616
682
|
deleteVersion: async ({ options }: { options: VersionCommandOptions }) => {
|
|
683
|
+
const nonInteractive =
|
|
684
|
+
getBooleanOption(options, 'no-interactive', false) || isNonInteractive();
|
|
617
685
|
let appId = options.appId;
|
|
618
686
|
if (!appId) {
|
|
619
687
|
const platform = await getPlatform(options.platform);
|
|
@@ -622,6 +690,9 @@ export const versionCommands = {
|
|
|
622
690
|
|
|
623
691
|
let versionId = options.versionId;
|
|
624
692
|
if (!versionId) {
|
|
693
|
+
if (nonInteractive) {
|
|
694
|
+
throw new Error(t('versionIdRequired'));
|
|
695
|
+
}
|
|
625
696
|
versionId = (await chooseVersion(String(appId))).id;
|
|
626
697
|
}
|
|
627
698
|
|
package/lib/module-manager.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { CLIModule, CLIProvider, CommandContext, CommandDefinition, CommandResult } from './types';
|
|
2
|
-
export declare class ModuleManager {
|
|
3
|
-
private modules;
|
|
4
|
-
private provider;
|
|
5
|
-
private commands;
|
|
6
|
-
constructor();
|
|
7
|
-
registerModule(module: CLIModule): void;
|
|
8
|
-
unregisterModule(moduleName: string): void;
|
|
9
|
-
registerCommand(command: CommandDefinition): void;
|
|
10
|
-
executeCommand(commandName: string, context: CommandContext): Promise<CommandResult>;
|
|
11
|
-
getProvider(): CLIProvider;
|
|
12
|
-
listCommands(): CommandDefinition[];
|
|
13
|
-
listModules(): CLIModule[];
|
|
14
|
-
listAll(): void;
|
|
15
|
-
}
|
|
16
|
-
export declare const moduleManager: ModuleManager;
|
package/lib/module-manager.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get ModuleManager () {
|
|
13
|
-
return ModuleManager;
|
|
14
|
-
},
|
|
15
|
-
get moduleManager () {
|
|
16
|
-
return moduleManager;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _provider = require("./provider");
|
|
20
|
-
class ModuleManager {
|
|
21
|
-
registerModule(module) {
|
|
22
|
-
if (this.modules.has(module.name)) {
|
|
23
|
-
throw new Error(`Module '${module.name}' is already registered`);
|
|
24
|
-
}
|
|
25
|
-
this.modules.set(module.name, module);
|
|
26
|
-
if (module.commands) {
|
|
27
|
-
for (const command of module.commands){
|
|
28
|
-
this.registerCommand(command);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (module.init) {
|
|
32
|
-
module.init(this.provider);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
unregisterModule(moduleName) {
|
|
36
|
-
const module = this.modules.get(moduleName);
|
|
37
|
-
if (!module) {
|
|
38
|
-
throw new Error(`Module '${moduleName}' is not registered`);
|
|
39
|
-
}
|
|
40
|
-
if (module.commands) {
|
|
41
|
-
for (const command of module.commands){
|
|
42
|
-
this.commands.delete(command.name);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (module.cleanup) {
|
|
46
|
-
module.cleanup();
|
|
47
|
-
}
|
|
48
|
-
this.modules.delete(moduleName);
|
|
49
|
-
console.log(`Module '${moduleName}' unregistered successfully`);
|
|
50
|
-
}
|
|
51
|
-
registerCommand(command) {
|
|
52
|
-
if (this.commands.has(command.name)) {
|
|
53
|
-
throw new Error(`Command '${command.name}' is already registered`);
|
|
54
|
-
}
|
|
55
|
-
this.commands.set(command.name, command);
|
|
56
|
-
}
|
|
57
|
-
async executeCommand(commandName, context) {
|
|
58
|
-
const command = this.commands.get(commandName);
|
|
59
|
-
if (!command) {
|
|
60
|
-
throw new Error(`Command '${commandName}' not found`);
|
|
61
|
-
}
|
|
62
|
-
return await command.handler(context);
|
|
63
|
-
}
|
|
64
|
-
getProvider() {
|
|
65
|
-
return this.provider;
|
|
66
|
-
}
|
|
67
|
-
listCommands() {
|
|
68
|
-
return Array.from(this.commands.values());
|
|
69
|
-
}
|
|
70
|
-
listModules() {
|
|
71
|
-
return Array.from(this.modules.values());
|
|
72
|
-
}
|
|
73
|
-
listAll() {
|
|
74
|
-
console.log('\n=== Registered Commands ===');
|
|
75
|
-
for (const command of this.commands.values()){
|
|
76
|
-
console.log(` ${command.name}: ${command.description || 'No description'}`);
|
|
77
|
-
}
|
|
78
|
-
console.log('\n=== Registered Modules ===');
|
|
79
|
-
for (const module of this.modules.values()){
|
|
80
|
-
var _module_commands;
|
|
81
|
-
console.log(` ${module.name} (v${module.version}): ${((_module_commands = module.commands) == null ? void 0 : _module_commands.length) || 0} commands`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
constructor(){
|
|
85
|
-
this.modules = new Map();
|
|
86
|
-
this.commands = new Map();
|
|
87
|
-
this.provider = new _provider.CLIProviderImpl();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const moduleManager = new ModuleManager();
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "appModule", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return appModule;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const appModule = {
|
|
12
|
-
name: 'app',
|
|
13
|
-
version: '1.0.0',
|
|
14
|
-
commands: []
|
|
15
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "bundleModule", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return bundleModule;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const bundleModule = {
|
|
12
|
-
name: 'bundle',
|
|
13
|
-
version: '1.0.0',
|
|
14
|
-
commands: []
|
|
15
|
-
};
|
package/lib/modules/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { appModule } from './app-module';
|
|
2
|
-
export { bundleModule } from './bundle-module';
|
|
3
|
-
export { packageModule } from './package-module';
|
|
4
|
-
export { userModule } from './user-module';
|
|
5
|
-
export { versionModule } from './version-module';
|
|
6
|
-
export declare const builtinModules: import("..").CLIModule[];
|
package/lib/modules/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get appModule () {
|
|
13
|
-
return _appmodule.appModule;
|
|
14
|
-
},
|
|
15
|
-
get builtinModules () {
|
|
16
|
-
return builtinModules;
|
|
17
|
-
},
|
|
18
|
-
get bundleModule () {
|
|
19
|
-
return _bundlemodule.bundleModule;
|
|
20
|
-
},
|
|
21
|
-
get packageModule () {
|
|
22
|
-
return _packagemodule.packageModule;
|
|
23
|
-
},
|
|
24
|
-
get userModule () {
|
|
25
|
-
return _usermodule.userModule;
|
|
26
|
-
},
|
|
27
|
-
get versionModule () {
|
|
28
|
-
return _versionmodule.versionModule;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const _appmodule = require("./app-module");
|
|
32
|
-
const _bundlemodule = require("./bundle-module");
|
|
33
|
-
const _packagemodule = require("./package-module");
|
|
34
|
-
const _usermodule = require("./user-module");
|
|
35
|
-
const _versionmodule = require("./version-module");
|
|
36
|
-
const builtinModules = [
|
|
37
|
-
_bundlemodule.bundleModule,
|
|
38
|
-
_versionmodule.versionModule,
|
|
39
|
-
_appmodule.appModule,
|
|
40
|
-
_usermodule.userModule,
|
|
41
|
-
_packagemodule.packageModule
|
|
42
|
-
];
|