react-native-update-cli 2.10.2 → 2.12.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/README.md +4 -0
- package/README.zh-CN.md +4 -0
- package/cli.json +6 -0
- package/lib/api.js +10 -12
- package/lib/app.d.ts +2 -2
- package/lib/app.js +42 -45
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +73 -0
- package/lib/bundle-runner.d.ts +1 -0
- package/lib/bundle-runner.js +68 -22
- package/lib/exports.d.ts +2 -9
- package/lib/exports.js +0 -31
- package/lib/index.d.ts +1 -4
- package/lib/index.js +12 -80
- package/lib/install.js +3 -4
- package/lib/locales/en.d.ts +1 -0
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.d.ts +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/package.d.ts +3 -0
- package/lib/package.js +50 -6
- package/lib/provider.d.ts +2 -2
- package/lib/provider.js +26 -25
- package/lib/types.d.ts +17 -21
- package/lib/utils/app-info-parser/aab.js +45 -4
- package/lib/utils/app-info-parser/zip.d.ts +3 -3
- package/lib/utils/app-info-parser/zip.js +33 -19
- package/lib/utils/http-helper.js +2 -7
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +9 -14
- package/lib/utils/plugin-config.js +42 -6
- package/lib/utils/runtime.d.ts +28 -0
- package/lib/utils/runtime.js +185 -0
- package/lib/versions.d.ts +6 -3
- package/lib/versions.js +80 -25
- package/package.json +8 -15
- package/src/api.ts +23 -15
- package/src/app.ts +40 -40
- package/src/bin.ts +93 -0
- package/src/bundle-runner.ts +161 -62
- package/src/exports.ts +1 -10
- package/src/index.ts +1 -94
- package/src/install.ts +3 -1
- package/src/locales/en.ts +1 -0
- package/src/locales/zh.ts +1 -0
- package/src/package.ts +12 -5
- package/src/provider.ts +49 -40
- package/src/types.ts +18 -26
- package/src/utils/app-info-parser/aab.ts +1 -1
- package/src/utils/app-info-parser/zip.ts +41 -24
- package/src/utils/http-helper.ts +2 -2
- package/src/utils/index.ts +9 -13
- package/src/utils/plugin-config.ts +1 -1
- package/src/utils/runtime.ts +190 -0
- package/src/versions.ts +105 -34
- package/lib/module-manager.d.ts +0 -16
- package/lib/module-manager.js +0 -90
- package/lib/modules/app-module.d.ts +0 -2
- package/lib/modules/app-module.js +0 -15
- package/lib/modules/bundle-module.d.ts +0 -2
- package/lib/modules/bundle-module.js +0 -15
- package/lib/modules/index.d.ts +0 -6
- package/lib/modules/index.js +0 -42
- package/lib/modules/package-module.d.ts +0 -2
- package/lib/modules/package-module.js +0 -15
- package/lib/modules/user-module.d.ts +0 -2
- package/lib/modules/user-module.js +0 -15
- package/lib/modules/version-module.d.ts +0 -2
- package/lib/modules/version-module.js +0 -15
- package/lib/utils/latest-version/cli.d.ts +0 -1
- package/lib/utils/latest-version/cli.js +0 -308
- package/src/module-manager.ts +0 -105
- package/src/modules/app-module.ts +0 -7
- package/src/modules/bundle-module.ts +0 -7
- package/src/modules/index.ts +0 -19
- package/src/modules/package-module.ts +0 -7
- package/src/modules/user-module.ts +0 -7
- package/src/modules/version-module.ts +0 -7
- package/src/utils/latest-version/cli.ts +0 -445
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "command line tool for react-native-update (remote updates for react native)",
|
|
5
5
|
"main": "lib/exports.js",
|
|
6
6
|
"types": "lib/exports.d.ts",
|
|
7
7
|
"bin": {
|
|
8
|
-
"pushy": "lib/
|
|
9
|
-
"cresc": "lib/
|
|
8
|
+
"pushy": "lib/bin.js",
|
|
9
|
+
"cresc": "lib/bin.js"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -14,11 +14,6 @@
|
|
|
14
14
|
"require": "./lib/exports.js",
|
|
15
15
|
"default": "./lib/exports.js"
|
|
16
16
|
},
|
|
17
|
-
"./cli": {
|
|
18
|
-
"types": "./lib/index.d.ts",
|
|
19
|
-
"require": "./lib/index.js",
|
|
20
|
-
"default": "./lib/index.js"
|
|
21
|
-
},
|
|
22
17
|
"./diff": {
|
|
23
18
|
"types": "./lib/diff.d.ts",
|
|
24
19
|
"require": "./lib/diff.js",
|
|
@@ -37,8 +32,8 @@
|
|
|
37
32
|
"cli.json"
|
|
38
33
|
],
|
|
39
34
|
"scripts": {
|
|
40
|
-
"build": "rm -rf lib && swc src -d lib --strip-leading-paths && bun run typecheck:build",
|
|
41
|
-
"prepublishOnly": "bun run build
|
|
35
|
+
"build": "rm -rf lib && swc src -d lib --strip-leading-paths && bun run typecheck:build && chmod +x lib/bin.js",
|
|
36
|
+
"prepublishOnly": "bun run build",
|
|
42
37
|
"typecheck": "tsc --noEmit",
|
|
43
38
|
"typecheck:build": "tsc -p tsconfig.build.json",
|
|
44
39
|
"lint": "bun run typecheck && biome check .",
|
|
@@ -64,13 +59,11 @@
|
|
|
64
59
|
},
|
|
65
60
|
"homepage": "https://github.com/reactnativecn/react-native-update-cli",
|
|
66
61
|
"dependencies": {
|
|
67
|
-
"@colors/colors": "^1.6.0",
|
|
68
62
|
"bplist-parser": "^0.3.2",
|
|
69
63
|
"bytebuffer": "^5.0.1",
|
|
70
64
|
"cgbi-to-png": "^1.0.7",
|
|
71
65
|
"chalk": "4",
|
|
72
66
|
"cli-arguments": "^0.2.1",
|
|
73
|
-
"commander": "^13",
|
|
74
67
|
"compare-versions": "^6.1.1",
|
|
75
68
|
"filesize-parser": "^1.5.1",
|
|
76
69
|
"form-data": "^4.0.5",
|
|
@@ -79,7 +72,6 @@
|
|
|
79
72
|
"gradle-to-js": "^2.0.1",
|
|
80
73
|
"i18next": "^26.0.4",
|
|
81
74
|
"isomorphic-git": "^1.37.5",
|
|
82
|
-
"isomorphic-unzip": "^1.1.5",
|
|
83
75
|
"node-fetch": "^2.6.1",
|
|
84
76
|
"plist": "^3.1.0",
|
|
85
77
|
"progress": "^2.0.3",
|
|
@@ -88,11 +80,13 @@
|
|
|
88
80
|
"read": "^4.1.0",
|
|
89
81
|
"registry-auth-token": "^5.1.1",
|
|
90
82
|
"semver": "^7.7.4",
|
|
91
|
-
"tcp-ping": "^0.1.1",
|
|
92
83
|
"tty-table": "5.0",
|
|
93
84
|
"yauzl": "^3.3.0",
|
|
94
85
|
"yazl": "3.3.1"
|
|
95
86
|
},
|
|
87
|
+
"overrides": {
|
|
88
|
+
"@xmldom/xmldom": "0.8.13"
|
|
89
|
+
},
|
|
96
90
|
"engines": {
|
|
97
91
|
"node": ">= 16.6.0"
|
|
98
92
|
},
|
|
@@ -107,7 +101,6 @@
|
|
|
107
101
|
"@types/node-fetch": "^2.6.13",
|
|
108
102
|
"@types/progress": "^2.0.7",
|
|
109
103
|
"@types/semver": "^7.7.1",
|
|
110
|
-
"@types/tcp-ping": "^0.1.6",
|
|
111
104
|
"@types/yauzl": "^2.10.3",
|
|
112
105
|
"@types/yazl": "^2.4.6",
|
|
113
106
|
"typescript": "^6.0.2"
|
package/src/api.ts
CHANGED
|
@@ -4,15 +4,17 @@ import fs from 'fs';
|
|
|
4
4
|
import fetch from 'node-fetch';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import ProgressBar from 'progress';
|
|
7
|
-
import tcpp from 'tcp-ping';
|
|
8
|
-
import util from 'util';
|
|
9
7
|
import { getBaseUrl } from 'utils/http-helper';
|
|
10
8
|
import packageJson from '../package.json';
|
|
11
9
|
import type { Package, Session } from './types';
|
|
12
10
|
import { credentialFile, IS_CRESC, pricingPageUrl } from './utils/constants';
|
|
13
11
|
import { t } from './utils/i18n';
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
import {
|
|
13
|
+
measureTcpLatency,
|
|
14
|
+
type RuntimeRequestInit,
|
|
15
|
+
type RuntimeResponse,
|
|
16
|
+
runtimeFetch,
|
|
17
|
+
} from './utils/runtime';
|
|
16
18
|
|
|
17
19
|
let session: Session | undefined;
|
|
18
20
|
let savedSession: Session | undefined;
|
|
@@ -75,22 +77,30 @@ export const closeSession = () => {
|
|
|
75
77
|
session = undefined;
|
|
76
78
|
};
|
|
77
79
|
|
|
78
|
-
function createRequestError(
|
|
80
|
+
function createRequestError(
|
|
81
|
+
error: unknown,
|
|
82
|
+
requestUrl: string,
|
|
83
|
+
status?: number,
|
|
84
|
+
) {
|
|
79
85
|
const message =
|
|
80
86
|
typeof error === 'string'
|
|
81
87
|
? error
|
|
82
88
|
: error instanceof Error
|
|
83
89
|
? error.message
|
|
84
90
|
: String(error);
|
|
85
|
-
|
|
91
|
+
const requestError = new Error(`${message}\nURL: ${requestUrl}`) as Error & {
|
|
92
|
+
status?: number;
|
|
93
|
+
};
|
|
94
|
+
requestError.status = status;
|
|
95
|
+
return requestError;
|
|
86
96
|
}
|
|
87
97
|
|
|
88
|
-
async function query(url: string, options:
|
|
98
|
+
async function query(url: string, options: RuntimeRequestInit) {
|
|
89
99
|
const baseUrl = await getBaseUrl;
|
|
90
100
|
const fullUrl = `${baseUrl}${url}`;
|
|
91
|
-
let resp:
|
|
101
|
+
let resp: RuntimeResponse;
|
|
92
102
|
try {
|
|
93
|
-
resp = await
|
|
103
|
+
resp = await runtimeFetch(fullUrl, options);
|
|
94
104
|
} catch (error) {
|
|
95
105
|
throw createRequestError(error, fullUrl);
|
|
96
106
|
}
|
|
@@ -109,9 +119,9 @@ async function query(url: string, options: fetch.RequestInit) {
|
|
|
109
119
|
if (resp.status !== 200) {
|
|
110
120
|
const message = json?.message || resp.statusText || `HTTP ${resp.status}`;
|
|
111
121
|
if (resp.status === 401) {
|
|
112
|
-
throw createRequestError(t('loginExpired'), fullUrl);
|
|
122
|
+
throw createRequestError(t('loginExpired'), fullUrl, resp.status);
|
|
113
123
|
}
|
|
114
|
-
throw createRequestError(message, fullUrl);
|
|
124
|
+
throw createRequestError(message, fullUrl, resp.status);
|
|
115
125
|
}
|
|
116
126
|
return json;
|
|
117
127
|
}
|
|
@@ -166,13 +176,11 @@ export async function uploadFile(fn: string, key?: string) {
|
|
|
166
176
|
if (global.USE_ACC_OSS) {
|
|
167
177
|
realUrl = backupUrl;
|
|
168
178
|
} else {
|
|
169
|
-
const
|
|
170
|
-
address: url.replace('https://', ''),
|
|
179
|
+
const latency = await measureTcpLatency(url, {
|
|
171
180
|
attempts: 4,
|
|
172
181
|
timeout: 1000,
|
|
173
182
|
});
|
|
174
|
-
|
|
175
|
-
if (Number.isNaN(pingResult.avg) || pingResult.avg > 150) {
|
|
183
|
+
if (!Number.isFinite(latency) || latency > 150) {
|
|
176
184
|
realUrl = backupUrl;
|
|
177
185
|
}
|
|
178
186
|
}
|
package/src/app.ts
CHANGED
|
@@ -11,8 +11,6 @@ interface AppSummary {
|
|
|
11
11
|
platform: Platform;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const validPlatforms = ['ios', 'android', 'harmony'] as const;
|
|
15
|
-
|
|
16
14
|
export async function getPlatform(platform?: string) {
|
|
17
15
|
return assertPlatform(
|
|
18
16
|
platform || (await question(t('platformQuestion'))),
|
|
@@ -20,7 +18,7 @@ export async function getPlatform(platform?: string) {
|
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
export function assertPlatform(platform: string): Platform {
|
|
23
|
-
if (
|
|
21
|
+
if (platform !== 'ios' && platform !== 'android' && platform !== 'harmony') {
|
|
24
22
|
throw new Error(t('unsupportedPlatform', { platform }));
|
|
25
23
|
}
|
|
26
24
|
return platform as Platform;
|
|
@@ -121,40 +119,42 @@ async function selectApp({
|
|
|
121
119
|
);
|
|
122
120
|
}
|
|
123
121
|
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
122
|
+
export function getAppCommands() {
|
|
123
|
+
return {
|
|
124
|
+
createApp: async ({
|
|
125
|
+
options,
|
|
126
|
+
}: {
|
|
127
|
+
options: { name: string; downloadUrl: string; platform?: Platform | '' };
|
|
128
|
+
}) => {
|
|
129
|
+
const name = options.name || (await question(t('appNameQuestion')));
|
|
130
|
+
const { downloadUrl } = options;
|
|
131
|
+
const platform = await getPlatform(options.platform);
|
|
132
|
+
const { id } = await post('/app/create', { name, platform, downloadUrl });
|
|
133
|
+
console.log(t('createAppSuccess', { id }));
|
|
134
|
+
await selectApp({
|
|
135
|
+
args: [String(id)],
|
|
136
|
+
options: { platform },
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
deleteApp: async ({
|
|
140
|
+
args,
|
|
141
|
+
options,
|
|
142
|
+
}: {
|
|
143
|
+
args: string[];
|
|
144
|
+
options: { platform: Platform };
|
|
145
|
+
}) => {
|
|
146
|
+
const { platform } = options;
|
|
147
|
+
const id = args[0] || (await chooseApp(platform)).id;
|
|
148
|
+
if (!id) {
|
|
149
|
+
console.log(t('cancelled'));
|
|
150
|
+
}
|
|
151
|
+
await doDelete(`/app/${id}`);
|
|
152
|
+
console.log(t('operationSuccess'));
|
|
153
|
+
},
|
|
154
|
+
apps: async ({ options }: { options: { platform?: Platform | '' } }) => {
|
|
155
|
+
const { platform = '' } = options;
|
|
156
|
+
return listApp(platform);
|
|
157
|
+
},
|
|
158
|
+
selectApp,
|
|
159
|
+
};
|
|
160
|
+
}
|
package/src/bin.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { loadSession } from './api';
|
|
4
|
+
import { getAppCommands } from './app';
|
|
5
|
+
import { bundleCommands } from './bundle';
|
|
6
|
+
import { diffCommands } from './diff';
|
|
7
|
+
import { installCommands } from './install';
|
|
8
|
+
import { packageCommands } from './package';
|
|
9
|
+
import { userCommands } from './user';
|
|
10
|
+
import { printVersionCommand } from './utils';
|
|
11
|
+
import { t } from './utils/i18n';
|
|
12
|
+
import { versionCommands } from './versions';
|
|
13
|
+
|
|
14
|
+
type CliCommandHandler = (argv: any) => Promise<unknown> | unknown;
|
|
15
|
+
|
|
16
|
+
interface CliArgv {
|
|
17
|
+
command: string;
|
|
18
|
+
args: string[];
|
|
19
|
+
options: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isTruthyEnv(value: string | undefined): boolean {
|
|
23
|
+
return value === '1' || value?.toLowerCase() === 'true';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function printUsage(exitCode = 1) {
|
|
27
|
+
console.log('React Native Update CLI');
|
|
28
|
+
console.log('');
|
|
29
|
+
console.log('Commands:');
|
|
30
|
+
for (const name of Object.keys(commandHandlers)) {
|
|
31
|
+
console.log(` ${name}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
console.log('');
|
|
35
|
+
console.log('Special commands:');
|
|
36
|
+
console.log(' list: List all available commands');
|
|
37
|
+
console.log(' help: Show this help message');
|
|
38
|
+
|
|
39
|
+
console.log('');
|
|
40
|
+
console.log(
|
|
41
|
+
'Visit `https://github.com/reactnativecn/react-native-update` for document.',
|
|
42
|
+
);
|
|
43
|
+
process.exit(exitCode);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const commandHandlers: Record<string, CliCommandHandler> = {
|
|
47
|
+
...userCommands,
|
|
48
|
+
...bundleCommands,
|
|
49
|
+
...diffCommands,
|
|
50
|
+
...getAppCommands(),
|
|
51
|
+
...packageCommands,
|
|
52
|
+
...versionCommands,
|
|
53
|
+
...installCommands,
|
|
54
|
+
help: printUsage,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
async function run() {
|
|
58
|
+
await printVersionCommand();
|
|
59
|
+
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
|
60
|
+
process.exit();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const argv: CliArgv = require('cli-arguments').parse(require('../cli.json'));
|
|
64
|
+
global.NO_INTERACTIVE =
|
|
65
|
+
Boolean(argv.options['no-interactive']) ||
|
|
66
|
+
isTruthyEnv(process.env.NO_INTERACTIVE);
|
|
67
|
+
global.USE_ACC_OSS =
|
|
68
|
+
Boolean(argv.options.acc) || isTruthyEnv(process.env.USE_ACC_OSS);
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
await loadSession();
|
|
72
|
+
|
|
73
|
+
if (argv.command === 'help') {
|
|
74
|
+
printUsage(0);
|
|
75
|
+
} else if (argv.command === 'list') {
|
|
76
|
+
printUsage(0);
|
|
77
|
+
} else if (commandHandlers[argv.command]) {
|
|
78
|
+
const handler = commandHandlers[argv.command];
|
|
79
|
+
await handler(argv);
|
|
80
|
+
} else {
|
|
81
|
+
throw new Error(`Unknown command: ${argv.command}`);
|
|
82
|
+
}
|
|
83
|
+
} catch (err: any) {
|
|
84
|
+
if (err.status === 401) {
|
|
85
|
+
console.log(t('loginFirst'));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
console.error(err.stack);
|
|
89
|
+
process.exit(-1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
run();
|
package/src/bundle-runner.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
2
|
import { satisfies } from 'compare-versions';
|
|
3
3
|
import * as fs from 'fs-extra';
|
|
4
4
|
import os from 'os';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { t } from './utils/i18n';
|
|
7
|
+
import {
|
|
8
|
+
getJavaScriptRuntime,
|
|
9
|
+
spawnJavaScript,
|
|
10
|
+
spawnJavaScriptSync,
|
|
11
|
+
} from './utils/runtime';
|
|
7
12
|
|
|
8
13
|
const g2js = require('gradle-to-js/lib/parser');
|
|
9
14
|
const properties = require('properties');
|
|
@@ -39,6 +44,12 @@ const dependencyFields = [
|
|
|
39
44
|
'optionalDependencies',
|
|
40
45
|
] as const;
|
|
41
46
|
|
|
47
|
+
type SyncProcessResult = {
|
|
48
|
+
status: number | null;
|
|
49
|
+
signal: NodeJS.Signals | null;
|
|
50
|
+
error?: Error;
|
|
51
|
+
};
|
|
52
|
+
|
|
42
53
|
type ResolvedExpoCli = {
|
|
43
54
|
cliPath: string;
|
|
44
55
|
usingExpo: boolean;
|
|
@@ -242,9 +253,10 @@ export async function runReactNativeBundleCommand({
|
|
|
242
253
|
reactNativeBundleArgs.push('--config', config);
|
|
243
254
|
}
|
|
244
255
|
|
|
245
|
-
const
|
|
256
|
+
const jsRuntime = getJavaScriptRuntime();
|
|
257
|
+
const reactNativeBundleProcess = spawnJavaScript(reactNativeBundleArgs);
|
|
246
258
|
console.log(
|
|
247
|
-
`Running bundle command:
|
|
259
|
+
`Running bundle command: ${jsRuntime} ${reactNativeBundleArgs.join(' ')}`,
|
|
248
260
|
);
|
|
249
261
|
|
|
250
262
|
await new Promise<void>((resolve, reject) => {
|
|
@@ -331,6 +343,93 @@ function getHermesOSBin() {
|
|
|
331
343
|
if (os.platform() === 'linux') return 'linux64-bin';
|
|
332
344
|
}
|
|
333
345
|
|
|
346
|
+
function getHermesExecutableName() {
|
|
347
|
+
return os.platform() === 'win32' ? 'hermesc.exe' : 'hermesc';
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function dirnameOfPackage(
|
|
351
|
+
packageJsonPath: string,
|
|
352
|
+
projectRoot = process.cwd(),
|
|
353
|
+
) {
|
|
354
|
+
return path.dirname(
|
|
355
|
+
require.resolve(packageJsonPath, {
|
|
356
|
+
paths: [projectRoot],
|
|
357
|
+
}),
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function assertSuccessfulSyncProcess(
|
|
362
|
+
result: SyncProcessResult,
|
|
363
|
+
command: string,
|
|
364
|
+
) {
|
|
365
|
+
if (result.error) {
|
|
366
|
+
throw result.error;
|
|
367
|
+
}
|
|
368
|
+
if (result.status !== 0) {
|
|
369
|
+
throw new Error(
|
|
370
|
+
`${command} failed with ${
|
|
371
|
+
result.status === null
|
|
372
|
+
? `signal ${result.signal}`
|
|
373
|
+
: `exit code ${result.status}`
|
|
374
|
+
}`,
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export function resolveHermesCommand(projectRoot = process.cwd()): string {
|
|
380
|
+
const osBin = getHermesOSBin();
|
|
381
|
+
if (!osBin) {
|
|
382
|
+
throw new Error(`Unsupported platform for Hermes: ${os.platform()}`);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const executableName = getHermesExecutableName();
|
|
386
|
+
const candidates: string[] = [];
|
|
387
|
+
|
|
388
|
+
try {
|
|
389
|
+
const rnDir = dirnameOfPackage('react-native/package.json', projectRoot);
|
|
390
|
+
candidates.push(path.join(rnDir, 'sdks', 'hermesc', osBin, executableName));
|
|
391
|
+
} catch {
|
|
392
|
+
// react-native is required for normal RN projects; keep looking so the
|
|
393
|
+
// final error can include all candidates we were able to infer.
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
try {
|
|
397
|
+
const hermesCompilerDir = dirnameOfPackage(
|
|
398
|
+
'hermes-compiler/package.json',
|
|
399
|
+
projectRoot,
|
|
400
|
+
);
|
|
401
|
+
candidates.push(
|
|
402
|
+
path.join(hermesCompilerDir, 'hermesc', osBin, executableName),
|
|
403
|
+
);
|
|
404
|
+
} catch {
|
|
405
|
+
// RN 0.85+ uses hermes-compiler, older projects may still use other paths.
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
try {
|
|
409
|
+
const hermesEngineDir = dirnameOfPackage(
|
|
410
|
+
'hermes-engine/package.json',
|
|
411
|
+
projectRoot,
|
|
412
|
+
);
|
|
413
|
+
candidates.push(
|
|
414
|
+
path.join(hermesEngineDir, osBin, executableName),
|
|
415
|
+
path.join(hermesEngineDir, 'hermesc', osBin, executableName),
|
|
416
|
+
);
|
|
417
|
+
} catch {
|
|
418
|
+
// RN 0.70-era projects commonly used hermes-engine; optional for newer RN.
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const hermesCommand = candidates.find((candidate) =>
|
|
422
|
+
fs.existsSync(candidate),
|
|
423
|
+
);
|
|
424
|
+
if (hermesCommand) {
|
|
425
|
+
return hermesCommand;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
throw new Error(
|
|
429
|
+
`Cannot find hermesc. Tried:\n${candidates.map((candidate) => `- ${candidate}`).join('\n')}`,
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
334
433
|
async function checkGradleConfig(): Promise<GradleConfig> {
|
|
335
434
|
let enableHermes = false;
|
|
336
435
|
let crunchPngs: boolean | undefined;
|
|
@@ -365,18 +464,7 @@ async function compileHermesByteCode(
|
|
|
365
464
|
shouldCleanSourcemap: boolean,
|
|
366
465
|
) {
|
|
367
466
|
console.log(t('hermesEnabledCompiling'));
|
|
368
|
-
const
|
|
369
|
-
require.resolve('react-native', {
|
|
370
|
-
paths: [process.cwd()],
|
|
371
|
-
}),
|
|
372
|
-
);
|
|
373
|
-
let hermesPath = path.join(rnDir, `/sdks/hermesc/${getHermesOSBin()}`);
|
|
374
|
-
|
|
375
|
-
if (!fs.existsSync(hermesPath)) {
|
|
376
|
-
hermesPath = `node_modules/hermes-engine/${getHermesOSBin()}`;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const hermesCommand = `${hermesPath}/hermesc`;
|
|
467
|
+
const hermesCommand = resolveHermesCommand();
|
|
380
468
|
|
|
381
469
|
const args = [
|
|
382
470
|
'-emit-binary',
|
|
@@ -395,9 +483,12 @@ async function compileHermesByteCode(
|
|
|
395
483
|
console.log(
|
|
396
484
|
t('runningHermesc', { command: hermesCommand, args: args.join(' ') }),
|
|
397
485
|
);
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
486
|
+
assertSuccessfulSyncProcess(
|
|
487
|
+
spawnSync(hermesCommand, args, {
|
|
488
|
+
stdio: 'ignore',
|
|
489
|
+
}),
|
|
490
|
+
hermesCommand,
|
|
491
|
+
);
|
|
401
492
|
if (sourcemapOutput) {
|
|
402
493
|
const composerPath =
|
|
403
494
|
'node_modules/react-native/scripts/compose-source-maps.js';
|
|
@@ -405,18 +496,20 @@ async function compileHermesByteCode(
|
|
|
405
496
|
return;
|
|
406
497
|
}
|
|
407
498
|
console.log(t('composingSourceMap'));
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
499
|
+
assertSuccessfulSyncProcess(
|
|
500
|
+
spawnJavaScriptSync(
|
|
501
|
+
[
|
|
502
|
+
composerPath,
|
|
503
|
+
path.join(outputFolder, `${bundleName}.txt.map`),
|
|
504
|
+
path.join(outputFolder, `${bundleName}.map`),
|
|
505
|
+
'-o',
|
|
506
|
+
sourcemapOutput,
|
|
507
|
+
],
|
|
508
|
+
{
|
|
509
|
+
stdio: 'ignore',
|
|
510
|
+
},
|
|
511
|
+
),
|
|
512
|
+
composerPath,
|
|
420
513
|
);
|
|
421
514
|
}
|
|
422
515
|
if (shouldCleanSourcemap) {
|
|
@@ -447,16 +540,18 @@ export async function copyDebugidForSentry(
|
|
|
447
540
|
return;
|
|
448
541
|
}
|
|
449
542
|
console.log(t('copyingDebugId'));
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
543
|
+
assertSuccessfulSyncProcess(
|
|
544
|
+
spawnJavaScriptSync(
|
|
545
|
+
[
|
|
546
|
+
copyDebugidPath,
|
|
547
|
+
path.join(outputFolder, `${bundleName}.txt.map`),
|
|
548
|
+
path.join(outputFolder, `${bundleName}.map`),
|
|
549
|
+
],
|
|
550
|
+
{
|
|
551
|
+
stdio: 'ignore',
|
|
552
|
+
},
|
|
553
|
+
),
|
|
554
|
+
copyDebugidPath,
|
|
460
555
|
);
|
|
461
556
|
}
|
|
462
557
|
fs.removeSync(path.join(outputFolder, `${bundleName}.txt.map`));
|
|
@@ -486,31 +581,35 @@ export async function uploadSourcemapForSentry(
|
|
|
486
581
|
return;
|
|
487
582
|
}
|
|
488
583
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
584
|
+
assertSuccessfulSyncProcess(
|
|
585
|
+
spawnJavaScriptSync(
|
|
586
|
+
[sentryCliPath, 'releases', 'set-commits', version, '--auto'],
|
|
587
|
+
{
|
|
588
|
+
stdio: 'inherit',
|
|
589
|
+
},
|
|
590
|
+
),
|
|
591
|
+
sentryCliPath,
|
|
495
592
|
);
|
|
496
593
|
console.log(t('sentryReleaseCreated', { version }));
|
|
497
594
|
|
|
498
595
|
console.log(t('uploadingSourcemap'));
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
596
|
+
assertSuccessfulSyncProcess(
|
|
597
|
+
spawnJavaScriptSync(
|
|
598
|
+
[
|
|
599
|
+
sentryCliPath,
|
|
600
|
+
'releases',
|
|
601
|
+
'files',
|
|
602
|
+
version,
|
|
603
|
+
'upload-sourcemaps',
|
|
604
|
+
'--strip-prefix',
|
|
605
|
+
path.join(process.cwd(), outputFolder),
|
|
606
|
+
path.join(outputFolder, bundleName),
|
|
607
|
+
path.join(outputFolder, `${bundleName}.map`),
|
|
608
|
+
],
|
|
609
|
+
{
|
|
610
|
+
stdio: 'inherit',
|
|
611
|
+
},
|
|
612
|
+
),
|
|
613
|
+
sentryCliPath,
|
|
515
614
|
);
|
|
516
615
|
}
|
package/src/exports.ts
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
export { getSession, loadSession } from './api';
|
|
2
2
|
export { getPlatform, getSelectedApp } from './app';
|
|
3
3
|
export { diffCommands } from './diff';
|
|
4
|
-
export { moduleManager } from './module-manager';
|
|
5
|
-
export { builtinModules } from './modules';
|
|
6
|
-
export { appModule } from './modules/app-module';
|
|
7
|
-
export { bundleModule } from './modules/bundle-module';
|
|
8
|
-
export { packageModule } from './modules/package-module';
|
|
9
|
-
export { userModule } from './modules/user-module';
|
|
10
|
-
export { versionModule } from './modules/version-module';
|
|
11
4
|
export { CLIProviderImpl } from './provider';
|
|
12
5
|
export type {
|
|
13
6
|
BundleOptions,
|
|
14
|
-
CLIModule,
|
|
15
7
|
CLIProvider,
|
|
16
8
|
CommandContext,
|
|
17
|
-
CommandDefinition,
|
|
18
9
|
CommandResult,
|
|
19
10
|
Package,
|
|
20
11
|
Platform,
|
|
@@ -23,4 +14,4 @@ export type {
|
|
|
23
14
|
UploadOptions,
|
|
24
15
|
Version,
|
|
25
16
|
} from './types';
|
|
26
|
-
export { question
|
|
17
|
+
export { question } from './utils';
|