react-native-update-cli 1.39.1 → 1.40.0-beta.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/cli.json CHANGED
@@ -145,6 +145,15 @@
145
145
  },
146
146
  "sourcemap": {
147
147
  "default": false
148
+ },
149
+ "taro": {
150
+ "default": false
151
+ },
152
+ "expo": {
153
+ "default": false
154
+ },
155
+ "rncli": {
156
+ "default": false
148
157
  }
149
158
  }
150
159
  },
package/lib/bundle.js CHANGED
@@ -85,7 +85,7 @@ try {
85
85
  try {
86
86
  hdiff = require('node-hdiffpatch').diff;
87
87
  } catch (e) {}
88
- async function runReactNativeBundleCommand(bundleName, development, entryFile, outputFolder, platform, sourcemapOutput, config) {
88
+ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, cli }) {
89
89
  let gradleConfig = {};
90
90
  if (platform === 'android') {
91
91
  gradleConfig = await checkGradleConfig();
@@ -101,23 +101,27 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
101
101
  _fsextra.emptyDirSync(outputFolder);
102
102
  let cliPath;
103
103
  let usingExpo = false;
104
- try {
105
- cliPath = require.resolve('@expo/cli', {
106
- paths: [
107
- process.cwd()
108
- ]
109
- });
110
- const expoCliVersion = JSON.parse(_fsextra.readFileSync(require.resolve('@expo/cli/package.json', {
111
- paths: [
112
- process.cwd()
113
- ]
114
- }))).version;
115
- // expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
116
- if ((0, _satisfies.default)(expoCliVersion, '>= 0.10.17')) {
117
- usingExpo = true;
118
- }
119
- } catch (e) {}
120
- if (!usingExpo) {
104
+ const getExpoCli = ()=>{
105
+ try {
106
+ cliPath = require.resolve('@expo/cli', {
107
+ paths: [
108
+ process.cwd()
109
+ ]
110
+ });
111
+ const expoCliVersion = JSON.parse(_fsextra.readFileSync(require.resolve('@expo/cli/package.json', {
112
+ paths: [
113
+ process.cwd()
114
+ ]
115
+ }))).version;
116
+ // expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
117
+ if ((0, _satisfies.default)(expoCliVersion, '>= 0.10.17')) {
118
+ usingExpo = true;
119
+ } else {
120
+ cliPath = undefined;
121
+ }
122
+ } catch (e) {}
123
+ };
124
+ const getRnCli = ()=>{
121
125
  try {
122
126
  // rn >= 0.75
123
127
  cliPath = require.resolve('@react-native-community/cli/build/bin.js', {
@@ -133,16 +137,45 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
133
137
  ]
134
138
  });
135
139
  }
140
+ };
141
+ const getTaroCli = ()=>{
142
+ try {
143
+ cliPath = require.resolve('@tarojs/cli/bin/taro.js', {
144
+ paths: [
145
+ process.cwd()
146
+ ]
147
+ });
148
+ } catch (e) {}
149
+ };
150
+ if (cli.expo) {
151
+ getExpoCli();
152
+ } else if (cli.taro) {
153
+ getTaroCli();
154
+ } else if (cli.rncli) {
155
+ getRnCli();
156
+ }
157
+ if (!cliPath) {
158
+ getExpoCli();
159
+ if (!usingExpo) {
160
+ getRnCli();
161
+ }
136
162
  }
137
163
  const bundleParams = await (0, _utils.checkPlugins)();
138
164
  const isSentry = bundleParams.sentry;
139
- const bundleCommand = usingExpo ? 'export:embed' : platform === 'harmony' ? 'bundle-harmony' : 'bundle';
165
+ let bundleCommand = 'bundle';
166
+ if (usingExpo) {
167
+ bundleCommand = 'export:embed';
168
+ } else if (platform === 'harmony') {
169
+ bundleCommand = 'bundle-harmony';
170
+ } else if (cli.taro) {
171
+ bundleCommand = 'build';
172
+ }
140
173
  if (platform === 'harmony') {
141
174
  Array.prototype.push.apply(reactNativeBundleArgs, [
142
175
  cliPath,
143
176
  bundleCommand,
144
177
  '--dev',
145
- development,
178
+ dev,
146
179
  '--entry-file',
147
180
  entryFile
148
181
  ]);
@@ -160,14 +193,23 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
160
193
  outputFolder,
161
194
  '--bundle-output',
162
195
  _nodepath.default.join(outputFolder, bundleName),
163
- '--dev',
164
- development,
165
- '--entry-file',
166
- entryFile,
167
196
  '--platform',
168
197
  platform,
169
198
  '--reset-cache'
170
199
  ]);
200
+ if (cli.taro) {
201
+ reactNativeBundleArgs.push(...[
202
+ '--type',
203
+ 'rn'
204
+ ]);
205
+ } else {
206
+ reactNativeBundleArgs.push(...[
207
+ '--dev',
208
+ dev,
209
+ '--entry-file',
210
+ entryFile
211
+ ]);
212
+ }
171
213
  if (sourcemapOutput) {
172
214
  reactNativeBundleArgs.push('--sourcemap-output', sourcemapOutput);
173
215
  }
@@ -196,7 +238,7 @@ async function runReactNativeBundleCommand(bundleName, development, entryFile, o
196
238
  }, (error, props)=>{
197
239
  if (error) {
198
240
  console.error(error);
199
- resolve(null);
241
+ resolve({});
200
242
  }
201
243
  resolve(props);
202
244
  });
@@ -378,6 +420,14 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
378
420
  });
379
421
  }
380
422
  }
423
+ const ignorePackingFileNames = [
424
+ '.',
425
+ '..',
426
+ 'index.bundlejs.map'
427
+ ];
428
+ const ignorePackingExtensions = [
429
+ 'DS_Store'
430
+ ];
381
431
  async function pack(dir, output) {
382
432
  console.log('Packing');
383
433
  _fsextra.ensureDirSync(_nodepath.default.dirname(output));
@@ -389,7 +439,7 @@ async function pack(dir, output) {
389
439
  }
390
440
  const childs = _fsextra.readdirSync(root);
391
441
  for (const name of childs){
392
- if (name === '.' || name === '..' || name === 'index.bundlejs.map' || name === 'index.bundlejs.txt.map') {
442
+ if (ignorePackingFileNames.includes(name) || ignorePackingExtensions.some((ext)=>name.endsWith(`.${ext}`))) {
393
443
  continue;
394
444
  }
395
445
  const fullPath = _nodepath.default.join(root, name);
@@ -701,7 +751,7 @@ function diffArgsCheck(args, options, diffFn) {
701
751
  const commands = {
702
752
  bundle: async function({ options }) {
703
753
  const platform = (0, _app.checkPlatform)(options.platform || await (0, _utils.question)('平台(ios/android/harmony):'));
704
- const { bundleName, entryFile, intermediaDir, output, dev, sourcemap } = (0, _utils.translateOptions)({
754
+ const { bundleName, entryFile, intermediaDir, output, dev, sourcemap, taro, expo, rncli } = (0, _utils.translateOptions)({
705
755
  ...options,
706
756
  platform
707
757
  });
@@ -715,7 +765,19 @@ const commands = {
715
765
  }
716
766
  const { version, major, minor } = (0, _utils.getRNVersion)();
717
767
  console.log(`Bundling with react-native: ${version}`);
718
- await runReactNativeBundleCommand(bundleName, dev, entryFile, intermediaDir, platform, sourcemap || sourcemapPlugin ? sourcemapOutput : '');
768
+ await runReactNativeBundleCommand({
769
+ bundleName,
770
+ dev,
771
+ entryFile,
772
+ outputFolder: intermediaDir,
773
+ platform,
774
+ sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '',
775
+ cli: {
776
+ taro,
777
+ expo,
778
+ rncli
779
+ }
780
+ });
719
781
  await pack(_nodepath.default.resolve(intermediaDir), realOutput);
720
782
  const v = await (0, _utils.question)('是否现在上传此热更包?(Y/N)');
721
783
  if (v.toLowerCase() === 'y') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "1.39.1",
3
+ "version": "1.40.0-beta.0",
4
4
  "description": "Command tools for javaScript updater with `pushy` service for react native apps.",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/.DS_Store ADDED
Binary file
@@ -22,16 +22,33 @@ try {
22
22
  hdiff = require('node-hdiffpatch').diff;
23
23
  } catch (e) {}
24
24
 
25
- async function runReactNativeBundleCommand(
25
+ async function runReactNativeBundleCommand({
26
26
  bundleName,
27
- development,
27
+ dev,
28
28
  entryFile,
29
29
  outputFolder,
30
30
  platform,
31
31
  sourcemapOutput,
32
32
  config,
33
- ) {
34
- let gradleConfig = {};
33
+ cli,
34
+ }: {
35
+ bundleName: string;
36
+ dev: string;
37
+ entryFile: string;
38
+ outputFolder: string;
39
+ platform: string;
40
+ sourcemapOutput: string;
41
+ config?: string;
42
+ cli: {
43
+ taro?: boolean;
44
+ expo?: boolean;
45
+ rncli?: boolean;
46
+ };
47
+ }) {
48
+ let gradleConfig: {
49
+ crunchPngs?: boolean;
50
+ enableHermes?: boolean;
51
+ } = {};
35
52
  if (platform === 'android') {
36
53
  gradleConfig = await checkGradleConfig();
37
54
  if (gradleConfig.crunchPngs !== false) {
@@ -41,7 +58,7 @@ async function runReactNativeBundleCommand(
41
58
  }
42
59
  }
43
60
 
44
- const reactNativeBundleArgs = [];
61
+ const reactNativeBundleArgs: string[] = [];
45
62
 
46
63
  const envArgs = process.env.PUSHY_ENV_ARGS;
47
64
 
@@ -54,26 +71,31 @@ async function runReactNativeBundleCommand(
54
71
 
55
72
  fs.emptyDirSync(outputFolder);
56
73
 
57
- let cliPath;
58
-
74
+ let cliPath: string | undefined;
59
75
  let usingExpo = false;
60
- try {
61
- cliPath = require.resolve('@expo/cli', {
62
- paths: [process.cwd()],
63
- });
64
- const expoCliVersion = JSON.parse(
65
- fs.readFileSync(
66
- require.resolve('@expo/cli/package.json', {
67
- paths: [process.cwd()],
68
- }),
69
- ),
70
- ).version;
71
- // expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
72
- if (semverSatisfies(expoCliVersion, '>= 0.10.17')) {
73
- usingExpo = true;
74
- }
75
- } catch (e) {}
76
- if (!usingExpo) {
76
+
77
+ const getExpoCli = () => {
78
+ try {
79
+ cliPath = require.resolve('@expo/cli', {
80
+ paths: [process.cwd()],
81
+ });
82
+ const expoCliVersion = JSON.parse(
83
+ fs.readFileSync(
84
+ require.resolve('@expo/cli/package.json', {
85
+ paths: [process.cwd()],
86
+ }),
87
+ ),
88
+ ).version;
89
+ // expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
90
+ if (semverSatisfies(expoCliVersion, '>= 0.10.17')) {
91
+ usingExpo = true;
92
+ } else {
93
+ cliPath = undefined;
94
+ }
95
+ } catch (e) {}
96
+ };
97
+
98
+ const getRnCli = () => {
77
99
  try {
78
100
  // rn >= 0.75
79
101
  cliPath = require.resolve('@react-native-community/cli/build/bin.js', {
@@ -85,20 +107,49 @@ async function runReactNativeBundleCommand(
85
107
  paths: [process.cwd()],
86
108
  });
87
109
  }
110
+ };
111
+
112
+ const getTaroCli = () => {
113
+ try {
114
+ cliPath = require.resolve('@tarojs/cli/bin/taro.js', {
115
+ paths: [process.cwd()],
116
+ });
117
+ } catch (e) {}
118
+ };
119
+
120
+ if (cli.expo) {
121
+ getExpoCli();
122
+ } else if (cli.taro) {
123
+ getTaroCli();
124
+ } else if (cli.rncli) {
125
+ getRnCli();
126
+ }
127
+
128
+ if (!cliPath) {
129
+ getExpoCli();
130
+ if (!usingExpo) {
131
+ getRnCli();
132
+ }
88
133
  }
134
+
89
135
  const bundleParams = await checkPlugins();
90
136
  const isSentry = bundleParams.sentry;
91
- const bundleCommand = usingExpo
92
- ? 'export:embed'
93
- : platform === 'harmony'
94
- ? 'bundle-harmony'
95
- : 'bundle';
137
+
138
+ let bundleCommand = 'bundle';
139
+ if (usingExpo) {
140
+ bundleCommand = 'export:embed';
141
+ } else if (platform === 'harmony') {
142
+ bundleCommand = 'bundle-harmony';
143
+ } else if (cli.taro) {
144
+ bundleCommand = 'build';
145
+ }
146
+
96
147
  if (platform === 'harmony') {
97
148
  Array.prototype.push.apply(reactNativeBundleArgs, [
98
149
  cliPath,
99
150
  bundleCommand,
100
151
  '--dev',
101
- development,
152
+ dev,
102
153
  '--entry-file',
103
154
  entryFile,
104
155
  ]);
@@ -118,14 +169,24 @@ async function runReactNativeBundleCommand(
118
169
  outputFolder,
119
170
  '--bundle-output',
120
171
  path.join(outputFolder, bundleName),
121
- '--dev',
122
- development,
123
- '--entry-file',
124
- entryFile,
125
172
  '--platform',
126
173
  platform,
127
174
  '--reset-cache',
128
175
  ]);
176
+
177
+ if (cli.taro) {
178
+ reactNativeBundleArgs.push(...[
179
+ '--type',
180
+ 'rn',
181
+ ])
182
+ } else {
183
+ reactNativeBundleArgs.push(...[
184
+ '--dev',
185
+ dev,
186
+ '--entry-file',
187
+ entryFile,
188
+ ])
189
+ }
129
190
 
130
191
  if (sourcemapOutput) {
131
192
  reactNativeBundleArgs.push('--sourcemap-output', sourcemapOutput);
@@ -158,17 +219,19 @@ async function runReactNativeBundleCommand(
158
219
  ),
159
220
  );
160
221
  } else {
161
- let hermesEnabled = false;
222
+ let hermesEnabled: boolean | undefined = false;
162
223
 
163
224
  if (platform === 'android') {
164
- const gradlePropeties = await new Promise((resolve) => {
225
+ const gradlePropeties = await new Promise<{
226
+ hermesEnabled?: boolean;
227
+ }>((resolve) => {
165
228
  properties.parse(
166
229
  './android/gradle.properties',
167
230
  { path: true },
168
- (error, props) => {
231
+ (error: any, props: { hermesEnabled?: boolean }) => {
169
232
  if (error) {
170
233
  console.error(error);
171
- resolve(null);
234
+ resolve({});
172
235
  }
173
236
 
174
237
  resolve(props);
@@ -201,7 +264,7 @@ async function runReactNativeBundleCommand(
201
264
  });
202
265
  }
203
266
 
204
- async function copyHarmonyBundle(outputFolder) {
267
+ async function copyHarmonyBundle(outputFolder: string) {
205
268
  const harmonyRawPath = 'harmony/entry/src/main/resources/rawfile';
206
269
  try {
207
270
  await fs.ensureDir(harmonyRawPath);
@@ -215,7 +278,7 @@ async function copyHarmonyBundle(outputFolder) {
215
278
 
216
279
  await fs.ensureDir(outputFolder);
217
280
  await fs.copy(harmonyRawPath, outputFolder);
218
- } catch (error) {
281
+ } catch (error: any) {
219
282
  console.error('copyHarmonyBundle 错误:', error);
220
283
  throw new Error(`复制文件失败: ${error.message}`);
221
284
  }
@@ -253,10 +316,10 @@ async function checkGradleConfig() {
253
316
  }
254
317
 
255
318
  async function compileHermesByteCode(
256
- bundleName,
257
- outputFolder,
258
- sourcemapOutput,
259
- shouldCleanSourcemap,
319
+ bundleName: string,
320
+ outputFolder: string,
321
+ sourcemapOutput: string,
322
+ shouldCleanSourcemap: boolean,
260
323
  ) {
261
324
  console.log('Hermes enabled, now compiling to hermes bytecode:\n');
262
325
  // >= rn 0.69
@@ -318,7 +381,11 @@ async function compileHermesByteCode(
318
381
  }
319
382
  }
320
383
 
321
- async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
384
+ async function copyDebugidForSentry(
385
+ bundleName: string,
386
+ outputFolder: string,
387
+ sourcemapOutput: string,
388
+ ) {
322
389
  if (sourcemapOutput) {
323
390
  let copyDebugidPath;
324
391
  try {
@@ -355,10 +422,10 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
355
422
  }
356
423
 
357
424
  async function uploadSourcemapForSentry(
358
- bundleName,
359
- outputFolder,
360
- sourcemapOutput,
361
- version,
425
+ bundleName: string,
426
+ outputFolder: string,
427
+ sourcemapOutput: string,
428
+ version: string,
362
429
  ) {
363
430
  if (sourcemapOutput) {
364
431
  let sentryCliPath;
@@ -405,19 +472,24 @@ async function uploadSourcemapForSentry(
405
472
  }
406
473
  }
407
474
 
408
- async function pack(dir, output) {
475
+ const ignorePackingFileNames = ['.', '..', 'index.bundlejs.map'];
476
+ const ignorePackingExtensions = ['DS_Store'];
477
+ async function pack(dir: string, output: string) {
409
478
  console.log('Packing');
410
479
  fs.ensureDirSync(path.dirname(output));
411
- await new Promise((resolve, reject) => {
480
+ await new Promise<void>((resolve, reject) => {
412
481
  const zipfile = new ZipFile();
413
482
 
414
- function addDirectory(root, rel) {
483
+ function addDirectory(root: string, rel: string) {
415
484
  if (rel) {
416
485
  zipfile.addEmptyDirectory(rel);
417
486
  }
418
487
  const childs = fs.readdirSync(root);
419
488
  for (const name of childs) {
420
- if (name === '.' || name === '..' || name === 'index.bundlejs.map' || name === 'index.bundlejs.txt.map') {
489
+ if (
490
+ ignorePackingFileNames.includes(name) ||
491
+ ignorePackingExtensions.some((ext) => name.endsWith(`.${ext}`))
492
+ ) {
421
493
  continue;
422
494
  }
423
495
  const fullPath = path.join(root, name);
@@ -434,7 +506,7 @@ async function pack(dir, output) {
434
506
 
435
507
  addDirectory(dir, '');
436
508
 
437
- zipfile.outputStream.on('error', (err) => reject(err));
509
+ zipfile.outputStream.on('error', (err: any) => reject(err));
438
510
  zipfile.outputStream.pipe(fs.createWriteStream(output)).on('close', () => {
439
511
  resolve();
440
512
  });
@@ -443,12 +515,12 @@ async function pack(dir, output) {
443
515
  console.log(`ppk热更包已生成并保存到: ${output}`);
444
516
  }
445
517
 
446
- export function readEntire(entry, zipFile) {
447
- const buffers = [];
518
+ export function readEntire(entry: string, zipFile: ZipFile) {
519
+ const buffers: Buffer[] = [];
448
520
  return new Promise((resolve, reject) => {
449
- zipFile.openReadStream(entry, (err, stream) => {
521
+ zipFile.openReadStream(entry, (err: any, stream: any) => {
450
522
  stream.pipe({
451
- write(chunk) {
523
+ write(chunk: Buffer) {
452
524
  buffers.push(chunk);
453
525
  },
454
526
  end() {
@@ -463,12 +535,12 @@ export function readEntire(entry, zipFile) {
463
535
  });
464
536
  }
465
537
 
466
- function basename(fn) {
538
+ function basename(fn: string) {
467
539
  const m = /^(.+\/)[^\/]+\/?$/.exec(fn);
468
540
  return m?.[1];
469
541
  }
470
542
 
471
- async function diffFromPPK(origin, next, output) {
543
+ async function diffFromPPK(origin: string, next: string, output: string) {
472
544
  fs.ensureDirSync(path.dirname(output));
473
545
 
474
546
  const originEntries = {};
@@ -513,7 +585,7 @@ async function diffFromPPK(origin, next, output) {
513
585
 
514
586
  const addedEntry = {};
515
587
 
516
- function addEntry(fn) {
588
+ function addEntry(fn: string) {
517
589
  //console.log(fn);
518
590
  if (!fn || addedEntry[fn]) {
519
591
  return;
@@ -610,11 +682,11 @@ async function diffFromPPK(origin, next, output) {
610
682
  }
611
683
 
612
684
  async function diffFromPackage(
613
- origin,
614
- next,
615
- output,
616
- originBundleName,
617
- transformPackagePath = (v) => v,
685
+ origin: string,
686
+ next: string,
687
+ output: string,
688
+ originBundleName: string,
689
+ transformPackagePath = (v: string) => v,
618
690
  ) {
619
691
  fs.ensureDirSync(path.dirname(output));
620
692
 
@@ -623,7 +695,7 @@ async function diffFromPackage(
623
695
 
624
696
  let originSource;
625
697
 
626
- await enumZipEntries(origin, (entry, zipFile) => {
698
+ await enumZipEntries(origin, (entry: any, zipFile: any) => {
627
699
  if (!/\/$/.test(entry.fileName)) {
628
700
  const fn = transformPackagePath(entry.fileName);
629
701
  if (!fn) {
@@ -717,55 +789,66 @@ async function diffFromPackage(
717
789
  await writePromise;
718
790
  }
719
791
 
720
- export async function enumZipEntries(zipFn, callback, nestedPath = '') {
792
+ export async function enumZipEntries(
793
+ zipFn: string,
794
+ callback: (entry: any, zipFile: any) => void,
795
+ nestedPath = '',
796
+ ) {
721
797
  return new Promise((resolve, reject) => {
722
- openZipFile(zipFn, { lazyEntries: true }, async (err, zipfile) => {
723
- if (err) {
724
- return reject(err);
725
- }
798
+ openZipFile(
799
+ zipFn,
800
+ { lazyEntries: true },
801
+ async (err: any, zipfile: ZipFile) => {
802
+ if (err) {
803
+ return reject(err);
804
+ }
726
805
 
727
- zipfile.on('end', resolve);
728
- zipfile.on('error', reject);
729
- zipfile.on('entry', async (entry) => {
730
- const fullPath = nestedPath + entry.fileName;
731
-
732
- try {
733
- if (
734
- !entry.fileName.endsWith('/') &&
735
- entry.fileName.toLowerCase().endsWith('.hap')
736
- ) {
737
- const tempDir = path.join(os.tmpdir(), `nested_zip_${Date.now()}`);
738
- await fs.ensureDir(tempDir);
739
- const tempZipPath = path.join(tempDir, 'temp.zip');
740
-
741
- await new Promise((res, rej) => {
742
- zipfile.openReadStream(entry, async (err, readStream) => {
743
- if (err) return rej(err);
744
- const writeStream = fs.createWriteStream(tempZipPath);
745
- readStream.pipe(writeStream);
746
- writeStream.on('finish', res);
747
- writeStream.on('error', rej);
806
+ zipfile.on('end', resolve);
807
+ zipfile.on('error', reject);
808
+ zipfile.on('entry', async (entry) => {
809
+ const fullPath = nestedPath + entry.fileName;
810
+
811
+ try {
812
+ if (
813
+ !entry.fileName.endsWith('/') &&
814
+ entry.fileName.toLowerCase().endsWith('.hap')
815
+ ) {
816
+ const tempDir = path.join(
817
+ os.tmpdir(),
818
+ `nested_zip_${Date.now()}`,
819
+ );
820
+ await fs.ensureDir(tempDir);
821
+ const tempZipPath = path.join(tempDir, 'temp.zip');
822
+
823
+ await new Promise((res, rej) => {
824
+ zipfile.openReadStream(entry, async (err, readStream) => {
825
+ if (err) return rej(err);
826
+ const writeStream = fs.createWriteStream(tempZipPath);
827
+ readStream.pipe(writeStream);
828
+ writeStream.on('finish', res);
829
+ writeStream.on('error', rej);
830
+ });
748
831
  });
749
- });
750
832
 
751
- await enumZipEntries(tempZipPath, callback, `${fullPath}/`);
833
+ await enumZipEntries(tempZipPath, callback, `${fullPath}/`);
752
834
 
753
- await fs.remove(tempDir);
754
- }
835
+ await fs.remove(tempDir);
836
+ }
755
837
 
756
- const result = callback(entry, zipfile, fullPath);
757
- if (result && typeof result.then === 'function') {
758
- await result;
838
+ const result = callback(entry, zipfile, fullPath);
839
+ if (result && typeof result.then === 'function') {
840
+ await result;
841
+ }
842
+ } catch (error) {
843
+ console.error('处理文件时出错:', error);
759
844
  }
760
- } catch (error) {
761
- console.error('处理文件时出错:', error);
762
- }
763
845
 
764
- zipfile.readEntry();
765
- });
846
+ zipfile.readEntry();
847
+ });
766
848
 
767
- zipfile.readEntry();
768
- });
849
+ zipfile.readEntry();
850
+ },
851
+ );
769
852
  });
770
853
  }
771
854
 
@@ -811,11 +894,20 @@ export const commands = {
811
894
  options.platform || (await question('平台(ios/android/harmony):')),
812
895
  );
813
896
 
814
- const { bundleName, entryFile, intermediaDir, output, dev, sourcemap } =
815
- translateOptions({
816
- ...options,
817
- platform,
818
- });
897
+ const {
898
+ bundleName,
899
+ entryFile,
900
+ intermediaDir,
901
+ output,
902
+ dev,
903
+ sourcemap,
904
+ taro,
905
+ expo,
906
+ rncli,
907
+ } = translateOptions({
908
+ ...options,
909
+ platform,
910
+ });
819
911
 
820
912
  const bundleParams = await checkPlugins();
821
913
  const sourcemapPlugin = bundleParams.sourcemap;
@@ -833,20 +925,25 @@ export const commands = {
833
925
 
834
926
  console.log(`Bundling with react-native: ${version}`);
835
927
 
836
- await runReactNativeBundleCommand(
928
+ await runReactNativeBundleCommand({
837
929
  bundleName,
838
930
  dev,
839
931
  entryFile,
840
- intermediaDir,
932
+ outputFolder: intermediaDir,
841
933
  platform,
842
- sourcemap || sourcemapPlugin ? sourcemapOutput : '',
843
- );
934
+ sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '',
935
+ cli: {
936
+ taro,
937
+ expo,
938
+ rncli,
939
+ },
940
+ });
844
941
 
845
942
  await pack(path.resolve(intermediaDir), realOutput);
846
943
 
847
944
  const v = await question('是否现在上传此热更包?(Y/N)');
848
945
  if (v.toLowerCase() === 'y') {
849
- const versionName = await this.publish({
946
+ const versionName = await this.publish({
850
947
  args: [realOutput],
851
948
  options: {
852
949
  platform,
Binary file