react-native-update-cli 2.15.2 → 2.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.json +0 -6
- package/lib/api.js +25 -4
- package/lib/app.js +1 -0
- package/lib/bin-cresc.d.ts +1 -0
- package/lib/bin-cresc.js +7 -0
- package/lib/bin.js +5 -3
- package/lib/bundle-pack.d.ts +1 -1
- package/lib/bundle-pack.js +8 -7
- package/lib/bundle-runner.d.ts +3 -3
- package/lib/bundle-runner.js +68 -49
- package/lib/bundle.d.ts +26 -0
- package/lib/bundle.js +18 -6
- package/lib/diff.js +55 -70
- package/lib/install.js +30 -3
- package/lib/locales/en.d.ts +13 -0
- package/lib/locales/en.js +14 -1
- package/lib/locales/zh.d.ts +13 -0
- package/lib/locales/zh.js +14 -1
- package/lib/package.js +8 -2
- package/lib/provider.js +9 -3
- package/lib/types.d.ts +2 -2
- package/lib/utils/app-info-parser/aab.js +4 -4
- package/lib/utils/app-info-parser/xml-parser/binary.js +4 -3
- package/lib/utils/app-info-parser/xml-parser/manifest.js +3 -1
- package/lib/utils/app-info-parser/zip.d.ts +6 -0
- package/lib/utils/app-info-parser/zip.js +20 -5
- package/lib/utils/check-lockfile.js +5 -1
- package/lib/utils/constants.d.ts +1 -1
- package/lib/utils/constants.js +2 -1
- package/lib/utils/http-helper.js +20 -23
- package/lib/utils/index.js +48 -20
- package/lib/utils/zip-entries.js +4 -0
- package/lib/versions.d.ts +2 -0
- package/lib/versions.js +19 -8
- package/package.json +5 -5
- package/src/api.ts +30 -5
- package/src/app.ts +1 -0
- package/src/bin-cresc.ts +8 -0
- package/src/bin.ts +3 -3
- package/src/bundle-pack.ts +12 -7
- package/src/bundle-runner.ts +82 -56
- package/src/bundle.ts +13 -8
- package/src/diff.ts +87 -109
- package/src/install.ts +32 -3
- package/src/locales/en.ts +16 -0
- package/src/locales/zh.ts +15 -0
- package/src/package.ts +4 -4
- package/src/provider.ts +7 -3
- package/src/types.ts +3 -2
- package/src/utils/app-info-parser/aab.ts +4 -4
- package/src/utils/app-info-parser/xml-parser/binary.ts +4 -5
- package/src/utils/app-info-parser/xml-parser/manifest.ts +6 -3
- package/src/utils/app-info-parser/zip.ts +22 -5
- package/src/utils/check-lockfile.ts +5 -1
- package/src/utils/constants.ts +5 -1
- package/src/utils/http-helper.ts +16 -23
- package/src/utils/index.ts +51 -36
- package/src/utils/zip-entries.ts +4 -0
- package/src/versions.ts +15 -11
package/lib/install.js
CHANGED
|
@@ -10,23 +10,50 @@ Object.defineProperty(exports, "installCommands", {
|
|
|
10
10
|
});
|
|
11
11
|
const _child_process = require("child_process");
|
|
12
12
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
|
+
const _constants = require("./utils/constants");
|
|
14
|
+
const _i18n = require("./utils/i18n");
|
|
13
15
|
const _runtime = require("./utils/runtime");
|
|
14
16
|
function _interop_require_default(obj) {
|
|
15
17
|
return obj && obj.__esModule ? obj : {
|
|
16
18
|
default: obj
|
|
17
19
|
};
|
|
18
20
|
}
|
|
21
|
+
// package names / version specs only — rejects shell metacharacters since
|
|
22
|
+
// Windows needs shell: true to run package manager .cmd shims
|
|
23
|
+
const SAFE_PACKAGE_ARG = /^[@a-z0-9^~._/-]+$/i;
|
|
19
24
|
const installCommands = {
|
|
20
25
|
install: async ({ args })=>{
|
|
21
26
|
if (args.length === 0) {
|
|
22
|
-
|
|
27
|
+
throw new Error((0, _i18n.t)('installPackageRequired', {
|
|
28
|
+
scriptName: _constants.scriptName
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
for (const arg of args){
|
|
32
|
+
if (!SAFE_PACKAGE_ARG.test(arg)) {
|
|
33
|
+
throw new Error((0, _i18n.t)('installPackageRequired', {
|
|
34
|
+
scriptName: _constants.scriptName
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
23
37
|
}
|
|
24
38
|
const cliDir = _path.default.resolve(__dirname, '..');
|
|
25
39
|
const installCommand = (0, _runtime.getInstallCommand)(args, cliDir);
|
|
26
|
-
(0, _child_process.spawnSync)(installCommand.command, installCommand.args, {
|
|
40
|
+
const result = (0, _child_process.spawnSync)(installCommand.command, installCommand.args, {
|
|
27
41
|
cwd: cliDir,
|
|
28
42
|
stdio: 'inherit',
|
|
29
|
-
|
|
43
|
+
// package manager executables are .cmd shims on Windows
|
|
44
|
+
shell: process.platform === 'win32'
|
|
30
45
|
});
|
|
46
|
+
if (result.error) {
|
|
47
|
+
throw new Error((0, _i18n.t)('installFailed', {
|
|
48
|
+
packages: args.join(' '),
|
|
49
|
+
error: result.error.message
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
if (result.status !== 0) {
|
|
53
|
+
throw new Error((0, _i18n.t)('installFailed', {
|
|
54
|
+
packages: args.join(' '),
|
|
55
|
+
error: `${installCommand.command} exited with code ${result.status}`
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
31
58
|
}
|
|
32
59
|
};
|
package/lib/locales/en.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ declare const _default: {
|
|
|
95
95
|
rolloutConfigSet: string;
|
|
96
96
|
rolloutRangeError: string;
|
|
97
97
|
runningHermesc: string;
|
|
98
|
+
sentryReactNativeNotFound: string;
|
|
98
99
|
sentryCliNotFound: string;
|
|
99
100
|
sentryReleaseCreated: string;
|
|
100
101
|
totalApps: string;
|
|
@@ -136,7 +137,19 @@ declare const _default: {
|
|
|
136
137
|
diffPackageGenerated: string;
|
|
137
138
|
nodeHdiffpatchRequired: string;
|
|
138
139
|
apkExtracted: string;
|
|
140
|
+
composeSourceMapsNotFound: string;
|
|
141
|
+
installPackageRequired: string;
|
|
142
|
+
installFailed: string;
|
|
139
143
|
proxyNetworkError: string;
|
|
140
144
|
proxyNetworkErrorTips: string;
|
|
145
|
+
invalidId: string;
|
|
146
|
+
outputPathRequired: string;
|
|
147
|
+
unsupportedFileType: string;
|
|
148
|
+
failedToLoadSession: string;
|
|
149
|
+
appIdRequired: string;
|
|
150
|
+
unknownCommand: string;
|
|
151
|
+
unsupportedPlatformForHermes: string;
|
|
152
|
+
invalidManifest: string;
|
|
153
|
+
failedToResolveResource: string;
|
|
141
154
|
};
|
|
142
155
|
export default _default;
|
package/lib/locales/en.js
CHANGED
|
@@ -111,6 +111,7 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
111
111
|
rolloutConfigSet: 'Set {{rollout}}% rollout for OTA update {{version}} on native version(s) {{versions}}',
|
|
112
112
|
rolloutRangeError: 'rollout must be an integer between 1-100',
|
|
113
113
|
runningHermesc: 'Running hermesc: {{- command}} {{- args}}',
|
|
114
|
+
sentryReactNativeNotFound: 'Cannot find @sentry/react-native, please make sure it is properly installed',
|
|
114
115
|
sentryCliNotFound: 'Cannot find Sentry CLI tool, please make sure @sentry/cli is properly installed',
|
|
115
116
|
sentryReleaseCreated: 'Sentry release created for version: {{version}}',
|
|
116
117
|
totalApps: 'Total {{count}} {{platform}} apps',
|
|
@@ -152,6 +153,18 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
|
|
|
152
153
|
diffPackageGenerated: '{{- output}} generated.',
|
|
153
154
|
nodeHdiffpatchRequired: 'This function needs "node-hdiffpatch". Please run "{{scriptName}} install node-hdiffpatch" to install',
|
|
154
155
|
apkExtracted: 'APK extracted to {{output}}',
|
|
156
|
+
composeSourceMapsNotFound: 'Cannot find react-native/scripts/compose-source-maps.js, skipping hermes sourcemap composing. The uploaded sourcemap may not match the compiled bundle.',
|
|
157
|
+
installPackageRequired: 'Please specify the package to install, e.g. "{{scriptName}} install node-hdiffpatch"',
|
|
158
|
+
installFailed: 'Failed to install {{packages}}: {{error}}',
|
|
155
159
|
proxyNetworkError: 'Network error — likely caused by a proxy/VPN. Please try disabling your proxy and retry.',
|
|
156
|
-
proxyNetworkErrorTips: 'Common fixes:\n1. Disable system proxy or VPN\n2. Check HTTP_PROXY / HTTPS_PROXY environment variables\n3. Check proxy settings in .npmrc'
|
|
160
|
+
proxyNetworkErrorTips: 'Common fixes:\n1. Disable system proxy or VPN\n2. Check HTTP_PROXY / HTTPS_PROXY environment variables\n3. Check proxy settings in .npmrc',
|
|
161
|
+
invalidId: 'Invalid id: {{id}}',
|
|
162
|
+
outputPathRequired: 'Output path is required.',
|
|
163
|
+
unsupportedFileType: 'Unsupported file type: {{fileType}}',
|
|
164
|
+
failedToLoadSession: 'Failed to load session',
|
|
165
|
+
appIdRequired: 'appId is required',
|
|
166
|
+
unknownCommand: 'Unknown command: {{command}}',
|
|
167
|
+
unsupportedPlatformForHermes: 'Unsupported platform for Hermes: {{platform}}',
|
|
168
|
+
invalidManifest: 'Invalid manifest',
|
|
169
|
+
failedToResolveResource: 'Failed to resolve resource: {{error}}'
|
|
157
170
|
};
|
package/lib/locales/zh.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ declare const _default: {
|
|
|
95
95
|
rolloutConfigSet: string;
|
|
96
96
|
rolloutRangeError: string;
|
|
97
97
|
runningHermesc: string;
|
|
98
|
+
sentryReactNativeNotFound: string;
|
|
98
99
|
sentryCliNotFound: string;
|
|
99
100
|
sentryReleaseCreated: string;
|
|
100
101
|
totalApps: string;
|
|
@@ -135,7 +136,19 @@ declare const _default: {
|
|
|
135
136
|
diffPackageGenerated: string;
|
|
136
137
|
nodeHdiffpatchRequired: string;
|
|
137
138
|
apkExtracted: string;
|
|
139
|
+
composeSourceMapsNotFound: string;
|
|
140
|
+
installPackageRequired: string;
|
|
141
|
+
installFailed: string;
|
|
138
142
|
proxyNetworkError: string;
|
|
139
143
|
proxyNetworkErrorTips: string;
|
|
144
|
+
invalidId: string;
|
|
145
|
+
outputPathRequired: string;
|
|
146
|
+
unsupportedFileType: string;
|
|
147
|
+
failedToLoadSession: string;
|
|
148
|
+
appIdRequired: string;
|
|
149
|
+
unknownCommand: string;
|
|
150
|
+
unsupportedPlatformForHermes: string;
|
|
151
|
+
invalidManifest: string;
|
|
152
|
+
failedToResolveResource: string;
|
|
140
153
|
};
|
|
141
154
|
export default _default;
|
package/lib/locales/zh.js
CHANGED
|
@@ -111,6 +111,7 @@ const _default = {
|
|
|
111
111
|
rolloutConfigSet: '已在原生版本 {{versions}} 上设置灰度发布 {{rollout}}% 热更包 {{version}}',
|
|
112
112
|
rolloutRangeError: 'rollout 必须是 1-100 的整数',
|
|
113
113
|
runningHermesc: '运行 hermesc:{{- command}} {{- args}}',
|
|
114
|
+
sentryReactNativeNotFound: '无法找到 @sentry/react-native,请确保已正确安装',
|
|
114
115
|
sentryCliNotFound: '无法找到 Sentry CLI 工具,请确保已正确安装 @sentry/cli',
|
|
115
116
|
sentryReleaseCreated: '已为版本 {{version}} 创建 Sentry release',
|
|
116
117
|
totalApps: '共 {{count}} 个 {{platform}} 应用',
|
|
@@ -151,6 +152,18 @@ const _default = {
|
|
|
151
152
|
diffPackageGenerated: '{{- output}} 已生成。',
|
|
152
153
|
nodeHdiffpatchRequired: '此功能需要 "node-hdiffpatch"。请运行 "{{scriptName}} install node-hdiffpatch" 来安装',
|
|
153
154
|
apkExtracted: 'APK 已提取到 {{output}}',
|
|
155
|
+
composeSourceMapsNotFound: '找不到 react-native/scripts/compose-source-maps.js,跳过 hermes sourcemap 合成。上传的 sourcemap 可能与编译后的 bundle 不匹配。',
|
|
156
|
+
installPackageRequired: '请指定要安装的包,例如 "{{scriptName}} install node-hdiffpatch"',
|
|
157
|
+
installFailed: '安装 {{packages}} 失败: {{error}}',
|
|
154
158
|
proxyNetworkError: '网络连接异常,可能是代理/VPN 导致。请尝试关闭代理后重试。',
|
|
155
|
-
proxyNetworkErrorTips: '常见解决方法:\n1. 关闭系统代理或 VPN\n2. 检查 HTTP_PROXY / HTTPS_PROXY 环境变量\n3. 检查 .npmrc 中的 proxy 配置'
|
|
159
|
+
proxyNetworkErrorTips: '常见解决方法:\n1. 关闭系统代理或 VPN\n2. 检查 HTTP_PROXY / HTTPS_PROXY 环境变量\n3. 检查 .npmrc 中的 proxy 配置',
|
|
160
|
+
invalidId: '无效的 id:{{id}}',
|
|
161
|
+
outputPathRequired: '必须指定输出路径。',
|
|
162
|
+
unsupportedFileType: '不支持的文件类型:{{fileType}}',
|
|
163
|
+
failedToLoadSession: '加载登录状态失败',
|
|
164
|
+
appIdRequired: '必须指定 appId',
|
|
165
|
+
unknownCommand: '未知命令:{{command}}',
|
|
166
|
+
unsupportedPlatformForHermes: 'Hermes 不支持当前系统平台:{{platform}}',
|
|
167
|
+
invalidManifest: '无效的 manifest',
|
|
168
|
+
failedToResolveResource: '资源解析失败:{{error}}'
|
|
156
169
|
};
|
package/lib/package.js
CHANGED
|
@@ -103,7 +103,9 @@ function toNumericIds(ids) {
|
|
|
103
103
|
return ids.map((id)=>{
|
|
104
104
|
const numericId = Number(id);
|
|
105
105
|
if (!Number.isInteger(numericId) || numericId <= 0) {
|
|
106
|
-
throw new Error(
|
|
106
|
+
throw new Error((0, _i18n.t)('invalidId', {
|
|
107
|
+
id
|
|
108
|
+
}));
|
|
107
109
|
}
|
|
108
110
|
return numericId;
|
|
109
111
|
});
|
|
@@ -341,8 +343,12 @@ const packageCommands = {
|
|
|
341
343
|
appId
|
|
342
344
|
}));
|
|
343
345
|
}
|
|
346
|
+
const allPkgsMap = new Map(allPkgs.map((pkg)=>[
|
|
347
|
+
pkg.name,
|
|
348
|
+
pkg
|
|
349
|
+
]));
|
|
344
350
|
packageIds = packageVersions.map((packageVersion)=>{
|
|
345
|
-
const selectedPackage =
|
|
351
|
+
const selectedPackage = allPkgsMap.get(packageVersion);
|
|
346
352
|
if (!selectedPackage) {
|
|
347
353
|
throw new Error((0, _i18n.t)('packageNotFound', {
|
|
348
354
|
packageVersion
|
package/lib/provider.js
CHANGED
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "CLIProviderImpl", {
|
|
|
11
11
|
const _api = require("./api");
|
|
12
12
|
const _app = require("./app");
|
|
13
13
|
const _commandresult = require("./utils/command-result");
|
|
14
|
+
const _i18n = require("./utils/i18n");
|
|
14
15
|
function _getRequireWildcardCache(nodeInterop) {
|
|
15
16
|
if (typeof WeakMap !== "function") return null;
|
|
16
17
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -157,7 +158,9 @@ class CLIProviderImpl {
|
|
|
157
158
|
};
|
|
158
159
|
const uploadHandler = fileType && fileType in uploadHandlerMap ? uploadHandlerMap[fileType] : undefined;
|
|
159
160
|
if (!uploadHandler) {
|
|
160
|
-
throw new Error(
|
|
161
|
+
throw new Error((0, _i18n.t)('unsupportedFileType', {
|
|
162
|
+
fileType
|
|
163
|
+
}));
|
|
161
164
|
}
|
|
162
165
|
await uploadHandler(context);
|
|
163
166
|
}, 'Unknown error during upload', 'File uploaded successfully');
|
|
@@ -213,14 +216,17 @@ class CLIProviderImpl {
|
|
|
213
216
|
async loadSession() {
|
|
214
217
|
await this.ensureInitialized();
|
|
215
218
|
if (!this.session) {
|
|
216
|
-
throw new Error(
|
|
219
|
+
throw new Error((0, _i18n.t)('failedToLoadSession'));
|
|
217
220
|
}
|
|
218
221
|
return this.session;
|
|
219
222
|
}
|
|
220
223
|
async listPackages(appId) {
|
|
221
224
|
return this.runDataCommand(async ()=>{
|
|
225
|
+
if (!appId) {
|
|
226
|
+
throw new Error((0, _i18n.t)('appIdRequired'));
|
|
227
|
+
}
|
|
222
228
|
const { listPackage } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./package")));
|
|
223
|
-
return listPackage(appId
|
|
229
|
+
return listPackage(appId);
|
|
224
230
|
}, 'Unknown error listing packages');
|
|
225
231
|
}
|
|
226
232
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface Session {
|
|
|
7
7
|
}
|
|
8
8
|
export type Platform = 'ios' | 'android' | 'harmony';
|
|
9
9
|
export interface Package {
|
|
10
|
-
id:
|
|
10
|
+
id: number;
|
|
11
11
|
name: string;
|
|
12
12
|
version?: string;
|
|
13
13
|
status?: string;
|
|
@@ -18,7 +18,7 @@ export interface Package {
|
|
|
18
18
|
deps?: Record<string, string> | string | null;
|
|
19
19
|
}
|
|
20
20
|
export interface Version {
|
|
21
|
-
id:
|
|
21
|
+
id: number;
|
|
22
22
|
hash: string;
|
|
23
23
|
name: string;
|
|
24
24
|
packages?: Package[];
|
|
@@ -101,8 +101,8 @@ class AabParser extends _zip.Zip {
|
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
103
|
// Create a temp file for the .apks output
|
|
104
|
-
const tempDir = _os.default.tmpdir();
|
|
105
|
-
const tempApksPath = _path.default.join(tempDir,
|
|
104
|
+
const tempDir = await _fsextra.mkdtemp(_path.default.join(_os.default.tmpdir(), 'bundletool-'));
|
|
105
|
+
const tempApksPath = _path.default.join(tempDir, 'output.apks');
|
|
106
106
|
const needsNpxDownload = async ()=>{
|
|
107
107
|
try {
|
|
108
108
|
await runCommand('npx', [
|
|
@@ -191,8 +191,8 @@ class AabParser extends _zip.Zip {
|
|
|
191
191
|
});
|
|
192
192
|
} finally{
|
|
193
193
|
// Cleanup
|
|
194
|
-
if (await _fsextra.pathExists(
|
|
195
|
-
await _fsextra.remove(
|
|
194
|
+
if (await _fsextra.pathExists(tempDir)) {
|
|
195
|
+
await _fsextra.remove(tempDir);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
}
|
|
@@ -136,7 +136,6 @@ class BinaryXmlParser {
|
|
|
136
136
|
return len;
|
|
137
137
|
}
|
|
138
138
|
readDimension() {
|
|
139
|
-
var _dimension_value;
|
|
140
139
|
this.debug && console.group('readDimension');
|
|
141
140
|
const dimension = {
|
|
142
141
|
value: null,
|
|
@@ -144,7 +143,7 @@ class BinaryXmlParser {
|
|
|
144
143
|
rawUnit: null
|
|
145
144
|
};
|
|
146
145
|
const value = this.readU32();
|
|
147
|
-
const unit =
|
|
146
|
+
const unit = value & 0xff;
|
|
148
147
|
dimension.value = value >> 8;
|
|
149
148
|
dimension.rawUnit = unit;
|
|
150
149
|
switch(unit){
|
|
@@ -463,7 +462,9 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
|
|
|
463
462
|
attr.nodeName = attr.name = this.strings[nameRef];
|
|
464
463
|
if (valueRef > 0) {
|
|
465
464
|
if (attr.name === 'versionName') {
|
|
466
|
-
|
|
465
|
+
// strip UTF-16 null padding only; keep spaces and non-ASCII chars
|
|
466
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: removing NUL padding is the point
|
|
467
|
+
this.strings[valueRef] = this.strings[valueRef].replace(/\u0000/g, '');
|
|
467
468
|
}
|
|
468
469
|
attr.value = this.strings[valueRef];
|
|
469
470
|
}
|
|
@@ -15,7 +15,9 @@ const CATEGORY_LAUNCHER = 'android.intent.category.LAUNCHER';
|
|
|
15
15
|
class ManifestParser {
|
|
16
16
|
collapseAttributes(element) {
|
|
17
17
|
const collapsed = Object.create(null);
|
|
18
|
-
|
|
18
|
+
const attributes = element.attributes;
|
|
19
|
+
for(let i = 0, len = attributes.length; i < len; i++){
|
|
20
|
+
const attr = attributes[i];
|
|
19
21
|
collapsed[attr.name] = attr.typedValue.value;
|
|
20
22
|
}
|
|
21
23
|
return collapsed;
|
|
@@ -14,5 +14,11 @@ export declare class Zip {
|
|
|
14
14
|
*/
|
|
15
15
|
getEntry(regex: RegExp | string, type?: 'buffer' | 'blob'): Promise<Blob | Buffer<ArrayBufferLike>>;
|
|
16
16
|
getEntryFromHarmonyApp(regex: RegExp): Promise<Buffer | Blob | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Read multiple entries in a single pass over the archive (including
|
|
19
|
+
* nested .hap extraction), instead of one full scan per entry.
|
|
20
|
+
* Returns buffers in the same order as the given regexps.
|
|
21
|
+
*/
|
|
22
|
+
getEntriesFromHarmonyApp(regexps: RegExp[]): Promise<(Buffer | undefined)[]>;
|
|
17
23
|
private readEntries;
|
|
18
24
|
}
|
|
@@ -36,20 +36,31 @@ class Zip {
|
|
|
36
36
|
], type).then((buffers)=>buffers[decoded]);
|
|
37
37
|
}
|
|
38
38
|
async getEntryFromHarmonyApp(regex) {
|
|
39
|
+
return (await this.getEntriesFromHarmonyApp([
|
|
40
|
+
regex
|
|
41
|
+
]))[0];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Read multiple entries in a single pass over the archive (including
|
|
45
|
+
* nested .hap extraction), instead of one full scan per entry.
|
|
46
|
+
* Returns buffers in the same order as the given regexps.
|
|
47
|
+
*/ async getEntriesFromHarmonyApp(regexps) {
|
|
48
|
+
const results = new Array(regexps.length);
|
|
39
49
|
try {
|
|
40
|
-
let originSource;
|
|
41
50
|
if (typeof this.file !== 'string') {
|
|
42
51
|
throw new Error('Param error: [file] must be file path in Node.');
|
|
43
52
|
}
|
|
44
53
|
await (0, _zipentries.enumZipEntries)(this.file, async (entry, zipFile)=>{
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
for(let i = 0; i < regexps.length; i++){
|
|
55
|
+
if (regexps[i].test(entry.fileName)) {
|
|
56
|
+
results[i] = await (0, _zipentries.readEntry)(entry, zipFile);
|
|
57
|
+
}
|
|
47
58
|
}
|
|
48
59
|
});
|
|
49
|
-
return originSource;
|
|
50
60
|
} catch (error) {
|
|
51
|
-
console.error('Error in
|
|
61
|
+
console.error('Error in getEntriesFromHarmonyApp:', error);
|
|
52
62
|
}
|
|
63
|
+
return results;
|
|
53
64
|
}
|
|
54
65
|
async readEntries(decoded, type) {
|
|
55
66
|
if (typeof this.file !== 'string') {
|
|
@@ -67,6 +78,10 @@ class Zip {
|
|
|
67
78
|
return pattern === entryName || pattern === lowerEntryName;
|
|
68
79
|
}
|
|
69
80
|
pattern.lastIndex = 0;
|
|
81
|
+
if (pattern.test(entryName)) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
pattern.lastIndex = 0;
|
|
70
85
|
return pattern.test(lowerEntryName);
|
|
71
86
|
});
|
|
72
87
|
if (!matched) {
|
|
@@ -23,8 +23,12 @@ const lockFiles = [
|
|
|
23
23
|
'bun.lockb',
|
|
24
24
|
'bun.lock'
|
|
25
25
|
];
|
|
26
|
-
// Function to check if a
|
|
26
|
+
// Function to check if a directory is a monorepo root
|
|
27
|
+
// (package.json workspaces field, or pnpm-workspace.yaml)
|
|
27
28
|
function hasWorkspaces(dir) {
|
|
29
|
+
if (_fs.default.existsSync(_path.default.join(dir, 'pnpm-workspace.yaml'))) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
28
32
|
const pkgPath = _path.default.join(dir, 'package.json');
|
|
29
33
|
if (_fs.default.existsSync(pkgPath)) {
|
|
30
34
|
try {
|
package/lib/utils/constants.d.ts
CHANGED
package/lib/utils/constants.js
CHANGED
|
@@ -43,7 +43,8 @@ function _interop_require_default(obj) {
|
|
|
43
43
|
default: obj
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
var _process_argv_;
|
|
47
|
+
const scriptName = process.env.RNU_BRAND === 'cresc' || _path.default.basename((_process_argv_ = process.argv[1]) != null ? _process_argv_ : '') === 'cresc' ? 'cresc' : 'pushy';
|
|
47
48
|
const IS_CRESC = scriptName === 'cresc';
|
|
48
49
|
const ppkBundleFileNames = [
|
|
49
50
|
'index.bundlejs',
|
package/lib/utils/http-helper.js
CHANGED
|
@@ -38,30 +38,27 @@ function promiseAny(promises) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
const ping = async (url)=>{
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return url;
|
|
50
|
-
}
|
|
51
|
-
// console.log('ping failed', url, status, statusText);
|
|
52
|
-
throw new Error('ping failed');
|
|
53
|
-
}).catch((_e)=>{
|
|
54
|
-
pingFinished = true;
|
|
55
|
-
// console.log('ping error', url, e);
|
|
56
|
-
throw new Error('ping error');
|
|
57
|
-
}),
|
|
58
|
-
new Promise((_, reject)=>setTimeout(()=>{
|
|
59
|
-
reject(new Error('ping timeout'));
|
|
60
|
-
if (!pingFinished) {
|
|
61
|
-
// console.log('ping timeout', url);
|
|
41
|
+
let timer;
|
|
42
|
+
try {
|
|
43
|
+
return await Promise.race([
|
|
44
|
+
(0, _runtime.runtimeFetch)(url, {
|
|
45
|
+
method: 'HEAD'
|
|
46
|
+
}).then(({ status })=>{
|
|
47
|
+
if (status === 200) {
|
|
48
|
+
return url;
|
|
62
49
|
}
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
throw new Error('ping failed');
|
|
51
|
+
}),
|
|
52
|
+
new Promise((_, reject)=>{
|
|
53
|
+
timer = setTimeout(()=>{
|
|
54
|
+
reject(new Error('ping timeout'));
|
|
55
|
+
}, 5000);
|
|
56
|
+
})
|
|
57
|
+
]);
|
|
58
|
+
} finally{
|
|
59
|
+
// clear the timer so it doesn't keep the process alive for 5s
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
}
|
|
65
62
|
};
|
|
66
63
|
const testUrls = async (urls)=>{
|
|
67
64
|
if (!(urls == null ? void 0 : urls.length)) {
|
package/lib/utils/index.js
CHANGED
|
@@ -101,16 +101,23 @@ function translateOptions(options, map) {
|
|
|
101
101
|
}
|
|
102
102
|
return result;
|
|
103
103
|
}
|
|
104
|
+
const ApkBundleFileName = /assets\/index.android.bundle/;
|
|
105
|
+
const ApkUpdateJsonName = /res\/raw\/update.json/;
|
|
104
106
|
async function getApkInfo(fn) {
|
|
105
107
|
const appInfoParser = new _appinfoparser.default(fn);
|
|
106
|
-
|
|
108
|
+
// read both entries in a single scan over the archive
|
|
109
|
+
const entries = await appInfoParser.parser.getEntries([
|
|
110
|
+
ApkBundleFileName,
|
|
111
|
+
ApkUpdateJsonName
|
|
112
|
+
]);
|
|
113
|
+
const bundleFile = entries[String(ApkBundleFileName)];
|
|
107
114
|
if (!bundleFile) {
|
|
108
115
|
throw new Error((0, _i18n.t)('bundleNotFound', {
|
|
109
116
|
packageType: 'apk',
|
|
110
117
|
entryFile: 'index.android.bundle'
|
|
111
118
|
}));
|
|
112
119
|
}
|
|
113
|
-
const updateJsonFile =
|
|
120
|
+
const updateJsonFile = entries[String(ApkUpdateJsonName)];
|
|
114
121
|
let appCredential = {};
|
|
115
122
|
if (updateJsonFile) {
|
|
116
123
|
appCredential = JSON.parse(updateJsonFile.toString()).android;
|
|
@@ -129,7 +136,7 @@ async function getApkInfo(fn) {
|
|
|
129
136
|
}
|
|
130
137
|
}
|
|
131
138
|
}
|
|
132
|
-
if (buildTime
|
|
139
|
+
if (!Number.isFinite(buildTime) || buildTime === 0) {
|
|
133
140
|
throw new Error((0, _i18n.t)('buildTimeNotFound'));
|
|
134
141
|
}
|
|
135
142
|
return {
|
|
@@ -140,19 +147,22 @@ async function getApkInfo(fn) {
|
|
|
140
147
|
}
|
|
141
148
|
async function getAppInfo(fn) {
|
|
142
149
|
const appInfoParser = new _appinfoparser.default(fn);
|
|
143
|
-
|
|
150
|
+
// single scan (and single nested .hap extraction) for all three entries
|
|
151
|
+
const [bundleFile, updateJsonFile, metaJsonFile] = await appInfoParser.parser.getEntriesFromHarmonyApp([
|
|
152
|
+
/rawfile\/bundle.harmony.js/,
|
|
153
|
+
/rawfile\/update.json/,
|
|
154
|
+
/rawfile\/meta.json/
|
|
155
|
+
]);
|
|
144
156
|
if (!bundleFile) {
|
|
145
157
|
throw new Error((0, _i18n.t)('bundleNotFound', {
|
|
146
158
|
packageType: 'app',
|
|
147
159
|
entryFile: 'bundle.harmony.js'
|
|
148
160
|
}));
|
|
149
161
|
}
|
|
150
|
-
const updateJsonFile = await appInfoParser.parser.getEntryFromHarmonyApp(/rawfile\/update.json/);
|
|
151
162
|
let appCredential = {};
|
|
152
163
|
if (updateJsonFile) {
|
|
153
164
|
appCredential = JSON.parse(updateJsonFile.toString()).harmony;
|
|
154
165
|
}
|
|
155
|
-
const metaJsonFile = await appInfoParser.parser.getEntryFromHarmonyApp(/rawfile\/meta.json/);
|
|
156
166
|
let metaData = {};
|
|
157
167
|
if (metaJsonFile) {
|
|
158
168
|
metaData = JSON.parse(metaJsonFile.toString());
|
|
@@ -162,7 +172,7 @@ async function getAppInfo(fn) {
|
|
|
162
172
|
if (pushy_build_time) {
|
|
163
173
|
buildTime = Number(pushy_build_time);
|
|
164
174
|
}
|
|
165
|
-
if (buildTime
|
|
175
|
+
if (!Number.isFinite(buildTime) || buildTime === 0) {
|
|
166
176
|
throw new Error((0, _i18n.t)('buildTimeNotFound'));
|
|
167
177
|
}
|
|
168
178
|
return {
|
|
@@ -171,30 +181,39 @@ async function getAppInfo(fn) {
|
|
|
171
181
|
...appCredential
|
|
172
182
|
};
|
|
173
183
|
}
|
|
184
|
+
const IpaBundleFileName = /payload\/.+?\.app\/main.jsbundle/;
|
|
185
|
+
const IpaUpdateJsonName = /payload\/.+?\.app\/assets\/update.json/;
|
|
186
|
+
const IpaBuildTimeName = /payload\/.+?\.app\/pushy_build_time.txt/;
|
|
187
|
+
// Not in root bundle when use `use_frameworks`
|
|
188
|
+
const IpaBuildTimeFrameworkName = /payload\/.+?\.app\/frameworks\/react_native_update.framework\/pushy_build_time.txt/;
|
|
174
189
|
async function getIpaInfo(fn) {
|
|
190
|
+
var _entries_String;
|
|
175
191
|
const appInfoParser = new _appinfoparser.default(fn);
|
|
176
|
-
|
|
192
|
+
// read all four entries in a single scan over the archive
|
|
193
|
+
const entries = await appInfoParser.parser.getEntries([
|
|
194
|
+
IpaBundleFileName,
|
|
195
|
+
IpaUpdateJsonName,
|
|
196
|
+
IpaBuildTimeName,
|
|
197
|
+
IpaBuildTimeFrameworkName
|
|
198
|
+
]);
|
|
199
|
+
const bundleFile = entries[String(IpaBundleFileName)];
|
|
177
200
|
if (!bundleFile) {
|
|
178
201
|
throw new Error((0, _i18n.t)('bundleNotFound', {
|
|
179
202
|
packageType: 'ipa',
|
|
180
203
|
entryFile: 'main.jsbundle'
|
|
181
204
|
}));
|
|
182
205
|
}
|
|
183
|
-
const updateJsonFile =
|
|
206
|
+
const updateJsonFile = entries[String(IpaUpdateJsonName)];
|
|
184
207
|
let appCredential = {};
|
|
185
208
|
if (updateJsonFile) {
|
|
186
209
|
appCredential = JSON.parse(updateJsonFile.toString()).ios;
|
|
187
210
|
}
|
|
188
211
|
const { CFBundleShortVersionString: versionName } = await appInfoParser.parse();
|
|
189
|
-
|
|
190
|
-
if (!buildTimeTxtBuffer) {
|
|
191
|
-
// Not in root bundle when use `use_frameworks`
|
|
192
|
-
buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/frameworks\/react_native_update.framework\/pushy_build_time.txt/);
|
|
193
|
-
}
|
|
212
|
+
const buildTimeTxtBuffer = (_entries_String = entries[String(IpaBuildTimeName)]) != null ? _entries_String : entries[String(IpaBuildTimeFrameworkName)];
|
|
194
213
|
if (!buildTimeTxtBuffer) {
|
|
195
214
|
throw new Error((0, _i18n.t)('buildTimeNotFound'));
|
|
196
215
|
}
|
|
197
|
-
const buildTime = buildTimeTxtBuffer.toString().
|
|
216
|
+
const buildTime = buildTimeTxtBuffer.toString().trim();
|
|
198
217
|
return {
|
|
199
218
|
versionName,
|
|
200
219
|
buildTime,
|
|
@@ -216,7 +235,7 @@ async function getAabInfo(fn) {
|
|
|
216
235
|
});
|
|
217
236
|
const manifestElement = object.element;
|
|
218
237
|
if (manifestElement.name !== 'manifest') {
|
|
219
|
-
throw new Error(
|
|
238
|
+
throw new Error((0, _i18n.t)('invalidManifest'));
|
|
220
239
|
}
|
|
221
240
|
let versionName = '';
|
|
222
241
|
for (const attr of manifestElement.attribute){
|
|
@@ -270,7 +289,7 @@ async function getAabInfo(fn) {
|
|
|
270
289
|
}
|
|
271
290
|
}
|
|
272
291
|
}
|
|
273
|
-
if (buildTime === 0) {
|
|
292
|
+
if (!Number.isFinite(buildTime) || buildTime === 0) {
|
|
274
293
|
throw new Error((0, _i18n.t)('buildTimeNotFound'));
|
|
275
294
|
}
|
|
276
295
|
return {
|
|
@@ -295,13 +314,20 @@ async function readZipEntry(fn, entryName) {
|
|
|
295
314
|
found = true;
|
|
296
315
|
zipfile.openReadStream(entry, (streamError, readStream)=>{
|
|
297
316
|
if (streamError || !readStream) {
|
|
317
|
+
zipfile.close();
|
|
298
318
|
reject(streamError != null ? streamError : new Error('Failed to read zip entry'));
|
|
299
319
|
return;
|
|
300
320
|
}
|
|
301
321
|
const chunks = [];
|
|
302
322
|
readStream.on('data', (chunk)=>chunks.push(chunk));
|
|
303
|
-
readStream.on('end', ()=>
|
|
304
|
-
|
|
323
|
+
readStream.on('end', ()=>{
|
|
324
|
+
zipfile.close();
|
|
325
|
+
resolve(Buffer.concat(chunks));
|
|
326
|
+
});
|
|
327
|
+
readStream.on('error', (error)=>{
|
|
328
|
+
zipfile.close();
|
|
329
|
+
reject(error);
|
|
330
|
+
});
|
|
305
331
|
});
|
|
306
332
|
} else {
|
|
307
333
|
zipfile.readEntry();
|
|
@@ -348,7 +374,9 @@ async function resolveResource(fn, resourceId, root) {
|
|
|
348
374
|
}
|
|
349
375
|
}
|
|
350
376
|
} catch (e) {
|
|
351
|
-
console.warn(
|
|
377
|
+
console.warn((0, _i18n.t)('failedToResolveResource', {
|
|
378
|
+
error: e
|
|
379
|
+
}));
|
|
352
380
|
}
|
|
353
381
|
return null;
|
|
354
382
|
}
|
package/lib/utils/zip-entries.js
CHANGED
|
@@ -181,6 +181,7 @@ async function enumZipEntries(zipFn, callback, nestedPath = '') {
|
|
|
181
181
|
zipfile.openReadStream(entry, async (err, readStream)=>{
|
|
182
182
|
if (err) return rej(err);
|
|
183
183
|
const writeStream = _fsextra.createWriteStream(tempZipPath);
|
|
184
|
+
readStream.on('error', rej);
|
|
184
185
|
readStream.pipe(writeStream);
|
|
185
186
|
writeStream.on('finish', ()=>res(void 0));
|
|
186
187
|
writeStream.on('error', rej);
|
|
@@ -197,6 +198,9 @@ async function enumZipEntries(zipFn, callback, nestedPath = '') {
|
|
|
197
198
|
console.error((0, _i18n.t)('processingError', {
|
|
198
199
|
error
|
|
199
200
|
}));
|
|
201
|
+
zipfile.close();
|
|
202
|
+
reject(error);
|
|
203
|
+
return;
|
|
200
204
|
}
|
|
201
205
|
zipfile.readEntry();
|
|
202
206
|
});
|
package/lib/versions.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ interface VersionCommandOptions {
|
|
|
19
19
|
warnDepsChanges?: boolean;
|
|
20
20
|
'no-interactive'?: boolean | string;
|
|
21
21
|
}
|
|
22
|
+
type Deps = Record<string, string>;
|
|
23
|
+
export declare function normalizeDeps(input: unknown): Deps | undefined;
|
|
22
24
|
export declare function fetchVersions(appId: string, offset?: number, limit?: number): Promise<Version[]>;
|
|
23
25
|
export declare const bindVersionToPackages: ({ appId, versionId, pkgs, rollout, dryRun, }: {
|
|
24
26
|
appId: string;
|