react-native-update-cli 2.8.5 → 2.9.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.
Files changed (106) hide show
  1. package/lib/api.d.ts +18 -0
  2. package/lib/app.d.ts +38 -0
  3. package/lib/app.js +5 -4
  4. package/lib/bundle-pack.d.ts +1 -0
  5. package/lib/bundle-pack.js +104 -0
  6. package/lib/bundle-runner.d.ts +20 -0
  7. package/lib/bundle-runner.js +404 -0
  8. package/lib/bundle.d.ts +6 -0
  9. package/lib/bundle.js +73 -471
  10. package/lib/diff.d.ts +13 -0
  11. package/lib/diff.js +144 -123
  12. package/lib/exports.d.ts +12 -0
  13. package/lib/index.d.ts +5 -0
  14. package/lib/index.js +5 -13
  15. package/lib/install.d.ts +4 -0
  16. package/lib/locales/en.d.ts +137 -0
  17. package/lib/locales/zh.d.ts +136 -0
  18. package/lib/module-manager.d.ts +20 -0
  19. package/lib/module-manager.js +3 -9
  20. package/lib/modules/app-module.d.ts +2 -0
  21. package/lib/modules/app-module.js +84 -44
  22. package/lib/modules/bundle-module.d.ts +2 -0
  23. package/lib/modules/bundle-module.js +7 -8
  24. package/lib/modules/index.d.ts +6 -0
  25. package/lib/modules/package-module.d.ts +2 -0
  26. package/lib/modules/user-module.d.ts +2 -0
  27. package/lib/modules/user-module.js +55 -44
  28. package/lib/modules/version-module.d.ts +2 -0
  29. package/lib/package.d.ts +58 -0
  30. package/lib/package.js +103 -139
  31. package/lib/provider.d.ts +26 -0
  32. package/lib/provider.js +115 -217
  33. package/lib/types.d.ts +120 -0
  34. package/lib/user.d.ts +8 -0
  35. package/lib/utils/add-gitignore.d.ts +1 -0
  36. package/lib/utils/app-info-parser/aab.d.ts +22 -0
  37. package/lib/utils/app-info-parser/aab.js +0 -4
  38. package/lib/utils/app-info-parser/apk.d.ts +14 -0
  39. package/lib/utils/app-info-parser/apk.js +6 -4
  40. package/lib/utils/app-info-parser/app.d.ts +4 -0
  41. package/lib/utils/app-info-parser/app.js +3 -0
  42. package/lib/utils/app-info-parser/index.d.ts +16 -0
  43. package/lib/utils/app-info-parser/index.js +2 -0
  44. package/lib/utils/app-info-parser/ipa.d.ts +14 -0
  45. package/lib/utils/app-info-parser/ipa.js +1 -1
  46. package/lib/utils/app-info-parser/resource-finder.d.ts +49 -0
  47. package/lib/utils/app-info-parser/utils.d.ts +31 -0
  48. package/lib/utils/app-info-parser/utils.js +1 -0
  49. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +56 -0
  50. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +10 -0
  51. package/lib/utils/app-info-parser/zip.d.ts +18 -0
  52. package/lib/utils/app-info-parser/zip.js +7 -9
  53. package/lib/utils/check-lockfile.d.ts +1 -0
  54. package/lib/utils/check-plugin.d.ts +7 -0
  55. package/lib/utils/command-result.d.ts +3 -0
  56. package/lib/utils/command-result.js +35 -0
  57. package/lib/utils/constants.d.ts +9 -0
  58. package/lib/utils/dep-versions.d.ts +1 -0
  59. package/lib/utils/git.d.ts +8 -0
  60. package/lib/utils/http-helper.d.ts +4 -0
  61. package/lib/utils/i18n.d.ts +12 -0
  62. package/lib/utils/index.d.ts +22 -0
  63. package/lib/utils/index.js +52 -22
  64. package/lib/utils/latest-version/cli.d.ts +1 -0
  65. package/lib/utils/latest-version/cli.js +24 -60
  66. package/lib/utils/latest-version/index.d.ts +146 -0
  67. package/lib/utils/latest-version/index.js +22 -22
  68. package/lib/utils/options.d.ts +4 -0
  69. package/lib/utils/options.js +63 -0
  70. package/lib/utils/plugin-config.d.ts +9 -0
  71. package/lib/utils/zip-entries.d.ts +3 -0
  72. package/lib/versions.d.ts +43 -0
  73. package/lib/workflow-runner.d.ts +2 -0
  74. package/lib/workflow-runner.js +25 -0
  75. package/package.json +20 -5
  76. package/src/api.ts +1 -1
  77. package/src/app.ts +20 -11
  78. package/src/bundle-pack.ts +51 -0
  79. package/src/bundle-runner.ts +463 -0
  80. package/src/bundle.ts +184 -571
  81. package/src/diff.ts +208 -174
  82. package/src/index.ts +15 -17
  83. package/src/module-manager.ts +15 -15
  84. package/src/modules/app-module.ts +120 -48
  85. package/src/modules/bundle-module.ts +21 -11
  86. package/src/modules/package-module.ts +0 -1
  87. package/src/modules/user-module.ts +117 -58
  88. package/src/package.ts +158 -138
  89. package/src/provider.ts +164 -240
  90. package/src/types.ts +13 -8
  91. package/src/utils/app-info-parser/aab.ts +0 -7
  92. package/src/utils/app-info-parser/apk.ts +9 -6
  93. package/src/utils/app-info-parser/app.ts +5 -1
  94. package/src/utils/app-info-parser/index.ts +11 -6
  95. package/src/utils/app-info-parser/ipa.ts +1 -1
  96. package/src/utils/app-info-parser/utils.ts +3 -0
  97. package/src/utils/app-info-parser/xml-parser/manifest.ts +3 -1
  98. package/src/utils/app-info-parser/zip.ts +12 -14
  99. package/src/utils/command-result.ts +24 -0
  100. package/src/utils/index.ts +138 -39
  101. package/src/utils/latest-version/cli.ts +22 -20
  102. package/src/utils/latest-version/index.ts +20 -20
  103. package/src/utils/options.ts +56 -0
  104. package/src/utils/zip-entries.ts +1 -1
  105. package/src/workflow-runner.ts +24 -0
  106. package/index.js +0 -1
package/lib/bundle.js CHANGED
@@ -8,518 +8,120 @@ Object.defineProperty(exports, "bundleCommands", {
8
8
  return bundleCommands;
9
9
  }
10
10
  });
11
- const _child_process = require("child_process");
12
11
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
- const _compareversions = require("compare-versions");
14
- const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
15
- const _yazl = require("yazl");
16
12
  const _app = require("./app");
13
+ const _bundlepack = require("./bundle-pack");
14
+ const _bundlerunner = require("./bundle-runner");
17
15
  const _utils = require("./utils");
18
16
  const _addgitignore = require("./utils/add-gitignore");
19
17
  const _checklockfile = require("./utils/check-lockfile");
20
18
  const _constants = require("./utils/constants");
21
19
  const _depversions = require("./utils/dep-versions");
22
20
  const _i18n = require("./utils/i18n");
21
+ const _options = require("./utils/options");
23
22
  const _versions = require("./versions");
24
- const _os = /*#__PURE__*/ _interop_require_default(require("os"));
25
23
  function _interop_require_default(obj) {
26
24
  return obj && obj.__esModule ? obj : {
27
25
  default: obj
28
26
  };
29
27
  }
30
- function _getRequireWildcardCache(nodeInterop) {
31
- if (typeof WeakMap !== "function") return null;
32
- var cacheBabelInterop = new WeakMap();
33
- var cacheNodeInterop = new WeakMap();
34
- return (_getRequireWildcardCache = function(nodeInterop) {
35
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
36
- })(nodeInterop);
37
- }
38
- function _interop_require_wildcard(obj, nodeInterop) {
39
- if (!nodeInterop && obj && obj.__esModule) {
40
- return obj;
41
- }
42
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
43
- return {
44
- default: obj
45
- };
46
- }
47
- var cache = _getRequireWildcardCache(nodeInterop);
48
- if (cache && cache.has(obj)) {
49
- return cache.get(obj);
50
- }
51
- var newObj = {
52
- __proto__: null
53
- };
54
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
55
- for(var key in obj){
56
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
57
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
58
- if (desc && (desc.get || desc.set)) {
59
- Object.defineProperty(newObj, key, desc);
60
- } else {
61
- newObj[key] = obj[key];
62
- }
63
- }
64
- }
65
- newObj.default = obj;
66
- if (cache) {
67
- cache.set(obj, newObj);
68
- }
69
- return newObj;
70
- }
71
- const g2js = require('gradle-to-js/lib/parser');
72
- const properties = require('properties');
73
- async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli }) {
74
- let gradleConfig = {};
75
- if (platform === 'android') {
76
- gradleConfig = await checkGradleConfig();
77
- if (gradleConfig.crunchPngs !== false) {
78
- console.warn((0, _i18n.t)('androidCrunchPngsWarning'));
79
- }
80
- }
81
- const reactNativeBundleArgs = [];
82
- const envArgs = process.env.PUSHY_ENV_ARGS;
83
- if (envArgs) {
84
- reactNativeBundleArgs.push(...envArgs.trim().split(/\s+/));
85
- }
86
- _fsextra.emptyDirSync(outputFolder);
87
- let cliPath = '';
88
- let usingExpo = false;
89
- const getExpoCli = ()=>{
90
- try {
91
- const searchPaths = [
92
- process.cwd()
93
- ];
94
- // 尝试添加 expo 包的路径作为额外的搜索路径
95
- try {
96
- const expoPath = require.resolve('expo/package.json', {
97
- paths: [
98
- process.cwd()
99
- ]
100
- });
101
- // 获取 expo 包的目录路径
102
- const expoDir = expoPath.replace(/\/package\.json$/, '');
103
- searchPaths.push(expoDir);
104
- } catch (e) {
105
- // expo 包不存在,忽略
106
- }
107
- // 尝试从搜索路径中解析 @expo/cli
108
- cliPath = require.resolve('@expo/cli', {
109
- paths: searchPaths
110
- });
111
- const expoCliVersion = JSON.parse(_fsextra.readFileSync(require.resolve('@expo/cli/package.json', {
112
- paths: searchPaths
113
- })).toString()).version;
114
- // expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
115
- if ((0, _compareversions.satisfies)(expoCliVersion, '>= 0.10.17')) {
116
- usingExpo = true;
117
- } else {
118
- cliPath = '';
119
- }
120
- } catch (e) {}
121
- };
122
- const getRnCli = ()=>{
123
- try {
124
- // rn < 0.75
125
- cliPath = require.resolve('react-native/local-cli/cli.js', {
126
- paths: [
127
- process.cwd()
128
- ]
129
- });
130
- } catch (e) {
131
- // rn >= 0.75
132
- cliPath = require.resolve('@react-native-community/cli/build/bin.js', {
133
- paths: [
134
- process.cwd()
135
- ]
136
- });
137
- }
138
- };
139
- const getTaroCli = ()=>{
140
- try {
141
- cliPath = require.resolve('@tarojs/cli/bin/taro', {
142
- paths: [
143
- process.cwd()
144
- ]
145
- });
146
- } catch (e) {}
147
- };
148
- if (cli.expo) {
149
- getExpoCli();
150
- } else if (cli.taro) {
151
- getTaroCli();
152
- } else if (cli.rncli) {
153
- getRnCli();
154
- }
155
- if (!cliPath) {
156
- getExpoCli();
157
- if (!usingExpo) {
158
- getRnCli();
159
- }
160
- }
161
- const bundleParams = await (0, _utils.checkPlugins)();
162
- const isSentry = bundleParams.sentry;
163
- if (isSentry) {
164
- if (platform === 'ios') {
165
- process.env.SENTRY_PROPERTIES = 'ios/sentry.properties';
166
- } else if (platform === 'android') {
167
- process.env.SENTRY_PROPERTIES = 'android/sentry.properties';
168
- }
169
- }
170
- let bundleCommand = 'bundle';
171
- if (usingExpo) {
172
- bundleCommand = 'export:embed';
173
- } else if (platform === 'harmony') {
174
- bundleCommand = 'bundle-harmony';
175
- } else if (cli.taro) {
176
- bundleCommand = 'build';
177
- }
178
- if (platform === 'harmony') {
179
- bundleName = 'bundle.harmony.js';
180
- if (forceHermes === undefined) {
181
- // enable hermes by default for harmony
182
- forceHermes = true;
183
- }
184
- }
185
- reactNativeBundleArgs.push(cliPath, bundleCommand, '--assets-dest', outputFolder, '--bundle-output', _path.default.join(outputFolder, bundleName));
186
- if (platform !== 'harmony') {
187
- reactNativeBundleArgs.push('--platform', platform, '--reset-cache');
188
- }
189
- if (cli.taro) {
190
- reactNativeBundleArgs.push('--type', 'rn');
191
- } else {
192
- reactNativeBundleArgs.push('--dev', dev, '--entry-file', entryFile);
193
- }
194
- if (sourcemapOutput) {
195
- reactNativeBundleArgs.push('--sourcemap-output', sourcemapOutput);
196
- }
197
- if (config) {
198
- reactNativeBundleArgs.push('--config', config);
199
- }
200
- const reactNativeBundleProcess = (0, _child_process.spawn)('node', reactNativeBundleArgs);
201
- console.log(`Running bundle command: node ${reactNativeBundleArgs.join(' ')}`);
202
- return new Promise((resolve, reject)=>{
203
- reactNativeBundleProcess.stdout.on('data', (data)=>{
204
- console.log(data.toString().trim());
205
- });
206
- reactNativeBundleProcess.stderr.on('data', (data)=>{
207
- console.error(data.toString().trim());
208
- });
209
- reactNativeBundleProcess.on('close', async (exitCode)=>{
210
- if (exitCode) {
211
- reject(new Error((0, _i18n.t)('bundleCommandError', {
212
- code: exitCode
213
- })));
214
- } else {
215
- let hermesEnabled = false;
216
- if (forceHermes) {
217
- hermesEnabled = true;
218
- console.log((0, _i18n.t)('forceHermes'));
219
- } else if (platform === 'android') {
220
- const gradlePropeties = await new Promise((resolve)=>{
221
- properties.parse('./android/gradle.properties', {
222
- path: true
223
- }, (error, props)=>{
224
- if (error) {
225
- console.error(error);
226
- resolve({});
227
- }
228
- resolve(props);
229
- });
230
- });
231
- hermesEnabled = gradlePropeties.hermesEnabled;
232
- if (typeof hermesEnabled !== 'boolean') hermesEnabled = gradleConfig.enableHermes;
233
- } else if (platform === 'ios' && _fsextra.existsSync('ios/Pods/hermes-engine')) {
234
- hermesEnabled = true;
235
- }
236
- if (hermesEnabled) {
237
- await compileHermesByteCode(bundleName, outputFolder, sourcemapOutput, !isSentry);
238
- }
239
- if (platform === 'harmony') {
240
- const harmonyRawAssetsPath = 'harmony/entry/src/main/resources/rawfile/assets';
241
- // copy all files in outputFolder to harmonyRawPath
242
- // assets should be in rawfile/assets
243
- _fsextra.ensureDirSync(harmonyRawAssetsPath);
244
- _fsextra.copySync(outputFolder, harmonyRawAssetsPath, {
245
- overwrite: true
246
- });
247
- _fsextra.moveSync(`${harmonyRawAssetsPath}/bundle.harmony.js`, `${harmonyRawAssetsPath}/../bundle.harmony.js`, {
248
- overwrite: true
249
- });
250
- }
251
- resolve(null);
252
- }
253
- });
254
- });
255
- }
256
- function getHermesOSBin() {
257
- if (_os.default.platform() === 'win32') return 'win64-bin';
258
- if (_os.default.platform() === 'darwin') return 'osx-bin';
259
- if (_os.default.platform() === 'linux') return 'linux64-bin';
260
- }
261
- async function checkGradleConfig() {
262
- let enableHermes = false;
263
- let crunchPngs;
264
- try {
265
- const gradleConfig = await g2js.parseFile('android/app/build.gradle');
266
- crunchPngs = gradleConfig.android.buildTypes.release.crunchPngs;
267
- const projectConfig = gradleConfig['project.ext.react'];
268
- if (projectConfig) {
269
- for (const packagerConfig of projectConfig){
270
- if (packagerConfig.includes('enableHermes') && packagerConfig.includes('true')) {
271
- enableHermes = true;
272
- break;
273
- }
274
- }
275
- }
276
- } catch (e) {}
28
+ function normalizeBundleOptions(translatedOptions, platform) {
277
29
  return {
278
- enableHermes,
279
- crunchPngs
30
+ bundleName: (0, _options.getStringOption)(translatedOptions, 'bundleName', 'index.bundlejs'),
31
+ entryFile: (0, _options.getStringOption)(translatedOptions, 'entryFile', 'index.js'),
32
+ intermediaDir: (0, _options.getStringOption)(translatedOptions, 'intermediaDir', `${_constants.tempDir}/intermedia/${platform}`),
33
+ output: (0, _options.getStringOption)(translatedOptions, 'output', `${_constants.tempDir}/output/${platform}.\${time}.ppk`),
34
+ dev: (0, _options.getBooleanOption)(translatedOptions, 'dev', false) ? 'true' : 'false',
35
+ sourcemap: (0, _options.getBooleanOption)(translatedOptions, 'sourcemap', false),
36
+ taro: (0, _options.getBooleanOption)(translatedOptions, 'taro', false),
37
+ expo: (0, _options.getBooleanOption)(translatedOptions, 'expo', false),
38
+ rncli: (0, _options.getBooleanOption)(translatedOptions, 'rncli', false),
39
+ hermes: (0, _options.getBooleanOption)(translatedOptions, 'hermes', false),
40
+ name: (0, _options.getOptionalStringOption)(translatedOptions, 'name'),
41
+ description: (0, _options.getOptionalStringOption)(translatedOptions, 'description'),
42
+ metaInfo: (0, _options.getOptionalStringOption)(translatedOptions, 'metaInfo'),
43
+ packageId: (0, _options.getOptionalStringOption)(translatedOptions, 'packageId'),
44
+ packageVersion: (0, _options.getOptionalStringOption)(translatedOptions, 'packageVersion'),
45
+ minPackageVersion: (0, _options.getOptionalStringOption)(translatedOptions, 'minPackageVersion'),
46
+ maxPackageVersion: (0, _options.getOptionalStringOption)(translatedOptions, 'maxPackageVersion'),
47
+ packageVersionRange: (0, _options.getOptionalStringOption)(translatedOptions, 'packageVersionRange'),
48
+ rollout: (0, _options.getOptionalStringOption)(translatedOptions, 'rollout'),
49
+ dryRun: (0, _options.getBooleanOption)(translatedOptions, 'dryRun', false)
280
50
  };
281
51
  }
282
- async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput, shouldCleanSourcemap) {
283
- console.log((0, _i18n.t)('hermesEnabledCompiling'));
284
- // >= rn 0.69
285
- const rnDir = _path.default.dirname(require.resolve('react-native', {
286
- paths: [
287
- process.cwd()
288
- ]
289
- }));
290
- let hermesPath = _path.default.join(rnDir, `/sdks/hermesc/${getHermesOSBin()}`);
291
- // < rn 0.69
292
- if (!_fsextra.existsSync(hermesPath)) {
293
- hermesPath = `node_modules/hermes-engine/${getHermesOSBin()}`;
294
- }
295
- const hermesCommand = `${hermesPath}/hermesc`;
296
- const args = [
297
- '-emit-binary',
298
- '-out',
299
- _path.default.join(outputFolder, bundleName),
300
- _path.default.join(outputFolder, bundleName),
301
- '-O'
302
- ];
303
- if (sourcemapOutput) {
304
- _fsextra.copyFileSync(sourcemapOutput, _path.default.join(outputFolder, `${bundleName}.txt.map`));
305
- args.push('-output-source-map');
306
- }
307
- console.log((0, _i18n.t)('runningHermesc', {
308
- command: hermesCommand,
309
- args: args.join(' ')
310
- }));
311
- (0, _child_process.spawnSync)(hermesCommand, args, {
312
- stdio: 'ignore'
313
- });
314
- if (sourcemapOutput) {
315
- const composerPath = 'node_modules/react-native/scripts/compose-source-maps.js';
316
- if (!_fsextra.existsSync(composerPath)) {
317
- return;
318
- }
319
- console.log((0, _i18n.t)('composingSourceMap'));
320
- (0, _child_process.spawnSync)('node', [
321
- composerPath,
322
- _path.default.join(outputFolder, `${bundleName}.txt.map`),
323
- _path.default.join(outputFolder, `${bundleName}.map`),
324
- '-o',
325
- sourcemapOutput
326
- ], {
327
- stdio: 'ignore'
328
- });
329
- }
330
- if (shouldCleanSourcemap) {
331
- _fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
332
- }
333
- }
334
- async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
335
- if (sourcemapOutput) {
336
- let copyDebugidPath;
337
- try {
338
- copyDebugidPath = require.resolve('@sentry/react-native/scripts/copy-debugid.js', {
339
- paths: [
340
- process.cwd()
341
- ]
342
- });
343
- } catch (error) {
344
- console.error((0, _i18n.t)('sentryCliNotFound'));
345
- return;
346
- }
347
- if (!_fsextra.existsSync(copyDebugidPath)) {
348
- return;
349
- }
350
- console.log((0, _i18n.t)('copyingDebugId'));
351
- (0, _child_process.spawnSync)('node', [
352
- copyDebugidPath,
353
- _path.default.join(outputFolder, `${bundleName}.txt.map`),
354
- _path.default.join(outputFolder, `${bundleName}.map`)
355
- ], {
356
- stdio: 'ignore'
357
- });
358
- }
359
- _fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
360
- }
361
- async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutput, version) {
362
- if (sourcemapOutput) {
363
- let sentryCliPath;
364
- try {
365
- sentryCliPath = require.resolve('@sentry/cli/bin/sentry-cli', {
366
- paths: [
367
- process.cwd()
368
- ]
369
- });
370
- } catch (error) {
371
- console.error((0, _i18n.t)('sentryCliNotFound'));
372
- return;
373
- }
374
- if (!_fsextra.existsSync(sentryCliPath)) {
375
- return;
376
- }
377
- (0, _child_process.spawnSync)('node', [
378
- sentryCliPath,
379
- 'releases',
380
- 'set-commits',
381
- version,
382
- '--auto'
383
- ], {
384
- stdio: 'inherit'
385
- });
386
- console.log((0, _i18n.t)('sentryReleaseCreated', {
387
- version
388
- }));
389
- console.log((0, _i18n.t)('uploadingSourcemap'));
390
- (0, _child_process.spawnSync)('node', [
391
- sentryCliPath,
392
- 'releases',
393
- 'files',
394
- version,
395
- 'upload-sourcemaps',
396
- '--strip-prefix',
397
- _path.default.join(process.cwd(), outputFolder),
398
- _path.default.join(outputFolder, bundleName),
399
- _path.default.join(outputFolder, `${bundleName}.map`)
400
- ], {
401
- stdio: 'inherit'
402
- });
52
+ async function uploadSentryArtifactsIfNeeded(shouldUpload, bundleName, intermediaDir, sourcemapOutput, versionName) {
53
+ if (!shouldUpload) {
54
+ return;
403
55
  }
56
+ await (0, _bundlerunner.copyDebugidForSentry)(bundleName, intermediaDir, sourcemapOutput);
57
+ await (0, _bundlerunner.uploadSourcemapForSentry)(bundleName, intermediaDir, sourcemapOutput, versionName);
404
58
  }
405
- const ignorePackingFileNames = [
406
- '.',
407
- '..',
408
- 'index.bundlejs.map',
409
- 'bundle.harmony.js.map'
410
- ];
411
- const ignorePackingExtensions = [
412
- 'DS_Store',
413
- 'txt.map'
414
- ];
415
- async function pack(dir, output) {
416
- console.log((0, _i18n.t)('packing'));
417
- _fsextra.ensureDirSync(_path.default.dirname(output));
418
- await new Promise((resolve, reject)=>{
419
- const zipfile = new _yazl.ZipFile();
420
- function addDirectory(root, rel) {
421
- if (rel) {
422
- zipfile.addEmptyDirectory(rel);
423
- }
424
- const childs = _fsextra.readdirSync(root);
425
- for (const name of childs){
426
- if (ignorePackingFileNames.includes(name) || ignorePackingExtensions.some((ext)=>name.endsWith(`.${ext}`))) {
427
- continue;
428
- }
429
- const fullPath = _path.default.join(root, name);
430
- const stat = _fsextra.statSync(fullPath);
431
- if (stat.isFile()) {
432
- //console.log('adding: ' + rel+name);
433
- zipfile.addFile(fullPath, rel + name);
434
- } else if (stat.isDirectory()) {
435
- //console.log('adding: ' + rel+name+'/');
436
- addDirectory(fullPath, `${rel}${name}/`);
437
- }
438
- }
59
+ async function publishBundleVersion(outputPath, platform, payload) {
60
+ return _versions.versionCommands.publish({
61
+ args: [
62
+ outputPath
63
+ ],
64
+ options: {
65
+ platform,
66
+ ...payload
439
67
  }
440
- addDirectory(dir, '');
441
- zipfile.outputStream.on('error', (err)=>reject(err));
442
- zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
443
- resolve(void 0);
444
- });
445
- zipfile.end();
446
68
  });
447
- console.log((0, _i18n.t)('fileGenerated', {
448
- file: output
449
- }));
450
69
  }
451
70
  const bundleCommands = {
452
71
  bundle: async ({ options })=>{
453
- const platform = await (0, _app.getPlatform)(options.platform);
454
- const { bundleName, entryFile, intermediaDir, output, dev, sourcemap, taro, expo, rncli, hermes, name, description, metaInfo, packageId, packageVersion, minPackageVersion, maxPackageVersion, packageVersionRange, rollout, dryRun } = (0, _utils.translateOptions)({
72
+ const platform = await (0, _app.getPlatform)(typeof options.platform === 'string' ? options.platform : undefined);
73
+ const translatedOptions = (0, _utils.translateOptions)({
455
74
  ...options,
456
75
  tempDir: _constants.tempDir,
457
76
  platform
458
77
  });
78
+ const normalized = normalizeBundleOptions(translatedOptions, platform);
459
79
  (0, _checklockfile.checkLockFiles)();
460
80
  (0, _addgitignore.addGitIgnore)();
461
81
  const bundleParams = await (0, _utils.checkPlugins)();
462
- const sourcemapPlugin = bundleParams.sourcemap;
463
- const isSentry = bundleParams.sentry;
464
- const sourcemapOutput = _path.default.join(intermediaDir, `${bundleName}.map`);
465
- const realOutput = output.replace(/\$\{time\}/g, `${Date.now()}`);
82
+ const sourcemapOutput = _path.default.join(normalized.intermediaDir, `${normalized.bundleName}.map`);
83
+ const realOutput = normalized.output.replace(/\$\{time\}/g, `${Date.now()}`);
466
84
  if (!platform) {
467
85
  throw new Error((0, _i18n.t)('platformRequired'));
468
86
  }
469
87
  console.log(`Bundling with react-native: ${_depversions.depVersions['react-native']}`);
470
- await runReactNativeBundleCommand({
471
- bundleName,
472
- dev,
473
- entryFile,
474
- outputFolder: intermediaDir,
88
+ await (0, _bundlerunner.runReactNativeBundleCommand)({
89
+ bundleName: normalized.bundleName,
90
+ dev: normalized.dev,
91
+ entryFile: normalized.entryFile,
92
+ outputFolder: normalized.intermediaDir,
475
93
  platform,
476
- sourcemapOutput: sourcemap || sourcemapPlugin ? sourcemapOutput : '',
477
- forceHermes: hermes,
94
+ sourcemapOutput: normalized.sourcemap || bundleParams.sourcemap ? sourcemapOutput : '',
95
+ forceHermes: normalized.hermes,
478
96
  cli: {
479
- taro: !!taro,
480
- expo: !!expo,
481
- rncli: !!rncli
482
- }
97
+ taro: normalized.taro,
98
+ expo: normalized.expo,
99
+ rncli: normalized.rncli
100
+ },
101
+ isSentry: bundleParams.sentry
483
102
  });
484
- await pack(_path.default.resolve(intermediaDir), realOutput);
485
- if (name) {
486
- const versionName = await _versions.versionCommands.publish({
487
- args: [
488
- realOutput
489
- ],
490
- options: {
491
- platform,
492
- name,
493
- description,
494
- metaInfo,
495
- packageId,
496
- packageVersion,
497
- minPackageVersion,
498
- maxPackageVersion,
499
- packageVersionRange,
500
- rollout,
501
- dryRun: Boolean(dryRun)
502
- }
103
+ await (0, _bundlepack.packBundle)(_path.default.resolve(normalized.intermediaDir), realOutput);
104
+ if (normalized.name) {
105
+ const versionName = await publishBundleVersion(realOutput, platform, {
106
+ name: normalized.name,
107
+ description: normalized.description,
108
+ metaInfo: normalized.metaInfo,
109
+ packageId: normalized.packageId,
110
+ packageVersion: normalized.packageVersion,
111
+ minPackageVersion: normalized.minPackageVersion,
112
+ maxPackageVersion: normalized.maxPackageVersion,
113
+ packageVersionRange: normalized.packageVersionRange,
114
+ rollout: normalized.rollout,
115
+ dryRun: normalized.dryRun
503
116
  });
504
- if (isSentry) {
505
- await copyDebugidForSentry(bundleName, intermediaDir, sourcemapOutput);
506
- await uploadSourcemapForSentry(bundleName, intermediaDir, sourcemapOutput, versionName);
507
- }
508
- } else if (!options['no-interactive']) {
117
+ await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, versionName);
118
+ return;
119
+ }
120
+ if (!(0, _options.getBooleanOption)(options, 'no-interactive', false)) {
509
121
  const v = await (0, _utils.question)((0, _i18n.t)('uploadBundlePrompt'));
510
122
  if (v.toLowerCase() === 'y') {
511
- const versionName = await _versions.versionCommands.publish({
512
- args: [
513
- realOutput
514
- ],
515
- options: {
516
- platform
517
- }
518
- });
519
- if (isSentry) {
520
- await copyDebugidForSentry(bundleName, intermediaDir, sourcemapOutput);
521
- await uploadSourcemapForSentry(bundleName, intermediaDir, sourcemapOutput, versionName);
522
- }
123
+ const versionName = await publishBundleVersion(realOutput, platform, {});
124
+ await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, versionName);
523
125
  }
524
126
  }
525
127
  }
package/lib/diff.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { CommandContext } from './types';
2
+ import { enumZipEntries, readEntry } from './utils/zip-entries';
3
+ export { enumZipEntries, readEntry };
4
+ export declare const diffCommands: {
5
+ diff: ({ args, options }: CommandContext) => Promise<void>;
6
+ hdiff: ({ args, options }: CommandContext) => Promise<void>;
7
+ diffFromApk: ({ args, options }: CommandContext) => Promise<void>;
8
+ hdiffFromApk: ({ args, options }: CommandContext) => Promise<void>;
9
+ diffFromApp: ({ args, options }: CommandContext) => Promise<void>;
10
+ hdiffFromApp: ({ args, options }: CommandContext) => Promise<void>;
11
+ diffFromIpa: ({ args, options }: CommandContext) => Promise<void>;
12
+ hdiffFromIpa: ({ args, options }: CommandContext) => Promise<void>;
13
+ };