react-native-update-cli 2.22.8 → 2.23.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 +3 -2
- package/README.zh-CN.md +3 -2
- package/cli.json +21 -1
- package/lib/bin.js +2 -0
- package/lib/bundle.js +9 -1
- package/lib/locales/en.d.ts +8 -0
- package/lib/locales/en.js +8 -0
- package/lib/locales/zh.d.ts +8 -0
- package/lib/locales/zh.js +8 -0
- package/lib/native-package.d.ts +5 -1
- package/lib/native-package.js +145 -84
- package/lib/provider.d.ts +2 -1
- package/lib/provider.js +15 -0
- package/lib/symbolicate.d.ts +30 -0
- package/lib/symbolicate.js +117 -0
- package/lib/types.d.ts +17 -0
- package/lib/utils/latest-version/index.js +28 -7
- package/lib/utils/zip-raw-writer.d.ts +47 -0
- package/lib/utils/zip-raw-writer.js +204 -0
- package/lib/versions.js +38 -1
- package/package.json +2 -3
- package/src/bin.ts +2 -0
- package/src/bundle.ts +13 -1
- package/src/locales/en.ts +14 -0
- package/src/locales/zh.ts +11 -0
- package/src/native-package.ts +186 -96
- package/src/provider.ts +24 -0
- package/src/symbolicate.ts +159 -0
- package/src/types.ts +18 -0
- package/src/utils/latest-version/index.ts +27 -4
- package/src/utils/zip-raw-writer.ts +247 -0
- package/src/versions.ts +47 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.symbolicateCommands = void 0;
|
|
7
|
+
exports.symbolicateStack = symbolicateStack;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
10
|
+
const source_map_1 = require("source-map");
|
|
11
|
+
const api_1 = require("./api");
|
|
12
|
+
const app_1 = require("./app");
|
|
13
|
+
const i18n_1 = require("./utils/i18n");
|
|
14
|
+
const versions_1 = require("./versions");
|
|
15
|
+
// A frame location inside a shipped bundle: `<bundle>:<line>:<column>`. Covers
|
|
16
|
+
// `index.bundlejs`, `index.android.bundle`, `main.jsbundle`, `bundle.harmony.js`
|
|
17
|
+
// and plain `.js`/`.hbc` names; an optional `address at ` prefix marks a
|
|
18
|
+
// Hermes bytecode frame (column = bytecode offset, already 0-based).
|
|
19
|
+
const FRAME_PATTERN = /(address at )?((?:[\w.-]+\/)*[\w.-]+\.(?:bundlejs|jsbundle|bundle|hbc|js))(?:\?[^\s:)]*)?:(\d+):(\d+)/g;
|
|
20
|
+
/**
|
|
21
|
+
* Rewrites every bundle frame of `stack` to its original source position.
|
|
22
|
+
* JS engines report 1-based columns, so they are shifted to the 0-based
|
|
23
|
+
* columns source maps use; Hermes bytecode frames (`address at`) carry the
|
|
24
|
+
* bytecode offset, which the composed hermes map keys directly.
|
|
25
|
+
*/
|
|
26
|
+
function symbolicateStack(stack, consumer) {
|
|
27
|
+
let mapped = 0;
|
|
28
|
+
const text = stack.replace(FRAME_PATTERN, (frame, hermes, _bundle, line, column) => {
|
|
29
|
+
const position = consumer.originalPositionFor({
|
|
30
|
+
line: Number(line),
|
|
31
|
+
column: hermes ? Number(column) : Math.max(0, Number(column) - 1),
|
|
32
|
+
});
|
|
33
|
+
if (!position.source ||
|
|
34
|
+
position.line === null ||
|
|
35
|
+
position.line === undefined) {
|
|
36
|
+
return frame;
|
|
37
|
+
}
|
|
38
|
+
mapped++;
|
|
39
|
+
const original = `${position.source}:${position.line}:${(position.column ?? 0) + 1}`;
|
|
40
|
+
return position.name ? `${original} (${position.name})` : original;
|
|
41
|
+
});
|
|
42
|
+
return { text, mapped };
|
|
43
|
+
}
|
|
44
|
+
async function findVersionByHash(appId, hash) {
|
|
45
|
+
const limit = 100;
|
|
46
|
+
// The list is newest-first; crashes are usually about recent versions.
|
|
47
|
+
for (let offset = 0; offset < 100 * limit; offset += limit) {
|
|
48
|
+
const page = await (0, versions_1.fetchVersions)(appId, offset, limit);
|
|
49
|
+
const found = page.find((version) => version.hash === hash);
|
|
50
|
+
if (found) {
|
|
51
|
+
return found;
|
|
52
|
+
}
|
|
53
|
+
if (page.length < limit) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
async function readStack(source) {
|
|
60
|
+
if (!source || source === '-') {
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
const chunks = [];
|
|
63
|
+
process.stdin.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
|
|
64
|
+
process.stdin.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
65
|
+
process.stdin.on('error', reject);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return fs_1.default.readFileSync(source, 'utf8');
|
|
69
|
+
}
|
|
70
|
+
exports.symbolicateCommands = {
|
|
71
|
+
symbolicate: async ({ args, options, }) => {
|
|
72
|
+
const hash = typeof options.hash === 'string' ? options.hash : '';
|
|
73
|
+
const versionIdOption = typeof options.versionId === 'string' ? options.versionId : '';
|
|
74
|
+
if (!hash && !versionIdOption) {
|
|
75
|
+
throw new Error((0, i18n_1.t)('symbolicateUsage'));
|
|
76
|
+
}
|
|
77
|
+
const platform = await (0, app_1.getPlatform)(typeof options.platform === 'string'
|
|
78
|
+
? options.platform
|
|
79
|
+
: undefined);
|
|
80
|
+
const appId = typeof options.appId === 'string' && options.appId
|
|
81
|
+
? options.appId
|
|
82
|
+
: (await (0, app_1.getSelectedApp)(platform, options.config))
|
|
83
|
+
.appId;
|
|
84
|
+
let versionId = versionIdOption;
|
|
85
|
+
if (!versionId) {
|
|
86
|
+
const version = await findVersionByHash(appId, hash);
|
|
87
|
+
if (!version) {
|
|
88
|
+
throw new Error((0, i18n_1.t)('symbolicateVersionNotFound', { hash }));
|
|
89
|
+
}
|
|
90
|
+
versionId = String(version.id);
|
|
91
|
+
}
|
|
92
|
+
const located = await (0, api_1.get)(`/app/${appId}/version/${versionId}/sourceMap`);
|
|
93
|
+
if (!located?.url) {
|
|
94
|
+
throw new Error((0, i18n_1.t)('symbolicateNoSourceMap', { id: versionId }));
|
|
95
|
+
}
|
|
96
|
+
const response = await (0, node_fetch_1.default)(located.url);
|
|
97
|
+
if (!response.ok) {
|
|
98
|
+
throw new Error(`Failed to download source map: HTTP ${response.status}`);
|
|
99
|
+
}
|
|
100
|
+
const rawMap = JSON.parse(await response.text());
|
|
101
|
+
const consumer = new source_map_1.SourceMapConsumer(rawMap);
|
|
102
|
+
const stack = await readStack(args[0]);
|
|
103
|
+
const { text, mapped } = symbolicateStack(stack, consumer);
|
|
104
|
+
if (typeof options.output === 'string' && options.output) {
|
|
105
|
+
fs_1.default.writeFileSync(options.output, text);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
process.stdout.write(text.endsWith('\n') ? text : `${text}\n`);
|
|
109
|
+
}
|
|
110
|
+
console.error((0, i18n_1.t)('symbolicateDone', {
|
|
111
|
+
count: mapped,
|
|
112
|
+
id: versionId,
|
|
113
|
+
hash: located.hash ?? hash,
|
|
114
|
+
}));
|
|
115
|
+
return { versionId, mapped };
|
|
116
|
+
},
|
|
117
|
+
};
|
package/lib/types.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface Version {
|
|
|
23
23
|
name: string;
|
|
24
24
|
packages?: Package[];
|
|
25
25
|
deps?: Record<string, string> | string | null;
|
|
26
|
+
/** storage key of the archived source map (absent when published without one) */
|
|
27
|
+
sourceMapKey?: string;
|
|
26
28
|
}
|
|
27
29
|
export interface CommandContext<TOptions extends Record<string, unknown> = Record<string, unknown>> {
|
|
28
30
|
args: string[];
|
|
@@ -58,6 +60,8 @@ export interface BundleOptions {
|
|
|
58
60
|
}
|
|
59
61
|
export interface PublishOptions {
|
|
60
62
|
filePath?: string;
|
|
63
|
+
/** path of the final source map to archive with the version */
|
|
64
|
+
sourcemap?: string;
|
|
61
65
|
platform?: Platform;
|
|
62
66
|
name?: string;
|
|
63
67
|
description?: string;
|
|
@@ -90,9 +94,22 @@ export interface UpdateVersionOptions {
|
|
|
90
94
|
rollout?: number | string;
|
|
91
95
|
dryRun?: boolean;
|
|
92
96
|
}
|
|
97
|
+
export interface SymbolicateOptions {
|
|
98
|
+
/** stack trace file ('-' for stdin) */
|
|
99
|
+
stackFile?: string;
|
|
100
|
+
/** update hash of the running version (from getUpdateMetadata().currentVersion) */
|
|
101
|
+
hash?: string;
|
|
102
|
+
versionId?: string;
|
|
103
|
+
platform?: Platform;
|
|
104
|
+
appId?: string;
|
|
105
|
+
config?: string;
|
|
106
|
+
/** write the symbolicated stack here instead of stdout */
|
|
107
|
+
output?: string;
|
|
108
|
+
}
|
|
93
109
|
export interface CLIProvider {
|
|
94
110
|
bundle: (options: BundleOptions) => Promise<CommandResult>;
|
|
95
111
|
publish: (options: PublishOptions) => Promise<CommandResult>;
|
|
112
|
+
symbolicate: (options: SymbolicateOptions) => Promise<CommandResult>;
|
|
96
113
|
upload: (options: UploadOptions) => Promise<CommandResult>;
|
|
97
114
|
createApp: (name: string, platform: Platform) => Promise<CommandResult>;
|
|
98
115
|
listApps: (platform?: Platform) => Promise<CommandResult>;
|
|
@@ -4,14 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ONE_DAY = void 0;
|
|
7
|
+
const compare_versions_1 = require("compare-versions");
|
|
7
8
|
const fs_1 = require("fs");
|
|
8
9
|
const global_dirs_1 = require("global-dirs");
|
|
9
10
|
const os_1 = require("os");
|
|
10
11
|
const path_1 = require("path");
|
|
11
12
|
const registry_auth_token_1 = __importDefault(require("registry-auth-token"));
|
|
12
13
|
const registry_url_1 = __importDefault(require("registry-auth-token/registry-url"));
|
|
13
|
-
const gt_1 = __importDefault(require("semver/functions/gt"));
|
|
14
|
-
const max_satisfying_1 = __importDefault(require("semver/ranges/max-satisfying"));
|
|
15
14
|
const url_1 = require("url");
|
|
16
15
|
exports.ONE_DAY = 1000 * 60 * 60 * 24; // eslint-disable-line @typescript-eslint/naming-convention
|
|
17
16
|
const isPackageJson = (obj) => {
|
|
@@ -187,11 +186,33 @@ const getRegistryVersions = async (pkgName, tagOrRange, options) => {
|
|
|
187
186
|
versions.wanted = pkgMetadata.distTags[tagOrRange];
|
|
188
187
|
}
|
|
189
188
|
else if (tagOrRange && pkgMetadata?.versions.length) {
|
|
190
|
-
versions.wanted =
|
|
191
|
-
(0, max_satisfying_1.default)(pkgMetadata.versions, tagOrRange) ?? undefined;
|
|
189
|
+
versions.wanted = maxSatisfying(pkgMetadata.versions, tagOrRange);
|
|
192
190
|
}
|
|
193
191
|
return versions;
|
|
194
192
|
};
|
|
193
|
+
/** the highest of `versions` within `range` (npm range syntax), if any */
|
|
194
|
+
const maxSatisfying = (versions, range) => {
|
|
195
|
+
const matching = versions.filter((version) => {
|
|
196
|
+
try {
|
|
197
|
+
return (0, compare_versions_1.satisfies)(version, range);
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
if (!matching.length)
|
|
204
|
+
return undefined;
|
|
205
|
+
return matching.sort(compare_versions_1.compareVersions)[matching.length - 1];
|
|
206
|
+
};
|
|
207
|
+
/** `a > b` for two versions; invalid input counts as "not newer" */
|
|
208
|
+
const gt = (a, b) => {
|
|
209
|
+
try {
|
|
210
|
+
return (0, compare_versions_1.compare)(a, b, '>');
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
195
216
|
const getInstalledVersion = (pkgName, location = 'local') => {
|
|
196
217
|
try {
|
|
197
218
|
if (location === 'globalNpm') {
|
|
@@ -248,17 +269,17 @@ const getInfo = async (pkg, options) => {
|
|
|
248
269
|
...(await getRegistryVersions(pkgInfo.name, pkgInfo.wantedTagOrRange, options)),
|
|
249
270
|
};
|
|
250
271
|
const local = pkgInfo.local && pkgInfo.wanted
|
|
251
|
-
? (
|
|
272
|
+
? gt(pkgInfo.wanted, pkgInfo.local)
|
|
252
273
|
? pkgInfo.wanted
|
|
253
274
|
: false
|
|
254
275
|
: false;
|
|
255
276
|
const globalNpm = pkgInfo.globalNpm && pkgInfo.wanted
|
|
256
|
-
? (
|
|
277
|
+
? gt(pkgInfo.wanted, pkgInfo.globalNpm)
|
|
257
278
|
? pkgInfo.wanted
|
|
258
279
|
: false
|
|
259
280
|
: false;
|
|
260
281
|
const globalYarn = pkgInfo.globalYarn && pkgInfo.wanted
|
|
261
|
-
? (
|
|
282
|
+
? gt(pkgInfo.wanted, pkgInfo.globalYarn)
|
|
262
283
|
? pkgInfo.wanted
|
|
263
284
|
: false
|
|
264
285
|
: false;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Readable } from 'stream';
|
|
2
|
+
import type { Entry } from 'yauzl';
|
|
3
|
+
export interface RawZipEntry {
|
|
4
|
+
fileName: string;
|
|
5
|
+
compressionMethod: number;
|
|
6
|
+
crc32: number;
|
|
7
|
+
compressedSize: number;
|
|
8
|
+
uncompressedSize: number;
|
|
9
|
+
lastModFileTime: number;
|
|
10
|
+
lastModFileDate: number;
|
|
11
|
+
generalPurposeBitFlag?: number;
|
|
12
|
+
versionMadeBy?: number;
|
|
13
|
+
versionNeededToExtract?: number;
|
|
14
|
+
internalFileAttributes?: number;
|
|
15
|
+
externalFileAttributes?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether an archive of `sourceSize` bytes with `entryCount` entries can be
|
|
19
|
+
* (partially) copied without zip64 structures: an output that only keeps a
|
|
20
|
+
* subset of the entries is never larger than its source.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fitsRawZip(sourceSize: number, entryCount: number): boolean;
|
|
23
|
+
/** CRC-32 (IEEE) continued from `seed` (the running value, not inverted) */
|
|
24
|
+
export declare function crc32Update(seed: number, chunk: Buffer): number;
|
|
25
|
+
export declare class RawZipWriter {
|
|
26
|
+
readonly output: string;
|
|
27
|
+
private readonly out;
|
|
28
|
+
private readonly central;
|
|
29
|
+
private offset;
|
|
30
|
+
private count;
|
|
31
|
+
private failure;
|
|
32
|
+
private readonly closed;
|
|
33
|
+
constructor(output: string);
|
|
34
|
+
/** Copy one entry with its file data exactly as stored in the source. */
|
|
35
|
+
addRawEntry(meta: RawZipEntry, data: Readable): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Add a local file uncompressed (its CRC is computed in a first pass).
|
|
38
|
+
* `like` lends its timestamp and attributes, e.g. the archive entry this
|
|
39
|
+
* file replaces.
|
|
40
|
+
*/
|
|
41
|
+
addStoredFile(filePath: string, fileName: string, like?: Pick<Entry, 'lastModFileTime' | 'lastModFileDate' | 'externalFileAttributes' | 'versionMadeBy'>): Promise<void>;
|
|
42
|
+
/** Write the central directory and close the file. */
|
|
43
|
+
end(): Promise<void>;
|
|
44
|
+
/** Stop writing and remove the partial output. */
|
|
45
|
+
abort(): Promise<void>;
|
|
46
|
+
private write;
|
|
47
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RawZipWriter = void 0;
|
|
7
|
+
exports.fitsRawZip = fitsRawZip;
|
|
8
|
+
exports.crc32Update = crc32Update;
|
|
9
|
+
// A minimal zip writer that copies entries *as stored* — their compressed
|
|
10
|
+
// bytes, CRC, sizes and timestamps straight from the source archive's central
|
|
11
|
+
// directory — so repacking a subset of an apk / ipa / hap costs disk I/O, not
|
|
12
|
+
// a second deflate of every asset (yazl can only add uncompressed data and
|
|
13
|
+
// re-deflates it). Plain zip only: no zip64, no data descriptors, no extra
|
|
14
|
+
// fields; callers must check `fitsRawZip` before choosing this writer.
|
|
15
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
16
|
+
const LOCAL_HEADER_SIGNATURE = 0x04034b50;
|
|
17
|
+
const CENTRAL_HEADER_SIGNATURE = 0x02014b50;
|
|
18
|
+
const EOCD_SIGNATURE = 0x06054b50;
|
|
19
|
+
const VERSION_NEEDED_DEFAULT = 20;
|
|
20
|
+
/** "made by" for entries this writer creates itself: unix, spec 2.0 */
|
|
21
|
+
const VERSION_MADE_BY_UNIX = (3 << 8) | 20;
|
|
22
|
+
const FLAG_UTF8_NAMES = 0x800;
|
|
23
|
+
const FLAG_DATA_DESCRIPTOR = 0x8;
|
|
24
|
+
/** general-purpose bits carried over from a copied entry: encryption, deflate strength */
|
|
25
|
+
const FLAG_KEEP_MASK = 0x0007;
|
|
26
|
+
const MAX_UINT32 = 0xffffffff;
|
|
27
|
+
const MAX_UINT16 = 0xffff;
|
|
28
|
+
/** external attributes of a plain `-rw-r--r--` file */
|
|
29
|
+
const UNIX_REGULAR_FILE_ATTRIBUTES = 0o100644 << 16;
|
|
30
|
+
/**
|
|
31
|
+
* Whether an archive of `sourceSize` bytes with `entryCount` entries can be
|
|
32
|
+
* (partially) copied without zip64 structures: an output that only keeps a
|
|
33
|
+
* subset of the entries is never larger than its source.
|
|
34
|
+
*/
|
|
35
|
+
function fitsRawZip(sourceSize, entryCount) {
|
|
36
|
+
return sourceSize < MAX_UINT32 && entryCount < MAX_UINT16;
|
|
37
|
+
}
|
|
38
|
+
let crcTable;
|
|
39
|
+
function getCrcTable() {
|
|
40
|
+
if (!crcTable) {
|
|
41
|
+
crcTable = new Int32Array(256);
|
|
42
|
+
for (let n = 0; n < 256; n++) {
|
|
43
|
+
let c = n;
|
|
44
|
+
for (let k = 0; k < 8; k++)
|
|
45
|
+
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
46
|
+
crcTable[n] = c;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return crcTable;
|
|
50
|
+
}
|
|
51
|
+
/** CRC-32 (IEEE) continued from `seed` (the running value, not inverted) */
|
|
52
|
+
function crc32Update(seed, chunk) {
|
|
53
|
+
const table = getCrcTable();
|
|
54
|
+
let crc = ~seed;
|
|
55
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
56
|
+
crc = table[(crc ^ chunk[i]) & 0xff] ^ (crc >>> 8);
|
|
57
|
+
}
|
|
58
|
+
return ~crc >>> 0;
|
|
59
|
+
}
|
|
60
|
+
class RawZipWriter {
|
|
61
|
+
output;
|
|
62
|
+
out;
|
|
63
|
+
central = [];
|
|
64
|
+
offset = 0;
|
|
65
|
+
count = 0;
|
|
66
|
+
failure = null;
|
|
67
|
+
closed;
|
|
68
|
+
constructor(output) {
|
|
69
|
+
this.output = output;
|
|
70
|
+
this.out = fs_extra_1.default.createWriteStream(output);
|
|
71
|
+
this.closed = new Promise((resolve, reject) => {
|
|
72
|
+
this.out.once('close', resolve);
|
|
73
|
+
this.out.once('error', (error) => {
|
|
74
|
+
this.failure = error;
|
|
75
|
+
reject(error);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
// surfaced by the next write / end(), never as an unhandled rejection
|
|
79
|
+
this.closed.catch(() => { });
|
|
80
|
+
}
|
|
81
|
+
/** Copy one entry with its file data exactly as stored in the source. */
|
|
82
|
+
async addRawEntry(meta, data) {
|
|
83
|
+
if (meta.compressedSize > MAX_UINT32 ||
|
|
84
|
+
meta.uncompressedSize > MAX_UINT32 ||
|
|
85
|
+
this.offset > MAX_UINT32 ||
|
|
86
|
+
this.count >= MAX_UINT16) {
|
|
87
|
+
throw new Error(`zip64 required for ${meta.fileName}`);
|
|
88
|
+
}
|
|
89
|
+
const name = Buffer.from(meta.fileName, 'utf8');
|
|
90
|
+
if (name.length > MAX_UINT16) {
|
|
91
|
+
throw new Error(`file name too long: ${meta.fileName}`);
|
|
92
|
+
}
|
|
93
|
+
const flags = ((meta.generalPurposeBitFlag ?? 0) &
|
|
94
|
+
FLAG_KEEP_MASK &
|
|
95
|
+
~FLAG_DATA_DESCRIPTOR) |
|
|
96
|
+
FLAG_UTF8_NAMES;
|
|
97
|
+
const versionNeeded = Math.max(VERSION_NEEDED_DEFAULT, meta.versionNeededToExtract ?? 0);
|
|
98
|
+
const localOffset = this.offset;
|
|
99
|
+
const local = Buffer.alloc(30 + name.length);
|
|
100
|
+
local.writeUInt32LE(LOCAL_HEADER_SIGNATURE, 0);
|
|
101
|
+
local.writeUInt16LE(versionNeeded, 4);
|
|
102
|
+
local.writeUInt16LE(flags, 6);
|
|
103
|
+
local.writeUInt16LE(meta.compressionMethod, 8);
|
|
104
|
+
local.writeUInt16LE(meta.lastModFileTime, 10);
|
|
105
|
+
local.writeUInt16LE(meta.lastModFileDate, 12);
|
|
106
|
+
local.writeUInt32LE(meta.crc32 >>> 0, 14);
|
|
107
|
+
local.writeUInt32LE(meta.compressedSize, 18);
|
|
108
|
+
local.writeUInt32LE(meta.uncompressedSize, 22);
|
|
109
|
+
local.writeUInt16LE(name.length, 26);
|
|
110
|
+
local.writeUInt16LE(0, 28);
|
|
111
|
+
name.copy(local, 30);
|
|
112
|
+
await this.write(local);
|
|
113
|
+
let copied = 0;
|
|
114
|
+
for await (const chunk of data) {
|
|
115
|
+
copied += chunk.length;
|
|
116
|
+
await this.write(chunk);
|
|
117
|
+
}
|
|
118
|
+
if (copied !== meta.compressedSize) {
|
|
119
|
+
throw new Error(`${meta.fileName}: read ${copied} bytes, expected ${meta.compressedSize}`);
|
|
120
|
+
}
|
|
121
|
+
const header = Buffer.alloc(46 + name.length);
|
|
122
|
+
header.writeUInt32LE(CENTRAL_HEADER_SIGNATURE, 0);
|
|
123
|
+
header.writeUInt16LE(meta.versionMadeBy ?? VERSION_MADE_BY_UNIX, 4);
|
|
124
|
+
header.writeUInt16LE(versionNeeded, 6);
|
|
125
|
+
header.writeUInt16LE(flags, 8);
|
|
126
|
+
header.writeUInt16LE(meta.compressionMethod, 10);
|
|
127
|
+
header.writeUInt16LE(meta.lastModFileTime, 12);
|
|
128
|
+
header.writeUInt16LE(meta.lastModFileDate, 14);
|
|
129
|
+
header.writeUInt32LE(meta.crc32 >>> 0, 16);
|
|
130
|
+
header.writeUInt32LE(meta.compressedSize, 20);
|
|
131
|
+
header.writeUInt32LE(meta.uncompressedSize, 24);
|
|
132
|
+
header.writeUInt16LE(name.length, 28);
|
|
133
|
+
header.writeUInt16LE(0, 30); // extra
|
|
134
|
+
header.writeUInt16LE(0, 32); // comment
|
|
135
|
+
header.writeUInt16LE(0, 34); // disk number start
|
|
136
|
+
header.writeUInt16LE(meta.internalFileAttributes ?? 0, 36);
|
|
137
|
+
header.writeUInt32LE((meta.externalFileAttributes ?? UNIX_REGULAR_FILE_ATTRIBUTES) >>> 0, 38);
|
|
138
|
+
header.writeUInt32LE(localOffset, 42);
|
|
139
|
+
name.copy(header, 46);
|
|
140
|
+
this.central.push(header);
|
|
141
|
+
this.count += 1;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Add a local file uncompressed (its CRC is computed in a first pass).
|
|
145
|
+
* `like` lends its timestamp and attributes, e.g. the archive entry this
|
|
146
|
+
* file replaces.
|
|
147
|
+
*/
|
|
148
|
+
async addStoredFile(filePath, fileName, like) {
|
|
149
|
+
let crc = 0;
|
|
150
|
+
let size = 0;
|
|
151
|
+
for await (const chunk of fs_extra_1.default.createReadStream(filePath)) {
|
|
152
|
+
crc = crc32Update(crc, chunk);
|
|
153
|
+
size += chunk.length;
|
|
154
|
+
}
|
|
155
|
+
await this.addRawEntry({
|
|
156
|
+
fileName,
|
|
157
|
+
compressionMethod: 0,
|
|
158
|
+
crc32: crc,
|
|
159
|
+
compressedSize: size,
|
|
160
|
+
uncompressedSize: size,
|
|
161
|
+
lastModFileTime: like?.lastModFileTime ?? 0,
|
|
162
|
+
lastModFileDate: like?.lastModFileDate ?? 0x21, // 1980-01-01
|
|
163
|
+
externalFileAttributes: like?.externalFileAttributes,
|
|
164
|
+
versionMadeBy: like?.versionMadeBy,
|
|
165
|
+
}, fs_extra_1.default.createReadStream(filePath));
|
|
166
|
+
}
|
|
167
|
+
/** Write the central directory and close the file. */
|
|
168
|
+
async end() {
|
|
169
|
+
const cdOffset = this.offset;
|
|
170
|
+
for (const header of this.central)
|
|
171
|
+
await this.write(header);
|
|
172
|
+
const cdSize = this.offset - cdOffset;
|
|
173
|
+
if (cdOffset > MAX_UINT32 || cdSize > MAX_UINT32) {
|
|
174
|
+
throw new Error('zip64 required for the central directory');
|
|
175
|
+
}
|
|
176
|
+
const eocd = Buffer.alloc(22);
|
|
177
|
+
eocd.writeUInt32LE(EOCD_SIGNATURE, 0);
|
|
178
|
+
eocd.writeUInt16LE(0, 4);
|
|
179
|
+
eocd.writeUInt16LE(0, 6);
|
|
180
|
+
eocd.writeUInt16LE(this.count, 8);
|
|
181
|
+
eocd.writeUInt16LE(this.count, 10);
|
|
182
|
+
eocd.writeUInt32LE(cdSize, 12);
|
|
183
|
+
eocd.writeUInt32LE(cdOffset, 16);
|
|
184
|
+
eocd.writeUInt16LE(0, 20);
|
|
185
|
+
await this.write(eocd);
|
|
186
|
+
this.out.end();
|
|
187
|
+
await this.closed;
|
|
188
|
+
}
|
|
189
|
+
/** Stop writing and remove the partial output. */
|
|
190
|
+
async abort() {
|
|
191
|
+
this.out.destroy();
|
|
192
|
+
await this.closed.catch(() => { });
|
|
193
|
+
await fs_extra_1.default.remove(this.output).catch(() => { });
|
|
194
|
+
}
|
|
195
|
+
write(chunk) {
|
|
196
|
+
if (this.failure)
|
|
197
|
+
return Promise.reject(this.failure);
|
|
198
|
+
this.offset += chunk.length;
|
|
199
|
+
return new Promise((resolve, reject) => {
|
|
200
|
+
this.out.write(chunk, (error) => (error ? reject(error) : resolve()));
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
exports.RawZipWriter = RawZipWriter;
|
package/lib/versions.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.normalizeDeps = normalizeDeps;
|
|
|
8
8
|
exports.fetchVersions = fetchVersions;
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
10
|
const compare_versions_1 = require("compare-versions");
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
12
|
const api_1 = require("./api");
|
|
12
13
|
const app_1 = require("./app");
|
|
13
14
|
const package_1 = require("./package");
|
|
@@ -371,15 +372,46 @@ exports.versionCommands = {
|
|
|
371
372
|
appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
|
|
372
373
|
}
|
|
373
374
|
const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
|
|
375
|
+
// The source map is archived with the version so `pushy symbolicate` can
|
|
376
|
+
// map crashes back to source. An explicit path that does not exist is a
|
|
377
|
+
// publish error; no path at all is a loud warning (custom pipelines that
|
|
378
|
+
// never produced a map keep working).
|
|
379
|
+
const sourcemapPath = typeof options.sourcemap === 'string' && options.sourcemap
|
|
380
|
+
? options.sourcemap
|
|
381
|
+
: undefined;
|
|
382
|
+
if (sourcemapPath && !fs_1.default.existsSync(sourcemapPath)) {
|
|
383
|
+
throw new Error((0, i18n_1.t)('sourceMapNotFound', { path: sourcemapPath }));
|
|
384
|
+
}
|
|
385
|
+
if (!sourcemapPath) {
|
|
386
|
+
console.log(chalk_1.default.yellow((0, i18n_1.t)('sourceMapMissingWarning')));
|
|
387
|
+
}
|
|
374
388
|
// Hashing/caching the bundle and asking git for the commit are independent
|
|
375
389
|
// of the upload, so they overlap with it instead of running afterwards.
|
|
376
390
|
// describePpkBundle never rejects (best effort); a failed upload still
|
|
377
391
|
// fails the publish exactly as before.
|
|
378
|
-
|
|
392
|
+
// A server that predates source-map archiving (self-hosted, or a SaaS
|
|
393
|
+
// region not yet rolled) rejects the .map upload with 400; that must not
|
|
394
|
+
// fail the publish, only lose the archive.
|
|
395
|
+
let sourceMapUploadError;
|
|
396
|
+
const [{ hash }, bundleMeta, commit, sourceMapUpload] = await Promise.all([
|
|
379
397
|
(0, api_1.uploadFile)(fn, undefined, appId),
|
|
380
398
|
describePpkBundle(fn, options.hermesBase),
|
|
381
399
|
(0, git_1.getCommitInfo)(),
|
|
400
|
+
sourcemapPath
|
|
401
|
+
? (0, api_1.uploadFile)(sourcemapPath, undefined, appId).catch((error) => {
|
|
402
|
+
sourceMapUploadError = error;
|
|
403
|
+
return undefined;
|
|
404
|
+
})
|
|
405
|
+
: Promise.resolve(undefined),
|
|
382
406
|
]);
|
|
407
|
+
const sourceMapKey = sourceMapUpload?.hash;
|
|
408
|
+
if (sourcemapPath && !sourceMapKey) {
|
|
409
|
+
console.log(chalk_1.default.yellow((0, i18n_1.t)('sourceMapUploadFailedWarning', {
|
|
410
|
+
error: sourceMapUploadError instanceof Error
|
|
411
|
+
? sourceMapUploadError.message
|
|
412
|
+
: String(sourceMapUploadError),
|
|
413
|
+
})));
|
|
414
|
+
}
|
|
383
415
|
const depVersions = (0, dep_versions_1.getDepVersions)();
|
|
384
416
|
const versionName = name ||
|
|
385
417
|
(nonInteractive ? '' : await (0, utils_1.question)((0, i18n_1.t)('versionNameQuestion'))) ||
|
|
@@ -395,8 +427,13 @@ exports.versionCommands = {
|
|
|
395
427
|
commit,
|
|
396
428
|
// Hermes delta-mode chain metadata (old servers drop unknown fields)
|
|
397
429
|
...bundleMeta,
|
|
430
|
+
// archived source map (old servers drop unknown fields)
|
|
431
|
+
...(sourceMapKey ? { sourceMapKey } : {}),
|
|
398
432
|
});
|
|
399
433
|
console.log((0, i18n_1.t)('packageUploadSuccess', { id }));
|
|
434
|
+
if (sourceMapKey) {
|
|
435
|
+
console.log((0, i18n_1.t)('sourceMapArchived', { id }));
|
|
436
|
+
}
|
|
400
437
|
const { packageId, packageVersion, packageVersionRange, minPackageVersion, maxPackageVersion, rollout, dryRun, } = options;
|
|
401
438
|
if (packageId ||
|
|
402
439
|
packageVersion ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"description": "command line tool for react-native-update (remote updates for react native)",
|
|
5
5
|
"main": "lib/exports.js",
|
|
6
6
|
"types": "lib/exports.d.ts",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"protobufjs": "^8.7.2",
|
|
80
80
|
"read": "^4.1.0",
|
|
81
81
|
"registry-auth-token": "^5.1.1",
|
|
82
|
-
"
|
|
82
|
+
"source-map": "0.6.1",
|
|
83
83
|
"tty-table": "5.0",
|
|
84
84
|
"yauzl": "^3.4.0",
|
|
85
85
|
"yazl": "3.3.1"
|
|
@@ -99,7 +99,6 @@
|
|
|
99
99
|
"@types/node": "^26.3.0",
|
|
100
100
|
"@types/node-fetch": "^2.6.13",
|
|
101
101
|
"@types/progress": "^2.0.7",
|
|
102
|
-
"@types/semver": "^7.8.0",
|
|
103
102
|
"@types/yauzl": "^3.4.0",
|
|
104
103
|
"@types/yazl": "^3.3.1",
|
|
105
104
|
"node-hdiffpatch": "^2.4.0",
|
package/src/bin.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { cacheCommands } from './cache';
|
|
|
7
7
|
import { diffCommands } from './diff';
|
|
8
8
|
import { installCommands } from './install';
|
|
9
9
|
import { packageCommands } from './package';
|
|
10
|
+
import { symbolicateCommands } from './symbolicate';
|
|
10
11
|
import { userCommands } from './user';
|
|
11
12
|
import { printVersionCommand } from './utils';
|
|
12
13
|
import { t } from './utils/i18n';
|
|
@@ -52,6 +53,7 @@ const commandHandlers: Record<string, CliCommandHandler> = {
|
|
|
52
53
|
...getAppCommands(),
|
|
53
54
|
...packageCommands,
|
|
54
55
|
...versionCommands,
|
|
56
|
+
...symbolicateCommands,
|
|
55
57
|
...installCommands,
|
|
56
58
|
help: printUsage,
|
|
57
59
|
};
|
package/src/bundle.ts
CHANGED
|
@@ -72,6 +72,8 @@ type PublishBundlePayload = {
|
|
|
72
72
|
rollout?: string;
|
|
73
73
|
dryRun?: boolean;
|
|
74
74
|
hermesBase?: HermesBaseMeta;
|
|
75
|
+
/** path of the final source map to archive with the version */
|
|
76
|
+
sourcemap?: string;
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
function getAliasedOptionalStringOption(
|
|
@@ -108,7 +110,9 @@ export function normalizeBundleOptions(
|
|
|
108
110
|
`${tempDir}/output/${platform}.\${time}.ppk`,
|
|
109
111
|
),
|
|
110
112
|
dev: getBooleanOption(translatedOptions, 'dev', false) ? 'true' : 'false',
|
|
111
|
-
|
|
113
|
+
// On by default since 2.23: the map is archived with the published
|
|
114
|
+
// version (pushy symbolicate). --no-sourcemap / --sourcemap=false opts out.
|
|
115
|
+
sourcemap: getBooleanOption(translatedOptions, 'sourcemap', true),
|
|
112
116
|
taro: getBooleanOption(translatedOptions, 'taro', false),
|
|
113
117
|
expo: getBooleanOption(translatedOptions, 'expo', false),
|
|
114
118
|
rncli: getBooleanOption(translatedOptions, 'rncli', false),
|
|
@@ -295,6 +299,10 @@ export const bundleCommands = {
|
|
|
295
299
|
rollout: normalized.rollout,
|
|
296
300
|
dryRun: normalized.dryRun,
|
|
297
301
|
hermesBase: baseMeta,
|
|
302
|
+
sourcemap:
|
|
303
|
+
normalized.sourcemap || bundleParams.sourcemap
|
|
304
|
+
? sourcemapOutput
|
|
305
|
+
: undefined,
|
|
298
306
|
});
|
|
299
307
|
await uploadSentryArtifactsIfNeeded(
|
|
300
308
|
bundleParams.sentry,
|
|
@@ -315,6 +323,10 @@ export const bundleCommands = {
|
|
|
315
323
|
if (v.toLowerCase() === 'y') {
|
|
316
324
|
await publishBundleVersion(realOutput, platform, {
|
|
317
325
|
hermesBase: baseMeta,
|
|
326
|
+
sourcemap:
|
|
327
|
+
normalized.sourcemap || bundleParams.sourcemap
|
|
328
|
+
? sourcemapOutput
|
|
329
|
+
: undefined,
|
|
318
330
|
});
|
|
319
331
|
await uploadSentryArtifactsIfNeeded(
|
|
320
332
|
bundleParams.sentry,
|
package/src/locales/en.ts
CHANGED
|
@@ -130,6 +130,20 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
130
130
|
processingStringPool: 'Processing the string pool ...',
|
|
131
131
|
publishUsage:
|
|
132
132
|
'Usage: pushy publish <ppk file> --platform ios|android|harmony',
|
|
133
|
+
sourceMapNotFound: 'Source map not found: {{path}}',
|
|
134
|
+
sourceMapMissingWarning:
|
|
135
|
+
'No source map was archived with this version: crashes cannot be symbolicated later. Bundle with the default --sourcemap, or pass --sourcemap <file> to publish.',
|
|
136
|
+
sourceMapArchived: 'Source map archived with version {{id}}',
|
|
137
|
+
sourceMapUploadFailedWarning:
|
|
138
|
+
'Source map upload failed ({{error}}); publishing without an archived map. Upgrade the update server to archive source maps.',
|
|
139
|
+
symbolicateUsage:
|
|
140
|
+
'Usage: pushy symbolicate <stack file | -> --hash <updateHash> [--platform ios|android|harmony] [--output <file>]',
|
|
141
|
+
symbolicateVersionNotFound:
|
|
142
|
+
'No published version with hash {{hash}} found for this app',
|
|
143
|
+
symbolicateNoSourceMap:
|
|
144
|
+
'Version {{id}} was published without a source map; nothing to symbolicate against',
|
|
145
|
+
symbolicateDone:
|
|
146
|
+
'Symbolicated {{count}} frame(s) against version {{id}} ({{hash}})',
|
|
133
147
|
rnuVersionNotFound:
|
|
134
148
|
'react-native-update: Cannot get the version number. Please run the command in the project directory',
|
|
135
149
|
rolloutConfigSet:
|
package/src/locales/zh.ts
CHANGED
|
@@ -118,6 +118,17 @@ export default {
|
|
|
118
118
|
processingError: '处理文件时出错:{{error}}',
|
|
119
119
|
processingPackage: '正在处理包 {{count}}...',
|
|
120
120
|
processingStringPool: '正在处理字符串池...',
|
|
121
|
+
sourceMapNotFound: '找不到 source map:{{path}}',
|
|
122
|
+
sourceMapMissingWarning:
|
|
123
|
+
'本版本没有归档 source map,之后的崩溃堆栈将无法还原。请用默认的 --sourcemap 打包,或在 publish 时传 --sourcemap <文件>。',
|
|
124
|
+
sourceMapArchived: 'source map 已随版本 {{id}} 归档',
|
|
125
|
+
sourceMapUploadFailedWarning:
|
|
126
|
+
'source map 上传失败({{error}}),本次发布不归档 map。升级更新服务端后可归档 source map。',
|
|
127
|
+
symbolicateUsage:
|
|
128
|
+
'用法:pushy symbolicate <堆栈文件 | -> --hash <热更 hash> [--platform ios|android|harmony] [--output <文件>]',
|
|
129
|
+
symbolicateVersionNotFound: '当前应用下找不到 hash 为 {{hash}} 的已发布版本',
|
|
130
|
+
symbolicateNoSourceMap: '版本 {{id}} 发布时未归档 source map,无法还原',
|
|
131
|
+
symbolicateDone: '已按版本 {{id}}({{hash}})还原 {{count}} 个堆栈帧',
|
|
121
132
|
publishUsage:
|
|
122
133
|
'使用方法: pushy publish ppk后缀文件 --platform ios|android|harmony',
|
|
123
134
|
rnuVersionNotFound:
|