react-native-update-cli 2.22.9 → 2.23.1

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 CHANGED
@@ -68,13 +68,14 @@ const publishResult = await provider.publish({
68
68
  - `hdiffFromApp`: Generate hdiff from APP files
69
69
  - `hdiffFromIpa`: Generate hdiff from IPA files
70
70
 
71
- Hermes projects: `bundle` always runs hermesc with `-output-source-map`, so the debug info section is stripped from the bytecode (15–40% smaller, same as React Native's own release builds). The Hermes sourcemap stays in the intermediate directory (`.pushy/intermedia/<platform>/<bundle>.map`, never packed into the ppk); with `--sourcemap` it is composed with the packager map as before. Keep it if you want to symbolicate `address at` crash stacks later.
71
+ Hermes projects: `bundle` always runs hermesc with `-output-source-map`, so the debug info section is stripped from the bytecode (15–40% smaller, same as React Native's own release builds). The Hermes sourcemap stays in the intermediate directory (`.pushy/intermedia/<platform>/<bundle>.map`, never packed into the ppk) and is composed with the packager map — `--sourcemap` is on by default since 2.23 (`--sourcemap false` opts out). When `bundle` publishes, that final map is uploaded and archived with the version (`sourceMapKey`), so `pushy symbolicate` can map crash stacks — including Hermes `address at` frames — back to source later. `pushy publish <ppk> --sourcemap <file.map>` archives a map for a ppk built elsewhere; publishing without a map prints a warning.
72
72
 
73
73
  Hermes delta mode (`-base-bytecode`): by default (`--hermesBase auto`) `bundle` compiles against the previous HBC of the same app, which keeps Hermes string IDs stable and makes hot-update patches 5–30× smaller. The base comes from the server (`GET /app/:id/hermesBase`), verified by sha256 and kept in a local cache (`.pushy/cache/<sha256>`, 500 MB / 20 files, `PUSHY_CACHE_DIR` / `--cacheMaxMb` to tune, `pushy cache [clean]` to inspect or clear). `--hermesBase none` disables it; `--hermesBase <file.hbc|.ppk|.apk|.ipa>` uses a local artifact (for example the store build). `--verifyHermesBase` (default on) additionally compiles without the base (concurrently with the base compile) and compares both disassemblies; on any mismatch or failure the CLI silently falls back to the plain compile, so the feature can never block a release. Only hermesc builds that include the upstream delta-mode fix are used (classic `react-native/sdks/hermesc`, or `hermes-compiler` ≥ 250829098). If a base compile fails, the full hermesc output is written to `hermes-base-error.log` next to the intermediate directory. `--resetCache false` skips Metro's `--reset-cache` and reuses its transform cache, which makes repeated bundles much faster.
74
74
 
75
75
  ### Version
76
76
 
77
- - `publish`: Publish a new version
77
+ - `publish`: Publish a new version (`--sourcemap <file.map>` archives the source map with it)
78
+ - `symbolicate`: Map a crash stack to source using the archived map: `pushy symbolicate stack.txt --hash <updateHash>` (`-` reads stdin, `--versionId` instead of `--hash`, `--output <file>`); the hash is `getUpdateMetadata().currentVersion` on the device
78
79
  - `versions`: List versions
79
80
  - `update`: Update version package rules
80
81
  - `updateVersionInfo`: Update version metadata
package/README.zh-CN.md CHANGED
@@ -68,13 +68,14 @@ const publishResult = await provider.publish({
68
68
  - `hdiffFromApp`: 基于 APP 文件生成 hdiff
69
69
  - `hdiffFromIpa`: 基于 IPA 文件生成 hdiff
70
70
 
71
- Hermes 工程:`bundle` 调用 hermesc 时始终带 `-output-source-map`,因此字节码不含 debug info 段(小 15%~40%,与 React Native 自身 release 构建一致)。Hermes sourcemap 保留在中间目录(`.pushy/intermedia/<platform>/<bundle>.map`,不会打进 ppk);传 `--sourcemap` 时照旧与 packager map 合成。留着它可以事后符号化 `address at` 形式的崩溃堆栈。
71
+ Hermes 工程:`bundle` 调用 hermesc 时始终带 `-output-source-map`,因此字节码不含 debug info 段(小 15%~40%,与 React Native 自身 release 构建一致)。Hermes sourcemap 保留在中间目录(`.pushy/intermedia/<platform>/<bundle>.map`,不会打进 ppk),并与 packager map 合成——自 2.23 起 `--sourcemap` 默认开启(`--sourcemap false` 关闭)。`bundle` 发布时会把这份最终 map 上传并随版本归档(`sourceMapKey`),之后用 `pushy symbolicate` 即可把崩溃堆栈(含 Hermes 的 `address at` 帧)还原到源码。别处打好的 ppk 可用 `pushy publish <ppk> --sourcemap <file.map>` 归档;不带 map 发布会打印警告。
72
72
 
73
73
  Hermes delta 模式(`-base-bytecode`):默认 `--hermesBase auto`,`bundle` 会以同一应用上一版的 HBC 为 base 编译,让 Hermes 字符串 ID 跨版本稳定,热更 patch 可缩小 5~30 倍。base 由服务端(`GET /app/:id/hermesBase`)给出、按 sha256 校验并存入本地缓存(`.pushy/cache/<sha256>`,默认 500 MB / 20 个,可用 `PUSHY_CACHE_DIR` / `--cacheMaxMb` 调整,`pushy cache [clean]` 查看或清空)。`--hermesBase none` 关闭;`--hermesBase <file.hbc|.ppk|.apk|.ipa>` 指定本地文件(比如商店包)作 base。`--verifyHermesBase`(默认开)会并行再做一次普通编译并比对两份反汇编;任何不一致或失败都静默回退到普通编译,不会阻塞发版。只有包含上游 delta 模式修复的 hermesc 才会启用(经典 `react-native/sdks/hermesc`,或 `hermes-compiler` ≥ 250829098)。base 编译失败时,完整的 hermesc 输出会写到中间目录旁边的 `hermes-base-error.log`。`--resetCache false` 可跳过 Metro 的 `--reset-cache`,复用其转换缓存,重复打包会快很多。
74
74
 
75
75
  ### Version
76
76
 
77
- - `publish`: 发布新版本
77
+ - `publish`: 发布新版本(`--sourcemap <file.map>` 随版本归档 source map)
78
+ - `symbolicate`: 用归档的 map 还原崩溃堆栈:`pushy symbolicate stack.txt --hash <热更 hash>`(`-` 读 stdin,可用 `--versionId` 代替 `--hash`,`--output <文件>` 写文件);hash 即设备上 `getUpdateMetadata().currentVersion`
78
79
  - `versions`: 列出版本
79
80
  - `update`: 更新版本包规则
80
81
  - `updateVersionInfo`: 更新版本元信息
package/cli.json CHANGED
@@ -139,6 +139,9 @@
139
139
  },
140
140
  "dryRun": {
141
141
  "default": false
142
+ },
143
+ "sourcemap": {
144
+ "hasValue": true
142
145
  }
143
146
  }
144
147
  },
@@ -248,7 +251,7 @@
248
251
  "hasValue": true
249
252
  },
250
253
  "sourcemap": {
251
- "default": false
254
+ "default": true
252
255
  },
253
256
  "taro": {
254
257
  "default": false
@@ -382,6 +385,23 @@
382
385
  "cache": {
383
386
  "description": "Inspect or clean the local bundle cache: cache [clean]",
384
387
  "options": {}
388
+ },
389
+ "symbolicate": {
390
+ "description": "Map a JS stack trace back to source using the source map archived with a published version.",
391
+ "options": {
392
+ "hash": {
393
+ "hasValue": true
394
+ },
395
+ "versionId": {
396
+ "hasValue": true
397
+ },
398
+ "platform": {
399
+ "hasValue": true
400
+ },
401
+ "output": {
402
+ "hasValue": true
403
+ }
404
+ }
385
405
  }
386
406
  },
387
407
  "globalOptions": {
package/lib/app.d.ts CHANGED
@@ -4,35 +4,63 @@ interface AppSummary {
4
4
  name: string;
5
5
  platform: Platform;
6
6
  }
7
+ export interface AppTargetOptions {
8
+ appId?: string;
9
+ config?: string;
10
+ platform?: Platform | '';
11
+ }
12
+ /** The selected-app config file was missing or has no entry for the platform. */
13
+ export declare class AppNotSelectedError extends Error {
14
+ readonly code = "APP_NOT_SELECTED";
15
+ constructor(platform: Platform);
16
+ }
17
+ /** Resolve an explicit platform or prompt for one interactively. */
7
18
  export declare function getPlatform(platform?: string): Promise<Platform>;
19
+ /** Validate that a string names a platform supported by the update service. */
8
20
  export declare function assertPlatform(platform: string): Platform;
21
+ /** Read the selected app for a platform from the requested config file. */
9
22
  export declare function getSelectedApp(platform: Platform, configPath?: string): Promise<{
10
23
  appId: string;
11
24
  appKey: string;
12
25
  platform: Platform;
13
26
  }>;
27
+ /**
28
+ * Resolve the app an operation targets: an explicit `--appId` wins, otherwise
29
+ * the app selected for the platform in `--config` (default: update.json).
30
+ * Prompts for the platform only when it is needed and not given.
31
+ */
32
+ export declare function resolveAppId(options?: AppTargetOptions): Promise<string>;
33
+ /** List apps, optionally filtering them to one platform. */
14
34
  export declare function listApp(platform?: Platform | ''): Promise<AppSummary[]>;
35
+ /** Prompt until the user chooses an app belonging to the target platform. */
15
36
  export declare function chooseApp(platform: Platform): Promise<AppSummary>;
37
+ /** Persist an app selection in the requested brand-aware config file. */
16
38
  declare function selectApp({ args, options, }: {
17
39
  args: string[];
18
40
  options: {
19
41
  platform?: Platform | '';
42
+ config?: string;
20
43
  };
21
44
  }): Promise<void>;
45
+ /** Build the application-management command handlers used by the CLI. */
22
46
  export declare function getAppCommands(): {
47
+ /** Create an app and select it in the same configuration file. */
23
48
  createApp: ({ options, }: {
24
49
  options: {
25
50
  name: string;
26
51
  downloadUrl: string;
27
52
  platform?: Platform | '';
53
+ config?: string;
28
54
  };
29
55
  }) => Promise<void>;
56
+ /** Delete the specified app, or prompt for one when no ID is supplied. */
30
57
  deleteApp: ({ args, options, }: {
31
58
  args: string[];
32
59
  options: {
33
60
  platform: Platform;
34
61
  };
35
62
  }) => Promise<void>;
63
+ /** List apps through the command interface. */
36
64
  apps: ({ options }: {
37
65
  options: {
38
66
  platform?: Platform | '';
package/lib/app.js CHANGED
@@ -3,40 +3,63 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AppNotSelectedError = void 0;
6
7
  exports.getPlatform = getPlatform;
7
8
  exports.assertPlatform = assertPlatform;
8
9
  exports.getSelectedApp = getSelectedApp;
10
+ exports.resolveAppId = resolveAppId;
9
11
  exports.listApp = listApp;
10
12
  exports.chooseApp = chooseApp;
11
13
  exports.getAppCommands = getAppCommands;
12
14
  const fs_1 = __importDefault(require("fs"));
13
15
  const api_1 = require("./api");
14
16
  const utils_1 = require("./utils");
17
+ const constants_1 = require("./utils/constants");
15
18
  const i18n_1 = require("./utils/i18n");
19
+ /** The selected-app config file was missing or has no entry for the platform. */
20
+ class AppNotSelectedError extends Error {
21
+ code = 'APP_NOT_SELECTED';
22
+ constructor(platform) {
23
+ super((0, i18n_1.t)('appNotSelected', { platform }));
24
+ this.name = 'AppNotSelectedError';
25
+ }
26
+ }
27
+ exports.AppNotSelectedError = AppNotSelectedError;
28
+ /** Resolve an explicit platform or prompt for one interactively. */
16
29
  async function getPlatform(platform) {
17
30
  return assertPlatform(platform || (await (0, utils_1.question)((0, i18n_1.t)('platformQuestion'))));
18
31
  }
32
+ /** Validate that a string names a platform supported by the update service. */
19
33
  function assertPlatform(platform) {
20
34
  if (platform !== 'ios' && platform !== 'android' && platform !== 'harmony') {
21
35
  throw new Error((0, i18n_1.t)('unsupportedPlatform', { platform }));
22
36
  }
23
37
  return platform;
24
38
  }
39
+ /** Read the selected app for a platform from the requested config file. */
25
40
  async function getSelectedApp(platform, configPath) {
26
41
  assertPlatform(platform);
27
- let updateInfo = {};
42
+ const resolvedConfigPath = configPath || constants_1.updateJson;
43
+ let raw;
28
44
  try {
29
- updateInfo = JSON.parse(await fs_1.default.promises.readFile(configPath || 'update.json', 'utf8'));
45
+ raw = await fs_1.default.promises.readFile(resolvedConfigPath, 'utf8');
30
46
  }
31
47
  catch (e) {
32
48
  if (e.code === 'ENOENT') {
33
- throw new Error((0, i18n_1.t)('appNotSelected', { platform }));
49
+ throw new AppNotSelectedError(platform);
34
50
  }
35
51
  throw e;
36
52
  }
53
+ let updateInfo;
54
+ try {
55
+ updateInfo = JSON.parse(raw);
56
+ }
57
+ catch {
58
+ throw new Error((0, i18n_1.t)('failedToParseUpdateJson', { configPath: resolvedConfigPath }));
59
+ }
37
60
  const info = updateInfo[platform];
38
61
  if (!info) {
39
- throw new Error((0, i18n_1.t)('appNotSelected', { platform }));
62
+ throw new AppNotSelectedError(platform);
40
63
  }
41
64
  return {
42
65
  appId: String(info.appId),
@@ -44,6 +67,39 @@ async function getSelectedApp(platform, configPath) {
44
67
  platform,
45
68
  };
46
69
  }
70
+ /**
71
+ * Fail fast when an explicit `--appId` names an app of another platform.
72
+ * The server accepts a bundle for any app the account owns and never sees
73
+ * the platform it was built for, so this is the only place the mistake can
74
+ * be caught before it reaches devices. A missing or foreign app fails here
75
+ * too (403/404) instead of after the expensive work.
76
+ */
77
+ async function assertAppPlatform(appId, platform) {
78
+ const app = (await (0, api_1.get)(`/app/${appId}`));
79
+ if (app.platform && app.platform !== platform) {
80
+ throw new Error((0, i18n_1.t)('appPlatformMismatch', { appId, appPlatform: app.platform, platform }));
81
+ }
82
+ }
83
+ /**
84
+ * Resolve the app an operation targets: an explicit `--appId` wins, otherwise
85
+ * the app selected for the platform in `--config` (default: update.json).
86
+ * Prompts for the platform only when it is needed and not given.
87
+ */
88
+ async function resolveAppId(options = {}) {
89
+ if (options.platform) {
90
+ assertPlatform(options.platform);
91
+ }
92
+ if (options.appId) {
93
+ const appId = String(options.appId);
94
+ if (options.platform) {
95
+ await assertAppPlatform(appId, options.platform);
96
+ }
97
+ return appId;
98
+ }
99
+ const platform = await getPlatform(options.platform || undefined);
100
+ return (await getSelectedApp(platform, options.config)).appId;
101
+ }
102
+ /** List apps, optionally filtering them to one platform. */
47
103
  async function listApp(platform = '') {
48
104
  const { data } = await (0, api_1.get)('/app/list');
49
105
  const allApps = data;
@@ -65,6 +121,7 @@ async function listApp(platform = '') {
65
121
  console.log(`\n${(0, i18n_1.t)('totalApps', { count: list.length, platform })}`);
66
122
  return list;
67
123
  }
124
+ /** Prompt until the user chooses an app belonging to the target platform. */
68
125
  async function chooseApp(platform) {
69
126
  const list = await listApp(platform);
70
127
  while (true) {
@@ -75,19 +132,20 @@ async function chooseApp(platform) {
75
132
  }
76
133
  }
77
134
  }
135
+ /** Persist an app selection in the requested brand-aware config file. */
78
136
  async function selectApp({ args, options, }) {
79
137
  const platform = await getPlatform(options.platform);
80
138
  const id = args[0]
81
139
  ? Number.parseInt(args[0], 10)
82
140
  : (await chooseApp(platform)).id;
83
- const configPath = options.config;
141
+ const configPath = options.config || constants_1.updateJson;
84
142
  let updateInfo = {};
85
143
  try {
86
- updateInfo = JSON.parse(await fs_1.default.promises.readFile(configPath || 'update.json', 'utf8'));
144
+ updateInfo = JSON.parse(await fs_1.default.promises.readFile(configPath, 'utf8'));
87
145
  }
88
146
  catch (e) {
89
147
  if (e.code !== 'ENOENT') {
90
- console.error((0, i18n_1.t)('failedToParseUpdateJson'));
148
+ console.error((0, i18n_1.t)('failedToParseUpdateJson', { configPath }));
91
149
  throw e;
92
150
  }
93
151
  }
@@ -96,10 +154,12 @@ async function selectApp({ args, options, }) {
96
154
  appId: id,
97
155
  appKey,
98
156
  };
99
- await fs_1.default.promises.writeFile(configPath || 'update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
157
+ await fs_1.default.promises.writeFile(configPath, JSON.stringify(updateInfo, null, 4), 'utf8');
100
158
  }
159
+ /** Build the application-management command handlers used by the CLI. */
101
160
  function getAppCommands() {
102
161
  return {
162
+ /** Create an app and select it in the same configuration file. */
103
163
  createApp: async ({ options, }) => {
104
164
  const name = options.name || (await (0, utils_1.question)((0, i18n_1.t)('appNameQuestion')));
105
165
  const { downloadUrl } = options;
@@ -108,9 +168,10 @@ function getAppCommands() {
108
168
  console.log((0, i18n_1.t)('createAppSuccess', { id }));
109
169
  await selectApp({
110
170
  args: [String(id)],
111
- options: { platform },
171
+ options: { platform, config: options.config },
112
172
  });
113
173
  },
174
+ /** Delete the specified app, or prompt for one when no ID is supplied. */
114
175
  deleteApp: async ({ args, options, }) => {
115
176
  const { platform } = options;
116
177
  const id = args[0] || (await chooseApp(platform)).id;
@@ -121,6 +182,7 @@ function getAppCommands() {
121
182
  await (0, api_1.doDelete)(`/app/${id}`);
122
183
  console.log((0, i18n_1.t)('operationSuccess'));
123
184
  },
185
+ /** List apps through the command interface. */
124
186
  apps: async ({ options }) => {
125
187
  const { platform = '' } = options;
126
188
  return listApp(platform);
package/lib/bin.js CHANGED
@@ -8,6 +8,7 @@ const cache_1 = require("./cache");
8
8
  const diff_1 = require("./diff");
9
9
  const install_1 = require("./install");
10
10
  const package_1 = require("./package");
11
+ const symbolicate_1 = require("./symbolicate");
11
12
  const user_1 = require("./user");
12
13
  const utils_1 = require("./utils");
13
14
  const i18n_1 = require("./utils/i18n");
@@ -38,6 +39,7 @@ const commandHandlers = {
38
39
  ...(0, app_1.getAppCommands)(),
39
40
  ...package_1.packageCommands,
40
41
  ...versions_1.versionCommands,
42
+ ...symbolicate_1.symbolicateCommands,
41
43
  ...install_1.installCommands,
42
44
  help: printUsage,
43
45
  };
package/lib/bundle.d.ts CHANGED
@@ -13,6 +13,8 @@ type NormalizedBundleOptions = {
13
13
  verifyHermesBase: boolean;
14
14
  resetCache: boolean;
15
15
  cacheMaxMb?: number;
16
+ appId?: string;
17
+ config?: string;
16
18
  name?: string;
17
19
  description?: string;
18
20
  metaInfo?: string;
@@ -26,8 +28,10 @@ type NormalizedBundleOptions = {
26
28
  sentryRelease?: string;
27
29
  sentryDist?: string;
28
30
  };
31
+ /** Normalize translated CLI values into the bundle command's typed options. */
29
32
  export declare function normalizeBundleOptions(translatedOptions: Record<string, unknown>, platform: string): NormalizedBundleOptions;
30
33
  export declare const bundleCommands: {
34
+ /** Build a bundle and optionally publish it to one operation-scoped app. */
31
35
  bundle: ({ options, }: {
32
36
  args?: string[];
33
37
  options: Record<string, unknown>;
package/lib/bundle.js CHANGED
@@ -18,14 +18,17 @@ const hermes_base_1 = require("./utils/hermes-base");
18
18
  const i18n_1 = require("./utils/i18n");
19
19
  const options_1 = require("./utils/options");
20
20
  const versions_1 = require("./versions");
21
+ /** Parse a positive cache-size option expressed in megabytes. */
21
22
  function parseCacheMaxMb(value) {
22
23
  const parsed = typeof value === 'string' ? Number(value) : value;
23
24
  return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
24
25
  }
26
+ /** Read either spelling of an aliased optional CLI string option. */
25
27
  function getAliasedOptionalStringOption(options, key, alias) {
26
28
  return ((0, options_1.getOptionalStringOption)(options, key) ??
27
29
  (0, options_1.getOptionalStringOption)(options, alias));
28
30
  }
31
+ /** Normalize translated CLI values into the bundle command's typed options. */
29
32
  function normalizeBundleOptions(translatedOptions, platform) {
30
33
  return {
31
34
  // harmony bundles always use this fixed name (runReactNativeBundleCommand
@@ -37,7 +40,9 @@ function normalizeBundleOptions(translatedOptions, platform) {
37
40
  intermediaDir: (0, options_1.getStringOption)(translatedOptions, 'intermediaDir', `${constants_1.tempDir}/intermedia/${platform}`),
38
41
  output: (0, options_1.getStringOption)(translatedOptions, 'output', `${constants_1.tempDir}/output/${platform}.\${time}.ppk`),
39
42
  dev: (0, options_1.getBooleanOption)(translatedOptions, 'dev', false) ? 'true' : 'false',
40
- sourcemap: (0, options_1.getBooleanOption)(translatedOptions, 'sourcemap', false),
43
+ // On by default since 2.23: the map is archived with the published
44
+ // version (pushy symbolicate). --no-sourcemap / --sourcemap=false opts out.
45
+ sourcemap: (0, options_1.getBooleanOption)(translatedOptions, 'sourcemap', true),
41
46
  taro: (0, options_1.getBooleanOption)(translatedOptions, 'taro', false),
42
47
  expo: (0, options_1.getBooleanOption)(translatedOptions, 'expo', false),
43
48
  rncli: (0, options_1.getBooleanOption)(translatedOptions, 'rncli', false),
@@ -46,6 +51,8 @@ function normalizeBundleOptions(translatedOptions, platform) {
46
51
  verifyHermesBase: (0, options_1.getBooleanOption)(translatedOptions, 'verifyHermesBase', true),
47
52
  resetCache: (0, options_1.getBooleanOption)(translatedOptions, 'resetCache', true),
48
53
  cacheMaxMb: parseCacheMaxMb(translatedOptions.cacheMaxMb),
54
+ appId: (0, options_1.getOptionalStringOption)(translatedOptions, 'appId'),
55
+ config: (0, options_1.getOptionalStringOption)(translatedOptions, 'config'),
49
56
  name: (0, options_1.getOptionalStringOption)(translatedOptions, 'name'),
50
57
  description: (0, options_1.getOptionalStringOption)(translatedOptions, 'description'),
51
58
  metaInfo: (0, options_1.getOptionalStringOption)(translatedOptions, 'metaInfo'),
@@ -60,6 +67,7 @@ function normalizeBundleOptions(translatedOptions, platform) {
60
67
  sentryDist: getAliasedOptionalStringOption(translatedOptions, 'sentry-dist', 'sentryDist'),
61
68
  };
62
69
  }
70
+ /** Upload generated Sentry artifacts when the detected plugin requires them. */
63
71
  async function uploadSentryArtifactsIfNeeded(shouldUpload, bundleName, intermediaDir, sourcemapOutput, platform, sentryOptions) {
64
72
  if (!shouldUpload) {
65
73
  return;
@@ -67,6 +75,7 @@ async function uploadSentryArtifactsIfNeeded(shouldUpload, bundleName, intermedi
67
75
  await (0, bundle_runner_1.copyDebugidForSentry)(bundleName, intermediaDir, sourcemapOutput);
68
76
  await (0, bundle_runner_1.uploadSourcemapForSentry)(bundleName, intermediaDir, sourcemapOutput, platform, sentryOptions);
69
77
  }
78
+ /** Publish a packed bundle through the version command implementation. */
70
79
  async function publishBundleVersion(outputPath, platform, payload) {
71
80
  return versions_1.versionCommands.publish({
72
81
  args: [outputPath],
@@ -77,6 +86,7 @@ async function publishBundleVersion(outputPath, platform, payload) {
77
86
  });
78
87
  }
79
88
  exports.bundleCommands = {
89
+ /** Build a bundle and optionally publish it to one operation-scoped app. */
80
90
  bundle: async ({ options, }) => {
81
91
  const platform = await (0, app_1.getPlatform)(typeof options.platform === 'string' ? options.platform : undefined);
82
92
  const translatedOptions = (0, utils_1.translateOptions)({
@@ -85,29 +95,51 @@ exports.bundleCommands = {
85
95
  platform,
86
96
  });
87
97
  const normalized = normalizeBundleOptions(translatedOptions, platform);
98
+ // One app per operation: the Hermes base lookup and the publish step must
99
+ // never see different apps, so the target is resolved once and reused.
100
+ let appId;
101
+ const getAppId = async () => (appId ??= await (0, app_1.resolveAppId)({
102
+ appId: normalized.appId,
103
+ config: normalized.config,
104
+ platform,
105
+ }));
106
+ const hermesBase = normalized.dev === 'true'
107
+ ? undefined
108
+ : {
109
+ option: normalized.hermesBase,
110
+ verify: normalized.verifyHermesBase,
111
+ cacheMaxMb: normalized.cacheMaxMb,
112
+ };
113
+ // Resolve before any side effect or expensive work. A named bundle is
114
+ // published, so a missing app fails right here; a bundle-only run only
115
+ // needs the app for the remote Hermes base lookup and may go on without
116
+ // one (it then compiles a full bundle). Any other config error (e.g.
117
+ // malformed JSON) is reported immediately either way.
118
+ if (normalized.name) {
119
+ await getAppId();
120
+ }
121
+ else if (hermesBase?.option === 'auto') {
122
+ try {
123
+ await getAppId();
124
+ }
125
+ catch (error) {
126
+ if (!(error instanceof app_1.AppNotSelectedError)) {
127
+ throw error;
128
+ }
129
+ }
130
+ }
88
131
  (0, check_lockfile_1.checkLockFiles)();
89
132
  (0, add_gitignore_1.addGitIgnore)();
90
- const bundleParams = await (0, utils_1.checkPlugins)();
133
+ const [bundleParams] = await Promise.all([
134
+ (0, utils_1.checkPlugins)(),
135
+ (0, hermes_base_1.cleanStaleTmp)().catch(() => { }),
136
+ ]);
91
137
  const sourcemapOutput = path_1.default.join(normalized.intermediaDir, `${normalized.bundleName}.map`);
92
138
  const realOutput = normalized.output.replace(/\$\{time\}/g, `${Date.now()}`);
93
139
  if (!platform) {
94
140
  throw new Error((0, i18n_1.t)('platformRequired'));
95
141
  }
96
142
  console.log((0, i18n_1.t)('bundlingWithRN', { version: dep_versions_1.depVersions['react-native'] }));
97
- await (0, hermes_base_1.cleanStaleTmp)().catch(() => { });
98
- // the hermes base lookup needs the app; resolve it up front but never
99
- // fail the bundle over it (publishing resolves it again and reports)
100
- let appIdForBase = typeof options.appId === 'string' && options.appId
101
- ? options.appId
102
- : undefined;
103
- if (!appIdForBase && normalized.hermesBase === 'auto') {
104
- try {
105
- appIdForBase = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
106
- }
107
- catch {
108
- appIdForBase = undefined;
109
- }
110
- }
111
143
  const hermesResult = await (0, bundle_runner_1.runReactNativeBundleCommand)({
112
144
  bundleName: normalized.bundleName,
113
145
  dev: normalized.dev,
@@ -116,14 +148,7 @@ exports.bundleCommands = {
116
148
  platform,
117
149
  sourcemapOutput: normalized.sourcemap || bundleParams.sourcemap ? sourcemapOutput : '',
118
150
  forceHermes: normalized.hermes,
119
- hermesBase: normalized.dev === 'true'
120
- ? undefined
121
- : {
122
- option: normalized.hermesBase,
123
- appId: appIdForBase,
124
- verify: normalized.verifyHermesBase,
125
- cacheMaxMb: normalized.cacheMaxMb,
126
- },
151
+ hermesBase: hermesBase ? { ...hermesBase, appId } : undefined,
127
152
  resetCache: normalized.resetCache,
128
153
  cli: {
129
154
  taro: normalized.taro,
@@ -138,6 +163,7 @@ exports.bundleCommands = {
138
163
  : undefined;
139
164
  if (normalized.name) {
140
165
  await publishBundleVersion(realOutput, platform, {
166
+ appId: await getAppId(),
141
167
  name: normalized.name,
142
168
  description: normalized.description,
143
169
  metaInfo: normalized.metaInfo,
@@ -149,6 +175,9 @@ exports.bundleCommands = {
149
175
  rollout: normalized.rollout,
150
176
  dryRun: normalized.dryRun,
151
177
  hermesBase: baseMeta,
178
+ sourcemap: normalized.sourcemap || bundleParams.sourcemap
179
+ ? sourcemapOutput
180
+ : undefined,
152
181
  });
153
182
  await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, platform, {
154
183
  sentryRelease: normalized.sentryRelease,
@@ -160,7 +189,11 @@ exports.bundleCommands = {
160
189
  const v = await (0, utils_1.question)((0, i18n_1.t)('uploadBundlePrompt'));
161
190
  if (v.toLowerCase() === 'y') {
162
191
  await publishBundleVersion(realOutput, platform, {
192
+ appId: await getAppId(),
163
193
  hermesBase: baseMeta,
194
+ sourcemap: normalized.sourcemap || bundleParams.sourcemap
195
+ ? sourcemapOutput
196
+ : undefined,
164
197
  });
165
198
  await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, platform, {
166
199
  sentryRelease: normalized.sentryRelease,
@@ -19,6 +19,7 @@ declare const _default: {
19
19
  appKeyMismatchIpa: string;
20
20
  appName: string;
21
21
  appNameQuestion: string;
22
+ appPlatformMismatch: string;
22
23
  appNotSelected: string;
23
24
  appUploadSuccess: string;
24
25
  apkUploadSuccess: string;
@@ -93,6 +94,14 @@ declare const _default: {
93
94
  processingPackage: string;
94
95
  processingStringPool: string;
95
96
  publishUsage: string;
97
+ sourceMapNotFound: string;
98
+ sourceMapMissingWarning: string;
99
+ sourceMapArchived: string;
100
+ sourceMapUploadFailedWarning: string;
101
+ symbolicateUsage: string;
102
+ symbolicateVersionNotFound: string;
103
+ symbolicateNoSourceMap: string;
104
+ symbolicateDone: string;
96
105
  rnuVersionNotFound: string;
97
106
  rolloutConfigSet: string;
98
107
  rolloutRangeError: string;
package/lib/locales/en.js CHANGED
@@ -13,14 +13,15 @@ exports.default = {
13
13
  aabParseManifestError: 'Parse AndroidManifest.xml error: {{error}}',
14
14
  aabParseResourcesError: 'Parser resources.arsc error: {{error}}',
15
15
  appId: 'App ID',
16
- appIdMismatchApk: 'App ID mismatch! Current APK: {{appIdInPkg}}, current update.json: {{appId}}',
17
- appIdMismatchApp: 'App ID mismatch! Current APP: {{appIdInPkg}}, current update.json: {{appId}}',
18
- appIdMismatchIpa: 'App ID mismatch! Current IPA: {{appIdInPkg}}, current update.json: {{appId}}',
19
- appKeyMismatchApk: 'App Key mismatch! Current APK: {{appKeyInPkg}}, current update.json: {{appKey}}',
20
- appKeyMismatchApp: 'App Key mismatch! Current APP: {{appKeyInPkg}}, current update.json: {{appKey}}',
21
- appKeyMismatchIpa: 'App Key mismatch! Current IPA: {{appKeyInPkg}}, current update.json: {{appKey}}',
16
+ appIdMismatchApk: 'App ID mismatch! Current APK: {{appIdInPkg}}, current {{- source}}: {{appId}}',
17
+ appIdMismatchApp: 'App ID mismatch! Current APP: {{appIdInPkg}}, current {{- source}}: {{appId}}',
18
+ appIdMismatchIpa: 'App ID mismatch! Current IPA: {{appIdInPkg}}, current {{- source}}: {{appId}}',
19
+ appKeyMismatchApk: 'App Key mismatch! Current APK: {{appKeyInPkg}}, current {{- source}}: {{appKey}}',
20
+ appKeyMismatchApp: 'App Key mismatch! Current APP: {{appKeyInPkg}}, current {{- source}}: {{appKey}}',
21
+ appKeyMismatchIpa: 'App Key mismatch! Current IPA: {{appKeyInPkg}}, current {{- source}}: {{appKey}}',
22
22
  appName: 'App Name',
23
23
  appNameQuestion: 'App Name:',
24
+ appPlatformMismatch: 'App {{appId}} is a {{appPlatform}} app, but this command targets {{platform}}',
24
25
  appNotSelected: 'App not selected. run `cresc selectApp --platform {{platform}}` first!',
25
26
  appUploadSuccess: 'Successfully uploaded APP native package (id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
26
27
  apkUploadSuccess: 'Successfully uploaded APK native package (id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
@@ -42,7 +43,7 @@ exports.default = {
42
43
  errorInHarmonyApp: 'Error in getEntryFromHarmonyApp: {{error}}',
43
44
  expiredStatus: '(Expired)',
44
45
  failedToParseIcon: '[Warning] failed to parse icon: {{error}}',
45
- failedToParseUpdateJson: 'Failed to parse file `update.json`. Try to remove it manually.',
46
+ failedToParseUpdateJson: 'Failed to parse file `{{- configPath}}`. Try to remove it manually.',
46
47
  fileGenerated: '{{- file}} generated.',
47
48
  fileSizeExceeded: 'This file size is {{fileSize}} , exceeding the current quota {{maxSize}} . You may consider upgrading to a higher plan to increase this quota. Details can be found at: {{- pricingPageUrl}}',
48
49
  forceHermes: 'Forcing Hermes enabled for this build',
@@ -101,6 +102,14 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
101
102
  processingPackage: 'Processing the package {{count}} ...',
102
103
  processingStringPool: 'Processing the string pool ...',
103
104
  publishUsage: 'Usage: pushy publish <ppk file> --platform ios|android|harmony',
105
+ sourceMapNotFound: 'Source map not found: {{path}}',
106
+ sourceMapMissingWarning: 'No source map was archived with this version: crashes cannot be symbolicated later. Bundle with the default --sourcemap, or pass --sourcemap <file> to publish.',
107
+ sourceMapArchived: 'Source map archived with version {{id}}',
108
+ sourceMapUploadFailedWarning: 'Source map upload failed ({{error}}); publishing without an archived map. Upgrade the update server to archive source maps.',
109
+ symbolicateUsage: 'Usage: pushy symbolicate <stack file | -> --hash <updateHash> [--platform ios|android|harmony] [--output <file>]',
110
+ symbolicateVersionNotFound: 'No published version with hash {{hash}} found for this app',
111
+ symbolicateNoSourceMap: 'Version {{id}} was published without a source map; nothing to symbolicate against',
112
+ symbolicateDone: 'Symbolicated {{count}} frame(s) against version {{id}} ({{hash}})',
104
113
  rnuVersionNotFound: 'react-native-update: Cannot get the version number. Please run the command in the project directory',
105
114
  rolloutConfigSet: 'Set {{rollout}}% rollout for OTA update {{version}} on native version(s) {{versions}}',
106
115
  rolloutRangeError: 'rollout must be an integer between 1-100',
@@ -19,6 +19,7 @@ declare const _default: {
19
19
  appKeyMismatchIpa: string;
20
20
  appName: string;
21
21
  appNameQuestion: string;
22
+ appPlatformMismatch: string;
22
23
  appNotSelected: string;
23
24
  appUploadSuccess: string;
24
25
  apkUploadSuccess: string;
@@ -92,6 +93,14 @@ declare const _default: {
92
93
  processingError: string;
93
94
  processingPackage: string;
94
95
  processingStringPool: string;
96
+ sourceMapNotFound: string;
97
+ sourceMapMissingWarning: string;
98
+ sourceMapArchived: string;
99
+ sourceMapUploadFailedWarning: string;
100
+ symbolicateUsage: string;
101
+ symbolicateVersionNotFound: string;
102
+ symbolicateNoSourceMap: string;
103
+ symbolicateDone: string;
95
104
  publishUsage: string;
96
105
  rnuVersionNotFound: string;
97
106
  rolloutConfigSet: string;