react-native-update-cli 2.8.4 → 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 (112) 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/en.js +11 -0
  18. package/lib/locales/zh.d.ts +136 -0
  19. package/lib/locales/zh.js +11 -0
  20. package/lib/module-manager.d.ts +20 -0
  21. package/lib/module-manager.js +3 -9
  22. package/lib/modules/app-module.d.ts +2 -0
  23. package/lib/modules/app-module.js +84 -44
  24. package/lib/modules/bundle-module.d.ts +2 -0
  25. package/lib/modules/bundle-module.js +7 -8
  26. package/lib/modules/index.d.ts +6 -0
  27. package/lib/modules/package-module.d.ts +2 -0
  28. package/lib/modules/user-module.d.ts +2 -0
  29. package/lib/modules/user-module.js +55 -44
  30. package/lib/modules/version-module.d.ts +2 -0
  31. package/lib/package.d.ts +58 -0
  32. package/lib/package.js +103 -139
  33. package/lib/provider.d.ts +26 -0
  34. package/lib/provider.js +115 -217
  35. package/lib/types.d.ts +120 -0
  36. package/lib/user.d.ts +8 -0
  37. package/lib/utils/add-gitignore.d.ts +1 -0
  38. package/lib/utils/app-info-parser/aab.d.ts +22 -0
  39. package/lib/utils/app-info-parser/aab.js +0 -4
  40. package/lib/utils/app-info-parser/apk.d.ts +14 -0
  41. package/lib/utils/app-info-parser/apk.js +6 -4
  42. package/lib/utils/app-info-parser/app.d.ts +4 -0
  43. package/lib/utils/app-info-parser/app.js +3 -0
  44. package/lib/utils/app-info-parser/index.d.ts +16 -0
  45. package/lib/utils/app-info-parser/index.js +2 -0
  46. package/lib/utils/app-info-parser/ipa.d.ts +14 -0
  47. package/lib/utils/app-info-parser/ipa.js +1 -1
  48. package/lib/utils/app-info-parser/resource-finder.d.ts +49 -0
  49. package/lib/utils/app-info-parser/utils.d.ts +31 -0
  50. package/lib/utils/app-info-parser/utils.js +1 -0
  51. package/lib/utils/app-info-parser/xml-parser/binary.d.ts +56 -0
  52. package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +10 -0
  53. package/lib/utils/app-info-parser/zip.d.ts +18 -0
  54. package/lib/utils/app-info-parser/zip.js +7 -9
  55. package/lib/utils/check-lockfile.d.ts +1 -0
  56. package/lib/utils/check-plugin.d.ts +7 -0
  57. package/lib/utils/command-result.d.ts +3 -0
  58. package/lib/utils/command-result.js +35 -0
  59. package/lib/utils/constants.d.ts +9 -0
  60. package/lib/utils/dep-versions.d.ts +1 -0
  61. package/lib/utils/git.d.ts +8 -0
  62. package/lib/utils/http-helper.d.ts +4 -0
  63. package/lib/utils/i18n.d.ts +12 -0
  64. package/lib/utils/index.d.ts +22 -0
  65. package/lib/utils/index.js +52 -22
  66. package/lib/utils/latest-version/cli.d.ts +1 -0
  67. package/lib/utils/latest-version/cli.js +24 -60
  68. package/lib/utils/latest-version/index.d.ts +146 -0
  69. package/lib/utils/latest-version/index.js +22 -22
  70. package/lib/utils/options.d.ts +4 -0
  71. package/lib/utils/options.js +63 -0
  72. package/lib/utils/plugin-config.d.ts +9 -0
  73. package/lib/utils/zip-entries.d.ts +3 -0
  74. package/lib/versions.d.ts +43 -0
  75. package/lib/versions.js +186 -2
  76. package/lib/workflow-runner.d.ts +2 -0
  77. package/lib/workflow-runner.js +25 -0
  78. package/package.json +20 -5
  79. package/src/api.ts +1 -1
  80. package/src/app.ts +20 -11
  81. package/src/bundle-pack.ts +51 -0
  82. package/src/bundle-runner.ts +463 -0
  83. package/src/bundle.ts +184 -571
  84. package/src/diff.ts +208 -174
  85. package/src/index.ts +15 -17
  86. package/src/locales/en.ts +15 -0
  87. package/src/locales/zh.ts +13 -0
  88. package/src/module-manager.ts +15 -15
  89. package/src/modules/app-module.ts +120 -48
  90. package/src/modules/bundle-module.ts +21 -11
  91. package/src/modules/package-module.ts +0 -1
  92. package/src/modules/user-module.ts +117 -58
  93. package/src/package.ts +158 -138
  94. package/src/provider.ts +164 -240
  95. package/src/types.ts +15 -8
  96. package/src/utils/app-info-parser/aab.ts +0 -7
  97. package/src/utils/app-info-parser/apk.ts +9 -6
  98. package/src/utils/app-info-parser/app.ts +5 -1
  99. package/src/utils/app-info-parser/index.ts +11 -6
  100. package/src/utils/app-info-parser/ipa.ts +1 -1
  101. package/src/utils/app-info-parser/utils.ts +3 -0
  102. package/src/utils/app-info-parser/xml-parser/manifest.ts +3 -1
  103. package/src/utils/app-info-parser/zip.ts +12 -14
  104. package/src/utils/command-result.ts +24 -0
  105. package/src/utils/index.ts +138 -39
  106. package/src/utils/latest-version/cli.ts +22 -20
  107. package/src/utils/latest-version/index.ts +20 -20
  108. package/src/utils/options.ts +56 -0
  109. package/src/utils/zip-entries.ts +1 -1
  110. package/src/versions.ts +265 -2
  111. package/src/workflow-runner.ts +24 -0
  112. package/index.js +0 -1
package/lib/api.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import type { Package, Session } from './types';
2
+ export declare const getSession: () => Session | undefined;
3
+ export declare const getApiToken: () => string | undefined;
4
+ export declare const setApiToken: (token: string) => void;
5
+ export declare const replaceSession: (newSession: {
6
+ token: string;
7
+ }) => void;
8
+ export declare const loadSession: () => Promise<void>;
9
+ export declare const saveSession: () => void;
10
+ export declare const closeSession: () => void;
11
+ export declare const get: (api: string) => Promise<any>;
12
+ export declare const post: (api: string, body?: Record<string, any>) => Promise<any>;
13
+ export declare const put: (api: string, body?: Record<string, any>) => Promise<any>;
14
+ export declare const doDelete: (api: string, body?: Record<string, any>) => Promise<any>;
15
+ export declare function uploadFile(fn: string, key?: string): Promise<{
16
+ hash: any;
17
+ }>;
18
+ export declare const getAllPackages: (appId: string) => Promise<Package[] | null | undefined>;
package/lib/app.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ import type { Platform } from './types';
2
+ interface AppSummary {
3
+ id: number;
4
+ name: string;
5
+ platform: Platform;
6
+ }
7
+ export declare function getPlatform(platform?: string): Promise<Platform>;
8
+ export declare function assertPlatform(platform: string): Platform;
9
+ export declare function getSelectedApp(platform: Platform): any;
10
+ export declare function listApp(platform?: Platform | ''): Promise<AppSummary[]>;
11
+ export declare function chooseApp(platform: Platform): Promise<AppSummary>;
12
+ export declare const appCommands: {
13
+ createApp: ({ options, }: {
14
+ options: {
15
+ name: string;
16
+ downloadUrl: string;
17
+ platform?: Platform | "";
18
+ };
19
+ }) => Promise<void>;
20
+ deleteApp: ({ args, options, }: {
21
+ args: string[];
22
+ options: {
23
+ platform: Platform;
24
+ };
25
+ }) => Promise<void>;
26
+ apps: ({ options }: {
27
+ options: {
28
+ platform?: Platform | "";
29
+ };
30
+ }) => Promise<void>;
31
+ selectApp: ({ args, options, }: {
32
+ args: string[];
33
+ options: {
34
+ platform?: Platform | "";
35
+ };
36
+ }) => Promise<void>;
37
+ };
38
+ export {};
package/lib/app.js CHANGED
@@ -71,7 +71,8 @@ function getSelectedApp(platform) {
71
71
  }
72
72
  async function listApp(platform = '') {
73
73
  const { data } = await (0, _api.get)('/app/list');
74
- const list = platform ? data.filter((v)=>v.platform === platform) : data;
74
+ const allApps = data;
75
+ const list = platform ? allApps.filter((app)=>app.platform === platform) : allApps;
75
76
  const header = [
76
77
  {
77
78
  value: (0, _i18n.t)('appId')
@@ -102,7 +103,7 @@ async function chooseApp(platform) {
102
103
  const list = await listApp(platform);
103
104
  while(true){
104
105
  const id = await (0, _utils.question)((0, _i18n.t)('enterAppIdQuestion'));
105
- const app = list.find((v)=>v.id === Number(id));
106
+ const app = list.find((item)=>item.id === Number(id));
106
107
  if (app) {
107
108
  return app;
108
109
  }
@@ -140,8 +141,8 @@ const appCommands = {
140
141
  console.log((0, _i18n.t)('operationSuccess'));
141
142
  },
142
143
  apps: async ({ options })=>{
143
- const { platform } = options;
144
- listApp(platform);
144
+ const { platform = '' } = options;
145
+ await listApp(platform);
145
146
  },
146
147
  selectApp: async ({ args, options })=>{
147
148
  const platform = await getPlatform(options.platform);
@@ -0,0 +1 @@
1
+ export declare function packBundle(dir: string, output: string): Promise<void>;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "packBundle", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return packBundle;
9
+ }
10
+ });
11
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
13
+ const _yazl = require("yazl");
14
+ const _i18n = require("./utils/i18n");
15
+ function _interop_require_default(obj) {
16
+ return obj && obj.__esModule ? obj : {
17
+ default: obj
18
+ };
19
+ }
20
+ function _getRequireWildcardCache(nodeInterop) {
21
+ if (typeof WeakMap !== "function") return null;
22
+ var cacheBabelInterop = new WeakMap();
23
+ var cacheNodeInterop = new WeakMap();
24
+ return (_getRequireWildcardCache = function(nodeInterop) {
25
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
26
+ })(nodeInterop);
27
+ }
28
+ function _interop_require_wildcard(obj, nodeInterop) {
29
+ if (!nodeInterop && obj && obj.__esModule) {
30
+ return obj;
31
+ }
32
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
33
+ return {
34
+ default: obj
35
+ };
36
+ }
37
+ var cache = _getRequireWildcardCache(nodeInterop);
38
+ if (cache && cache.has(obj)) {
39
+ return cache.get(obj);
40
+ }
41
+ var newObj = {
42
+ __proto__: null
43
+ };
44
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
45
+ for(var key in obj){
46
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
47
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
48
+ if (desc && (desc.get || desc.set)) {
49
+ Object.defineProperty(newObj, key, desc);
50
+ } else {
51
+ newObj[key] = obj[key];
52
+ }
53
+ }
54
+ }
55
+ newObj.default = obj;
56
+ if (cache) {
57
+ cache.set(obj, newObj);
58
+ }
59
+ return newObj;
60
+ }
61
+ const ignorePackingFileNames = [
62
+ '.',
63
+ '..',
64
+ 'index.bundlejs.map',
65
+ 'bundle.harmony.js.map'
66
+ ];
67
+ const ignorePackingExtensions = [
68
+ 'DS_Store',
69
+ 'txt.map'
70
+ ];
71
+ async function packBundle(dir, output) {
72
+ console.log((0, _i18n.t)('packing'));
73
+ _fsextra.ensureDirSync(_path.default.dirname(output));
74
+ await new Promise((resolve, reject)=>{
75
+ const zipfile = new _yazl.ZipFile();
76
+ function addDirectory(root, rel) {
77
+ if (rel) {
78
+ zipfile.addEmptyDirectory(rel);
79
+ }
80
+ const children = _fsextra.readdirSync(root);
81
+ for (const name of children){
82
+ if (ignorePackingFileNames.includes(name) || ignorePackingExtensions.some((ext)=>name.endsWith(`.${ext}`))) {
83
+ continue;
84
+ }
85
+ const fullPath = _path.default.join(root, name);
86
+ const stat = _fsextra.statSync(fullPath);
87
+ if (stat.isFile()) {
88
+ zipfile.addFile(fullPath, rel + name);
89
+ } else if (stat.isDirectory()) {
90
+ addDirectory(fullPath, `${rel}${name}/`);
91
+ }
92
+ }
93
+ }
94
+ addDirectory(dir, '');
95
+ zipfile.outputStream.on('error', (err)=>reject(err));
96
+ zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
97
+ resolve();
98
+ });
99
+ zipfile.end();
100
+ });
101
+ console.log((0, _i18n.t)('fileGenerated', {
102
+ file: output
103
+ }));
104
+ }
@@ -0,0 +1,20 @@
1
+ export interface BundleCliOptions {
2
+ taro?: boolean;
3
+ expo?: boolean;
4
+ rncli?: boolean;
5
+ }
6
+ export interface RunBundleCommandOptions {
7
+ bundleName: string;
8
+ dev: string;
9
+ entryFile: string;
10
+ outputFolder: string;
11
+ platform: string;
12
+ sourcemapOutput: string;
13
+ config?: string;
14
+ forceHermes?: boolean;
15
+ cli: BundleCliOptions;
16
+ isSentry: boolean;
17
+ }
18
+ export declare function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli, isSentry, }: RunBundleCommandOptions): Promise<void>;
19
+ export declare function copyDebugidForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string): Promise<void>;
20
+ export declare function uploadSourcemapForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string, version: string): Promise<void>;
@@ -0,0 +1,404 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ copyDebugidForSentry: function() {
13
+ return copyDebugidForSentry;
14
+ },
15
+ runReactNativeBundleCommand: function() {
16
+ return runReactNativeBundleCommand;
17
+ },
18
+ uploadSourcemapForSentry: function() {
19
+ return uploadSourcemapForSentry;
20
+ }
21
+ });
22
+ const _child_process = require("child_process");
23
+ const _os = /*#__PURE__*/ _interop_require_default(require("os"));
24
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
25
+ const _compareversions = require("compare-versions");
26
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
27
+ const _i18n = require("./utils/i18n");
28
+ function _interop_require_default(obj) {
29
+ return obj && obj.__esModule ? obj : {
30
+ default: obj
31
+ };
32
+ }
33
+ function _getRequireWildcardCache(nodeInterop) {
34
+ if (typeof WeakMap !== "function") return null;
35
+ var cacheBabelInterop = new WeakMap();
36
+ var cacheNodeInterop = new WeakMap();
37
+ return (_getRequireWildcardCache = function(nodeInterop) {
38
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
39
+ })(nodeInterop);
40
+ }
41
+ function _interop_require_wildcard(obj, nodeInterop) {
42
+ if (!nodeInterop && obj && obj.__esModule) {
43
+ return obj;
44
+ }
45
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
46
+ return {
47
+ default: obj
48
+ };
49
+ }
50
+ var cache = _getRequireWildcardCache(nodeInterop);
51
+ if (cache && cache.has(obj)) {
52
+ return cache.get(obj);
53
+ }
54
+ var newObj = {
55
+ __proto__: null
56
+ };
57
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
58
+ for(var key in obj){
59
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
60
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
61
+ if (desc && (desc.get || desc.set)) {
62
+ Object.defineProperty(newObj, key, desc);
63
+ } else {
64
+ newObj[key] = obj[key];
65
+ }
66
+ }
67
+ }
68
+ newObj.default = obj;
69
+ if (cache) {
70
+ cache.set(obj, newObj);
71
+ }
72
+ return newObj;
73
+ }
74
+ const g2js = require('gradle-to-js/lib/parser');
75
+ const properties = require('properties');
76
+ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli, isSentry }) {
77
+ let gradleConfig = {};
78
+ if (platform === 'android') {
79
+ gradleConfig = await checkGradleConfig();
80
+ if (gradleConfig.crunchPngs !== false) {
81
+ console.warn((0, _i18n.t)('androidCrunchPngsWarning'));
82
+ }
83
+ }
84
+ const reactNativeBundleArgs = [];
85
+ const envArgs = process.env.PUSHY_ENV_ARGS;
86
+ if (envArgs) {
87
+ reactNativeBundleArgs.push(...envArgs.trim().split(/\s+/));
88
+ }
89
+ _fsextra.emptyDirSync(outputFolder);
90
+ let cliPath = '';
91
+ let usingExpo = false;
92
+ const getExpoCli = ()=>{
93
+ try {
94
+ const searchPaths = [
95
+ process.cwd()
96
+ ];
97
+ try {
98
+ const expoPath = require.resolve('expo/package.json', {
99
+ paths: [
100
+ process.cwd()
101
+ ]
102
+ });
103
+ const expoDir = expoPath.replace(/\/package\.json$/, '');
104
+ searchPaths.push(expoDir);
105
+ } catch (e) {
106
+ // expo 包不存在,忽略
107
+ }
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
+ if ((0, _compareversions.satisfies)(expoCliVersion, '>= 0.10.17')) {
115
+ usingExpo = true;
116
+ } else {
117
+ cliPath = '';
118
+ }
119
+ } catch (e) {
120
+ // fallback 到 RN CLI
121
+ }
122
+ };
123
+ const getRnCli = ()=>{
124
+ try {
125
+ cliPath = require.resolve('react-native/local-cli/cli.js', {
126
+ paths: [
127
+ process.cwd()
128
+ ]
129
+ });
130
+ } catch (e) {
131
+ cliPath = require.resolve('@react-native-community/cli/build/bin.js', {
132
+ paths: [
133
+ process.cwd()
134
+ ]
135
+ });
136
+ }
137
+ };
138
+ const getTaroCli = ()=>{
139
+ try {
140
+ cliPath = require.resolve('@tarojs/cli/bin/taro', {
141
+ paths: [
142
+ process.cwd()
143
+ ]
144
+ });
145
+ } catch (e) {
146
+ // fallback 到 RN CLI
147
+ }
148
+ };
149
+ if (cli.expo) {
150
+ getExpoCli();
151
+ } else if (cli.taro) {
152
+ getTaroCli();
153
+ } else if (cli.rncli) {
154
+ getRnCli();
155
+ }
156
+ if (!cliPath) {
157
+ getExpoCli();
158
+ if (!usingExpo) {
159
+ getRnCli();
160
+ }
161
+ }
162
+ if (isSentry) {
163
+ if (platform === 'ios') {
164
+ process.env.SENTRY_PROPERTIES = 'ios/sentry.properties';
165
+ } else if (platform === 'android') {
166
+ process.env.SENTRY_PROPERTIES = 'android/sentry.properties';
167
+ }
168
+ }
169
+ let bundleCommand = 'bundle';
170
+ if (usingExpo) {
171
+ bundleCommand = 'export:embed';
172
+ } else if (platform === 'harmony') {
173
+ bundleCommand = 'bundle-harmony';
174
+ } else if (cli.taro) {
175
+ bundleCommand = 'build';
176
+ }
177
+ if (platform === 'harmony') {
178
+ bundleName = 'bundle.harmony.js';
179
+ if (forceHermes === undefined) {
180
+ forceHermes = true;
181
+ }
182
+ }
183
+ reactNativeBundleArgs.push(cliPath, bundleCommand, '--assets-dest', outputFolder, '--bundle-output', _path.default.join(outputFolder, bundleName));
184
+ if (platform !== 'harmony') {
185
+ reactNativeBundleArgs.push('--platform', platform, '--reset-cache');
186
+ }
187
+ if (cli.taro) {
188
+ reactNativeBundleArgs.push('--type', 'rn');
189
+ } else {
190
+ reactNativeBundleArgs.push('--dev', dev, '--entry-file', entryFile);
191
+ }
192
+ if (sourcemapOutput) {
193
+ reactNativeBundleArgs.push('--sourcemap-output', sourcemapOutput);
194
+ }
195
+ if (config) {
196
+ reactNativeBundleArgs.push('--config', config);
197
+ }
198
+ const reactNativeBundleProcess = (0, _child_process.spawn)('node', reactNativeBundleArgs);
199
+ console.log(`Running bundle command: node ${reactNativeBundleArgs.join(' ')}`);
200
+ await new Promise((resolve, reject)=>{
201
+ reactNativeBundleProcess.stdout.on('data', (data)=>{
202
+ console.log(data.toString().trim());
203
+ });
204
+ reactNativeBundleProcess.stderr.on('data', (data)=>{
205
+ console.error(data.toString().trim());
206
+ });
207
+ reactNativeBundleProcess.on('close', async (exitCode)=>{
208
+ if (exitCode) {
209
+ reject(new Error((0, _i18n.t)('bundleCommandError', {
210
+ code: exitCode
211
+ })));
212
+ return;
213
+ }
214
+ let hermesEnabled = false;
215
+ if (forceHermes) {
216
+ hermesEnabled = true;
217
+ console.log((0, _i18n.t)('forceHermes'));
218
+ } else if (platform === 'android') {
219
+ const gradleProperties = await new Promise((resolve)=>{
220
+ properties.parse('./android/gradle.properties', {
221
+ path: true
222
+ }, (error, props = {})=>{
223
+ if (error) {
224
+ console.error(error);
225
+ resolve({});
226
+ return;
227
+ }
228
+ resolve(props);
229
+ });
230
+ });
231
+ hermesEnabled = gradleProperties.hermesEnabled;
232
+ if (typeof hermesEnabled !== 'boolean') {
233
+ hermesEnabled = gradleConfig.enableHermes;
234
+ }
235
+ } else if (platform === 'ios' && _fsextra.existsSync('ios/Pods/hermes-engine')) {
236
+ hermesEnabled = true;
237
+ }
238
+ if (hermesEnabled) {
239
+ await compileHermesByteCode(bundleName, outputFolder, sourcemapOutput, !isSentry);
240
+ }
241
+ if (platform === 'harmony') {
242
+ const harmonyRawAssetsPath = 'harmony/entry/src/main/resources/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();
252
+ });
253
+ });
254
+ }
255
+ function getHermesOSBin() {
256
+ if (_os.default.platform() === 'win32') return 'win64-bin';
257
+ if (_os.default.platform() === 'darwin') return 'osx-bin';
258
+ if (_os.default.platform() === 'linux') return 'linux64-bin';
259
+ }
260
+ async function checkGradleConfig() {
261
+ let enableHermes = false;
262
+ let crunchPngs;
263
+ try {
264
+ const gradleConfig = await g2js.parseFile('android/app/build.gradle');
265
+ crunchPngs = gradleConfig.android.buildTypes.release.crunchPngs;
266
+ const projectConfig = gradleConfig['project.ext.react'];
267
+ if (projectConfig) {
268
+ for (const packagerConfig of projectConfig){
269
+ if (packagerConfig.includes('enableHermes') && packagerConfig.includes('true')) {
270
+ enableHermes = true;
271
+ break;
272
+ }
273
+ }
274
+ }
275
+ } catch (e) {
276
+ // ignore parsing failures
277
+ }
278
+ return {
279
+ enableHermes,
280
+ crunchPngs
281
+ };
282
+ }
283
+ async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput, shouldCleanSourcemap) {
284
+ console.log((0, _i18n.t)('hermesEnabledCompiling'));
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
+ if (!_fsextra.existsSync(hermesPath)) {
292
+ hermesPath = `node_modules/hermes-engine/${getHermesOSBin()}`;
293
+ }
294
+ const hermesCommand = `${hermesPath}/hermesc`;
295
+ const args = [
296
+ '-emit-binary',
297
+ '-out',
298
+ _path.default.join(outputFolder, bundleName),
299
+ _path.default.join(outputFolder, bundleName),
300
+ '-O'
301
+ ];
302
+ if (sourcemapOutput) {
303
+ _fsextra.copyFileSync(sourcemapOutput, _path.default.join(outputFolder, `${bundleName}.txt.map`));
304
+ args.push('-output-source-map');
305
+ }
306
+ console.log((0, _i18n.t)('runningHermesc', {
307
+ command: hermesCommand,
308
+ args: args.join(' ')
309
+ }));
310
+ (0, _child_process.spawnSync)(hermesCommand, args, {
311
+ stdio: 'ignore'
312
+ });
313
+ if (sourcemapOutput) {
314
+ const composerPath = 'node_modules/react-native/scripts/compose-source-maps.js';
315
+ if (!_fsextra.existsSync(composerPath)) {
316
+ return;
317
+ }
318
+ console.log((0, _i18n.t)('composingSourceMap'));
319
+ (0, _child_process.spawnSync)('node', [
320
+ composerPath,
321
+ _path.default.join(outputFolder, `${bundleName}.txt.map`),
322
+ _path.default.join(outputFolder, `${bundleName}.map`),
323
+ '-o',
324
+ sourcemapOutput
325
+ ], {
326
+ stdio: 'ignore'
327
+ });
328
+ }
329
+ if (shouldCleanSourcemap) {
330
+ _fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
331
+ }
332
+ }
333
+ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
334
+ if (sourcemapOutput) {
335
+ let copyDebugidPath;
336
+ try {
337
+ copyDebugidPath = require.resolve('@sentry/react-native/scripts/copy-debugid.js', {
338
+ paths: [
339
+ process.cwd()
340
+ ]
341
+ });
342
+ } catch (e) {
343
+ console.error((0, _i18n.t)('sentryCliNotFound'));
344
+ return;
345
+ }
346
+ if (!_fsextra.existsSync(copyDebugidPath)) {
347
+ return;
348
+ }
349
+ console.log((0, _i18n.t)('copyingDebugId'));
350
+ (0, _child_process.spawnSync)('node', [
351
+ copyDebugidPath,
352
+ _path.default.join(outputFolder, `${bundleName}.txt.map`),
353
+ _path.default.join(outputFolder, `${bundleName}.map`)
354
+ ], {
355
+ stdio: 'ignore'
356
+ });
357
+ }
358
+ _fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
359
+ }
360
+ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutput, version) {
361
+ if (!sourcemapOutput) {
362
+ return;
363
+ }
364
+ let sentryCliPath;
365
+ try {
366
+ sentryCliPath = require.resolve('@sentry/cli/bin/sentry-cli', {
367
+ paths: [
368
+ process.cwd()
369
+ ]
370
+ });
371
+ } catch (e) {
372
+ console.error((0, _i18n.t)('sentryCliNotFound'));
373
+ return;
374
+ }
375
+ if (!_fsextra.existsSync(sentryCliPath)) {
376
+ return;
377
+ }
378
+ (0, _child_process.spawnSync)('node', [
379
+ sentryCliPath,
380
+ 'releases',
381
+ 'set-commits',
382
+ version,
383
+ '--auto'
384
+ ], {
385
+ stdio: 'inherit'
386
+ });
387
+ console.log((0, _i18n.t)('sentryReleaseCreated', {
388
+ version
389
+ }));
390
+ console.log((0, _i18n.t)('uploadingSourcemap'));
391
+ (0, _child_process.spawnSync)('node', [
392
+ sentryCliPath,
393
+ 'releases',
394
+ 'files',
395
+ version,
396
+ 'upload-sourcemaps',
397
+ '--strip-prefix',
398
+ _path.default.join(process.cwd(), outputFolder),
399
+ _path.default.join(outputFolder, bundleName),
400
+ _path.default.join(outputFolder, `${bundleName}.map`)
401
+ ], {
402
+ stdio: 'inherit'
403
+ });
404
+ }
@@ -0,0 +1,6 @@
1
+ export declare const bundleCommands: {
2
+ bundle: ({ options, }: {
3
+ args?: string[];
4
+ options: Record<string, unknown>;
5
+ }) => Promise<void>;
6
+ };