react-native-update-cli 2.24.2 → 2.26.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 +12 -5
- package/README.zh-CN.md +12 -5
- package/cli.json +7 -1
- package/lib/api.d.ts +2 -0
- package/lib/api.js +63 -18
- package/lib/app.js +25 -3
- package/lib/bin.js +39 -45
- package/lib/bundle-runner.d.ts +45 -1
- package/lib/bundle-runner.js +303 -34
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +23 -7
- package/lib/commands.d.ts +6 -0
- package/lib/commands.js +65 -0
- package/lib/locales/en.d.ts +7 -14
- package/lib/locales/en.js +10 -17
- package/lib/locales/zh.d.ts +7 -13
- package/lib/locales/zh.js +10 -16
- package/lib/package.js +4 -0
- package/lib/provider.d.ts +1 -1
- package/lib/provider.js +3 -1
- package/lib/symbolicate.js +7 -2
- package/lib/types.d.ts +1 -0
- package/lib/user.js +6 -0
- package/lib/utils/add-gitignore.js +7 -1
- package/lib/utils/dep-versions.d.ts +7 -0
- package/lib/utils/dep-versions.js +78 -26
- package/lib/utils/git.js +9 -6
- package/lib/utils/hbcTransform.d.ts +15 -0
- package/lib/utils/hbcTransform.js +22 -0
- package/lib/utils/hermes-base.d.ts +61 -6
- package/lib/utils/hermes-base.js +328 -46
- package/lib/utils/hermes-literals.d.ts +51 -0
- package/lib/utils/hermes-literals.js +210 -0
- package/lib/utils/i18n.d.ts +5 -0
- package/lib/utils/i18n.js +14 -1
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +9 -4
- package/lib/utils/latest-version/index.js +8 -0
- package/lib/utils/runtime.d.ts +21 -0
- package/lib/utils/runtime.js +138 -5
- package/lib/utils/zip-range.js +3 -2
- package/lib/versions.js +14 -4
- package/package.json +6 -3
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -17
- package/src/api.ts +0 -470
- package/src/app.ts +0 -241
- package/src/auto-update.ts +0 -647
- package/src/bin-cresc.ts +0 -8
- package/src/bin.ts +0 -115
- package/src/bundle-pack.ts +0 -61
- package/src/bundle-runner.ts +0 -1430
- package/src/bundle.ts +0 -371
- package/src/cache.ts +0 -20
- package/src/diff.ts +0 -1010
- package/src/exports.ts +0 -17
- package/src/index.ts +0 -1
- package/src/install.ts +0 -50
- package/src/locales/en.ts +0 -257
- package/src/locales/zh.ts +0 -234
- package/src/native-package.ts +0 -338
- package/src/package.ts +0 -482
- package/src/provider.ts +0 -294
- package/src/symbolicate.ts +0 -164
- package/src/types.ts +0 -150
- package/src/user.ts +0 -39
- package/src/utils/add-gitignore.ts +0 -35
- package/src/utils/app-info-parser/aab.ts +0 -241
- package/src/utils/app-info-parser/apk.ts +0 -92
- package/src/utils/app-info-parser/app.ts +0 -7
- package/src/utils/app-info-parser/index.ts +0 -54
- package/src/utils/app-info-parser/ipa.ts +0 -109
- package/src/utils/app-info-parser/resource-finder.ts +0 -508
- package/src/utils/app-info-parser/utils.ts +0 -161
- package/src/utils/app-info-parser/xml-parser/binary.ts +0 -693
- package/src/utils/app-info-parser/xml-parser/manifest.ts +0 -228
- package/src/utils/app-info-parser/zip.ts +0 -108
- package/src/utils/check-lockfile.ts +0 -93
- package/src/utils/check-plugin.ts +0 -38
- package/src/utils/command-result.ts +0 -24
- package/src/utils/constants.ts +0 -25
- package/src/utils/dep-versions.ts +0 -83
- package/src/utils/git.ts +0 -71
- package/src/utils/hbcTransform.ts +0 -649
- package/src/utils/hermes-base.ts +0 -1137
- package/src/utils/http-helper.ts +0 -152
- package/src/utils/i18n.ts +0 -39
- package/src/utils/index.ts +0 -698
- package/src/utils/latest-version/index.ts +0 -573
- package/src/utils/options.ts +0 -78
- package/src/utils/plugin-config.ts +0 -32
- package/src/utils/runtime.ts +0 -187
- package/src/utils/slim-sourcemap.ts +0 -105
- package/src/utils/zip-entries.ts +0 -209
- package/src/utils/zip-options.ts +0 -178
- package/src/utils/zip-range.ts +0 -727
- package/src/utils/zip-raw-writer.ts +0 -247
- package/src/versions.ts +0 -892
package/src/provider.ts
DELETED
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import { getSession, loadSession } from './api';
|
|
2
|
-
import { getPlatform, getSelectedApp } from './app';
|
|
3
|
-
import type {
|
|
4
|
-
BundleOptions,
|
|
5
|
-
CLIProvider,
|
|
6
|
-
CommandContext,
|
|
7
|
-
CommandResult,
|
|
8
|
-
Platform,
|
|
9
|
-
PublishOptions,
|
|
10
|
-
Session,
|
|
11
|
-
SymbolicateOptions,
|
|
12
|
-
UpdateVersionOptions,
|
|
13
|
-
UploadOptions,
|
|
14
|
-
} from './types';
|
|
15
|
-
import { runAsCommandResult } from './utils/command-result';
|
|
16
|
-
import { t } from './utils/i18n';
|
|
17
|
-
|
|
18
|
-
const DEFAULT_BUNDLE_OUTPUT =
|
|
19
|
-
'$' + '{tempDir}/output/$' + '{platform}.$' + '{time}.ppk';
|
|
20
|
-
|
|
21
|
-
export class CLIProviderImpl implements CLIProvider {
|
|
22
|
-
private session?: Session;
|
|
23
|
-
private sessionInitPromise?: Promise<void>;
|
|
24
|
-
|
|
25
|
-
private createContext(
|
|
26
|
-
options: Record<string, unknown>,
|
|
27
|
-
args: string[] = [],
|
|
28
|
-
): CommandContext {
|
|
29
|
-
return { args, options };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private async ensureInitialized(): Promise<void> {
|
|
33
|
-
if (this.session) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!this.sessionInitPromise) {
|
|
38
|
-
this.sessionInitPromise = (async () => {
|
|
39
|
-
await loadSession();
|
|
40
|
-
this.session = getSession();
|
|
41
|
-
})().finally(() => {
|
|
42
|
-
this.sessionInitPromise = undefined;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
await this.sessionInitPromise;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private runMessageCommand(
|
|
50
|
-
task: () => Promise<void>,
|
|
51
|
-
fallbackError: string,
|
|
52
|
-
successMessage: string,
|
|
53
|
-
requireSession = true,
|
|
54
|
-
): Promise<CommandResult> {
|
|
55
|
-
return runAsCommandResult(
|
|
56
|
-
async () => {
|
|
57
|
-
if (requireSession) {
|
|
58
|
-
await this.ensureInitialized();
|
|
59
|
-
}
|
|
60
|
-
await task();
|
|
61
|
-
},
|
|
62
|
-
fallbackError,
|
|
63
|
-
() => ({ message: successMessage }),
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private runDataCommand<T>(
|
|
68
|
-
task: () => Promise<T>,
|
|
69
|
-
fallbackError: string,
|
|
70
|
-
requireSession = true,
|
|
71
|
-
): Promise<CommandResult> {
|
|
72
|
-
return runAsCommandResult(async () => {
|
|
73
|
-
if (requireSession) {
|
|
74
|
-
await this.ensureInitialized();
|
|
75
|
-
}
|
|
76
|
-
return task();
|
|
77
|
-
}, fallbackError);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async bundle(options: BundleOptions): Promise<CommandResult> {
|
|
81
|
-
return this.runMessageCommand(
|
|
82
|
-
async () => {
|
|
83
|
-
const context = this.createContext({
|
|
84
|
-
dev: options.dev || false,
|
|
85
|
-
platform: options.platform,
|
|
86
|
-
bundleName: options.bundleName || 'index.bundlejs',
|
|
87
|
-
entryFile: options.entryFile || 'index.js',
|
|
88
|
-
output: options.output || DEFAULT_BUNDLE_OUTPUT,
|
|
89
|
-
'no-interactive': true,
|
|
90
|
-
sourcemap: options.sourcemap || false,
|
|
91
|
-
taro: options.taro || false,
|
|
92
|
-
expo: options.expo || false,
|
|
93
|
-
rncli: options.rncli || false,
|
|
94
|
-
hermes: options.hermes || false,
|
|
95
|
-
hermesBase: options.hermesBase || 'auto',
|
|
96
|
-
verifyHermesBase: options.verifyHermesBase ?? true,
|
|
97
|
-
sentryRelease: options.sentryRelease,
|
|
98
|
-
sentryDist: options.sentryDist,
|
|
99
|
-
appId: options.appId,
|
|
100
|
-
config: options.config,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const { bundleCommands } = await import('./bundle');
|
|
104
|
-
await bundleCommands.bundle(context);
|
|
105
|
-
},
|
|
106
|
-
'Unknown error during bundling',
|
|
107
|
-
'Bundle created successfully',
|
|
108
|
-
false,
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async publish(options: PublishOptions): Promise<CommandResult> {
|
|
113
|
-
return this.runMessageCommand(
|
|
114
|
-
async () => {
|
|
115
|
-
const context = this.createContext(
|
|
116
|
-
{
|
|
117
|
-
name: options.name,
|
|
118
|
-
description: options.description,
|
|
119
|
-
metaInfo: options.metaInfo,
|
|
120
|
-
packageId: options.packageId,
|
|
121
|
-
packageVersion: options.packageVersion,
|
|
122
|
-
minPackageVersion: options.minPackageVersion,
|
|
123
|
-
maxPackageVersion: options.maxPackageVersion,
|
|
124
|
-
packageVersionRange: options.packageVersionRange,
|
|
125
|
-
platform: options.platform,
|
|
126
|
-
appId: options.appId,
|
|
127
|
-
config: options.config,
|
|
128
|
-
'no-interactive': true,
|
|
129
|
-
rollout:
|
|
130
|
-
options.rollout === undefined
|
|
131
|
-
? undefined
|
|
132
|
-
: String(options.rollout),
|
|
133
|
-
dryRun: options.dryRun || false,
|
|
134
|
-
sourcemap: options.sourcemap,
|
|
135
|
-
},
|
|
136
|
-
options.filePath ? [options.filePath] : [],
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
const { versionCommands } = await import('./versions');
|
|
140
|
-
await versionCommands.publish(context);
|
|
141
|
-
},
|
|
142
|
-
'Unknown error during publishing',
|
|
143
|
-
'Version published successfully',
|
|
144
|
-
);
|
|
145
|
-
}
|
|
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
|
-
|
|
169
|
-
async upload(options: UploadOptions): Promise<CommandResult> {
|
|
170
|
-
return this.runMessageCommand(
|
|
171
|
-
async () => {
|
|
172
|
-
const filePath = options.filePath;
|
|
173
|
-
const fileType = filePath.split('.').pop()?.toLowerCase();
|
|
174
|
-
|
|
175
|
-
const context = this.createContext(
|
|
176
|
-
{
|
|
177
|
-
platform: options.platform,
|
|
178
|
-
appId: options.appId,
|
|
179
|
-
appKey: options.appKey,
|
|
180
|
-
version: options.version,
|
|
181
|
-
config: options.config,
|
|
182
|
-
},
|
|
183
|
-
[filePath],
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
const { packageCommands } = await import('./package');
|
|
187
|
-
const uploadHandlerMap = {
|
|
188
|
-
ipa: packageCommands.uploadIpa,
|
|
189
|
-
apk: packageCommands.uploadApk,
|
|
190
|
-
aab: packageCommands.uploadAab,
|
|
191
|
-
app: packageCommands.uploadApp,
|
|
192
|
-
} as const;
|
|
193
|
-
const uploadHandler =
|
|
194
|
-
fileType && fileType in uploadHandlerMap
|
|
195
|
-
? uploadHandlerMap[fileType as keyof typeof uploadHandlerMap]
|
|
196
|
-
: undefined;
|
|
197
|
-
|
|
198
|
-
if (!uploadHandler) {
|
|
199
|
-
throw new Error(t('unsupportedFileType', { fileType }));
|
|
200
|
-
}
|
|
201
|
-
await uploadHandler(context);
|
|
202
|
-
},
|
|
203
|
-
'Unknown error during upload',
|
|
204
|
-
'File uploaded successfully',
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
async getSelectedApp(
|
|
209
|
-
platform?: Platform,
|
|
210
|
-
config?: string,
|
|
211
|
-
): Promise<{ appId: string; platform: Platform }> {
|
|
212
|
-
const resolvedPlatform = await this.getPlatform(platform);
|
|
213
|
-
return getSelectedApp(resolvedPlatform, config);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
async listApps(platform?: Platform): Promise<CommandResult> {
|
|
217
|
-
return this.runDataCommand(async () => {
|
|
218
|
-
const { getAppCommands } = await import('./app');
|
|
219
|
-
return getAppCommands().apps({
|
|
220
|
-
options: { platform: platform ?? '' },
|
|
221
|
-
});
|
|
222
|
-
}, 'Unknown error listing apps');
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
async createApp(name: string, platform: Platform): Promise<CommandResult> {
|
|
226
|
-
return this.runMessageCommand(
|
|
227
|
-
async () => {
|
|
228
|
-
const { getAppCommands } = await import('./app');
|
|
229
|
-
await getAppCommands().createApp({
|
|
230
|
-
options: {
|
|
231
|
-
name,
|
|
232
|
-
platform,
|
|
233
|
-
downloadUrl: '',
|
|
234
|
-
},
|
|
235
|
-
});
|
|
236
|
-
},
|
|
237
|
-
'Unknown error creating app',
|
|
238
|
-
'App created successfully',
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
async listVersions(appId: string): Promise<CommandResult> {
|
|
243
|
-
return this.runDataCommand(async () => {
|
|
244
|
-
const { fetchVersions } = await import('./versions');
|
|
245
|
-
return fetchVersions(appId);
|
|
246
|
-
}, 'Unknown error listing versions');
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
async updateVersion(
|
|
250
|
-
appId: string,
|
|
251
|
-
versionId: string,
|
|
252
|
-
updates: UpdateVersionOptions,
|
|
253
|
-
): Promise<CommandResult> {
|
|
254
|
-
return this.runMessageCommand(
|
|
255
|
-
async () => {
|
|
256
|
-
const context = this.createContext({
|
|
257
|
-
appId,
|
|
258
|
-
versionId,
|
|
259
|
-
...updates,
|
|
260
|
-
'no-interactive': true,
|
|
261
|
-
rollout:
|
|
262
|
-
updates.rollout === undefined ? undefined : String(updates.rollout),
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
const { versionCommands } = await import('./versions');
|
|
266
|
-
await versionCommands.update(context);
|
|
267
|
-
},
|
|
268
|
-
'Unknown error updating version',
|
|
269
|
-
'Version updated successfully',
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
async getPlatform(platform?: Platform): Promise<Platform> {
|
|
274
|
-
return getPlatform(platform);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
async loadSession(): Promise<Session> {
|
|
278
|
-
await this.ensureInitialized();
|
|
279
|
-
if (!this.session) {
|
|
280
|
-
throw new Error(t('failedToLoadSession'));
|
|
281
|
-
}
|
|
282
|
-
return this.session;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
async listPackages(appId?: string): Promise<CommandResult> {
|
|
286
|
-
return this.runDataCommand(async () => {
|
|
287
|
-
if (!appId) {
|
|
288
|
-
throw new Error(t('appIdRequired'));
|
|
289
|
-
}
|
|
290
|
-
const { listPackage } = await import('./package');
|
|
291
|
-
return listPackage(appId);
|
|
292
|
-
}, 'Unknown error listing packages');
|
|
293
|
-
}
|
|
294
|
-
}
|
package/src/symbolicate.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
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 { unpackSourceMap } from './utils/slim-sourcemap';
|
|
9
|
-
import { fetchVersions } from './versions';
|
|
10
|
-
|
|
11
|
-
// A frame location inside a shipped bundle: `<bundle>:<line>:<column>`. Covers
|
|
12
|
-
// `index.bundlejs`, `index.android.bundle`, `main.jsbundle`, `bundle.harmony.js`
|
|
13
|
-
// and plain `.js`/`.hbc` names; an optional `address at ` prefix marks a
|
|
14
|
-
// Hermes bytecode frame (column = bytecode offset, already 0-based).
|
|
15
|
-
const FRAME_PATTERN =
|
|
16
|
-
/(address at )?((?:[\w.-]+\/)*[\w.-]+\.(?:bundlejs|jsbundle|bundle|hbc|js))(?:\?[^\s:)]*)?:(\d+):(\d+)/g;
|
|
17
|
-
|
|
18
|
-
export interface FrameConsumer {
|
|
19
|
-
originalPositionFor(position: { line: number; column: number }): {
|
|
20
|
-
source?: string | null;
|
|
21
|
-
line?: number | null;
|
|
22
|
-
column?: number | null;
|
|
23
|
-
name?: string | null;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Rewrites every bundle frame of `stack` to its original source position.
|
|
29
|
-
* JS engines report 1-based columns, so they are shifted to the 0-based
|
|
30
|
-
* columns source maps use; Hermes bytecode frames (`address at`) carry the
|
|
31
|
-
* bytecode offset, which the composed hermes map keys directly.
|
|
32
|
-
*/
|
|
33
|
-
export function symbolicateStack(
|
|
34
|
-
stack: string,
|
|
35
|
-
consumer: FrameConsumer,
|
|
36
|
-
): { text: string; mapped: number } {
|
|
37
|
-
let mapped = 0;
|
|
38
|
-
const text = stack.replace(
|
|
39
|
-
FRAME_PATTERN,
|
|
40
|
-
(
|
|
41
|
-
frame,
|
|
42
|
-
hermes: string | undefined,
|
|
43
|
-
_bundle,
|
|
44
|
-
line: string,
|
|
45
|
-
column: string,
|
|
46
|
-
) => {
|
|
47
|
-
const position = consumer.originalPositionFor({
|
|
48
|
-
line: Number(line),
|
|
49
|
-
column: hermes ? Number(column) : Math.max(0, Number(column) - 1),
|
|
50
|
-
});
|
|
51
|
-
if (
|
|
52
|
-
!position.source ||
|
|
53
|
-
position.line === null ||
|
|
54
|
-
position.line === undefined
|
|
55
|
-
) {
|
|
56
|
-
return frame;
|
|
57
|
-
}
|
|
58
|
-
mapped++;
|
|
59
|
-
const original = `${position.source}:${position.line}:${(position.column ?? 0) + 1}`;
|
|
60
|
-
return position.name ? `${original} (${position.name})` : original;
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
return { text, mapped };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async function findVersionByHash(
|
|
67
|
-
appId: string,
|
|
68
|
-
hash: string,
|
|
69
|
-
): Promise<Version | undefined> {
|
|
70
|
-
const limit = 100;
|
|
71
|
-
// The list is newest-first; crashes are usually about recent versions.
|
|
72
|
-
for (let offset = 0; offset < 100 * limit; offset += limit) {
|
|
73
|
-
const page = await fetchVersions(appId, offset, limit);
|
|
74
|
-
const found = page.find((version) => version.hash === hash);
|
|
75
|
-
if (found) {
|
|
76
|
-
return found;
|
|
77
|
-
}
|
|
78
|
-
if (page.length < limit) {
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async function readStack(source: string | undefined): Promise<string> {
|
|
86
|
-
if (!source || source === '-') {
|
|
87
|
-
return new Promise((resolve, reject) => {
|
|
88
|
-
const chunks: Buffer[] = [];
|
|
89
|
-
process.stdin.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
|
|
90
|
-
process.stdin.on('end', () =>
|
|
91
|
-
resolve(Buffer.concat(chunks).toString('utf8')),
|
|
92
|
-
);
|
|
93
|
-
process.stdin.on('error', reject);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return fs.readFileSync(source, 'utf8');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export const symbolicateCommands = {
|
|
100
|
-
symbolicate: async ({
|
|
101
|
-
args,
|
|
102
|
-
options,
|
|
103
|
-
}: {
|
|
104
|
-
args: string[];
|
|
105
|
-
options: Record<string, unknown>;
|
|
106
|
-
}) => {
|
|
107
|
-
const hash = typeof options.hash === 'string' ? options.hash : '';
|
|
108
|
-
const versionIdOption =
|
|
109
|
-
typeof options.versionId === 'string' ? options.versionId : '';
|
|
110
|
-
if (!hash && !versionIdOption) {
|
|
111
|
-
throw new Error(t('symbolicateUsage'));
|
|
112
|
-
}
|
|
113
|
-
const platform = await getPlatform(
|
|
114
|
-
typeof options.platform === 'string'
|
|
115
|
-
? (options.platform as Platform)
|
|
116
|
-
: undefined,
|
|
117
|
-
);
|
|
118
|
-
const appId =
|
|
119
|
-
typeof options.appId === 'string' && options.appId
|
|
120
|
-
? options.appId
|
|
121
|
-
: (await getSelectedApp(platform, options.config as string | undefined))
|
|
122
|
-
.appId;
|
|
123
|
-
|
|
124
|
-
let versionId = versionIdOption;
|
|
125
|
-
if (!versionId) {
|
|
126
|
-
const version = await findVersionByHash(appId, hash);
|
|
127
|
-
if (!version) {
|
|
128
|
-
throw new Error(t('symbolicateVersionNotFound', { hash }));
|
|
129
|
-
}
|
|
130
|
-
versionId = String(version.id);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const located = await get(`/app/${appId}/version/${versionId}/sourceMap`);
|
|
134
|
-
if (!located?.url) {
|
|
135
|
-
throw new Error(t('symbolicateNoSourceMap', { id: versionId }));
|
|
136
|
-
}
|
|
137
|
-
const response = await fetch(located.url);
|
|
138
|
-
if (!response.ok) {
|
|
139
|
-
throw new Error(`Failed to download source map: HTTP ${response.status}`);
|
|
140
|
-
}
|
|
141
|
-
// Maps archived by recent CLI versions are gzipped; older ones are plain
|
|
142
|
-
// JSON, and unpackSourceMap accepts both.
|
|
143
|
-
const rawMap = JSON.parse(
|
|
144
|
-
unpackSourceMap(Buffer.from(await response.arrayBuffer())),
|
|
145
|
-
);
|
|
146
|
-
const consumer = new SourceMapConsumer(rawMap);
|
|
147
|
-
|
|
148
|
-
const stack = await readStack(args[0]);
|
|
149
|
-
const { text, mapped } = symbolicateStack(stack, consumer);
|
|
150
|
-
if (typeof options.output === 'string' && options.output) {
|
|
151
|
-
fs.writeFileSync(options.output, text);
|
|
152
|
-
} else {
|
|
153
|
-
process.stdout.write(text.endsWith('\n') ? text : `${text}\n`);
|
|
154
|
-
}
|
|
155
|
-
console.error(
|
|
156
|
-
t('symbolicateDone', {
|
|
157
|
-
count: mapped,
|
|
158
|
-
id: versionId,
|
|
159
|
-
hash: located.hash ?? hash,
|
|
160
|
-
}),
|
|
161
|
-
);
|
|
162
|
-
return { versionId, mapped };
|
|
163
|
-
},
|
|
164
|
-
};
|
package/src/types.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
var NO_INTERACTIVE: boolean | undefined;
|
|
3
|
-
var USE_ACC_OSS: boolean | undefined;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface Session {
|
|
7
|
-
token: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type Platform = 'ios' | 'android' | 'harmony';
|
|
11
|
-
|
|
12
|
-
export interface Package {
|
|
13
|
-
// server-side ids are numeric (auto-increment primary keys)
|
|
14
|
-
id: number;
|
|
15
|
-
name: string;
|
|
16
|
-
version?: string;
|
|
17
|
-
status?: string;
|
|
18
|
-
appId?: string;
|
|
19
|
-
appKey?: string;
|
|
20
|
-
versionName?: string | number | null;
|
|
21
|
-
buildTime?: string | number | null;
|
|
22
|
-
deps?: Record<string, string> | string | null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface Version {
|
|
26
|
-
id: number;
|
|
27
|
-
hash: string;
|
|
28
|
-
name: string;
|
|
29
|
-
packages?: Package[];
|
|
30
|
-
deps?: Record<string, string> | string | null;
|
|
31
|
-
/** storage key of the archived source map (absent when published without one) */
|
|
32
|
-
sourceMapKey?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface CommandContext<
|
|
36
|
-
TOptions extends Record<string, unknown> = Record<string, unknown>,
|
|
37
|
-
> {
|
|
38
|
-
args: string[];
|
|
39
|
-
options: TOptions;
|
|
40
|
-
platform?: Platform;
|
|
41
|
-
appId?: string;
|
|
42
|
-
session?: Session;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface CommandResult {
|
|
46
|
-
success: boolean;
|
|
47
|
-
data?: unknown;
|
|
48
|
-
error?: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface BundleOptions {
|
|
52
|
-
dev?: boolean;
|
|
53
|
-
platform?: Platform;
|
|
54
|
-
bundleName?: string;
|
|
55
|
-
entryFile?: string;
|
|
56
|
-
output?: string;
|
|
57
|
-
sourcemap?: boolean;
|
|
58
|
-
taro?: boolean;
|
|
59
|
-
expo?: boolean;
|
|
60
|
-
rncli?: boolean;
|
|
61
|
-
hermes?: boolean;
|
|
62
|
-
/** 'auto' (default) | 'none' | path to a .hbc/.ppk/.apk/.ipa used as hermesc -base-bytecode */
|
|
63
|
-
hermesBase?: string;
|
|
64
|
-
/** run the disassembly equivalence check after a base compile (default true) */
|
|
65
|
-
verifyHermesBase?: boolean;
|
|
66
|
-
/** pass --reset-cache to Metro (default true); false reuses its transform cache */
|
|
67
|
-
resetCache?: boolean;
|
|
68
|
-
sentryRelease?: string;
|
|
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;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface PublishOptions {
|
|
77
|
-
filePath?: string;
|
|
78
|
-
/** path of the final source map to archive with the version */
|
|
79
|
-
sourcemap?: string;
|
|
80
|
-
platform?: Platform;
|
|
81
|
-
name?: string;
|
|
82
|
-
description?: string;
|
|
83
|
-
metaInfo?: string;
|
|
84
|
-
packageId?: string;
|
|
85
|
-
packageVersion?: string;
|
|
86
|
-
minPackageVersion?: string;
|
|
87
|
-
maxPackageVersion?: string;
|
|
88
|
-
packageVersionRange?: string;
|
|
89
|
-
rollout?: number | string;
|
|
90
|
-
dryRun?: boolean;
|
|
91
|
-
appId?: string;
|
|
92
|
-
config?: string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface UploadOptions {
|
|
96
|
-
platform?: Platform;
|
|
97
|
-
filePath: string;
|
|
98
|
-
appId?: string;
|
|
99
|
-
appKey?: string;
|
|
100
|
-
version?: string;
|
|
101
|
-
config?: string;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export interface UpdateVersionOptions {
|
|
105
|
-
platform?: Platform;
|
|
106
|
-
packageId?: string;
|
|
107
|
-
packageVersion?: string;
|
|
108
|
-
minPackageVersion?: string;
|
|
109
|
-
maxPackageVersion?: string;
|
|
110
|
-
packageVersionRange?: string;
|
|
111
|
-
rollout?: number | string;
|
|
112
|
-
dryRun?: boolean;
|
|
113
|
-
}
|
|
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
|
-
|
|
128
|
-
export interface CLIProvider {
|
|
129
|
-
bundle: (options: BundleOptions) => Promise<CommandResult>;
|
|
130
|
-
publish: (options: PublishOptions) => Promise<CommandResult>;
|
|
131
|
-
symbolicate: (options: SymbolicateOptions) => Promise<CommandResult>;
|
|
132
|
-
upload: (options: UploadOptions) => Promise<CommandResult>;
|
|
133
|
-
|
|
134
|
-
createApp: (name: string, platform: Platform) => Promise<CommandResult>;
|
|
135
|
-
listApps: (platform?: Platform) => Promise<CommandResult>;
|
|
136
|
-
getSelectedApp: (
|
|
137
|
-
platform?: Platform,
|
|
138
|
-
config?: string,
|
|
139
|
-
) => Promise<{ appId: string; platform: Platform }>;
|
|
140
|
-
|
|
141
|
-
listVersions: (appId: string) => Promise<CommandResult>;
|
|
142
|
-
updateVersion: (
|
|
143
|
-
appId: string,
|
|
144
|
-
versionId: string,
|
|
145
|
-
updates: UpdateVersionOptions,
|
|
146
|
-
) => Promise<CommandResult>;
|
|
147
|
-
|
|
148
|
-
getPlatform: (platform?: Platform) => Promise<Platform>;
|
|
149
|
-
loadSession: () => Promise<Session>;
|
|
150
|
-
}
|
package/src/user.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
import { closeSession, get, post, replaceSession, saveSession } from './api';
|
|
3
|
-
import type { CommandContext } from './types';
|
|
4
|
-
import { question } from './utils';
|
|
5
|
-
import { addGitIgnore } from './utils/add-gitignore';
|
|
6
|
-
import { t } from './utils/i18n';
|
|
7
|
-
|
|
8
|
-
function md5(str: string) {
|
|
9
|
-
return crypto.createHash('md5').update(str).digest('hex');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const userCommands = {
|
|
13
|
-
login: async ({ args }: { args: string[] }) => {
|
|
14
|
-
const email = args[0] || (await question('email:'));
|
|
15
|
-
const pwd = args[1] || (await question('password:', true));
|
|
16
|
-
const { token, info } = await post('/user/login', {
|
|
17
|
-
email,
|
|
18
|
-
pwd: md5(pwd),
|
|
19
|
-
});
|
|
20
|
-
replaceSession({ token });
|
|
21
|
-
await saveSession();
|
|
22
|
-
// make sure the token file is ignored before the user's next commit,
|
|
23
|
-
// not only when they first run `bundle`
|
|
24
|
-
addGitIgnore();
|
|
25
|
-
console.log(t('welcomeMessage', { name: info.name }));
|
|
26
|
-
},
|
|
27
|
-
logout: async (_context: CommandContext) => {
|
|
28
|
-
await closeSession();
|
|
29
|
-
console.log(t('loggedOut'));
|
|
30
|
-
},
|
|
31
|
-
me: async () => {
|
|
32
|
-
const me = await get('/user/me');
|
|
33
|
-
for (const k in me) {
|
|
34
|
-
if (k !== 'ok') {
|
|
35
|
-
console.log(`${k}: ${me[k]}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
// import path from 'path';
|
|
3
|
-
import { credentialFile, tempDir } from './constants';
|
|
4
|
-
import { t } from './i18n';
|
|
5
|
-
|
|
6
|
-
export function addGitIgnore() {
|
|
7
|
-
const shouldIgnore = [credentialFile, tempDir];
|
|
8
|
-
|
|
9
|
-
const gitignorePath = '.gitignore';
|
|
10
|
-
|
|
11
|
-
if (!fs.existsSync(gitignorePath)) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const gitignoreContent = fs.readFileSync(gitignorePath, 'utf-8');
|
|
16
|
-
|
|
17
|
-
const gitignoreLines = gitignoreContent.split('\n');
|
|
18
|
-
|
|
19
|
-
for (const line of gitignoreLines) {
|
|
20
|
-
const index = shouldIgnore.indexOf(line.trim());
|
|
21
|
-
if (index !== -1) {
|
|
22
|
-
shouldIgnore.splice(index, 1);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (shouldIgnore.length > 0) {
|
|
27
|
-
gitignoreLines.push('# react-native-update');
|
|
28
|
-
for (const line of shouldIgnore) {
|
|
29
|
-
gitignoreLines.push(line);
|
|
30
|
-
console.log(t('addedToGitignore', { line }));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
fs.writeFileSync(gitignorePath, gitignoreLines.join('\n'));
|
|
34
|
-
}
|
|
35
|
-
}
|