react-native-update-cli 2.15.3 → 2.16.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.
@@ -241,6 +241,11 @@ export async function runReactNativeBundleCommand({
241
241
  process.env.SENTRY_PROPERTIES = 'ios/sentry.properties';
242
242
  } else if (platform === 'android') {
243
243
  process.env.SENTRY_PROPERTIES = 'android/sentry.properties';
244
+ } else if (
245
+ platform === 'harmony' &&
246
+ fs.existsSync('harmony/sentry.properties')
247
+ ) {
248
+ process.env.SENTRY_PROPERTIES = 'harmony/sentry.properties';
244
249
  }
245
250
  }
246
251
 
@@ -302,20 +307,24 @@ export async function runReactNativeBundleCommand({
302
307
  console.error(data.toString().trim());
303
308
  });
304
309
 
310
+ reactNativeBundleProcess.once('error', reject);
311
+
305
312
  reactNativeBundleProcess.on('close', async (exitCode) => {
306
313
  if (exitCode) {
307
314
  reject(new Error(t('bundleCommandError', { code: exitCode })));
308
315
  return;
309
316
  }
310
317
 
311
- let hermesEnabled: boolean | undefined = false;
318
+ try {
319
+ let hermesEnabled: boolean | undefined = false;
312
320
 
313
- if (forceHermes) {
314
- hermesEnabled = true;
315
- console.log(t('forceHermes'));
316
- } else if (platform === 'android') {
317
- const gradleProperties = await new Promise<{ hermesEnabled?: boolean }>(
318
- (resolve) => {
321
+ if (forceHermes) {
322
+ hermesEnabled = true;
323
+ console.log(t('forceHermes'));
324
+ } else if (platform === 'android') {
325
+ const gradleProperties = await new Promise<{
326
+ hermesEnabled?: boolean;
327
+ }>((resolve) => {
319
328
  properties.parse(
320
329
  './android/gradle.properties',
321
330
  { path: true },
@@ -331,42 +340,48 @@ export async function runReactNativeBundleCommand({
331
340
  resolve(props);
332
341
  },
333
342
  );
334
- },
335
- );
336
- hermesEnabled = gradleProperties.hermesEnabled;
343
+ });
344
+ hermesEnabled = gradleProperties.hermesEnabled;
345
+
346
+ if (typeof hermesEnabled !== 'boolean') {
347
+ hermesEnabled = gradleConfig.enableHermes;
348
+ }
349
+ } else if (
350
+ platform === 'ios' &&
351
+ fs.existsSync('ios/Pods/hermes-engine')
352
+ ) {
353
+ hermesEnabled = true;
354
+ }
337
355
 
338
- if (typeof hermesEnabled !== 'boolean') {
339
- hermesEnabled = gradleConfig.enableHermes;
356
+ if (hermesEnabled) {
357
+ await compileHermesByteCode(
358
+ bundleName,
359
+ outputFolder,
360
+ sourcemapOutput,
361
+ !isSentry,
362
+ );
340
363
  }
341
- } else if (
342
- platform === 'ios' &&
343
- fs.existsSync('ios/Pods/hermes-engine')
344
- ) {
345
- hermesEnabled = true;
346
- }
347
364
 
348
- if (hermesEnabled) {
349
- await compileHermesByteCode(
350
- bundleName,
351
- outputFolder,
352
- sourcemapOutput,
353
- !isSentry,
354
- );
355
- }
365
+ if (platform === 'harmony') {
366
+ const harmonyRawAssetsPath =
367
+ 'harmony/entry/src/main/resources/rawfile/assets';
368
+ fs.ensureDirSync(harmonyRawAssetsPath);
369
+ fs.copySync(outputFolder, harmonyRawAssetsPath, {
370
+ overwrite: true,
371
+ // sourcemaps must not ship inside the native package
372
+ filter: (src) => !src.endsWith('.map'),
373
+ });
374
+ fs.moveSync(
375
+ `${harmonyRawAssetsPath}/bundle.harmony.js`,
376
+ `${harmonyRawAssetsPath}/../bundle.harmony.js`,
377
+ { overwrite: true },
378
+ );
379
+ }
356
380
 
357
- if (platform === 'harmony') {
358
- const harmonyRawAssetsPath =
359
- 'harmony/entry/src/main/resources/rawfile/assets';
360
- fs.ensureDirSync(harmonyRawAssetsPath);
361
- fs.copySync(outputFolder, harmonyRawAssetsPath, { overwrite: true });
362
- fs.moveSync(
363
- `${harmonyRawAssetsPath}/bundle.harmony.js`,
364
- `${harmonyRawAssetsPath}/../bundle.harmony.js`,
365
- { overwrite: true },
366
- );
381
+ resolve();
382
+ } catch (error) {
383
+ reject(error);
367
384
  }
368
-
369
- resolve();
370
385
  });
371
386
  });
372
387
  }
@@ -418,7 +433,9 @@ function normalizeString(value: string | undefined): string | undefined {
418
433
  export function resolveHermesCommand(projectRoot = process.cwd()): string {
419
434
  const osBin = getHermesOSBin();
420
435
  if (!osBin) {
421
- throw new Error(`Unsupported platform for Hermes: ${os.platform()}`);
436
+ throw new Error(
437
+ t('unsupportedPlatformForHermes', { platform: os.platform() }),
438
+ );
422
439
  }
423
440
 
424
441
  const executableName = getHermesExecutableName();
@@ -529,9 +546,15 @@ async function compileHermesByteCode(
529
546
  hermesCommand,
530
547
  );
531
548
  if (sourcemapOutput) {
532
- const composerPath =
533
- 'node_modules/react-native/scripts/compose-source-maps.js';
534
- if (!fs.existsSync(composerPath)) {
549
+ let composerPath: string;
550
+ try {
551
+ // resolve through the project so hoisted node_modules (monorepos) work
552
+ composerPath = require.resolve(
553
+ 'react-native/scripts/compose-source-maps.js',
554
+ { paths: [process.cwd()] },
555
+ );
556
+ } catch {
557
+ console.warn(t('composeSourceMapsNotFound'));
535
558
  return;
536
559
  }
537
560
  console.log(t('composingSourceMap'));
@@ -571,7 +594,7 @@ export async function copyDebugidForSentry(
571
594
  },
572
595
  );
573
596
  } catch {
574
- console.error(t('sentryCliNotFound'));
597
+ console.error(t('sentryReactNativeNotFound'));
575
598
  return;
576
599
  }
577
600
 
package/src/bundle.ts CHANGED
@@ -70,16 +70,17 @@ function getAliasedOptionalStringOption(
70
70
  );
71
71
  }
72
72
 
73
- function normalizeBundleOptions(
73
+ export function normalizeBundleOptions(
74
74
  translatedOptions: Record<string, unknown>,
75
75
  platform: string,
76
76
  ): NormalizedBundleOptions {
77
77
  return {
78
- bundleName: getStringOption(
79
- translatedOptions,
80
- 'bundleName',
81
- 'index.bundlejs',
82
- ),
78
+ // harmony bundles always use this fixed name (runReactNativeBundleCommand
79
+ // forces it), so sourcemap paths and Sentry uploads must match
80
+ bundleName:
81
+ platform === 'harmony'
82
+ ? 'bundle.harmony.js'
83
+ : getStringOption(translatedOptions, 'bundleName', 'index.bundlejs'),
83
84
  entryFile: getStringOption(translatedOptions, 'entryFile', 'index.js'),
84
85
  intermediaDir: getStringOption(
85
86
  translatedOptions,
@@ -203,7 +204,7 @@ export const bundleCommands = {
203
204
  throw new Error(t('platformRequired'));
204
205
  }
205
206
 
206
- console.log(`Bundling with react-native: ${depVersions['react-native']}`);
207
+ console.log(t('bundlingWithRN', { version: depVersions['react-native'] }));
207
208
 
208
209
  await runReactNativeBundleCommand({
209
210
  bundleName: normalized.bundleName,
@@ -222,7 +223,11 @@ export const bundleCommands = {
222
223
  isSentry: bundleParams.sentry,
223
224
  });
224
225
 
225
- await packBundle(path.resolve(normalized.intermediaDir), realOutput);
226
+ await packBundle(
227
+ path.resolve(normalized.intermediaDir),
228
+ realOutput,
229
+ normalized.bundleName,
230
+ );
226
231
 
227
232
  if (normalized.name) {
228
233
  await publishBundleVersion(realOutput, platform, {
package/src/diff.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as fs from 'fs-extra';
2
2
  import { npm, yarn } from 'global-dirs';
3
3
  import path from 'path';
4
+ import type { Entry, ZipFile as YauzlZipFile } from 'yauzl';
4
5
  import { ZipFile as YazlZipFile } from 'yazl';
5
6
  import type { CommandContext } from './types';
6
7
  import { translateOptions } from './utils';
@@ -18,7 +19,10 @@ import {
18
19
  zipOptionsForPayloadEntry,
19
20
  } from './utils/zip-options';
20
21
 
21
- type Diff = (oldSource?: Buffer, newSource?: Buffer) => Buffer;
22
+ type Diff = (
23
+ oldSource?: Buffer,
24
+ newSource?: Buffer,
25
+ ) => Buffer | Promise<Buffer>;
22
26
  type HdiffModule = {
23
27
  diff?: Diff;
24
28
  };
@@ -61,14 +65,85 @@ function basename(fn: string): string | undefined {
61
65
  return m?.[1];
62
66
  }
63
67
 
68
+ function createOutputZip(output: string) {
69
+ fs.ensureDirSync(path.dirname(output));
70
+ const zipfile = new YazlZipFile();
71
+ const writePromise = new Promise<void>((resolve, reject) => {
72
+ zipfile.outputStream.on('error', reject);
73
+ zipfile.outputStream.pipe(fs.createWriteStream(output)).on('close', () => {
74
+ resolve(void 0);
75
+ });
76
+ });
77
+ return { zipfile, writePromise };
78
+ }
79
+
80
+ async function addBundlePatch(
81
+ zipfile: YazlZipFile,
82
+ entry: Entry,
83
+ nextZipfile: YauzlZipFile,
84
+ diffFn: Diff,
85
+ originSource: Buffer | undefined,
86
+ ) {
87
+ const newSource = await readEntry(entry, nextZipfile);
88
+ zipfile.addBuffer(
89
+ await diffFn(originSource, newSource),
90
+ `${entry.fileName}.patch`,
91
+ zipOptionsForPatchEntry(),
92
+ );
93
+ }
94
+
95
+ async function addFileFromZipEntry(
96
+ zipfile: YazlZipFile,
97
+ entry: Entry,
98
+ nextZipfile: YauzlZipFile,
99
+ ) {
100
+ const entryPrefix = await readEntryPrefix(
101
+ entry,
102
+ nextZipfile,
103
+ ZIP_ENTRY_SNIFF_BYTES,
104
+ );
105
+ await new Promise<void>((resolve, reject) => {
106
+ nextZipfile.openReadStream(entry, (err, readStream) => {
107
+ if (err) {
108
+ return reject(err);
109
+ }
110
+ if (!readStream) {
111
+ return reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
112
+ }
113
+ zipfile.addReadStream(
114
+ readStream,
115
+ entry.fileName,
116
+ zipOptionsForPayloadEntry(entry.fileName, entryPrefix),
117
+ );
118
+ readStream.on('error', reject);
119
+ readStream.on('end', () => {
120
+ resolve(void 0);
121
+ });
122
+ });
123
+ });
124
+ }
125
+
126
+ function finishDiffZip(
127
+ zipfile: YazlZipFile,
128
+ writePromise: Promise<void>,
129
+ manifest: Record<string, unknown>,
130
+ ) {
131
+ const diffManifest = Buffer.from(JSON.stringify(manifest));
132
+ zipfile.addBuffer(
133
+ diffManifest,
134
+ '__diff.json',
135
+ zipOptionsForManifestEntry(diffManifest.length),
136
+ );
137
+ zipfile.end();
138
+ return writePromise;
139
+ }
140
+
64
141
  async function diffFromPPK(
65
142
  origin: string,
66
143
  next: string,
67
144
  output: string,
68
145
  diffFn: Diff,
69
146
  ) {
70
- fs.ensureDirSync(path.dirname(output));
71
-
72
147
  const originEntries: EntryMap = {};
73
148
  const originMap: CrcMap = {};
74
149
 
@@ -93,14 +168,7 @@ async function diffFromPPK(
93
168
 
94
169
  const copies: CopyMap = {};
95
170
 
96
- const zipfile = new YazlZipFile();
97
-
98
- const writePromise = new Promise<void>((resolve, reject) => {
99
- zipfile.outputStream.on('error', reject);
100
- zipfile.outputStream.pipe(fs.createWriteStream(output)).on('close', () => {
101
- resolve(void 0);
102
- });
103
- });
171
+ const { zipfile, writePromise } = createOutputZip(output);
104
172
 
105
173
  const addedEntry: Record<string, true> = {};
106
174
 
@@ -128,15 +196,7 @@ async function diffFromPPK(
128
196
  addEntry(entry.fileName);
129
197
  }
130
198
  } else if (isPPKBundleFileName(entry.fileName)) {
131
- //console.log('Found bundle');
132
- const newSource = await readEntry(entry, nextZipfile);
133
- //console.log('Begin diff');
134
- zipfile.addBuffer(
135
- diffFn(originSource, newSource),
136
- `${entry.fileName}.patch`,
137
- zipOptionsForPatchEntry(),
138
- );
139
- //console.log('End diff');
199
+ await addBundlePatch(zipfile, entry, nextZipfile, diffFn, originSource);
140
200
  } else {
141
201
  // If same file.
142
202
  const originEntry = originEntries[entry.fileName];
@@ -162,33 +222,7 @@ async function diffFromPPK(
162
222
  addEntry(basePath);
163
223
  }
164
224
 
165
- const entryPrefix = await readEntryPrefix(
166
- entry,
167
- nextZipfile,
168
- ZIP_ENTRY_SNIFF_BYTES,
169
- );
170
- await new Promise<void>((resolve, reject) => {
171
- nextZipfile.openReadStream(entry, (err, readStream) => {
172
- if (err) {
173
- return reject(err);
174
- }
175
- if (!readStream) {
176
- return reject(
177
- new Error(`Unable to read zip entry: ${entry.fileName}`),
178
- );
179
- }
180
- zipfile.addReadStream(
181
- readStream,
182
- entry.fileName,
183
- zipOptionsForPayloadEntry(entry.fileName, entryPrefix),
184
- );
185
- readStream.on('error', reject);
186
- readStream.on('end', () => {
187
- //console.log('add finished');
188
- resolve(void 0);
189
- });
190
- });
191
- });
225
+ await addFileFromZipEntry(zipfile, entry, nextZipfile);
192
226
  }
193
227
  });
194
228
 
@@ -201,15 +235,7 @@ async function diffFromPPK(
201
235
  }
202
236
  }
203
237
 
204
- //console.log({copies, deletes});
205
- const diffManifest = Buffer.from(JSON.stringify({ copies, deletes }));
206
- zipfile.addBuffer(
207
- diffManifest,
208
- '__diff.json',
209
- zipOptionsForManifestEntry(diffManifest.length),
210
- );
211
- zipfile.end();
212
- await writePromise;
238
+ await finishDiffZip(zipfile, writePromise, { copies, deletes });
213
239
  }
214
240
 
215
241
  async function diffFromPackage(
@@ -220,8 +246,6 @@ async function diffFromPackage(
220
246
  originBundleName: string,
221
247
  transformPackagePath: (v: string) => string | undefined = (v: string) => v,
222
248
  ) {
223
- fs.ensureDirSync(path.dirname(output));
224
-
225
249
  const originEntries: Record<string, number> = {};
226
250
  const originMap: CrcMap = {};
227
251
 
@@ -259,29 +283,14 @@ async function diffFromPackage(
259
283
 
260
284
  const copies: CopyMap = {};
261
285
 
262
- const zipfile = new YazlZipFile();
263
-
264
- const writePromise = new Promise<void>((resolve, reject) => {
265
- zipfile.outputStream.on('error', reject);
266
- zipfile.outputStream.pipe(fs.createWriteStream(output)).on('close', () => {
267
- resolve(void 0);
268
- });
269
- });
286
+ const { zipfile, writePromise } = createOutputZip(output);
270
287
 
271
288
  await enumZipEntries(next, async (entry, nextZipfile) => {
272
289
  if (/\/$/.test(entry.fileName)) {
273
290
  // Directory
274
291
  zipfile.addEmptyDirectory(entry.fileName);
275
292
  } else if (isPPKBundleFileName(entry.fileName)) {
276
- //console.log('Found bundle');
277
- const newSource = await readEntry(entry, nextZipfile);
278
- //console.log('Begin diff');
279
- zipfile.addBuffer(
280
- diffFn(originSource, newSource),
281
- `${entry.fileName}.patch`,
282
- zipOptionsForPatchEntry(),
283
- );
284
- //console.log('End diff');
293
+ await addBundlePatch(zipfile, entry, nextZipfile, diffFn, originSource);
285
294
  } else {
286
295
  // If same file.
287
296
  if (originEntries[entry.fileName] === entry.crc32) {
@@ -299,44 +308,11 @@ async function diffFromPackage(
299
308
  return;
300
309
  }
301
310
 
302
- const entryPrefix = await readEntryPrefix(
303
- entry,
304
- nextZipfile,
305
- ZIP_ENTRY_SNIFF_BYTES,
306
- );
307
- await new Promise<void>((resolve, reject) => {
308
- nextZipfile.openReadStream(entry, (err, readStream) => {
309
- if (err) {
310
- return reject(err);
311
- }
312
- if (!readStream) {
313
- return reject(
314
- new Error(`Unable to read zip entry: ${entry.fileName}`),
315
- );
316
- }
317
- zipfile.addReadStream(
318
- readStream,
319
- entry.fileName,
320
- zipOptionsForPayloadEntry(entry.fileName, entryPrefix),
321
- );
322
- readStream.on('error', reject);
323
- readStream.on('end', () => {
324
- //console.log('add finished');
325
- resolve(void 0);
326
- });
327
- });
328
- });
311
+ await addFileFromZipEntry(zipfile, entry, nextZipfile);
329
312
  }
330
313
  });
331
314
 
332
- const diffManifest = Buffer.from(JSON.stringify({ copies, copiesCrc }));
333
- zipfile.addBuffer(
334
- diffManifest,
335
- '__diff.json',
336
- zipOptionsForManifestEntry(diffManifest.length),
337
- );
338
- zipfile.end();
339
- await writePromise;
315
+ await finishDiffZip(zipfile, writePromise, { copies, copiesCrc });
340
316
  }
341
317
 
342
318
  type DiffCommandOptions = {
@@ -374,7 +350,7 @@ function diffArgsCheck(
374
350
  tempDir,
375
351
  } as DiffCommandOptions & { tempDir: string });
376
352
  if (typeof output !== 'string') {
377
- throw new Error('Output path is required.');
353
+ throw new Error(t('outputPathRequired'));
378
354
  }
379
355
 
380
356
  return {
package/src/locales/en.ts CHANGED
@@ -132,6 +132,8 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
132
132
  'Set {{rollout}}% rollout for OTA update {{version}} on native version(s) {{versions}}',
133
133
  rolloutRangeError: 'rollout must be an integer between 1-100',
134
134
  runningHermesc: 'Running hermesc: {{- command}} {{- args}}',
135
+ sentryReactNativeNotFound:
136
+ 'Cannot find @sentry/react-native, please make sure it is properly installed',
135
137
  sentryCliNotFound:
136
138
  'Cannot find Sentry CLI tool, please make sure @sentry/cli is properly installed',
137
139
  sentryReleaseCreated: 'Sentry release created for version: {{version}}',
@@ -182,6 +184,8 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
182
184
  nodeHdiffpatchRequired:
183
185
  'This function needs "node-hdiffpatch". Please run "{{scriptName}} install node-hdiffpatch" to install',
184
186
  apkExtracted: 'APK extracted to {{output}}',
187
+ composeSourceMapsNotFound:
188
+ 'Cannot find react-native/scripts/compose-source-maps.js, skipping hermes sourcemap composing. The uploaded sourcemap may not match the compiled bundle.',
185
189
  installPackageRequired:
186
190
  'Please specify the package to install, e.g. "{{scriptName}} install node-hdiffpatch"',
187
191
  installFailed: 'Failed to install {{packages}}: {{error}}',
@@ -189,4 +193,13 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
189
193
  'Network error — likely caused by a proxy/VPN. Please try disabling your proxy and retry.',
190
194
  proxyNetworkErrorTips:
191
195
  'Common fixes:\n1. Disable system proxy or VPN\n2. Check HTTP_PROXY / HTTPS_PROXY environment variables\n3. Check proxy settings in .npmrc',
196
+ invalidId: 'Invalid id: {{id}}',
197
+ outputPathRequired: 'Output path is required.',
198
+ unsupportedFileType: 'Unsupported file type: {{fileType}}',
199
+ failedToLoadSession: 'Failed to load session',
200
+ appIdRequired: 'appId is required',
201
+ unknownCommand: 'Unknown command: {{command}}',
202
+ unsupportedPlatformForHermes: 'Unsupported platform for Hermes: {{platform}}',
203
+ invalidManifest: 'Invalid manifest',
204
+ failedToResolveResource: 'Failed to resolve resource: {{error}}',
192
205
  };
package/src/locales/zh.ts CHANGED
@@ -123,6 +123,7 @@ export default {
123
123
  '已在原生版本 {{versions}} 上设置灰度发布 {{rollout}}% 热更包 {{version}}',
124
124
  rolloutRangeError: 'rollout 必须是 1-100 的整数',
125
125
  runningHermesc: '运行 hermesc:{{- command}} {{- args}}',
126
+ sentryReactNativeNotFound: '无法找到 @sentry/react-native,请确保已正确安装',
126
127
  sentryCliNotFound: '无法找到 Sentry CLI 工具,请确保已正确安装 @sentry/cli',
127
128
  sentryReleaseCreated: '已为版本 {{version}} 创建 Sentry release',
128
129
  totalApps: '共 {{count}} 个 {{platform}} 应用',
@@ -168,6 +169,8 @@ export default {
168
169
  nodeHdiffpatchRequired:
169
170
  '此功能需要 "node-hdiffpatch"。请运行 "{{scriptName}} install node-hdiffpatch" 来安装',
170
171
  apkExtracted: 'APK 已提取到 {{output}}',
172
+ composeSourceMapsNotFound:
173
+ '找不到 react-native/scripts/compose-source-maps.js,跳过 hermes sourcemap 合成。上传的 sourcemap 可能与编译后的 bundle 不匹配。',
171
174
  installPackageRequired:
172
175
  '请指定要安装的包,例如 "{{scriptName}} install node-hdiffpatch"',
173
176
  installFailed: '安装 {{packages}} 失败: {{error}}',
@@ -175,4 +178,13 @@ export default {
175
178
  '网络连接异常,可能是代理/VPN 导致。请尝试关闭代理后重试。',
176
179
  proxyNetworkErrorTips:
177
180
  '常见解决方法:\n1. 关闭系统代理或 VPN\n2. 检查 HTTP_PROXY / HTTPS_PROXY 环境变量\n3. 检查 .npmrc 中的 proxy 配置',
181
+ invalidId: '无效的 id:{{id}}',
182
+ outputPathRequired: '必须指定输出路径。',
183
+ unsupportedFileType: '不支持的文件类型:{{fileType}}',
184
+ failedToLoadSession: '加载登录状态失败',
185
+ appIdRequired: '必须指定 appId',
186
+ unknownCommand: '未知命令:{{command}}',
187
+ unsupportedPlatformForHermes: 'Hermes 不支持当前系统平台:{{platform}}',
188
+ invalidManifest: '无效的 manifest',
189
+ failedToResolveResource: '资源解析失败:{{error}}',
178
190
  };
package/src/package.ts CHANGED
@@ -90,7 +90,7 @@ function toNumericIds(ids: string[]) {
90
90
  return ids.map((id) => {
91
91
  const numericId = Number(id);
92
92
  if (!Number.isInteger(numericId) || numericId <= 0) {
93
- throw new Error(`Invalid id: ${id}`);
93
+ throw new Error(t('invalidId', { id }));
94
94
  }
95
95
  return numericId;
96
96
  });
package/src/provider.ts CHANGED
@@ -12,6 +12,7 @@ import type {
12
12
  UploadOptions,
13
13
  } from './types';
14
14
  import { runAsCommandResult } from './utils/command-result';
15
+ import { t } from './utils/i18n';
15
16
 
16
17
  const DEFAULT_BUNDLE_OUTPUT =
17
18
  '$' + '{tempDir}/output/$' + '{platform}.$' + '{time}.ppk';
@@ -164,7 +165,7 @@ export class CLIProviderImpl implements CLIProvider {
164
165
  : undefined;
165
166
 
166
167
  if (!uploadHandler) {
167
- throw new Error(`Unsupported file type: ${fileType}`);
168
+ throw new Error(t('unsupportedFileType', { fileType }));
168
169
  }
169
170
  await uploadHandler(context);
170
171
  },
@@ -244,15 +245,18 @@ export class CLIProviderImpl implements CLIProvider {
244
245
  async loadSession(): Promise<Session> {
245
246
  await this.ensureInitialized();
246
247
  if (!this.session) {
247
- throw new Error('Failed to load session');
248
+ throw new Error(t('failedToLoadSession'));
248
249
  }
249
250
  return this.session;
250
251
  }
251
252
 
252
253
  async listPackages(appId?: string): Promise<CommandResult> {
253
254
  return this.runDataCommand(async () => {
255
+ if (!appId) {
256
+ throw new Error(t('appIdRequired'));
257
+ }
254
258
  const { listPackage } = await import('./package');
255
- return listPackage(appId || '');
259
+ return listPackage(appId);
256
260
  }, 'Unknown error listing packages');
257
261
  }
258
262
  }
package/src/types.ts CHANGED
@@ -10,7 +10,8 @@ export interface Session {
10
10
  export type Platform = 'ios' | 'android' | 'harmony';
11
11
 
12
12
  export interface Package {
13
- id: string;
13
+ // server-side ids are numeric (auto-increment primary keys)
14
+ id: number;
14
15
  name: string;
15
16
  version?: string;
16
17
  status?: string;
@@ -22,7 +23,7 @@ export interface Package {
22
23
  }
23
24
 
24
25
  export interface Version {
25
- id: string;
26
+ id: number;
26
27
  hash: string;
27
28
  name: string;
28
29
  packages?: Package[];
@@ -173,7 +173,7 @@ export class BinaryXmlParser {
173
173
  };
174
174
 
175
175
  const value = this.readU32();
176
- const unit = (dimension.value ?? 0) & 0xff;
176
+ const unit = value & 0xff;
177
177
 
178
178
  dimension.value = value >> 8;
179
179
  dimension.rawUnit = unit;
@@ -567,10 +567,9 @@ and is supposed to end at offset ${end}. Ignoring the rest of the value.`);
567
567
 
568
568
  if (valueRef > 0) {
569
569
  if (attr.name === 'versionName') {
570
- this.strings[valueRef] = this.strings[valueRef].replace(
571
- /[^\x21-\x7E]/g,
572
- '',
573
- );
570
+ // strip UTF-16 null padding only; keep spaces and non-ASCII chars
571
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: removing NUL padding is the point
572
+ this.strings[valueRef] = this.strings[valueRef].replace(/\u0000/g, '');
574
573
  }
575
574
  attr.value = this.strings[valueRef];
576
575
  }