react-native-update-cli 1.39.0 → 1.39.2
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/bundle.js
CHANGED
|
@@ -135,7 +135,6 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
const bundleParams = await (0, _utils.checkPlugins)();
|
|
138
|
-
const minifyOption = bundleParams.minify;
|
|
139
138
|
const isSentry = bundleParams.sentry;
|
|
140
139
|
const bundleCommand = usingExpo ? 'export:embed' : platform === 'harmony' ? 'bundle-harmony' : 'bundle';
|
|
141
140
|
if (platform === 'harmony') {
|
|
@@ -167,9 +166,7 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
|
|
|
167
166
|
entryFile,
|
|
168
167
|
'--platform',
|
|
169
168
|
platform,
|
|
170
|
-
'--reset-cache'
|
|
171
|
-
'--minify',
|
|
172
|
-
minifyOption
|
|
169
|
+
'--reset-cache'
|
|
173
170
|
]);
|
|
174
171
|
if (sourcemapOutput) {
|
|
175
172
|
reactNativeBundleArgs.push('--sourcemap-output', sourcemapOutput);
|
|
@@ -199,7 +196,7 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
|
|
|
199
196
|
}, (error, props)=>{
|
|
200
197
|
if (error) {
|
|
201
198
|
console.error(error);
|
|
202
|
-
resolve(
|
|
199
|
+
resolve({});
|
|
203
200
|
}
|
|
204
201
|
resolve(props);
|
|
205
202
|
});
|
|
@@ -381,6 +378,14 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
381
378
|
});
|
|
382
379
|
}
|
|
383
380
|
}
|
|
381
|
+
const ignorePackingFileNames = [
|
|
382
|
+
'.',
|
|
383
|
+
'..',
|
|
384
|
+
'index.bundlejs.map'
|
|
385
|
+
];
|
|
386
|
+
const ignorePackingExtensions = [
|
|
387
|
+
'DS_Store'
|
|
388
|
+
];
|
|
384
389
|
async function pack(dir, output) {
|
|
385
390
|
console.log('Packing');
|
|
386
391
|
_fsextra.ensureDirSync(_nodepath.default.dirname(output));
|
|
@@ -392,7 +397,7 @@ async function pack(dir, output) {
|
|
|
392
397
|
}
|
|
393
398
|
const childs = _fsextra.readdirSync(root);
|
|
394
399
|
for (const name of childs){
|
|
395
|
-
if (
|
|
400
|
+
if (ignorePackingFileNames.includes(name) || ignorePackingExtensions.some((ext)=>name.endsWith(`.${ext}`))) {
|
|
396
401
|
continue;
|
|
397
402
|
}
|
|
398
403
|
const fullPath = _nodepath.default.join(root, name);
|
|
@@ -704,12 +709,12 @@ function diffArgsCheck(args, options, diffFn) {
|
|
|
704
709
|
const commands = {
|
|
705
710
|
bundle: async function({ options }) {
|
|
706
711
|
const platform = (0, _app.checkPlatform)(options.platform || await (0, _utils.question)('平台(ios/android/harmony):'));
|
|
707
|
-
const { bundleName, entryFile, intermediaDir, output, dev } = (0, _utils.translateOptions)({
|
|
712
|
+
const { bundleName, entryFile, intermediaDir, output, dev, sourcemap } = (0, _utils.translateOptions)({
|
|
708
713
|
...options,
|
|
709
714
|
platform
|
|
710
715
|
});
|
|
711
716
|
const bundleParams = await (0, _utils.checkPlugins)();
|
|
712
|
-
const
|
|
717
|
+
const sourcemapPlugin = bundleParams.sourcemap;
|
|
713
718
|
const isSentry = bundleParams.sentry;
|
|
714
719
|
const sourcemapOutput = _nodepath.default.join(intermediaDir, `${bundleName}.map`);
|
|
715
720
|
const realOutput = output.replace(/\$\{time\}/g, `${Date.now()}`);
|
|
@@ -718,7 +723,7 @@ const commands = {
|
|
|
718
723
|
}
|
|
719
724
|
const { version, major, minor } = (0, _utils.getRNVersion)();
|
|
720
725
|
console.log(`Bundling with react-native: ${version}`);
|
|
721
|
-
await runReactNativeBundleCommand(bundleName, dev, entryFile, intermediaDir, platform, sourcemap ? sourcemapOutput : '');
|
|
726
|
+
await runReactNativeBundleCommand(bundleName, dev, entryFile, intermediaDir, platform, sourcemap || sourcemapPlugin ? sourcemapOutput : '');
|
|
722
727
|
await pack(_nodepath.default.resolve(intermediaDir), realOutput);
|
|
723
728
|
const v = await (0, _utils.question)('是否现在上传此热更包?(Y/N)');
|
|
724
729
|
if (v.toLowerCase() === 'y') {
|
package/package.json
CHANGED
|
@@ -22,16 +22,20 @@ try {
|
|
|
22
22
|
hdiff = require('node-hdiffpatch').diff;
|
|
23
23
|
} catch (e) {}
|
|
24
24
|
|
|
25
|
+
|
|
25
26
|
async function runReactNativeBundleCommand(
|
|
26
|
-
bundleName,
|
|
27
|
-
development,
|
|
28
|
-
entryFile,
|
|
29
|
-
outputFolder,
|
|
30
|
-
platform,
|
|
31
|
-
sourcemapOutput,
|
|
32
|
-
config,
|
|
27
|
+
bundleName: string,
|
|
28
|
+
development: string,
|
|
29
|
+
entryFile: string,
|
|
30
|
+
outputFolder: string,
|
|
31
|
+
platform: string,
|
|
32
|
+
sourcemapOutput: string,
|
|
33
|
+
config: string,
|
|
33
34
|
) {
|
|
34
|
-
let gradleConfig
|
|
35
|
+
let gradleConfig: {
|
|
36
|
+
crunchPngs?: boolean;
|
|
37
|
+
enableHermes?: boolean;
|
|
38
|
+
} = {};
|
|
35
39
|
if (platform === 'android') {
|
|
36
40
|
gradleConfig = await checkGradleConfig();
|
|
37
41
|
if (gradleConfig.crunchPngs !== false) {
|
|
@@ -41,7 +45,7 @@ async function runReactNativeBundleCommand(
|
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
const reactNativeBundleArgs = [];
|
|
48
|
+
const reactNativeBundleArgs: string[] = [];
|
|
45
49
|
|
|
46
50
|
const envArgs = process.env.PUSHY_ENV_ARGS;
|
|
47
51
|
|
|
@@ -87,7 +91,6 @@ async function runReactNativeBundleCommand(
|
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
const bundleParams = await checkPlugins();
|
|
90
|
-
const minifyOption = bundleParams.minify;
|
|
91
94
|
const isSentry = bundleParams.sentry;
|
|
92
95
|
const bundleCommand = usingExpo
|
|
93
96
|
? 'export:embed'
|
|
@@ -126,8 +129,6 @@ async function runReactNativeBundleCommand(
|
|
|
126
129
|
'--platform',
|
|
127
130
|
platform,
|
|
128
131
|
'--reset-cache',
|
|
129
|
-
'--minify',
|
|
130
|
-
minifyOption,
|
|
131
132
|
]);
|
|
132
133
|
|
|
133
134
|
if (sourcemapOutput) {
|
|
@@ -161,17 +162,17 @@ async function runReactNativeBundleCommand(
|
|
|
161
162
|
),
|
|
162
163
|
);
|
|
163
164
|
} else {
|
|
164
|
-
let hermesEnabled = false;
|
|
165
|
+
let hermesEnabled: boolean | undefined = false;
|
|
165
166
|
|
|
166
167
|
if (platform === 'android') {
|
|
167
|
-
const gradlePropeties = await new Promise((resolve) => {
|
|
168
|
+
const gradlePropeties = await new Promise<{ hermesEnabled?: boolean }>((resolve) => {
|
|
168
169
|
properties.parse(
|
|
169
170
|
'./android/gradle.properties',
|
|
170
171
|
{ path: true },
|
|
171
|
-
(error, props) => {
|
|
172
|
+
(error: any, props: { hermesEnabled?: boolean }) => {
|
|
172
173
|
if (error) {
|
|
173
174
|
console.error(error);
|
|
174
|
-
resolve(
|
|
175
|
+
resolve({});
|
|
175
176
|
}
|
|
176
177
|
|
|
177
178
|
resolve(props);
|
|
@@ -204,7 +205,7 @@ async function runReactNativeBundleCommand(
|
|
|
204
205
|
});
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
async function copyHarmonyBundle(outputFolder) {
|
|
208
|
+
async function copyHarmonyBundle(outputFolder: string) {
|
|
208
209
|
const harmonyRawPath = 'harmony/entry/src/main/resources/rawfile';
|
|
209
210
|
try {
|
|
210
211
|
await fs.ensureDir(harmonyRawPath);
|
|
@@ -218,7 +219,7 @@ async function copyHarmonyBundle(outputFolder) {
|
|
|
218
219
|
|
|
219
220
|
await fs.ensureDir(outputFolder);
|
|
220
221
|
await fs.copy(harmonyRawPath, outputFolder);
|
|
221
|
-
} catch (error) {
|
|
222
|
+
} catch (error: any) {
|
|
222
223
|
console.error('copyHarmonyBundle 错误:', error);
|
|
223
224
|
throw new Error(`复制文件失败: ${error.message}`);
|
|
224
225
|
}
|
|
@@ -256,10 +257,10 @@ async function checkGradleConfig() {
|
|
|
256
257
|
}
|
|
257
258
|
|
|
258
259
|
async function compileHermesByteCode(
|
|
259
|
-
bundleName,
|
|
260
|
-
outputFolder,
|
|
261
|
-
sourcemapOutput,
|
|
262
|
-
shouldCleanSourcemap,
|
|
260
|
+
bundleName: string,
|
|
261
|
+
outputFolder: string,
|
|
262
|
+
sourcemapOutput: string,
|
|
263
|
+
shouldCleanSourcemap: boolean,
|
|
263
264
|
) {
|
|
264
265
|
console.log('Hermes enabled, now compiling to hermes bytecode:\n');
|
|
265
266
|
// >= rn 0.69
|
|
@@ -321,7 +322,7 @@ async function compileHermesByteCode(
|
|
|
321
322
|
}
|
|
322
323
|
}
|
|
323
324
|
|
|
324
|
-
async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
|
|
325
|
+
async function copyDebugidForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string) {
|
|
325
326
|
if (sourcemapOutput) {
|
|
326
327
|
let copyDebugidPath;
|
|
327
328
|
try {
|
|
@@ -358,10 +359,10 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
|
|
|
358
359
|
}
|
|
359
360
|
|
|
360
361
|
async function uploadSourcemapForSentry(
|
|
361
|
-
bundleName,
|
|
362
|
-
outputFolder,
|
|
363
|
-
sourcemapOutput,
|
|
364
|
-
version,
|
|
362
|
+
bundleName: string,
|
|
363
|
+
outputFolder: string,
|
|
364
|
+
sourcemapOutput: string,
|
|
365
|
+
version: string,
|
|
365
366
|
) {
|
|
366
367
|
if (sourcemapOutput) {
|
|
367
368
|
let sentryCliPath;
|
|
@@ -408,19 +409,21 @@ async function uploadSourcemapForSentry(
|
|
|
408
409
|
}
|
|
409
410
|
}
|
|
410
411
|
|
|
411
|
-
|
|
412
|
+
const ignorePackingFileNames = ['.', '..', 'index.bundlejs.map'];
|
|
413
|
+
const ignorePackingExtensions = ['DS_Store'];
|
|
414
|
+
async function pack(dir: string, output: string) {
|
|
412
415
|
console.log('Packing');
|
|
413
416
|
fs.ensureDirSync(path.dirname(output));
|
|
414
|
-
await new Promise((resolve, reject) => {
|
|
417
|
+
await new Promise<void>((resolve, reject) => {
|
|
415
418
|
const zipfile = new ZipFile();
|
|
416
419
|
|
|
417
|
-
function addDirectory(root, rel) {
|
|
420
|
+
function addDirectory(root: string, rel: string) {
|
|
418
421
|
if (rel) {
|
|
419
422
|
zipfile.addEmptyDirectory(rel);
|
|
420
423
|
}
|
|
421
424
|
const childs = fs.readdirSync(root);
|
|
422
425
|
for (const name of childs) {
|
|
423
|
-
if (name
|
|
426
|
+
if (ignorePackingFileNames.includes(name) || ignorePackingExtensions.some(ext => name.endsWith(`.${ext}`))) {
|
|
424
427
|
continue;
|
|
425
428
|
}
|
|
426
429
|
const fullPath = path.join(root, name);
|
|
@@ -437,7 +440,7 @@ async function pack(dir, output) {
|
|
|
437
440
|
|
|
438
441
|
addDirectory(dir, '');
|
|
439
442
|
|
|
440
|
-
zipfile.outputStream.on('error', (err) => reject(err));
|
|
443
|
+
zipfile.outputStream.on('error', (err: any) => reject(err));
|
|
441
444
|
zipfile.outputStream.pipe(fs.createWriteStream(output)).on('close', () => {
|
|
442
445
|
resolve();
|
|
443
446
|
});
|
|
@@ -446,12 +449,12 @@ async function pack(dir, output) {
|
|
|
446
449
|
console.log(`ppk热更包已生成并保存到: ${output}`);
|
|
447
450
|
}
|
|
448
451
|
|
|
449
|
-
export function readEntire(entry, zipFile) {
|
|
450
|
-
const buffers = [];
|
|
452
|
+
export function readEntire(entry: string, zipFile: ZipFile) {
|
|
453
|
+
const buffers: Buffer[] = [];
|
|
451
454
|
return new Promise((resolve, reject) => {
|
|
452
|
-
zipFile.openReadStream(entry, (err, stream) => {
|
|
455
|
+
zipFile.openReadStream(entry, (err: any, stream: any) => {
|
|
453
456
|
stream.pipe({
|
|
454
|
-
write(chunk) {
|
|
457
|
+
write(chunk: Buffer) {
|
|
455
458
|
buffers.push(chunk);
|
|
456
459
|
},
|
|
457
460
|
end() {
|
|
@@ -466,12 +469,12 @@ export function readEntire(entry, zipFile) {
|
|
|
466
469
|
});
|
|
467
470
|
}
|
|
468
471
|
|
|
469
|
-
function basename(fn) {
|
|
472
|
+
function basename(fn: string) {
|
|
470
473
|
const m = /^(.+\/)[^\/]+\/?$/.exec(fn);
|
|
471
474
|
return m?.[1];
|
|
472
475
|
}
|
|
473
476
|
|
|
474
|
-
async function diffFromPPK(origin, next, output) {
|
|
477
|
+
async function diffFromPPK(origin: string, next: string, output: string) {
|
|
475
478
|
fs.ensureDirSync(path.dirname(output));
|
|
476
479
|
|
|
477
480
|
const originEntries = {};
|
|
@@ -516,7 +519,7 @@ async function diffFromPPK(origin, next, output) {
|
|
|
516
519
|
|
|
517
520
|
const addedEntry = {};
|
|
518
521
|
|
|
519
|
-
function addEntry(fn) {
|
|
522
|
+
function addEntry(fn: string) {
|
|
520
523
|
//console.log(fn);
|
|
521
524
|
if (!fn || addedEntry[fn]) {
|
|
522
525
|
return;
|
|
@@ -613,11 +616,11 @@ async function diffFromPPK(origin, next, output) {
|
|
|
613
616
|
}
|
|
614
617
|
|
|
615
618
|
async function diffFromPackage(
|
|
616
|
-
origin,
|
|
617
|
-
next,
|
|
618
|
-
output,
|
|
619
|
-
originBundleName,
|
|
620
|
-
transformPackagePath = (v) => v,
|
|
619
|
+
origin: string,
|
|
620
|
+
next: string,
|
|
621
|
+
output: string,
|
|
622
|
+
originBundleName: string,
|
|
623
|
+
transformPackagePath = (v: string) => v,
|
|
621
624
|
) {
|
|
622
625
|
fs.ensureDirSync(path.dirname(output));
|
|
623
626
|
|
|
@@ -626,7 +629,7 @@ async function diffFromPackage(
|
|
|
626
629
|
|
|
627
630
|
let originSource;
|
|
628
631
|
|
|
629
|
-
await enumZipEntries(origin, (entry, zipFile) => {
|
|
632
|
+
await enumZipEntries(origin, (entry: any, zipFile: any) => {
|
|
630
633
|
if (!/\/$/.test(entry.fileName)) {
|
|
631
634
|
const fn = transformPackagePath(entry.fileName);
|
|
632
635
|
if (!fn) {
|
|
@@ -720,9 +723,9 @@ async function diffFromPackage(
|
|
|
720
723
|
await writePromise;
|
|
721
724
|
}
|
|
722
725
|
|
|
723
|
-
export async function enumZipEntries(zipFn, callback, nestedPath = '') {
|
|
726
|
+
export async function enumZipEntries(zipFn: string, callback: (entry: any, zipFile: any) => void, nestedPath = '') {
|
|
724
727
|
return new Promise((resolve, reject) => {
|
|
725
|
-
openZipFile(zipFn, { lazyEntries: true }, async (err, zipfile) => {
|
|
728
|
+
openZipFile(zipFn, { lazyEntries: true }, async (err: any, zipfile: ZipFile) => {
|
|
726
729
|
if (err) {
|
|
727
730
|
return reject(err);
|
|
728
731
|
}
|
|
@@ -814,14 +817,14 @@ export const commands = {
|
|
|
814
817
|
options.platform || (await question('平台(ios/android/harmony):')),
|
|
815
818
|
);
|
|
816
819
|
|
|
817
|
-
const { bundleName, entryFile, intermediaDir, output, dev } =
|
|
820
|
+
const { bundleName, entryFile, intermediaDir, output, dev, sourcemap } =
|
|
818
821
|
translateOptions({
|
|
819
822
|
...options,
|
|
820
823
|
platform,
|
|
821
824
|
});
|
|
822
825
|
|
|
823
826
|
const bundleParams = await checkPlugins();
|
|
824
|
-
const
|
|
827
|
+
const sourcemapPlugin = bundleParams.sourcemap;
|
|
825
828
|
const isSentry = bundleParams.sentry;
|
|
826
829
|
|
|
827
830
|
const sourcemapOutput = path.join(intermediaDir, `${bundleName}.map`);
|
|
@@ -842,7 +845,7 @@ export const commands = {
|
|
|
842
845
|
entryFile,
|
|
843
846
|
intermediaDir,
|
|
844
847
|
platform,
|
|
845
|
-
sourcemap ? sourcemapOutput : '',
|
|
848
|
+
sourcemap || sourcemapPlugin ? sourcemapOutput : '',
|
|
846
849
|
);
|
|
847
850
|
|
|
848
851
|
await pack(path.resolve(intermediaDir), realOutput);
|
|
@@ -2,7 +2,6 @@ import { plugins } from './plugin-config';
|
|
|
2
2
|
|
|
3
3
|
interface BundleParams {
|
|
4
4
|
sentry: boolean;
|
|
5
|
-
minify: boolean;
|
|
6
5
|
sourcemap: boolean;
|
|
7
6
|
[key: string]: any;
|
|
8
7
|
}
|
|
@@ -10,7 +9,6 @@ interface BundleParams {
|
|
|
10
9
|
export async function checkPlugins(): Promise<BundleParams> {
|
|
11
10
|
const params: BundleParams = {
|
|
12
11
|
sentry: false,
|
|
13
|
-
minify: true,
|
|
14
12
|
sourcemap: false,
|
|
15
13
|
};
|
|
16
14
|
|
|
@@ -3,7 +3,6 @@ import fs from 'fs-extra';
|
|
|
3
3
|
interface PluginConfig {
|
|
4
4
|
name: string;
|
|
5
5
|
bundleParams?: {
|
|
6
|
-
minify?: boolean;
|
|
7
6
|
[key: string]: any;
|
|
8
7
|
};
|
|
9
8
|
detect: () => Promise<boolean>;
|
|
@@ -14,7 +13,6 @@ export const plugins: PluginConfig[] = [
|
|
|
14
13
|
name: 'sentry',
|
|
15
14
|
bundleParams: {
|
|
16
15
|
sentry: true,
|
|
17
|
-
minify: false,
|
|
18
16
|
sourcemap: true,
|
|
19
17
|
},
|
|
20
18
|
detect: async () => {
|