react-native-update-cli 2.15.3 → 2.16.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/lib/api.js +25 -4
- package/lib/app.js +1 -0
- package/lib/bin.js +3 -1
- package/lib/bundle-pack.d.ts +1 -1
- package/lib/bundle-pack.js +8 -7
- package/lib/bundle-runner.js +58 -39
- package/lib/bundle.d.ts +26 -0
- package/lib/bundle.js +18 -6
- package/lib/diff.js +53 -72
- package/lib/locales/en.d.ts +11 -0
- package/lib/locales/en.js +12 -1
- package/lib/locales/zh.d.ts +11 -0
- package/lib/locales/zh.js +12 -1
- package/lib/package.js +3 -1
- package/lib/provider.js +9 -3
- package/lib/types.d.ts +2 -2
- package/lib/utils/app-info-parser/xml-parser/binary.js +4 -3
- package/lib/utils/app-info-parser/zip.d.ts +6 -0
- package/lib/utils/app-info-parser/zip.js +20 -5
- package/lib/utils/check-lockfile.js +5 -1
- package/lib/utils/http-helper.js +20 -23
- package/lib/utils/index.js +48 -20
- package/lib/versions.js +7 -5
- package/package.json +1 -1
- package/src/api.ts +30 -5
- package/src/app.ts +1 -0
- package/src/bin.ts +1 -1
- package/src/bundle-pack.ts +12 -7
- package/src/bundle-runner.ts +66 -43
- package/src/bundle.ts +13 -8
- package/src/diff.ts +87 -111
- package/src/locales/en.ts +13 -0
- package/src/locales/zh.ts +12 -0
- package/src/package.ts +1 -1
- package/src/provider.ts +7 -3
- package/src/types.ts +3 -2
- package/src/utils/app-info-parser/xml-parser/binary.ts +4 -5
- package/src/utils/app-info-parser/zip.ts +22 -5
- package/src/utils/check-lockfile.ts +5 -1
- package/src/utils/http-helper.ts +16 -23
- package/src/utils/index.ts +51 -36
- package/src/versions.ts +5 -5
package/lib/api.js
CHANGED
|
@@ -154,8 +154,10 @@ async function query(url, options) {
|
|
|
154
154
|
try {
|
|
155
155
|
json = JSON.parse(text);
|
|
156
156
|
} catch (_e) {
|
|
157
|
-
if (resp.status === 200
|
|
158
|
-
|
|
157
|
+
if (resp.status === 200) {
|
|
158
|
+
// a proxy/gateway likely replaced the response; surface it instead of
|
|
159
|
+
// returning undefined and crashing callers on destructuring
|
|
160
|
+
throw createRequestError(`API returned 200 with non-JSON body (${text.length} bytes)`, fullUrl, resp.status);
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
if (resp.status !== 200) {
|
|
@@ -275,6 +277,25 @@ async function uploadFile(fn, key) {
|
|
|
275
277
|
};
|
|
276
278
|
}
|
|
277
279
|
const getAllPackages = async (appId)=>{
|
|
278
|
-
|
|
279
|
-
|
|
280
|
+
// the server caps limit at 100, so page through with offset
|
|
281
|
+
const limit = 100;
|
|
282
|
+
let offset = 0;
|
|
283
|
+
let allPackages;
|
|
284
|
+
while(true){
|
|
285
|
+
const { data, count } = await get(`/app/${appId}/package/list?offset=${offset}&limit=${limit}`);
|
|
286
|
+
const packages = data;
|
|
287
|
+
if (allPackages === undefined || allPackages === null) {
|
|
288
|
+
allPackages = packages;
|
|
289
|
+
} else if (packages) {
|
|
290
|
+
allPackages.push(...packages);
|
|
291
|
+
}
|
|
292
|
+
if (!packages || packages.length === 0) {
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
offset += packages.length;
|
|
296
|
+
if (offset >= Number(count || 0)) {
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return allPackages;
|
|
280
301
|
};
|
package/lib/app.js
CHANGED
|
@@ -161,6 +161,7 @@ function getAppCommands() {
|
|
|
161
161
|
const id = args[0] || (await chooseApp(platform)).id;
|
|
162
162
|
if (!id) {
|
|
163
163
|
console.log((0, _i18n.t)('cancelled'));
|
|
164
|
+
return;
|
|
164
165
|
}
|
|
165
166
|
await (0, _api.doDelete)(`/app/${id}`);
|
|
166
167
|
console.log((0, _i18n.t)('operationSuccess'));
|
package/lib/bin.js
CHANGED
|
@@ -59,7 +59,9 @@ async function run() {
|
|
|
59
59
|
const handler = commandHandlers[argv.command];
|
|
60
60
|
await handler(argv);
|
|
61
61
|
} else {
|
|
62
|
-
throw new Error(
|
|
62
|
+
throw new Error((0, _i18n.t)('unknownCommand', {
|
|
63
|
+
command: argv.command
|
|
64
|
+
}));
|
|
63
65
|
}
|
|
64
66
|
} catch (err) {
|
|
65
67
|
if (err.status === 401) {
|
package/lib/bundle-pack.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function packBundle(dir: string, output: string): Promise<void>;
|
|
1
|
+
export declare function packBundle(dir: string, output: string, bundleName?: string): Promise<void>;
|
package/lib/bundle-pack.js
CHANGED
|
@@ -59,17 +59,18 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
59
59
|
}
|
|
60
60
|
return newObj;
|
|
61
61
|
}
|
|
62
|
-
const ignorePackingFileNames = [
|
|
63
|
-
'.',
|
|
64
|
-
'..',
|
|
65
|
-
'index.bundlejs.map',
|
|
66
|
-
'bundle.harmony.js.map'
|
|
67
|
-
];
|
|
68
62
|
const ignorePackingExtensions = [
|
|
69
63
|
'DS_Store',
|
|
70
64
|
'txt.map'
|
|
71
65
|
];
|
|
72
|
-
async function packBundle(dir, output) {
|
|
66
|
+
async function packBundle(dir, output, bundleName) {
|
|
67
|
+
const ignorePackingFileNames = [
|
|
68
|
+
'index.bundlejs.map',
|
|
69
|
+
'bundle.harmony.js.map'
|
|
70
|
+
];
|
|
71
|
+
if (bundleName) {
|
|
72
|
+
ignorePackingFileNames.push(`${bundleName}.map`);
|
|
73
|
+
}
|
|
73
74
|
console.log((0, _i18n.t)('packing'));
|
|
74
75
|
_fsextra.ensureDirSync(_path.default.dirname(output));
|
|
75
76
|
await new Promise((resolve, reject)=>{
|
package/lib/bundle-runner.js
CHANGED
|
@@ -225,6 +225,8 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
225
225
|
process.env.SENTRY_PROPERTIES = 'ios/sentry.properties';
|
|
226
226
|
} else if (platform === 'android') {
|
|
227
227
|
process.env.SENTRY_PROPERTIES = 'android/sentry.properties';
|
|
228
|
+
} else if (platform === 'harmony' && _fsextra.existsSync('harmony/sentry.properties')) {
|
|
229
|
+
process.env.SENTRY_PROPERTIES = 'harmony/sentry.properties';
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
232
|
let bundleCommand = 'bundle';
|
|
@@ -266,6 +268,7 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
266
268
|
reactNativeBundleProcess.stderr.on('data', (data)=>{
|
|
267
269
|
console.error(data.toString().trim());
|
|
268
270
|
});
|
|
271
|
+
reactNativeBundleProcess.once('error', reject);
|
|
269
272
|
reactNativeBundleProcess.on('close', async (exitCode)=>{
|
|
270
273
|
if (exitCode) {
|
|
271
274
|
reject(new Error((0, _i18n.t)('bundleCommandError', {
|
|
@@ -273,44 +276,50 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
273
276
|
})));
|
|
274
277
|
return;
|
|
275
278
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
279
|
+
try {
|
|
280
|
+
let hermesEnabled = false;
|
|
281
|
+
if (forceHermes) {
|
|
282
|
+
hermesEnabled = true;
|
|
283
|
+
console.log((0, _i18n.t)('forceHermes'));
|
|
284
|
+
} else if (platform === 'android') {
|
|
285
|
+
const gradleProperties = await new Promise((resolve)=>{
|
|
286
|
+
properties.parse('./android/gradle.properties', {
|
|
287
|
+
path: true
|
|
288
|
+
}, (error, props = {})=>{
|
|
289
|
+
if (error) {
|
|
290
|
+
console.error(error);
|
|
291
|
+
resolve({});
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
resolve(props);
|
|
295
|
+
});
|
|
291
296
|
});
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
297
|
+
hermesEnabled = gradleProperties.hermesEnabled;
|
|
298
|
+
if (typeof hermesEnabled !== 'boolean') {
|
|
299
|
+
hermesEnabled = gradleConfig.enableHermes;
|
|
300
|
+
}
|
|
301
|
+
} else if (platform === 'ios' && _fsextra.existsSync('ios/Pods/hermes-engine')) {
|
|
302
|
+
hermesEnabled = true;
|
|
296
303
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
304
|
+
if (hermesEnabled) {
|
|
305
|
+
await compileHermesByteCode(bundleName, outputFolder, sourcemapOutput, !isSentry);
|
|
306
|
+
}
|
|
307
|
+
if (platform === 'harmony') {
|
|
308
|
+
const harmonyRawAssetsPath = 'harmony/entry/src/main/resources/rawfile/assets';
|
|
309
|
+
_fsextra.ensureDirSync(harmonyRawAssetsPath);
|
|
310
|
+
_fsextra.copySync(outputFolder, harmonyRawAssetsPath, {
|
|
311
|
+
overwrite: true,
|
|
312
|
+
// sourcemaps must not ship inside the native package
|
|
313
|
+
filter: (src)=>!src.endsWith('.map')
|
|
314
|
+
});
|
|
315
|
+
_fsextra.moveSync(`${harmonyRawAssetsPath}/bundle.harmony.js`, `${harmonyRawAssetsPath}/../bundle.harmony.js`, {
|
|
316
|
+
overwrite: true
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
resolve();
|
|
320
|
+
} catch (error) {
|
|
321
|
+
reject(error);
|
|
312
322
|
}
|
|
313
|
-
resolve();
|
|
314
323
|
});
|
|
315
324
|
});
|
|
316
325
|
}
|
|
@@ -344,7 +353,9 @@ function normalizeString(value) {
|
|
|
344
353
|
function resolveHermesCommand(projectRoot = process.cwd()) {
|
|
345
354
|
const osBin = getHermesOSBin();
|
|
346
355
|
if (!osBin) {
|
|
347
|
-
throw new Error(
|
|
356
|
+
throw new Error((0, _i18n.t)('unsupportedPlatformForHermes', {
|
|
357
|
+
platform: _os.default.platform()
|
|
358
|
+
}));
|
|
348
359
|
}
|
|
349
360
|
const executableName = getHermesExecutableName();
|
|
350
361
|
const candidates = [];
|
|
@@ -418,8 +429,16 @@ async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput,
|
|
|
418
429
|
stdio: 'ignore'
|
|
419
430
|
}), hermesCommand);
|
|
420
431
|
if (sourcemapOutput) {
|
|
421
|
-
|
|
422
|
-
|
|
432
|
+
let composerPath;
|
|
433
|
+
try {
|
|
434
|
+
// resolve through the project so hoisted node_modules (monorepos) work
|
|
435
|
+
composerPath = require.resolve('react-native/scripts/compose-source-maps.js', {
|
|
436
|
+
paths: [
|
|
437
|
+
process.cwd()
|
|
438
|
+
]
|
|
439
|
+
});
|
|
440
|
+
} catch (unused) {
|
|
441
|
+
console.warn((0, _i18n.t)('composeSourceMapsNotFound'));
|
|
423
442
|
return;
|
|
424
443
|
}
|
|
425
444
|
console.log((0, _i18n.t)('composingSourceMap'));
|
|
@@ -447,7 +466,7 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
|
|
|
447
466
|
]
|
|
448
467
|
});
|
|
449
468
|
} catch (unused) {
|
|
450
|
-
console.error((0, _i18n.t)('
|
|
469
|
+
console.error((0, _i18n.t)('sentryReactNativeNotFound'));
|
|
451
470
|
return;
|
|
452
471
|
}
|
|
453
472
|
if (!_fsextra.existsSync(copyDebugidPath)) {
|
package/lib/bundle.d.ts
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
|
+
type NormalizedBundleOptions = {
|
|
2
|
+
bundleName: string;
|
|
3
|
+
entryFile: string;
|
|
4
|
+
intermediaDir: string;
|
|
5
|
+
output: string;
|
|
6
|
+
dev: string;
|
|
7
|
+
sourcemap: boolean;
|
|
8
|
+
taro: boolean;
|
|
9
|
+
expo: boolean;
|
|
10
|
+
rncli: boolean;
|
|
11
|
+
hermes: boolean;
|
|
12
|
+
name?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
metaInfo?: string;
|
|
15
|
+
packageId?: string;
|
|
16
|
+
packageVersion?: string;
|
|
17
|
+
minPackageVersion?: string;
|
|
18
|
+
maxPackageVersion?: string;
|
|
19
|
+
packageVersionRange?: string;
|
|
20
|
+
rollout?: string;
|
|
21
|
+
dryRun: boolean;
|
|
22
|
+
sentryRelease?: string;
|
|
23
|
+
sentryDist?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function normalizeBundleOptions(translatedOptions: Record<string, unknown>, platform: string): NormalizedBundleOptions;
|
|
1
26
|
export declare const bundleCommands: {
|
|
2
27
|
bundle: ({ options, }: {
|
|
3
28
|
args?: string[];
|
|
4
29
|
options: Record<string, unknown>;
|
|
5
30
|
}) => Promise<void>;
|
|
6
31
|
};
|
|
32
|
+
export {};
|
package/lib/bundle.js
CHANGED
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 bundleCommands () {
|
|
8
13
|
return bundleCommands;
|
|
14
|
+
},
|
|
15
|
+
get normalizeBundleOptions () {
|
|
16
|
+
return normalizeBundleOptions;
|
|
9
17
|
}
|
|
10
18
|
});
|
|
11
19
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
@@ -31,7 +39,9 @@ function getAliasedOptionalStringOption(options, key, alias) {
|
|
|
31
39
|
}
|
|
32
40
|
function normalizeBundleOptions(translatedOptions, platform) {
|
|
33
41
|
return {
|
|
34
|
-
|
|
42
|
+
// harmony bundles always use this fixed name (runReactNativeBundleCommand
|
|
43
|
+
// forces it), so sourcemap paths and Sentry uploads must match
|
|
44
|
+
bundleName: platform === 'harmony' ? 'bundle.harmony.js' : (0, _options.getStringOption)(translatedOptions, 'bundleName', 'index.bundlejs'),
|
|
35
45
|
entryFile: (0, _options.getStringOption)(translatedOptions, 'entryFile', 'index.js'),
|
|
36
46
|
intermediaDir: (0, _options.getStringOption)(translatedOptions, 'intermediaDir', `${_constants.tempDir}/intermedia/${platform}`),
|
|
37
47
|
output: (0, _options.getStringOption)(translatedOptions, 'output', `${_constants.tempDir}/output/${platform}.\${time}.ppk`),
|
|
@@ -90,7 +100,9 @@ const bundleCommands = {
|
|
|
90
100
|
if (!platform) {
|
|
91
101
|
throw new Error((0, _i18n.t)('platformRequired'));
|
|
92
102
|
}
|
|
93
|
-
console.log(
|
|
103
|
+
console.log((0, _i18n.t)('bundlingWithRN', {
|
|
104
|
+
version: _depversions.depVersions['react-native']
|
|
105
|
+
}));
|
|
94
106
|
await (0, _bundlerunner.runReactNativeBundleCommand)({
|
|
95
107
|
bundleName: normalized.bundleName,
|
|
96
108
|
dev: normalized.dev,
|
|
@@ -106,7 +118,7 @@ const bundleCommands = {
|
|
|
106
118
|
},
|
|
107
119
|
isSentry: bundleParams.sentry
|
|
108
120
|
});
|
|
109
|
-
await (0, _bundlepack.packBundle)(_path.default.resolve(normalized.intermediaDir), realOutput);
|
|
121
|
+
await (0, _bundlepack.packBundle)(_path.default.resolve(normalized.intermediaDir), realOutput, normalized.bundleName);
|
|
110
122
|
if (normalized.name) {
|
|
111
123
|
await publishBundleVersion(realOutput, platform, {
|
|
112
124
|
name: normalized.name,
|
package/lib/diff.js
CHANGED
|
@@ -95,8 +95,49 @@ function basename(fn) {
|
|
|
95
95
|
const m = /^(.+\/)[^/]+\/?$/.exec(fn);
|
|
96
96
|
return m == null ? void 0 : m[1];
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
function createOutputZip(output) {
|
|
99
99
|
_fsextra.ensureDirSync(_path.default.dirname(output));
|
|
100
|
+
const zipfile = new _yazl.ZipFile();
|
|
101
|
+
const writePromise = new Promise((resolve, reject)=>{
|
|
102
|
+
zipfile.outputStream.on('error', reject);
|
|
103
|
+
zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
|
|
104
|
+
resolve(void 0);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
zipfile,
|
|
109
|
+
writePromise
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
async function addBundlePatch(zipfile, entry, nextZipfile, diffFn, originSource) {
|
|
113
|
+
const newSource = await (0, _zipentries.readEntry)(entry, nextZipfile);
|
|
114
|
+
zipfile.addBuffer(await diffFn(originSource, newSource), `${entry.fileName}.patch`, (0, _zipoptions.zipOptionsForPatchEntry)());
|
|
115
|
+
}
|
|
116
|
+
async function addFileFromZipEntry(zipfile, entry, nextZipfile) {
|
|
117
|
+
const entryPrefix = await (0, _zipentries.readEntryPrefix)(entry, nextZipfile, _zipoptions.ZIP_ENTRY_SNIFF_BYTES);
|
|
118
|
+
await new Promise((resolve, reject)=>{
|
|
119
|
+
nextZipfile.openReadStream(entry, (err, readStream)=>{
|
|
120
|
+
if (err) {
|
|
121
|
+
return reject(err);
|
|
122
|
+
}
|
|
123
|
+
if (!readStream) {
|
|
124
|
+
return reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
|
|
125
|
+
}
|
|
126
|
+
zipfile.addReadStream(readStream, entry.fileName, (0, _zipoptions.zipOptionsForPayloadEntry)(entry.fileName, entryPrefix));
|
|
127
|
+
readStream.on('error', reject);
|
|
128
|
+
readStream.on('end', ()=>{
|
|
129
|
+
resolve(void 0);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function finishDiffZip(zipfile, writePromise, manifest) {
|
|
135
|
+
const diffManifest = Buffer.from(JSON.stringify(manifest));
|
|
136
|
+
zipfile.addBuffer(diffManifest, '__diff.json', (0, _zipoptions.zipOptionsForManifestEntry)(diffManifest.length));
|
|
137
|
+
zipfile.end();
|
|
138
|
+
return writePromise;
|
|
139
|
+
}
|
|
140
|
+
async function diffFromPPK(origin, next, output, diffFn) {
|
|
100
141
|
const originEntries = {};
|
|
101
142
|
const originMap = {};
|
|
102
143
|
let originSource;
|
|
@@ -115,13 +156,7 @@ async function diffFromPPK(origin, next, output, diffFn) {
|
|
|
115
156
|
throw new Error((0, _i18n.t)('bundleFileNotFound'));
|
|
116
157
|
}
|
|
117
158
|
const copies = {};
|
|
118
|
-
const zipfile =
|
|
119
|
-
const writePromise = new Promise((resolve, reject)=>{
|
|
120
|
-
zipfile.outputStream.on('error', reject);
|
|
121
|
-
zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
|
|
122
|
-
resolve(void 0);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
159
|
+
const { zipfile, writePromise } = createOutputZip(output);
|
|
125
160
|
const addedEntry = {};
|
|
126
161
|
function addEntry(fn) {
|
|
127
162
|
//console.log(fn);
|
|
@@ -144,11 +179,7 @@ async function diffFromPPK(origin, next, output, diffFn) {
|
|
|
144
179
|
addEntry(entry.fileName);
|
|
145
180
|
}
|
|
146
181
|
} else if ((0, _constants.isPPKBundleFileName)(entry.fileName)) {
|
|
147
|
-
|
|
148
|
-
const newSource = await (0, _zipentries.readEntry)(entry, nextZipfile);
|
|
149
|
-
//console.log('Begin diff');
|
|
150
|
-
zipfile.addBuffer(diffFn(originSource, newSource), `${entry.fileName}.patch`, (0, _zipoptions.zipOptionsForPatchEntry)());
|
|
151
|
-
//console.log('End diff');
|
|
182
|
+
await addBundlePatch(zipfile, entry, nextZipfile, diffFn, originSource);
|
|
152
183
|
} else {
|
|
153
184
|
// If same file.
|
|
154
185
|
const originEntry = originEntries[entry.fileName];
|
|
@@ -171,23 +202,7 @@ async function diffFromPPK(origin, next, output, diffFn) {
|
|
|
171
202
|
if (basePath) {
|
|
172
203
|
addEntry(basePath);
|
|
173
204
|
}
|
|
174
|
-
|
|
175
|
-
await new Promise((resolve, reject)=>{
|
|
176
|
-
nextZipfile.openReadStream(entry, (err, readStream)=>{
|
|
177
|
-
if (err) {
|
|
178
|
-
return reject(err);
|
|
179
|
-
}
|
|
180
|
-
if (!readStream) {
|
|
181
|
-
return reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
|
|
182
|
-
}
|
|
183
|
-
zipfile.addReadStream(readStream, entry.fileName, (0, _zipoptions.zipOptionsForPayloadEntry)(entry.fileName, entryPrefix));
|
|
184
|
-
readStream.on('error', reject);
|
|
185
|
-
readStream.on('end', ()=>{
|
|
186
|
-
//console.log('add finished');
|
|
187
|
-
resolve(void 0);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
205
|
+
await addFileFromZipEntry(zipfile, entry, nextZipfile);
|
|
191
206
|
}
|
|
192
207
|
});
|
|
193
208
|
const deletes = {};
|
|
@@ -199,17 +214,12 @@ async function diffFromPPK(origin, next, output, diffFn) {
|
|
|
199
214
|
deletes[k] = 1;
|
|
200
215
|
}
|
|
201
216
|
}
|
|
202
|
-
|
|
203
|
-
const diffManifest = Buffer.from(JSON.stringify({
|
|
217
|
+
await finishDiffZip(zipfile, writePromise, {
|
|
204
218
|
copies,
|
|
205
219
|
deletes
|
|
206
|
-
})
|
|
207
|
-
zipfile.addBuffer(diffManifest, '__diff.json', (0, _zipoptions.zipOptionsForManifestEntry)(diffManifest.length));
|
|
208
|
-
zipfile.end();
|
|
209
|
-
await writePromise;
|
|
220
|
+
});
|
|
210
221
|
}
|
|
211
222
|
async function diffFromPackage(origin, next, output, diffFn, originBundleName, transformPackagePath = (v)=>v) {
|
|
212
|
-
_fsextra.ensureDirSync(_path.default.dirname(output));
|
|
213
223
|
const originEntries = {};
|
|
214
224
|
const originMap = {};
|
|
215
225
|
let originSource;
|
|
@@ -239,23 +249,13 @@ async function diffFromPackage(origin, next, output, diffFn, originBundleName, t
|
|
|
239
249
|
throw new Error((0, _i18n.t)('bundleFileNotFound'));
|
|
240
250
|
}
|
|
241
251
|
const copies = {};
|
|
242
|
-
const zipfile =
|
|
243
|
-
const writePromise = new Promise((resolve, reject)=>{
|
|
244
|
-
zipfile.outputStream.on('error', reject);
|
|
245
|
-
zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
|
|
246
|
-
resolve(void 0);
|
|
247
|
-
});
|
|
248
|
-
});
|
|
252
|
+
const { zipfile, writePromise } = createOutputZip(output);
|
|
249
253
|
await (0, _zipentries.enumZipEntries)(next, async (entry, nextZipfile)=>{
|
|
250
254
|
if (/\/$/.test(entry.fileName)) {
|
|
251
255
|
// Directory
|
|
252
256
|
zipfile.addEmptyDirectory(entry.fileName);
|
|
253
257
|
} else if ((0, _constants.isPPKBundleFileName)(entry.fileName)) {
|
|
254
|
-
|
|
255
|
-
const newSource = await (0, _zipentries.readEntry)(entry, nextZipfile);
|
|
256
|
-
//console.log('Begin diff');
|
|
257
|
-
zipfile.addBuffer(diffFn(originSource, newSource), `${entry.fileName}.patch`, (0, _zipoptions.zipOptionsForPatchEntry)());
|
|
258
|
-
//console.log('End diff');
|
|
258
|
+
await addBundlePatch(zipfile, entry, nextZipfile, diffFn, originSource);
|
|
259
259
|
} else {
|
|
260
260
|
// If same file.
|
|
261
261
|
if (originEntries[entry.fileName] === entry.crc32) {
|
|
@@ -272,32 +272,13 @@ async function diffFromPackage(origin, next, output, diffFn, originBundleName, t
|
|
|
272
272
|
copiesCrc[entry.fileName] = entry.crc32;
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
-
|
|
276
|
-
await new Promise((resolve, reject)=>{
|
|
277
|
-
nextZipfile.openReadStream(entry, (err, readStream)=>{
|
|
278
|
-
if (err) {
|
|
279
|
-
return reject(err);
|
|
280
|
-
}
|
|
281
|
-
if (!readStream) {
|
|
282
|
-
return reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
|
|
283
|
-
}
|
|
284
|
-
zipfile.addReadStream(readStream, entry.fileName, (0, _zipoptions.zipOptionsForPayloadEntry)(entry.fileName, entryPrefix));
|
|
285
|
-
readStream.on('error', reject);
|
|
286
|
-
readStream.on('end', ()=>{
|
|
287
|
-
//console.log('add finished');
|
|
288
|
-
resolve(void 0);
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
});
|
|
275
|
+
await addFileFromZipEntry(zipfile, entry, nextZipfile);
|
|
292
276
|
}
|
|
293
277
|
});
|
|
294
|
-
|
|
278
|
+
await finishDiffZip(zipfile, writePromise, {
|
|
295
279
|
copies,
|
|
296
280
|
copiesCrc
|
|
297
|
-
})
|
|
298
|
-
zipfile.addBuffer(diffManifest, '__diff.json', (0, _zipoptions.zipOptionsForManifestEntry)(diffManifest.length));
|
|
299
|
-
zipfile.end();
|
|
300
|
-
await writePromise;
|
|
281
|
+
});
|
|
301
282
|
}
|
|
302
283
|
function resolveDiffImplementation(options) {
|
|
303
284
|
var _options_customHdiffModule;
|
|
@@ -325,7 +306,7 @@ function diffArgsCheck(args, options, diffFnName) {
|
|
|
325
306
|
tempDir: _constants.tempDir
|
|
326
307
|
});
|
|
327
308
|
if (typeof output !== 'string') {
|
|
328
|
-
throw new Error(
|
|
309
|
+
throw new Error((0, _i18n.t)('outputPathRequired'));
|
|
329
310
|
}
|
|
330
311
|
return {
|
|
331
312
|
origin,
|
package/lib/locales/en.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ declare const _default: {
|
|
|
95
95
|
rolloutConfigSet: string;
|
|
96
96
|
rolloutRangeError: string;
|
|
97
97
|
runningHermesc: string;
|
|
98
|
+
sentryReactNativeNotFound: string;
|
|
98
99
|
sentryCliNotFound: string;
|
|
99
100
|
sentryReleaseCreated: string;
|
|
100
101
|
totalApps: string;
|
|
@@ -136,9 +137,19 @@ declare const _default: {
|
|
|
136
137
|
diffPackageGenerated: string;
|
|
137
138
|
nodeHdiffpatchRequired: string;
|
|
138
139
|
apkExtracted: string;
|
|
140
|
+
composeSourceMapsNotFound: string;
|
|
139
141
|
installPackageRequired: string;
|
|
140
142
|
installFailed: string;
|
|
141
143
|
proxyNetworkError: string;
|
|
142
144
|
proxyNetworkErrorTips: string;
|
|
145
|
+
invalidId: string;
|
|
146
|
+
outputPathRequired: string;
|
|
147
|
+
unsupportedFileType: string;
|
|
148
|
+
failedToLoadSession: string;
|
|
149
|
+
appIdRequired: string;
|
|
150
|
+
unknownCommand: string;
|
|
151
|
+
unsupportedPlatformForHermes: string;
|
|
152
|
+
invalidManifest: string;
|
|
153
|
+
failedToResolveResource: string;
|
|
143
154
|
};
|
|
144
155
|
export default _default;
|
package/lib/locales/en.js
CHANGED
|
@@ -111,6 +111,7 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
111
111
|
rolloutConfigSet: 'Set {{rollout}}% rollout for OTA update {{version}} on native version(s) {{versions}}',
|
|
112
112
|
rolloutRangeError: 'rollout must be an integer between 1-100',
|
|
113
113
|
runningHermesc: 'Running hermesc: {{- command}} {{- args}}',
|
|
114
|
+
sentryReactNativeNotFound: 'Cannot find @sentry/react-native, please make sure it is properly installed',
|
|
114
115
|
sentryCliNotFound: 'Cannot find Sentry CLI tool, please make sure @sentry/cli is properly installed',
|
|
115
116
|
sentryReleaseCreated: 'Sentry release created for version: {{version}}',
|
|
116
117
|
totalApps: 'Total {{count}} {{platform}} apps',
|
|
@@ -152,8 +153,18 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
152
153
|
diffPackageGenerated: '{{- output}} generated.',
|
|
153
154
|
nodeHdiffpatchRequired: 'This function needs "node-hdiffpatch". Please run "{{scriptName}} install node-hdiffpatch" to install',
|
|
154
155
|
apkExtracted: 'APK extracted to {{output}}',
|
|
156
|
+
composeSourceMapsNotFound: 'Cannot find react-native/scripts/compose-source-maps.js, skipping hermes sourcemap composing. The uploaded sourcemap may not match the compiled bundle.',
|
|
155
157
|
installPackageRequired: 'Please specify the package to install, e.g. "{{scriptName}} install node-hdiffpatch"',
|
|
156
158
|
installFailed: 'Failed to install {{packages}}: {{error}}',
|
|
157
159
|
proxyNetworkError: 'Network error — likely caused by a proxy/VPN. Please try disabling your proxy and retry.',
|
|
158
|
-
proxyNetworkErrorTips: 'Common fixes:\n1. Disable system proxy or VPN\n2. Check HTTP_PROXY / HTTPS_PROXY environment variables\n3. Check proxy settings in .npmrc'
|
|
160
|
+
proxyNetworkErrorTips: 'Common fixes:\n1. Disable system proxy or VPN\n2. Check HTTP_PROXY / HTTPS_PROXY environment variables\n3. Check proxy settings in .npmrc',
|
|
161
|
+
invalidId: 'Invalid id: {{id}}',
|
|
162
|
+
outputPathRequired: 'Output path is required.',
|
|
163
|
+
unsupportedFileType: 'Unsupported file type: {{fileType}}',
|
|
164
|
+
failedToLoadSession: 'Failed to load session',
|
|
165
|
+
appIdRequired: 'appId is required',
|
|
166
|
+
unknownCommand: 'Unknown command: {{command}}',
|
|
167
|
+
unsupportedPlatformForHermes: 'Unsupported platform for Hermes: {{platform}}',
|
|
168
|
+
invalidManifest: 'Invalid manifest',
|
|
169
|
+
failedToResolveResource: 'Failed to resolve resource: {{error}}'
|
|
159
170
|
};
|
package/lib/locales/zh.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ declare const _default: {
|
|
|
95
95
|
rolloutConfigSet: string;
|
|
96
96
|
rolloutRangeError: string;
|
|
97
97
|
runningHermesc: string;
|
|
98
|
+
sentryReactNativeNotFound: string;
|
|
98
99
|
sentryCliNotFound: string;
|
|
99
100
|
sentryReleaseCreated: string;
|
|
100
101
|
totalApps: string;
|
|
@@ -135,9 +136,19 @@ declare const _default: {
|
|
|
135
136
|
diffPackageGenerated: string;
|
|
136
137
|
nodeHdiffpatchRequired: string;
|
|
137
138
|
apkExtracted: string;
|
|
139
|
+
composeSourceMapsNotFound: string;
|
|
138
140
|
installPackageRequired: string;
|
|
139
141
|
installFailed: string;
|
|
140
142
|
proxyNetworkError: string;
|
|
141
143
|
proxyNetworkErrorTips: string;
|
|
144
|
+
invalidId: string;
|
|
145
|
+
outputPathRequired: string;
|
|
146
|
+
unsupportedFileType: string;
|
|
147
|
+
failedToLoadSession: string;
|
|
148
|
+
appIdRequired: string;
|
|
149
|
+
unknownCommand: string;
|
|
150
|
+
unsupportedPlatformForHermes: string;
|
|
151
|
+
invalidManifest: string;
|
|
152
|
+
failedToResolveResource: string;
|
|
142
153
|
};
|
|
143
154
|
export default _default;
|
package/lib/locales/zh.js
CHANGED
|
@@ -111,6 +111,7 @@ const _default = {
|
|
|
111
111
|
rolloutConfigSet: '已在原生版本 {{versions}} 上设置灰度发布 {{rollout}}% 热更包 {{version}}',
|
|
112
112
|
rolloutRangeError: 'rollout 必须是 1-100 的整数',
|
|
113
113
|
runningHermesc: '运行 hermesc:{{- command}} {{- args}}',
|
|
114
|
+
sentryReactNativeNotFound: '无法找到 @sentry/react-native,请确保已正确安装',
|
|
114
115
|
sentryCliNotFound: '无法找到 Sentry CLI 工具,请确保已正确安装 @sentry/cli',
|
|
115
116
|
sentryReleaseCreated: '已为版本 {{version}} 创建 Sentry release',
|
|
116
117
|
totalApps: '共 {{count}} 个 {{platform}} 应用',
|
|
@@ -151,8 +152,18 @@ const _default = {
|
|
|
151
152
|
diffPackageGenerated: '{{- output}} 已生成。',
|
|
152
153
|
nodeHdiffpatchRequired: '此功能需要 "node-hdiffpatch"。请运行 "{{scriptName}} install node-hdiffpatch" 来安装',
|
|
153
154
|
apkExtracted: 'APK 已提取到 {{output}}',
|
|
155
|
+
composeSourceMapsNotFound: '找不到 react-native/scripts/compose-source-maps.js,跳过 hermes sourcemap 合成。上传的 sourcemap 可能与编译后的 bundle 不匹配。',
|
|
154
156
|
installPackageRequired: '请指定要安装的包,例如 "{{scriptName}} install node-hdiffpatch"',
|
|
155
157
|
installFailed: '安装 {{packages}} 失败: {{error}}',
|
|
156
158
|
proxyNetworkError: '网络连接异常,可能是代理/VPN 导致。请尝试关闭代理后重试。',
|
|
157
|
-
proxyNetworkErrorTips: '常见解决方法:\n1. 关闭系统代理或 VPN\n2. 检查 HTTP_PROXY / HTTPS_PROXY 环境变量\n3. 检查 .npmrc 中的 proxy 配置'
|
|
159
|
+
proxyNetworkErrorTips: '常见解决方法:\n1. 关闭系统代理或 VPN\n2. 检查 HTTP_PROXY / HTTPS_PROXY 环境变量\n3. 检查 .npmrc 中的 proxy 配置',
|
|
160
|
+
invalidId: '无效的 id:{{id}}',
|
|
161
|
+
outputPathRequired: '必须指定输出路径。',
|
|
162
|
+
unsupportedFileType: '不支持的文件类型:{{fileType}}',
|
|
163
|
+
failedToLoadSession: '加载登录状态失败',
|
|
164
|
+
appIdRequired: '必须指定 appId',
|
|
165
|
+
unknownCommand: '未知命令:{{command}}',
|
|
166
|
+
unsupportedPlatformForHermes: 'Hermes 不支持当前系统平台:{{platform}}',
|
|
167
|
+
invalidManifest: '无效的 manifest',
|
|
168
|
+
failedToResolveResource: '资源解析失败:{{error}}'
|
|
158
169
|
};
|
package/lib/package.js
CHANGED
|
@@ -103,7 +103,9 @@ function toNumericIds(ids) {
|
|
|
103
103
|
return ids.map((id)=>{
|
|
104
104
|
const numericId = Number(id);
|
|
105
105
|
if (!Number.isInteger(numericId) || numericId <= 0) {
|
|
106
|
-
throw new Error(
|
|
106
|
+
throw new Error((0, _i18n.t)('invalidId', {
|
|
107
|
+
id
|
|
108
|
+
}));
|
|
107
109
|
}
|
|
108
110
|
return numericId;
|
|
109
111
|
});
|