react-native-update-cli 2.22.9 → 2.23.1
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 +3 -2
- package/README.zh-CN.md +3 -2
- package/cli.json +21 -1
- package/lib/app.d.ts +28 -0
- package/lib/app.js +71 -9
- package/lib/bin.js +2 -0
- package/lib/bundle.d.ts +4 -0
- package/lib/bundle.js +57 -24
- package/lib/locales/en.d.ts +9 -0
- package/lib/locales/en.js +16 -7
- package/lib/locales/zh.d.ts +9 -0
- package/lib/locales/zh.js +16 -7
- package/lib/package.d.ts +1 -0
- package/lib/package.js +7 -13
- package/lib/provider.d.ts +3 -2
- package/lib/provider.js +19 -2
- package/lib/symbolicate.d.ts +30 -0
- package/lib/symbolicate.js +117 -0
- package/lib/types.d.ts +22 -1
- package/lib/utils/constants.d.ts +1 -1
- package/lib/utils/constants.js +3 -1
- package/lib/versions.js +56 -44
- package/package.json +2 -1
- package/src/app.ts +89 -16
- package/src/bin.ts +2 -0
- package/src/bundle.ts +67 -29
- package/src/locales/en.ts +23 -7
- package/src/locales/zh.ts +20 -7
- package/src/package.ts +12 -23
- package/src/provider.ts +28 -1
- package/src/symbolicate.ts +159 -0
- package/src/types.ts +23 -0
- package/src/utils/constants.ts +3 -1
- package/src/versions.ts +66 -53
package/src/provider.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
Platform,
|
|
9
9
|
PublishOptions,
|
|
10
10
|
Session,
|
|
11
|
+
SymbolicateOptions,
|
|
11
12
|
UpdateVersionOptions,
|
|
12
13
|
UploadOptions,
|
|
13
14
|
} from './types';
|
|
@@ -95,6 +96,8 @@ export class CLIProviderImpl implements CLIProvider {
|
|
|
95
96
|
verifyHermesBase: options.verifyHermesBase ?? true,
|
|
96
97
|
sentryRelease: options.sentryRelease,
|
|
97
98
|
sentryDist: options.sentryDist,
|
|
99
|
+
appId: options.appId,
|
|
100
|
+
config: options.config,
|
|
98
101
|
});
|
|
99
102
|
|
|
100
103
|
const { bundleCommands } = await import('./bundle');
|
|
@@ -128,6 +131,7 @@ export class CLIProviderImpl implements CLIProvider {
|
|
|
128
131
|
? undefined
|
|
129
132
|
: String(options.rollout),
|
|
130
133
|
dryRun: options.dryRun || false,
|
|
134
|
+
sourcemap: options.sourcemap,
|
|
131
135
|
},
|
|
132
136
|
options.filePath ? [options.filePath] : [],
|
|
133
137
|
);
|
|
@@ -140,6 +144,28 @@ export class CLIProviderImpl implements CLIProvider {
|
|
|
140
144
|
);
|
|
141
145
|
}
|
|
142
146
|
|
|
147
|
+
async symbolicate(options: SymbolicateOptions): Promise<CommandResult> {
|
|
148
|
+
return this.runMessageCommand(
|
|
149
|
+
async () => {
|
|
150
|
+
const context = this.createContext(
|
|
151
|
+
{
|
|
152
|
+
hash: options.hash,
|
|
153
|
+
versionId: options.versionId,
|
|
154
|
+
platform: options.platform,
|
|
155
|
+
appId: options.appId,
|
|
156
|
+
config: options.config,
|
|
157
|
+
output: options.output,
|
|
158
|
+
},
|
|
159
|
+
options.stackFile ? [options.stackFile] : [],
|
|
160
|
+
);
|
|
161
|
+
const { symbolicateCommands } = await import('./symbolicate');
|
|
162
|
+
await symbolicateCommands.symbolicate(context);
|
|
163
|
+
},
|
|
164
|
+
'Unknown error during symbolication',
|
|
165
|
+
'Stack symbolicated',
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
143
169
|
async upload(options: UploadOptions): Promise<CommandResult> {
|
|
144
170
|
return this.runMessageCommand(
|
|
145
171
|
async () => {
|
|
@@ -181,9 +207,10 @@ export class CLIProviderImpl implements CLIProvider {
|
|
|
181
207
|
|
|
182
208
|
async getSelectedApp(
|
|
183
209
|
platform?: Platform,
|
|
210
|
+
config?: string,
|
|
184
211
|
): Promise<{ appId: string; platform: Platform }> {
|
|
185
212
|
const resolvedPlatform = await this.getPlatform(platform);
|
|
186
|
-
return getSelectedApp(resolvedPlatform);
|
|
213
|
+
return getSelectedApp(resolvedPlatform, config);
|
|
187
214
|
}
|
|
188
215
|
|
|
189
216
|
async listApps(platform?: Platform): Promise<CommandResult> {
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import fetch from 'node-fetch';
|
|
3
|
+
import { SourceMapConsumer } from 'source-map';
|
|
4
|
+
import { get } from './api';
|
|
5
|
+
import { getPlatform, getSelectedApp } from './app';
|
|
6
|
+
import type { Platform, Version } from './types';
|
|
7
|
+
import { t } from './utils/i18n';
|
|
8
|
+
import { fetchVersions } from './versions';
|
|
9
|
+
|
|
10
|
+
// A frame location inside a shipped bundle: `<bundle>:<line>:<column>`. Covers
|
|
11
|
+
// `index.bundlejs`, `index.android.bundle`, `main.jsbundle`, `bundle.harmony.js`
|
|
12
|
+
// and plain `.js`/`.hbc` names; an optional `address at ` prefix marks a
|
|
13
|
+
// Hermes bytecode frame (column = bytecode offset, already 0-based).
|
|
14
|
+
const FRAME_PATTERN =
|
|
15
|
+
/(address at )?((?:[\w.-]+\/)*[\w.-]+\.(?:bundlejs|jsbundle|bundle|hbc|js))(?:\?[^\s:)]*)?:(\d+):(\d+)/g;
|
|
16
|
+
|
|
17
|
+
export interface FrameConsumer {
|
|
18
|
+
originalPositionFor(position: { line: number; column: number }): {
|
|
19
|
+
source?: string | null;
|
|
20
|
+
line?: number | null;
|
|
21
|
+
column?: number | null;
|
|
22
|
+
name?: string | null;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Rewrites every bundle frame of `stack` to its original source position.
|
|
28
|
+
* JS engines report 1-based columns, so they are shifted to the 0-based
|
|
29
|
+
* columns source maps use; Hermes bytecode frames (`address at`) carry the
|
|
30
|
+
* bytecode offset, which the composed hermes map keys directly.
|
|
31
|
+
*/
|
|
32
|
+
export function symbolicateStack(
|
|
33
|
+
stack: string,
|
|
34
|
+
consumer: FrameConsumer,
|
|
35
|
+
): { text: string; mapped: number } {
|
|
36
|
+
let mapped = 0;
|
|
37
|
+
const text = stack.replace(
|
|
38
|
+
FRAME_PATTERN,
|
|
39
|
+
(
|
|
40
|
+
frame,
|
|
41
|
+
hermes: string | undefined,
|
|
42
|
+
_bundle,
|
|
43
|
+
line: string,
|
|
44
|
+
column: string,
|
|
45
|
+
) => {
|
|
46
|
+
const position = consumer.originalPositionFor({
|
|
47
|
+
line: Number(line),
|
|
48
|
+
column: hermes ? Number(column) : Math.max(0, Number(column) - 1),
|
|
49
|
+
});
|
|
50
|
+
if (
|
|
51
|
+
!position.source ||
|
|
52
|
+
position.line === null ||
|
|
53
|
+
position.line === undefined
|
|
54
|
+
) {
|
|
55
|
+
return frame;
|
|
56
|
+
}
|
|
57
|
+
mapped++;
|
|
58
|
+
const original = `${position.source}:${position.line}:${(position.column ?? 0) + 1}`;
|
|
59
|
+
return position.name ? `${original} (${position.name})` : original;
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
return { text, mapped };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function findVersionByHash(
|
|
66
|
+
appId: string,
|
|
67
|
+
hash: string,
|
|
68
|
+
): Promise<Version | undefined> {
|
|
69
|
+
const limit = 100;
|
|
70
|
+
// The list is newest-first; crashes are usually about recent versions.
|
|
71
|
+
for (let offset = 0; offset < 100 * limit; offset += limit) {
|
|
72
|
+
const page = await fetchVersions(appId, offset, limit);
|
|
73
|
+
const found = page.find((version) => version.hash === hash);
|
|
74
|
+
if (found) {
|
|
75
|
+
return found;
|
|
76
|
+
}
|
|
77
|
+
if (page.length < limit) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function readStack(source: string | undefined): Promise<string> {
|
|
85
|
+
if (!source || source === '-') {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
const chunks: Buffer[] = [];
|
|
88
|
+
process.stdin.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
|
|
89
|
+
process.stdin.on('end', () =>
|
|
90
|
+
resolve(Buffer.concat(chunks).toString('utf8')),
|
|
91
|
+
);
|
|
92
|
+
process.stdin.on('error', reject);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return fs.readFileSync(source, 'utf8');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const symbolicateCommands = {
|
|
99
|
+
symbolicate: async ({
|
|
100
|
+
args,
|
|
101
|
+
options,
|
|
102
|
+
}: {
|
|
103
|
+
args: string[];
|
|
104
|
+
options: Record<string, unknown>;
|
|
105
|
+
}) => {
|
|
106
|
+
const hash = typeof options.hash === 'string' ? options.hash : '';
|
|
107
|
+
const versionIdOption =
|
|
108
|
+
typeof options.versionId === 'string' ? options.versionId : '';
|
|
109
|
+
if (!hash && !versionIdOption) {
|
|
110
|
+
throw new Error(t('symbolicateUsage'));
|
|
111
|
+
}
|
|
112
|
+
const platform = await getPlatform(
|
|
113
|
+
typeof options.platform === 'string'
|
|
114
|
+
? (options.platform as Platform)
|
|
115
|
+
: undefined,
|
|
116
|
+
);
|
|
117
|
+
const appId =
|
|
118
|
+
typeof options.appId === 'string' && options.appId
|
|
119
|
+
? options.appId
|
|
120
|
+
: (await getSelectedApp(platform, options.config as string | undefined))
|
|
121
|
+
.appId;
|
|
122
|
+
|
|
123
|
+
let versionId = versionIdOption;
|
|
124
|
+
if (!versionId) {
|
|
125
|
+
const version = await findVersionByHash(appId, hash);
|
|
126
|
+
if (!version) {
|
|
127
|
+
throw new Error(t('symbolicateVersionNotFound', { hash }));
|
|
128
|
+
}
|
|
129
|
+
versionId = String(version.id);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const located = await get(`/app/${appId}/version/${versionId}/sourceMap`);
|
|
133
|
+
if (!located?.url) {
|
|
134
|
+
throw new Error(t('symbolicateNoSourceMap', { id: versionId }));
|
|
135
|
+
}
|
|
136
|
+
const response = await fetch(located.url);
|
|
137
|
+
if (!response.ok) {
|
|
138
|
+
throw new Error(`Failed to download source map: HTTP ${response.status}`);
|
|
139
|
+
}
|
|
140
|
+
const rawMap = JSON.parse(await response.text());
|
|
141
|
+
const consumer = new SourceMapConsumer(rawMap);
|
|
142
|
+
|
|
143
|
+
const stack = await readStack(args[0]);
|
|
144
|
+
const { text, mapped } = symbolicateStack(stack, consumer);
|
|
145
|
+
if (typeof options.output === 'string' && options.output) {
|
|
146
|
+
fs.writeFileSync(options.output, text);
|
|
147
|
+
} else {
|
|
148
|
+
process.stdout.write(text.endsWith('\n') ? text : `${text}\n`);
|
|
149
|
+
}
|
|
150
|
+
console.error(
|
|
151
|
+
t('symbolicateDone', {
|
|
152
|
+
count: mapped,
|
|
153
|
+
id: versionId,
|
|
154
|
+
hash: located.hash ?? hash,
|
|
155
|
+
}),
|
|
156
|
+
);
|
|
157
|
+
return { versionId, mapped };
|
|
158
|
+
},
|
|
159
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -28,6 +28,8 @@ export interface Version {
|
|
|
28
28
|
name: string;
|
|
29
29
|
packages?: Package[];
|
|
30
30
|
deps?: Record<string, string> | string | null;
|
|
31
|
+
/** storage key of the archived source map (absent when published without one) */
|
|
32
|
+
sourceMapKey?: string;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export interface CommandContext<
|
|
@@ -65,10 +67,16 @@ export interface BundleOptions {
|
|
|
65
67
|
resetCache?: boolean;
|
|
66
68
|
sentryRelease?: string;
|
|
67
69
|
sentryDist?: string;
|
|
70
|
+
/** publish to this app instead of the one selected in the config file */
|
|
71
|
+
appId?: string;
|
|
72
|
+
/** selected-app config file (default: update.json) */
|
|
73
|
+
config?: string;
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
export interface PublishOptions {
|
|
71
77
|
filePath?: string;
|
|
78
|
+
/** path of the final source map to archive with the version */
|
|
79
|
+
sourcemap?: string;
|
|
72
80
|
platform?: Platform;
|
|
73
81
|
name?: string;
|
|
74
82
|
description?: string;
|
|
@@ -104,15 +112,30 @@ export interface UpdateVersionOptions {
|
|
|
104
112
|
dryRun?: boolean;
|
|
105
113
|
}
|
|
106
114
|
|
|
115
|
+
export interface SymbolicateOptions {
|
|
116
|
+
/** stack trace file ('-' for stdin) */
|
|
117
|
+
stackFile?: string;
|
|
118
|
+
/** update hash of the running version (from getUpdateMetadata().currentVersion) */
|
|
119
|
+
hash?: string;
|
|
120
|
+
versionId?: string;
|
|
121
|
+
platform?: Platform;
|
|
122
|
+
appId?: string;
|
|
123
|
+
config?: string;
|
|
124
|
+
/** write the symbolicated stack here instead of stdout */
|
|
125
|
+
output?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
107
128
|
export interface CLIProvider {
|
|
108
129
|
bundle: (options: BundleOptions) => Promise<CommandResult>;
|
|
109
130
|
publish: (options: PublishOptions) => Promise<CommandResult>;
|
|
131
|
+
symbolicate: (options: SymbolicateOptions) => Promise<CommandResult>;
|
|
110
132
|
upload: (options: UploadOptions) => Promise<CommandResult>;
|
|
111
133
|
|
|
112
134
|
createApp: (name: string, platform: Platform) => Promise<CommandResult>;
|
|
113
135
|
listApps: (platform?: Platform) => Promise<CommandResult>;
|
|
114
136
|
getSelectedApp: (
|
|
115
137
|
platform?: Platform,
|
|
138
|
+
config?: string,
|
|
116
139
|
) => Promise<{ appId: string; platform: Platform }>;
|
|
117
140
|
|
|
118
141
|
listVersions: (appId: string) => Promise<CommandResult>;
|
package/src/utils/constants.ts
CHANGED
|
@@ -12,7 +12,9 @@ export const isPPKBundleFileName = (fileName: string) =>
|
|
|
12
12
|
ppkBundleFileNames.includes(fileName);
|
|
13
13
|
|
|
14
14
|
export const credentialFile = IS_CRESC ? '.cresc.token' : '.update';
|
|
15
|
-
|
|
15
|
+
// Both brands select apps in update.json: the cresc docs and the client SDK
|
|
16
|
+
// (`import _updateConfig from './update.json'`) read that name too.
|
|
17
|
+
export const updateJson = 'update.json';
|
|
16
18
|
export const tempDir = IS_CRESC ? '.cresc.temp' : '.pushy';
|
|
17
19
|
export const pricingPageUrl = IS_CRESC
|
|
18
20
|
? 'https://cresc.dev/pricing'
|
package/src/versions.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { compare, satisfies } from 'compare-versions';
|
|
3
|
+
import fs from 'fs';
|
|
3
4
|
import { doDelete, get, getAllPackages, post, put, uploadFile } from './api';
|
|
4
|
-
import { getPlatform,
|
|
5
|
+
import { getPlatform, resolveAppId } from './app';
|
|
5
6
|
import { choosePackage } from './package';
|
|
6
7
|
import type { Package, Platform, Version } from './types';
|
|
7
8
|
import { isNonInteractive, loadTtyTable, question } from './utils';
|
|
@@ -524,24 +525,59 @@ export const versionCommands = {
|
|
|
524
525
|
}
|
|
525
526
|
|
|
526
527
|
const platform = await getPlatform(options.platform);
|
|
527
|
-
|
|
528
|
-
if (!appId) {
|
|
529
|
-
appId = (
|
|
530
|
-
await getSelectedApp(platform, options.config as string | undefined)
|
|
531
|
-
).appId;
|
|
532
|
-
}
|
|
528
|
+
const appId = await resolveAppId({ ...options, platform });
|
|
533
529
|
const nonInteractive =
|
|
534
530
|
getBooleanOption(options, 'no-interactive', false) || isNonInteractive();
|
|
535
531
|
|
|
532
|
+
// The source map is archived with the version so `pushy symbolicate` can
|
|
533
|
+
// map crashes back to source. An explicit path that does not exist is a
|
|
534
|
+
// publish error; no path at all is a loud warning (custom pipelines that
|
|
535
|
+
// never produced a map keep working).
|
|
536
|
+
const sourcemapPath =
|
|
537
|
+
typeof options.sourcemap === 'string' && options.sourcemap
|
|
538
|
+
? options.sourcemap
|
|
539
|
+
: undefined;
|
|
540
|
+
if (sourcemapPath && !fs.existsSync(sourcemapPath)) {
|
|
541
|
+
throw new Error(t('sourceMapNotFound', { path: sourcemapPath }));
|
|
542
|
+
}
|
|
543
|
+
if (!sourcemapPath) {
|
|
544
|
+
console.log(chalk.yellow(t('sourceMapMissingWarning')));
|
|
545
|
+
}
|
|
546
|
+
|
|
536
547
|
// Hashing/caching the bundle and asking git for the commit are independent
|
|
537
548
|
// of the upload, so they overlap with it instead of running afterwards.
|
|
538
549
|
// describePpkBundle never rejects (best effort); a failed upload still
|
|
539
550
|
// fails the publish exactly as before.
|
|
540
|
-
|
|
551
|
+
// A server that predates source-map archiving (self-hosted, or a SaaS
|
|
552
|
+
// region not yet rolled) rejects the .map upload with 400; that must not
|
|
553
|
+
// fail the publish, only lose the archive.
|
|
554
|
+
let sourceMapUploadError: unknown;
|
|
555
|
+
const [{ hash }, bundleMeta, commit, sourceMapUpload] = await Promise.all([
|
|
541
556
|
uploadFile(fn, undefined, appId),
|
|
542
557
|
describePpkBundle(fn, options.hermesBase),
|
|
543
558
|
getCommitInfo(),
|
|
559
|
+
sourcemapPath
|
|
560
|
+
? uploadFile(sourcemapPath, undefined, appId).catch(
|
|
561
|
+
(error: unknown) => {
|
|
562
|
+
sourceMapUploadError = error;
|
|
563
|
+
return undefined;
|
|
564
|
+
},
|
|
565
|
+
)
|
|
566
|
+
: Promise.resolve(undefined),
|
|
544
567
|
]);
|
|
568
|
+
const sourceMapKey = sourceMapUpload?.hash;
|
|
569
|
+
if (sourcemapPath && !sourceMapKey) {
|
|
570
|
+
console.log(
|
|
571
|
+
chalk.yellow(
|
|
572
|
+
t('sourceMapUploadFailedWarning', {
|
|
573
|
+
error:
|
|
574
|
+
sourceMapUploadError instanceof Error
|
|
575
|
+
? sourceMapUploadError.message
|
|
576
|
+
: String(sourceMapUploadError),
|
|
577
|
+
}),
|
|
578
|
+
),
|
|
579
|
+
);
|
|
580
|
+
}
|
|
545
581
|
const depVersions = getDepVersions();
|
|
546
582
|
|
|
547
583
|
const versionName =
|
|
@@ -561,8 +597,13 @@ export const versionCommands = {
|
|
|
561
597
|
commit,
|
|
562
598
|
// Hermes delta-mode chain metadata (old servers drop unknown fields)
|
|
563
599
|
...bundleMeta,
|
|
600
|
+
// archived source map (old servers drop unknown fields)
|
|
601
|
+
...(sourceMapKey ? { sourceMapKey } : {}),
|
|
564
602
|
});
|
|
565
603
|
console.log(t('packageUploadSuccess', { id }));
|
|
604
|
+
if (sourceMapKey) {
|
|
605
|
+
console.log(t('sourceMapArchived', { id }));
|
|
606
|
+
}
|
|
566
607
|
|
|
567
608
|
const {
|
|
568
609
|
packageId,
|
|
@@ -585,6 +626,7 @@ export const versionCommands = {
|
|
|
585
626
|
options: {
|
|
586
627
|
versionId: id,
|
|
587
628
|
platform,
|
|
629
|
+
appId,
|
|
588
630
|
packageId,
|
|
589
631
|
packageVersion,
|
|
590
632
|
packageVersionRange,
|
|
@@ -603,6 +645,7 @@ export const versionCommands = {
|
|
|
603
645
|
options: {
|
|
604
646
|
versionId: id,
|
|
605
647
|
platform,
|
|
648
|
+
appId,
|
|
606
649
|
versionDeps: depVersions,
|
|
607
650
|
warnDepsChanges: true,
|
|
608
651
|
},
|
|
@@ -612,38 +655,23 @@ export const versionCommands = {
|
|
|
612
655
|
return versionName;
|
|
613
656
|
},
|
|
614
657
|
versions: async ({ options }: { options: VersionCommandOptions }) => {
|
|
615
|
-
|
|
616
|
-
if (!appId) {
|
|
617
|
-
const platform = await getPlatform(options.platform);
|
|
618
|
-
appId = (
|
|
619
|
-
await getSelectedApp(platform, options.config as string | undefined)
|
|
620
|
-
).appId;
|
|
621
|
-
}
|
|
658
|
+
const appId = await resolveAppId(options);
|
|
622
659
|
const interactive = !(
|
|
623
660
|
getBooleanOption(options, 'no-interactive', false) || isNonInteractive()
|
|
624
661
|
);
|
|
625
|
-
await listVersions(
|
|
662
|
+
await listVersions(appId, interactive);
|
|
626
663
|
},
|
|
627
664
|
update: async ({ options }: { options: VersionCommandOptions }) => {
|
|
628
665
|
const nonInteractive =
|
|
629
666
|
getBooleanOption(options, 'no-interactive', false) || isNonInteractive();
|
|
630
|
-
|
|
631
|
-
let platform = options.platform;
|
|
632
|
-
if (!appId) {
|
|
633
|
-
platform = await getPlatform(platform);
|
|
634
|
-
appId = (
|
|
635
|
-
await getSelectedApp(platform, options.config as string | undefined)
|
|
636
|
-
).appId;
|
|
637
|
-
} else if (platform) {
|
|
638
|
-
platform = await getPlatform(platform);
|
|
639
|
-
}
|
|
667
|
+
const appId = await resolveAppId(options);
|
|
640
668
|
|
|
641
669
|
let versionId: string | null | undefined = options.versionId;
|
|
642
670
|
if (!versionId) {
|
|
643
671
|
if (nonInteractive) {
|
|
644
672
|
throw new Error(t('versionIdRequired'));
|
|
645
673
|
}
|
|
646
|
-
versionId = String((await chooseVersion(
|
|
674
|
+
versionId = String((await chooseVersion(appId)).id);
|
|
647
675
|
}
|
|
648
676
|
if (versionId === 'null') {
|
|
649
677
|
versionId = null;
|
|
@@ -663,7 +691,7 @@ export const versionCommands = {
|
|
|
663
691
|
}
|
|
664
692
|
}
|
|
665
693
|
|
|
666
|
-
const allPkgs = await getAllPackages(
|
|
694
|
+
const allPkgs = await getAllPackages(appId);
|
|
667
695
|
|
|
668
696
|
if (!allPkgs) {
|
|
669
697
|
throw new Error(t('noPackagesFound', { appId }));
|
|
@@ -739,7 +767,7 @@ export const versionCommands = {
|
|
|
739
767
|
throw new Error(t('packageIdRequired'));
|
|
740
768
|
}
|
|
741
769
|
// the package list was already fetched above: no second round trip
|
|
742
|
-
pkgId = String((await choosePackage(
|
|
770
|
+
pkgId = String((await choosePackage(appId, allPkgs)).id);
|
|
743
771
|
}
|
|
744
772
|
|
|
745
773
|
if (!pkgId) {
|
|
@@ -755,7 +783,7 @@ export const versionCommands = {
|
|
|
755
783
|
|
|
756
784
|
if (options.warnDepsChanges && versionId) {
|
|
757
785
|
await printDepsChangesForPublish({
|
|
758
|
-
appId
|
|
786
|
+
appId,
|
|
759
787
|
versionId: String(versionId),
|
|
760
788
|
pkgs: pkgsToBind,
|
|
761
789
|
providedVersionDeps: options.versionDeps,
|
|
@@ -763,7 +791,7 @@ export const versionCommands = {
|
|
|
763
791
|
}
|
|
764
792
|
|
|
765
793
|
await bindVersionToPackages({
|
|
766
|
-
appId
|
|
794
|
+
appId,
|
|
767
795
|
// keep null as-is: `--versionId null` means unbinding the version
|
|
768
796
|
versionId: versionId ?? null,
|
|
769
797
|
pkgs: pkgsToBind,
|
|
@@ -778,23 +806,14 @@ export const versionCommands = {
|
|
|
778
806
|
}) => {
|
|
779
807
|
const nonInteractive =
|
|
780
808
|
getBooleanOption(options, 'no-interactive', false) || isNonInteractive();
|
|
781
|
-
|
|
782
|
-
let platform = options.platform;
|
|
783
|
-
if (!appId) {
|
|
784
|
-
platform = await getPlatform(platform);
|
|
785
|
-
appId = (
|
|
786
|
-
await getSelectedApp(platform, options.config as string | undefined)
|
|
787
|
-
).appId;
|
|
788
|
-
} else if (platform) {
|
|
789
|
-
await getPlatform(platform);
|
|
790
|
-
}
|
|
809
|
+
const appId = await resolveAppId(options);
|
|
791
810
|
|
|
792
811
|
let versionId = options.versionId;
|
|
793
812
|
if (!versionId) {
|
|
794
813
|
if (nonInteractive) {
|
|
795
814
|
throw new Error(t('versionIdRequired'));
|
|
796
815
|
}
|
|
797
|
-
versionId = String((await chooseVersion(
|
|
816
|
+
versionId = String((await chooseVersion(appId)).id);
|
|
798
817
|
}
|
|
799
818
|
|
|
800
819
|
const updateParams: Record<string, string> = {};
|
|
@@ -802,19 +821,13 @@ export const versionCommands = {
|
|
|
802
821
|
if (options.description) updateParams.description = options.description;
|
|
803
822
|
if (options.metaInfo) updateParams.metaInfo = options.metaInfo;
|
|
804
823
|
|
|
805
|
-
await put(`/app/${
|
|
824
|
+
await put(`/app/${appId}/version/${versionId}`, updateParams);
|
|
806
825
|
console.log(t('operationSuccess'));
|
|
807
826
|
},
|
|
808
827
|
deleteVersion: async ({ options }: { options: VersionCommandOptions }) => {
|
|
809
828
|
const nonInteractive =
|
|
810
829
|
getBooleanOption(options, 'no-interactive', false) || isNonInteractive();
|
|
811
|
-
|
|
812
|
-
if (!appId) {
|
|
813
|
-
const platform = await getPlatform(options.platform);
|
|
814
|
-
appId = (
|
|
815
|
-
await getSelectedApp(platform, options.config as string | undefined)
|
|
816
|
-
).appId;
|
|
817
|
-
}
|
|
830
|
+
const appId = await resolveAppId(options);
|
|
818
831
|
|
|
819
832
|
const parsedVersionIds =
|
|
820
833
|
getStringListOption(options, 'versionIds') ??
|
|
@@ -824,16 +837,16 @@ export const versionCommands = {
|
|
|
824
837
|
if (nonInteractive) {
|
|
825
838
|
throw new Error(t('versionIdRequired'));
|
|
826
839
|
}
|
|
827
|
-
versionIds = [String((await chooseVersion(
|
|
840
|
+
versionIds = [String((await chooseVersion(appId)).id)];
|
|
828
841
|
}
|
|
829
842
|
|
|
830
843
|
try {
|
|
831
844
|
if (versionIds.length === 1) {
|
|
832
845
|
const [versionId] = versionIds;
|
|
833
|
-
await doDelete(`/app/${
|
|
846
|
+
await doDelete(`/app/${appId}/version/${versionId}`);
|
|
834
847
|
console.log(t('deleteVersionSuccess', { versionId }));
|
|
835
848
|
} else {
|
|
836
|
-
await doDelete(`/app/${
|
|
849
|
+
await doDelete(`/app/${appId}/version`, {
|
|
837
850
|
versionIds: toNumericIds(versionIds),
|
|
838
851
|
});
|
|
839
852
|
console.log(
|