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/README.md
CHANGED
|
@@ -46,6 +46,8 @@ if (!bundleResult.success) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const publishResult = await provider.publish({
|
|
49
|
+
filePath: '.pushy/output/ios.ppk',
|
|
50
|
+
platform: 'ios',
|
|
49
51
|
name: 'v1.2.3',
|
|
50
52
|
description: 'Bug fixes and improvements',
|
|
51
53
|
rollout: 100,
|
|
@@ -125,6 +127,8 @@ interface CLIProvider {
|
|
|
125
127
|
|
|
126
128
|
## Environment Variables
|
|
127
129
|
|
|
130
|
+
`publish` requires a generated `.ppk` path via `filePath`. Provider list methods return data in `CommandResult.data` and do not enter interactive paging.
|
|
131
|
+
|
|
128
132
|
```bash
|
|
129
133
|
export PUSHY_REGISTRY=https://your-api-endpoint.com
|
|
130
134
|
export NO_INTERACTIVE=true
|
package/README.zh-CN.md
CHANGED
|
@@ -46,6 +46,8 @@ if (!bundleResult.success) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const publishResult = await provider.publish({
|
|
49
|
+
filePath: '.pushy/output/ios.ppk',
|
|
50
|
+
platform: 'ios',
|
|
49
51
|
name: 'v1.2.3',
|
|
50
52
|
description: 'Bug fixes and improvements',
|
|
51
53
|
rollout: 100,
|
|
@@ -125,6 +127,8 @@ interface CLIProvider {
|
|
|
125
127
|
|
|
126
128
|
## 环境变量
|
|
127
129
|
|
|
130
|
+
`publish` 需要通过 `filePath` 传入已生成的 `.ppk` 文件路径。Provider 的列表方法会把数据放在 `CommandResult.data`,不会进入交互式翻页。
|
|
131
|
+
|
|
128
132
|
```bash
|
|
129
133
|
export PUSHY_REGISTRY=https://your-api-endpoint.com
|
|
130
134
|
export NO_INTERACTIVE=true
|
package/cli.json
CHANGED
|
@@ -182,6 +182,9 @@
|
|
|
182
182
|
"platform": {
|
|
183
183
|
"hasValue": true
|
|
184
184
|
},
|
|
185
|
+
"appId": {
|
|
186
|
+
"hasValue": true
|
|
187
|
+
},
|
|
185
188
|
"versionId": {
|
|
186
189
|
"hasValue": true
|
|
187
190
|
},
|
|
@@ -342,6 +345,9 @@
|
|
|
342
345
|
"globalOptions": {
|
|
343
346
|
"no-interactive": {
|
|
344
347
|
"default": false
|
|
348
|
+
},
|
|
349
|
+
"acc": {
|
|
350
|
+
"default": false
|
|
345
351
|
}
|
|
346
352
|
}
|
|
347
353
|
}
|
package/lib/api.js
CHANGED
|
@@ -55,18 +55,16 @@ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
|
55
55
|
const _nodefetch = /*#__PURE__*/ _interop_require_default(require("node-fetch"));
|
|
56
56
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
57
57
|
const _progress = /*#__PURE__*/ _interop_require_default(require("progress"));
|
|
58
|
-
const _tcpping = /*#__PURE__*/ _interop_require_default(require("tcp-ping"));
|
|
59
|
-
const _util = /*#__PURE__*/ _interop_require_default(require("util"));
|
|
60
58
|
const _httphelper = require("./utils/http-helper");
|
|
61
59
|
const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
|
|
62
60
|
const _constants = require("./utils/constants");
|
|
63
61
|
const _i18n = require("./utils/i18n");
|
|
62
|
+
const _runtime = require("./utils/runtime");
|
|
64
63
|
function _interop_require_default(obj) {
|
|
65
64
|
return obj && obj.__esModule ? obj : {
|
|
66
65
|
default: obj
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
|
-
const tcpPing = _util.default.promisify(_tcpping.default.ping);
|
|
70
68
|
let session;
|
|
71
69
|
let savedSession;
|
|
72
70
|
let apiToken;
|
|
@@ -114,16 +112,18 @@ const closeSession = ()=>{
|
|
|
114
112
|
}
|
|
115
113
|
session = undefined;
|
|
116
114
|
};
|
|
117
|
-
function createRequestError(error, requestUrl) {
|
|
115
|
+
function createRequestError(error, requestUrl, status) {
|
|
118
116
|
const message = typeof error === 'string' ? error : error instanceof Error ? error.message : String(error);
|
|
119
|
-
|
|
117
|
+
const requestError = new Error(`${message}\nURL: ${requestUrl}`);
|
|
118
|
+
requestError.status = status;
|
|
119
|
+
return requestError;
|
|
120
120
|
}
|
|
121
121
|
async function query(url, options) {
|
|
122
122
|
const baseUrl = await _httphelper.getBaseUrl;
|
|
123
123
|
const fullUrl = `${baseUrl}${url}`;
|
|
124
124
|
let resp;
|
|
125
125
|
try {
|
|
126
|
-
resp = await (0,
|
|
126
|
+
resp = await (0, _runtime.runtimeFetch)(fullUrl, options);
|
|
127
127
|
} catch (error) {
|
|
128
128
|
throw createRequestError(error, fullUrl);
|
|
129
129
|
}
|
|
@@ -139,9 +139,9 @@ async function query(url, options) {
|
|
|
139
139
|
if (resp.status !== 200) {
|
|
140
140
|
const message = (json == null ? void 0 : json.message) || resp.statusText || `HTTP ${resp.status}`;
|
|
141
141
|
if (resp.status === 401) {
|
|
142
|
-
throw createRequestError((0, _i18n.t)('loginExpired'), fullUrl);
|
|
142
|
+
throw createRequestError((0, _i18n.t)('loginExpired'), fullUrl, resp.status);
|
|
143
143
|
}
|
|
144
|
-
throw createRequestError(message, fullUrl);
|
|
144
|
+
throw createRequestError(message, fullUrl, resp.status);
|
|
145
145
|
}
|
|
146
146
|
return json;
|
|
147
147
|
}
|
|
@@ -192,13 +192,11 @@ async function uploadFile(fn, key) {
|
|
|
192
192
|
if (global.USE_ACC_OSS) {
|
|
193
193
|
realUrl = backupUrl;
|
|
194
194
|
} else {
|
|
195
|
-
const
|
|
196
|
-
address: url.replace('https://', ''),
|
|
195
|
+
const latency = await (0, _runtime.measureTcpLatency)(url, {
|
|
197
196
|
attempts: 4,
|
|
198
197
|
timeout: 1000
|
|
199
198
|
});
|
|
200
|
-
|
|
201
|
-
if (Number.isNaN(pingResult.avg) || pingResult.avg > 150) {
|
|
199
|
+
if (!Number.isFinite(latency) || latency > 150) {
|
|
202
200
|
realUrl = backupUrl;
|
|
203
201
|
}
|
|
204
202
|
}
|
package/lib/app.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ declare function selectApp({ args, options, }: {
|
|
|
19
19
|
platform?: Platform | '';
|
|
20
20
|
};
|
|
21
21
|
}): Promise<void>;
|
|
22
|
-
export declare
|
|
22
|
+
export declare function getAppCommands(): {
|
|
23
23
|
createApp: ({ options, }: {
|
|
24
24
|
options: {
|
|
25
25
|
name: string;
|
|
@@ -37,7 +37,7 @@ export declare const appCommands: {
|
|
|
37
37
|
options: {
|
|
38
38
|
platform?: Platform | "";
|
|
39
39
|
};
|
|
40
|
-
}) => Promise<
|
|
40
|
+
}) => Promise<AppSummary[]>;
|
|
41
41
|
selectApp: typeof selectApp;
|
|
42
42
|
};
|
|
43
43
|
export {};
|
package/lib/app.js
CHANGED
|
@@ -9,15 +9,15 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
get appCommands () {
|
|
13
|
-
return appCommands;
|
|
14
|
-
},
|
|
15
12
|
get assertPlatform () {
|
|
16
13
|
return assertPlatform;
|
|
17
14
|
},
|
|
18
15
|
get chooseApp () {
|
|
19
16
|
return chooseApp;
|
|
20
17
|
},
|
|
18
|
+
get getAppCommands () {
|
|
19
|
+
return getAppCommands;
|
|
20
|
+
},
|
|
21
21
|
get getPlatform () {
|
|
22
22
|
return getPlatform;
|
|
23
23
|
},
|
|
@@ -38,16 +38,11 @@ function _interop_require_default(obj) {
|
|
|
38
38
|
default: obj
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
const validPlatforms = [
|
|
42
|
-
'ios',
|
|
43
|
-
'android',
|
|
44
|
-
'harmony'
|
|
45
|
-
];
|
|
46
41
|
async function getPlatform(platform) {
|
|
47
42
|
return assertPlatform(platform || await (0, _utils.question)((0, _i18n.t)('platformQuestion')));
|
|
48
43
|
}
|
|
49
44
|
function assertPlatform(platform) {
|
|
50
|
-
if (
|
|
45
|
+
if (platform !== 'ios' && platform !== 'android' && platform !== 'harmony') {
|
|
51
46
|
throw new Error((0, _i18n.t)('unsupportedPlatform', {
|
|
52
47
|
platform
|
|
53
48
|
}));
|
|
@@ -138,40 +133,42 @@ async function selectApp({ args, options }) {
|
|
|
138
133
|
};
|
|
139
134
|
await _fs.default.promises.writeFile('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
|
|
140
135
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
136
|
+
function getAppCommands() {
|
|
137
|
+
return {
|
|
138
|
+
createApp: async ({ options })=>{
|
|
139
|
+
const name = options.name || await (0, _utils.question)((0, _i18n.t)('appNameQuestion'));
|
|
140
|
+
const { downloadUrl } = options;
|
|
141
|
+
const platform = await getPlatform(options.platform);
|
|
142
|
+
const { id } = await (0, _api.post)('/app/create', {
|
|
143
|
+
name,
|
|
144
|
+
platform,
|
|
145
|
+
downloadUrl
|
|
146
|
+
});
|
|
147
|
+
console.log((0, _i18n.t)('createAppSuccess', {
|
|
148
|
+
id
|
|
149
|
+
}));
|
|
150
|
+
await selectApp({
|
|
151
|
+
args: [
|
|
152
|
+
String(id)
|
|
153
|
+
],
|
|
154
|
+
options: {
|
|
155
|
+
platform
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
deleteApp: async ({ args, options })=>{
|
|
160
|
+
const { platform } = options;
|
|
161
|
+
const id = args[0] || (await chooseApp(platform)).id;
|
|
162
|
+
if (!id) {
|
|
163
|
+
console.log((0, _i18n.t)('cancelled'));
|
|
160
164
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
},
|
|
172
|
-
apps: async ({ options })=>{
|
|
173
|
-
const { platform = '' } = options;
|
|
174
|
-
await listApp(platform);
|
|
175
|
-
},
|
|
176
|
-
selectApp
|
|
177
|
-
};
|
|
165
|
+
await (0, _api.doDelete)(`/app/${id}`);
|
|
166
|
+
console.log((0, _i18n.t)('operationSuccess'));
|
|
167
|
+
},
|
|
168
|
+
apps: async ({ options })=>{
|
|
169
|
+
const { platform = '' } = options;
|
|
170
|
+
return listApp(platform);
|
|
171
|
+
},
|
|
172
|
+
selectApp
|
|
173
|
+
};
|
|
174
|
+
}
|
package/lib/bin.d.ts
ADDED
package/lib/bin.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
const _api = require("./api");
|
|
7
|
+
const _app = require("./app");
|
|
8
|
+
const _bundle = require("./bundle");
|
|
9
|
+
const _diff = require("./diff");
|
|
10
|
+
const _install = require("./install");
|
|
11
|
+
const _package = require("./package");
|
|
12
|
+
const _user = require("./user");
|
|
13
|
+
const _utils = require("./utils");
|
|
14
|
+
const _i18n = require("./utils/i18n");
|
|
15
|
+
const _versions = require("./versions");
|
|
16
|
+
function isTruthyEnv(value) {
|
|
17
|
+
return value === '1' || (value == null ? void 0 : value.toLowerCase()) === 'true';
|
|
18
|
+
}
|
|
19
|
+
function printUsage(exitCode = 1) {
|
|
20
|
+
console.log('React Native Update CLI');
|
|
21
|
+
console.log('');
|
|
22
|
+
console.log('Commands:');
|
|
23
|
+
for (const name of Object.keys(commandHandlers)){
|
|
24
|
+
console.log(` ${name}`);
|
|
25
|
+
}
|
|
26
|
+
console.log('');
|
|
27
|
+
console.log('Special commands:');
|
|
28
|
+
console.log(' list: List all available commands');
|
|
29
|
+
console.log(' help: Show this help message');
|
|
30
|
+
console.log('');
|
|
31
|
+
console.log('Visit `https://github.com/reactnativecn/react-native-update` for document.');
|
|
32
|
+
process.exit(exitCode);
|
|
33
|
+
}
|
|
34
|
+
const commandHandlers = {
|
|
35
|
+
..._user.userCommands,
|
|
36
|
+
..._bundle.bundleCommands,
|
|
37
|
+
..._diff.diffCommands,
|
|
38
|
+
...(0, _app.getAppCommands)(),
|
|
39
|
+
..._package.packageCommands,
|
|
40
|
+
..._versions.versionCommands,
|
|
41
|
+
..._install.installCommands,
|
|
42
|
+
help: printUsage
|
|
43
|
+
};
|
|
44
|
+
async function run() {
|
|
45
|
+
await (0, _utils.printVersionCommand)();
|
|
46
|
+
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
|
47
|
+
process.exit();
|
|
48
|
+
}
|
|
49
|
+
const argv = require('cli-arguments').parse(require('../cli.json'));
|
|
50
|
+
global.NO_INTERACTIVE = Boolean(argv.options['no-interactive']) || isTruthyEnv(process.env.NO_INTERACTIVE);
|
|
51
|
+
global.USE_ACC_OSS = Boolean(argv.options.acc) || isTruthyEnv(process.env.USE_ACC_OSS);
|
|
52
|
+
try {
|
|
53
|
+
await (0, _api.loadSession)();
|
|
54
|
+
if (argv.command === 'help') {
|
|
55
|
+
printUsage(0);
|
|
56
|
+
} else if (argv.command === 'list') {
|
|
57
|
+
printUsage(0);
|
|
58
|
+
} else if (commandHandlers[argv.command]) {
|
|
59
|
+
const handler = commandHandlers[argv.command];
|
|
60
|
+
await handler(argv);
|
|
61
|
+
} else {
|
|
62
|
+
throw new Error(`Unknown command: ${argv.command}`);
|
|
63
|
+
}
|
|
64
|
+
} catch (err) {
|
|
65
|
+
if (err.status === 401) {
|
|
66
|
+
console.log((0, _i18n.t)('loginFirst'));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
console.error(err.stack);
|
|
70
|
+
process.exit(-1);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
run();
|
package/lib/bundle-runner.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ type ResolvedExpoCli = {
|
|
|
22
22
|
export declare function hasProjectDependency(dependencyName: string, projectRoot?: string): boolean;
|
|
23
23
|
export declare function resolveExpoCli(projectRoot?: string): ResolvedExpoCli;
|
|
24
24
|
export declare function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli, isSentry, }: RunBundleCommandOptions): Promise<void>;
|
|
25
|
+
export declare function resolveHermesCommand(projectRoot?: string): string;
|
|
25
26
|
export declare function copyDebugidForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string): Promise<void>;
|
|
26
27
|
export declare function uploadSourcemapForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string, version: string): Promise<void>;
|
|
27
28
|
export {};
|
package/lib/bundle-runner.js
CHANGED
|
@@ -18,6 +18,9 @@ _export(exports, {
|
|
|
18
18
|
get resolveExpoCli () {
|
|
19
19
|
return resolveExpoCli;
|
|
20
20
|
},
|
|
21
|
+
get resolveHermesCommand () {
|
|
22
|
+
return resolveHermesCommand;
|
|
23
|
+
},
|
|
21
24
|
get runReactNativeBundleCommand () {
|
|
22
25
|
return runReactNativeBundleCommand;
|
|
23
26
|
},
|
|
@@ -31,6 +34,7 @@ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
|
31
34
|
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
32
35
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
33
36
|
const _i18n = require("./utils/i18n");
|
|
37
|
+
const _runtime = require("./utils/runtime");
|
|
34
38
|
function _interop_require_default(obj) {
|
|
35
39
|
return obj && obj.__esModule ? obj : {
|
|
36
40
|
default: obj
|
|
@@ -239,8 +243,9 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
|
|
|
239
243
|
if (config) {
|
|
240
244
|
reactNativeBundleArgs.push('--config', config);
|
|
241
245
|
}
|
|
242
|
-
const
|
|
243
|
-
|
|
246
|
+
const jsRuntime = (0, _runtime.getJavaScriptRuntime)();
|
|
247
|
+
const reactNativeBundleProcess = (0, _runtime.spawnJavaScript)(reactNativeBundleArgs);
|
|
248
|
+
console.log(`Running bundle command: ${jsRuntime} ${reactNativeBundleArgs.join(' ')}`);
|
|
244
249
|
await new Promise((resolve, reject)=>{
|
|
245
250
|
reactNativeBundleProcess.stdout.on('data', (data)=>{
|
|
246
251
|
console.log(data.toString().trim());
|
|
@@ -301,6 +306,56 @@ function getHermesOSBin() {
|
|
|
301
306
|
if (_os.default.platform() === 'darwin') return 'osx-bin';
|
|
302
307
|
if (_os.default.platform() === 'linux') return 'linux64-bin';
|
|
303
308
|
}
|
|
309
|
+
function getHermesExecutableName() {
|
|
310
|
+
return _os.default.platform() === 'win32' ? 'hermesc.exe' : 'hermesc';
|
|
311
|
+
}
|
|
312
|
+
function dirnameOfPackage(packageJsonPath, projectRoot = process.cwd()) {
|
|
313
|
+
return _path.default.dirname(require.resolve(packageJsonPath, {
|
|
314
|
+
paths: [
|
|
315
|
+
projectRoot
|
|
316
|
+
]
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
function assertSuccessfulSyncProcess(result, command) {
|
|
320
|
+
if (result.error) {
|
|
321
|
+
throw result.error;
|
|
322
|
+
}
|
|
323
|
+
if (result.status !== 0) {
|
|
324
|
+
throw new Error(`${command} failed with ${result.status === null ? `signal ${result.signal}` : `exit code ${result.status}`}`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function resolveHermesCommand(projectRoot = process.cwd()) {
|
|
328
|
+
const osBin = getHermesOSBin();
|
|
329
|
+
if (!osBin) {
|
|
330
|
+
throw new Error(`Unsupported platform for Hermes: ${_os.default.platform()}`);
|
|
331
|
+
}
|
|
332
|
+
const executableName = getHermesExecutableName();
|
|
333
|
+
const candidates = [];
|
|
334
|
+
try {
|
|
335
|
+
const rnDir = dirnameOfPackage('react-native/package.json', projectRoot);
|
|
336
|
+
candidates.push(_path.default.join(rnDir, 'sdks', 'hermesc', osBin, executableName));
|
|
337
|
+
} catch (unused) {
|
|
338
|
+
// react-native is required for normal RN projects; keep looking so the
|
|
339
|
+
// final error can include all candidates we were able to infer.
|
|
340
|
+
}
|
|
341
|
+
try {
|
|
342
|
+
const hermesCompilerDir = dirnameOfPackage('hermes-compiler/package.json', projectRoot);
|
|
343
|
+
candidates.push(_path.default.join(hermesCompilerDir, 'hermesc', osBin, executableName));
|
|
344
|
+
} catch (unused) {
|
|
345
|
+
// RN 0.85+ uses hermes-compiler, older projects may still use other paths.
|
|
346
|
+
}
|
|
347
|
+
try {
|
|
348
|
+
const hermesEngineDir = dirnameOfPackage('hermes-engine/package.json', projectRoot);
|
|
349
|
+
candidates.push(_path.default.join(hermesEngineDir, osBin, executableName), _path.default.join(hermesEngineDir, 'hermesc', osBin, executableName));
|
|
350
|
+
} catch (unused) {
|
|
351
|
+
// RN 0.70-era projects commonly used hermes-engine; optional for newer RN.
|
|
352
|
+
}
|
|
353
|
+
const hermesCommand = candidates.find((candidate)=>_fsextra.existsSync(candidate));
|
|
354
|
+
if (hermesCommand) {
|
|
355
|
+
return hermesCommand;
|
|
356
|
+
}
|
|
357
|
+
throw new Error(`Cannot find hermesc. Tried:\n${candidates.map((candidate)=>`- ${candidate}`).join('\n')}`);
|
|
358
|
+
}
|
|
304
359
|
async function checkGradleConfig() {
|
|
305
360
|
let enableHermes = false;
|
|
306
361
|
let crunchPngs;
|
|
@@ -326,16 +381,7 @@ async function checkGradleConfig() {
|
|
|
326
381
|
}
|
|
327
382
|
async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput, shouldCleanSourcemap) {
|
|
328
383
|
console.log((0, _i18n.t)('hermesEnabledCompiling'));
|
|
329
|
-
const
|
|
330
|
-
paths: [
|
|
331
|
-
process.cwd()
|
|
332
|
-
]
|
|
333
|
-
}));
|
|
334
|
-
let hermesPath = _path.default.join(rnDir, `/sdks/hermesc/${getHermesOSBin()}`);
|
|
335
|
-
if (!_fsextra.existsSync(hermesPath)) {
|
|
336
|
-
hermesPath = `node_modules/hermes-engine/${getHermesOSBin()}`;
|
|
337
|
-
}
|
|
338
|
-
const hermesCommand = `${hermesPath}/hermesc`;
|
|
384
|
+
const hermesCommand = resolveHermesCommand();
|
|
339
385
|
const args = [
|
|
340
386
|
'-emit-binary',
|
|
341
387
|
'-out',
|
|
@@ -351,16 +397,16 @@ async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput,
|
|
|
351
397
|
command: hermesCommand,
|
|
352
398
|
args: args.join(' ')
|
|
353
399
|
}));
|
|
354
|
-
(0, _child_process.spawnSync)(hermesCommand, args, {
|
|
400
|
+
assertSuccessfulSyncProcess((0, _child_process.spawnSync)(hermesCommand, args, {
|
|
355
401
|
stdio: 'ignore'
|
|
356
|
-
});
|
|
402
|
+
}), hermesCommand);
|
|
357
403
|
if (sourcemapOutput) {
|
|
358
404
|
const composerPath = 'node_modules/react-native/scripts/compose-source-maps.js';
|
|
359
405
|
if (!_fsextra.existsSync(composerPath)) {
|
|
360
406
|
return;
|
|
361
407
|
}
|
|
362
408
|
console.log((0, _i18n.t)('composingSourceMap'));
|
|
363
|
-
(0,
|
|
409
|
+
assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)([
|
|
364
410
|
composerPath,
|
|
365
411
|
_path.default.join(outputFolder, `${bundleName}.txt.map`),
|
|
366
412
|
_path.default.join(outputFolder, `${bundleName}.map`),
|
|
@@ -368,7 +414,7 @@ async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput,
|
|
|
368
414
|
sourcemapOutput
|
|
369
415
|
], {
|
|
370
416
|
stdio: 'ignore'
|
|
371
|
-
});
|
|
417
|
+
}), composerPath);
|
|
372
418
|
}
|
|
373
419
|
if (shouldCleanSourcemap) {
|
|
374
420
|
_fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
|
|
@@ -391,13 +437,13 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
|
|
|
391
437
|
return;
|
|
392
438
|
}
|
|
393
439
|
console.log((0, _i18n.t)('copyingDebugId'));
|
|
394
|
-
(0,
|
|
440
|
+
assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)([
|
|
395
441
|
copyDebugidPath,
|
|
396
442
|
_path.default.join(outputFolder, `${bundleName}.txt.map`),
|
|
397
443
|
_path.default.join(outputFolder, `${bundleName}.map`)
|
|
398
444
|
], {
|
|
399
445
|
stdio: 'ignore'
|
|
400
|
-
});
|
|
446
|
+
}), copyDebugidPath);
|
|
401
447
|
}
|
|
402
448
|
_fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
|
|
403
449
|
}
|
|
@@ -419,7 +465,7 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
419
465
|
if (!_fsextra.existsSync(sentryCliPath)) {
|
|
420
466
|
return;
|
|
421
467
|
}
|
|
422
|
-
(0,
|
|
468
|
+
assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)([
|
|
423
469
|
sentryCliPath,
|
|
424
470
|
'releases',
|
|
425
471
|
'set-commits',
|
|
@@ -427,12 +473,12 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
427
473
|
'--auto'
|
|
428
474
|
], {
|
|
429
475
|
stdio: 'inherit'
|
|
430
|
-
});
|
|
476
|
+
}), sentryCliPath);
|
|
431
477
|
console.log((0, _i18n.t)('sentryReleaseCreated', {
|
|
432
478
|
version
|
|
433
479
|
}));
|
|
434
480
|
console.log((0, _i18n.t)('uploadingSourcemap'));
|
|
435
|
-
(0,
|
|
481
|
+
assertSuccessfulSyncProcess((0, _runtime.spawnJavaScriptSync)([
|
|
436
482
|
sentryCliPath,
|
|
437
483
|
'releases',
|
|
438
484
|
'files',
|
|
@@ -444,5 +490,5 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
444
490
|
_path.default.join(outputFolder, `${bundleName}.map`)
|
|
445
491
|
], {
|
|
446
492
|
stdio: 'inherit'
|
|
447
|
-
});
|
|
493
|
+
}), sentryCliPath);
|
|
448
494
|
}
|
package/lib/exports.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
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
|
-
export type { BundleOptions,
|
|
13
|
-
export { question
|
|
5
|
+
export type { BundleOptions, CLIProvider, CommandContext, CommandResult, Package, Platform, PublishOptions, Session, UploadOptions, Version, } from './types';
|
|
6
|
+
export { question } from './utils';
|
package/lib/exports.js
CHANGED
|
@@ -12,15 +12,6 @@ _export(exports, {
|
|
|
12
12
|
get CLIProviderImpl () {
|
|
13
13
|
return _provider.CLIProviderImpl;
|
|
14
14
|
},
|
|
15
|
-
get appModule () {
|
|
16
|
-
return _appmodule.appModule;
|
|
17
|
-
},
|
|
18
|
-
get builtinModules () {
|
|
19
|
-
return _modules.builtinModules;
|
|
20
|
-
},
|
|
21
|
-
get bundleModule () {
|
|
22
|
-
return _bundlemodule.bundleModule;
|
|
23
|
-
},
|
|
24
15
|
get diffCommands () {
|
|
25
16
|
return _diff.diffCommands;
|
|
26
17
|
},
|
|
@@ -36,34 +27,12 @@ _export(exports, {
|
|
|
36
27
|
get loadSession () {
|
|
37
28
|
return _api.loadSession;
|
|
38
29
|
},
|
|
39
|
-
get moduleManager () {
|
|
40
|
-
return _modulemanager.moduleManager;
|
|
41
|
-
},
|
|
42
|
-
get packageModule () {
|
|
43
|
-
return _packagemodule.packageModule;
|
|
44
|
-
},
|
|
45
30
|
get question () {
|
|
46
31
|
return _utils.question;
|
|
47
|
-
},
|
|
48
|
-
get saveToLocal () {
|
|
49
|
-
return _utils.saveToLocal;
|
|
50
|
-
},
|
|
51
|
-
get userModule () {
|
|
52
|
-
return _usermodule.userModule;
|
|
53
|
-
},
|
|
54
|
-
get versionModule () {
|
|
55
|
-
return _versionmodule.versionModule;
|
|
56
32
|
}
|
|
57
33
|
});
|
|
58
34
|
const _api = require("./api");
|
|
59
35
|
const _app = require("./app");
|
|
60
36
|
const _diff = require("./diff");
|
|
61
|
-
const _modulemanager = require("./module-manager");
|
|
62
|
-
const _modules = require("./modules");
|
|
63
|
-
const _appmodule = require("./modules/app-module");
|
|
64
|
-
const _bundlemodule = require("./modules/bundle-module");
|
|
65
|
-
const _packagemodule = require("./modules/package-module");
|
|
66
|
-
const _usermodule = require("./modules/user-module");
|
|
67
|
-
const _versionmodule = require("./modules/version-module");
|
|
68
37
|
const _provider = require("./provider");
|
|
69
38
|
const _utils = require("./utils");
|
package/lib/index.d.ts
CHANGED