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/lib/locales/zh.js CHANGED
@@ -13,14 +13,15 @@ exports.default = {
13
13
  aabParseManifestError: '解析 AndroidManifest.xml 出错:{{error}}',
14
14
  aabParseResourcesError: '解析 resources.arsc 出错:{{error}}',
15
15
  appId: '应用 id',
16
- appIdMismatchApk: 'appId不匹配!当前apk: {{appIdInPkg}}, 当前update.json: {{appId}}',
17
- appIdMismatchApp: 'appId不匹配!当前app: {{appIdInPkg}}, 当前update.json: {{appId}}',
18
- appIdMismatchIpa: 'appId不匹配!当前ipa: {{appIdInPkg}}, 当前update.json: {{appId}}',
19
- appKeyMismatchApk: 'appKey不匹配!当前apk: {{appKeyInPkg}}, 当前update.json: {{appKey}}',
20
- appKeyMismatchApp: 'appKey不匹配!当前app: {{appKeyInPkg}}, 当前update.json: {{appKey}}',
21
- appKeyMismatchIpa: 'appKey不匹配!当前ipa: {{appKeyInPkg}}, 当前update.json: {{appKey}}',
16
+ appIdMismatchApk: 'appId不匹配!当前apk: {{appIdInPkg}}, 当前{{- source}}: {{appId}}',
17
+ appIdMismatchApp: 'appId不匹配!当前app: {{appIdInPkg}}, 当前{{- source}}: {{appId}}',
18
+ appIdMismatchIpa: 'appId不匹配!当前ipa: {{appIdInPkg}}, 当前{{- source}}: {{appId}}',
19
+ appKeyMismatchApk: 'appKey不匹配!当前apk: {{appKeyInPkg}}, 当前{{- source}}: {{appKey}}',
20
+ appKeyMismatchApp: 'appKey不匹配!当前app: {{appKeyInPkg}}, 当前{{- source}}: {{appKey}}',
21
+ appKeyMismatchIpa: 'appKey不匹配!当前ipa: {{appKeyInPkg}}, 当前{{- source}}: {{appKey}}',
22
22
  appName: '应用名称',
23
23
  appNameQuestion: '应用名称:',
24
+ appPlatformMismatch: '应用 {{appId}} 是 {{appPlatform}} 平台的应用,但当前命令的平台是 {{platform}}',
24
25
  appNotSelected: '尚未选择应用。请先运行 `pushy selectApp --platform {{platform}}` 来选择应用',
25
26
  appUploadSuccess: '已成功上传app原生包(id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
26
27
  apkUploadSuccess: '已成功上传apk原生包(id: {{id}}, version: {{version}}, buildTime: {{buildTime}})',
@@ -42,7 +43,7 @@ exports.default = {
42
43
  errorInHarmonyApp: '获取 Harmony 应用入口时出错:{{error}}',
43
44
  expiredStatus: '(已过期)',
44
45
  failedToParseIcon: '[警告] 解析图标失败:{{error}}',
45
- failedToParseUpdateJson: '无法解析文件 `update.json`。请手动删除它。',
46
+ failedToParseUpdateJson: '无法解析文件 `{{- configPath}}`。请手动删除它。',
46
47
  fileGenerated: '已生成 {{- file}}',
47
48
  fileSizeExceeded: '此文件大小 {{fileSize}} , 超出当前额度 {{maxSize}} 。您可以考虑升级付费业务以提升此额度。详情请访问: {{- pricingPageUrl}}',
48
49
  forceHermes: '强制启用 Hermes 编译',
@@ -100,6 +101,14 @@ exports.default = {
100
101
  processingError: '处理文件时出错:{{error}}',
101
102
  processingPackage: '正在处理包 {{count}}...',
102
103
  processingStringPool: '正在处理字符串池...',
104
+ sourceMapNotFound: '找不到 source map:{{path}}',
105
+ sourceMapMissingWarning: '本版本没有归档 source map,之后的崩溃堆栈将无法还原。请用默认的 --sourcemap 打包,或在 publish 时传 --sourcemap <文件>。',
106
+ sourceMapArchived: 'source map 已随版本 {{id}} 归档',
107
+ sourceMapUploadFailedWarning: 'source map 上传失败({{error}}),本次发布不归档 map。升级更新服务端后可归档 source map。',
108
+ symbolicateUsage: '用法:pushy symbolicate <堆栈文件 | -> --hash <热更 hash> [--platform ios|android|harmony] [--output <文件>]',
109
+ symbolicateVersionNotFound: '当前应用下找不到 hash 为 {{hash}} 的已发布版本',
110
+ symbolicateNoSourceMap: '版本 {{id}} 发布时未归档 source map,无法还原',
111
+ symbolicateDone: '已按版本 {{id}}({{hash}})还原 {{count}} 个堆栈帧',
103
112
  publishUsage: '使用方法: pushy publish ppk后缀文件 --platform ios|android|harmony',
104
113
  rnuVersionNotFound: 'react-native-update: 无法获取版本号。请在项目目录中运行命令',
105
114
  rolloutConfigSet: '已在原生版本 {{versions}} 上设置灰度发布 {{rollout}}% 热更包 {{version}}',
package/lib/package.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { Package, Platform } from './types';
2
2
  type PackageCommandOptions = Record<string, unknown> & {
3
3
  appId?: string;
4
4
  appKey?: string;
5
+ config?: string;
5
6
  platform?: Platform;
6
7
  version?: string;
7
8
  packageId?: string;
package/lib/package.js CHANGED
@@ -47,6 +47,7 @@ const api_1 = require("./api");
47
47
  const app_1 = require("./app");
48
48
  const native_package_1 = require("./native-package");
49
49
  const utils_1 = require("./utils");
50
+ const constants_1 = require("./utils/constants");
50
51
  const dep_versions_1 = require("./utils/dep-versions");
51
52
  const git_1 = require("./utils/git");
52
53
  const hermes_base_1 = require("./utils/hermes-base");
@@ -108,11 +109,13 @@ async function uploadNativePackage(filePath, options, config) {
108
109
  }
109
110
  : await (0, app_1.getSelectedApp)(config.platform, options.config);
110
111
  const { appId, appKey } = selectedApp;
112
+ // where the expected app came from, for the mismatch messages
113
+ const source = options.appId ? '--appId' : options.config || constants_1.updateJson;
111
114
  if (appIdInPkg && String(appIdInPkg) !== appId) {
112
- throw new Error((0, i18n_1.t)(config.appIdMismatchKey, { appIdInPkg, appId }));
115
+ throw new Error((0, i18n_1.t)(config.appIdMismatchKey, { appIdInPkg, appId, source }));
113
116
  }
114
117
  if (appKeyInPkg && appKey && appKeyInPkg !== appKey) {
115
- throw new Error((0, i18n_1.t)(config.appKeyMismatchKey, { appKeyInPkg, appKey }));
118
+ throw new Error((0, i18n_1.t)(config.appKeyMismatchKey, { appKeyInPkg, appKey, source }));
116
119
  }
117
120
  const customVersion = typeof options.version === 'string' && options.version
118
121
  ? options.version
@@ -313,21 +316,12 @@ exports.packageCommands = {
313
316
  console.log((0, i18n_1.t)('apkExtracted', { output }));
314
317
  },
315
318
  packages: async ({ options, }) => {
316
- let appId = options.appId;
317
- if (!appId) {
318
- const platform = await (0, app_1.getPlatform)(options.platform);
319
- appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
320
- }
321
- await listPackage(String(appId));
319
+ await listPackage(await (0, app_1.resolveAppId)(options));
322
320
  },
323
321
  deletePackage: async ({ options }) => {
324
- let { appId } = options;
322
+ const appId = await (0, app_1.resolveAppId)(options);
325
323
  let packageIds = (0, options_1.getStringListOption)(options, 'packageIds') ??
326
324
  (0, options_1.getStringListOption)(options, 'packageId');
327
- if (!appId) {
328
- const platform = await (0, app_1.getPlatform)(options.platform);
329
- appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
330
- }
331
325
  if (!packageIds) {
332
326
  const packageVersions = (0, options_1.getStringListOption)(options, 'packageVersion');
333
327
  if (!packageVersions) {
package/lib/provider.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BundleOptions, CLIProvider, CommandResult, Platform, PublishOptions, Session, UpdateVersionOptions, UploadOptions } from './types';
1
+ import type { BundleOptions, CLIProvider, CommandResult, Platform, PublishOptions, Session, SymbolicateOptions, UpdateVersionOptions, UploadOptions } from './types';
2
2
  export declare class CLIProviderImpl implements CLIProvider {
3
3
  private session?;
4
4
  private sessionInitPromise?;
@@ -8,8 +8,9 @@ export declare class CLIProviderImpl implements CLIProvider {
8
8
  private runDataCommand;
9
9
  bundle(options: BundleOptions): Promise<CommandResult>;
10
10
  publish(options: PublishOptions): Promise<CommandResult>;
11
+ symbolicate(options: SymbolicateOptions): Promise<CommandResult>;
11
12
  upload(options: UploadOptions): Promise<CommandResult>;
12
- getSelectedApp(platform?: Platform): Promise<{
13
+ getSelectedApp(platform?: Platform, config?: string): Promise<{
13
14
  appId: string;
14
15
  platform: Platform;
15
16
  }>;
package/lib/provider.js CHANGED
@@ -93,6 +93,8 @@ class CLIProviderImpl {
93
93
  verifyHermesBase: options.verifyHermesBase ?? true,
94
94
  sentryRelease: options.sentryRelease,
95
95
  sentryDist: options.sentryDist,
96
+ appId: options.appId,
97
+ config: options.config,
96
98
  });
97
99
  const { bundleCommands } = await Promise.resolve().then(() => __importStar(require('./bundle')));
98
100
  await bundleCommands.bundle(context);
@@ -117,11 +119,26 @@ class CLIProviderImpl {
117
119
  ? undefined
118
120
  : String(options.rollout),
119
121
  dryRun: options.dryRun || false,
122
+ sourcemap: options.sourcemap,
120
123
  }, options.filePath ? [options.filePath] : []);
121
124
  const { versionCommands } = await Promise.resolve().then(() => __importStar(require('./versions')));
122
125
  await versionCommands.publish(context);
123
126
  }, 'Unknown error during publishing', 'Version published successfully');
124
127
  }
128
+ async symbolicate(options) {
129
+ return this.runMessageCommand(async () => {
130
+ const context = this.createContext({
131
+ hash: options.hash,
132
+ versionId: options.versionId,
133
+ platform: options.platform,
134
+ appId: options.appId,
135
+ config: options.config,
136
+ output: options.output,
137
+ }, options.stackFile ? [options.stackFile] : []);
138
+ const { symbolicateCommands } = await Promise.resolve().then(() => __importStar(require('./symbolicate')));
139
+ await symbolicateCommands.symbolicate(context);
140
+ }, 'Unknown error during symbolication', 'Stack symbolicated');
141
+ }
125
142
  async upload(options) {
126
143
  return this.runMessageCommand(async () => {
127
144
  const filePath = options.filePath;
@@ -149,9 +166,9 @@ class CLIProviderImpl {
149
166
  await uploadHandler(context);
150
167
  }, 'Unknown error during upload', 'File uploaded successfully');
151
168
  }
152
- async getSelectedApp(platform) {
169
+ async getSelectedApp(platform, config) {
153
170
  const resolvedPlatform = await this.getPlatform(platform);
154
- return (0, app_1.getSelectedApp)(resolvedPlatform);
171
+ return (0, app_1.getSelectedApp)(resolvedPlatform, config);
155
172
  }
156
173
  async listApps(platform) {
157
174
  return this.runDataCommand(async () => {
@@ -0,0 +1,30 @@
1
+ export interface FrameConsumer {
2
+ originalPositionFor(position: {
3
+ line: number;
4
+ column: number;
5
+ }): {
6
+ source?: string | null;
7
+ line?: number | null;
8
+ column?: number | null;
9
+ name?: string | null;
10
+ };
11
+ }
12
+ /**
13
+ * Rewrites every bundle frame of `stack` to its original source position.
14
+ * JS engines report 1-based columns, so they are shifted to the 0-based
15
+ * columns source maps use; Hermes bytecode frames (`address at`) carry the
16
+ * bytecode offset, which the composed hermes map keys directly.
17
+ */
18
+ export declare function symbolicateStack(stack: string, consumer: FrameConsumer): {
19
+ text: string;
20
+ mapped: number;
21
+ };
22
+ export declare const symbolicateCommands: {
23
+ symbolicate: ({ args, options, }: {
24
+ args: string[];
25
+ options: Record<string, unknown>;
26
+ }) => Promise<{
27
+ versionId: string;
28
+ mapped: number;
29
+ }>;
30
+ };
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.symbolicateCommands = void 0;
7
+ exports.symbolicateStack = symbolicateStack;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const node_fetch_1 = __importDefault(require("node-fetch"));
10
+ const source_map_1 = require("source-map");
11
+ const api_1 = require("./api");
12
+ const app_1 = require("./app");
13
+ const i18n_1 = require("./utils/i18n");
14
+ const versions_1 = require("./versions");
15
+ // A frame location inside a shipped bundle: `<bundle>:<line>:<column>`. Covers
16
+ // `index.bundlejs`, `index.android.bundle`, `main.jsbundle`, `bundle.harmony.js`
17
+ // and plain `.js`/`.hbc` names; an optional `address at ` prefix marks a
18
+ // Hermes bytecode frame (column = bytecode offset, already 0-based).
19
+ const FRAME_PATTERN = /(address at )?((?:[\w.-]+\/)*[\w.-]+\.(?:bundlejs|jsbundle|bundle|hbc|js))(?:\?[^\s:)]*)?:(\d+):(\d+)/g;
20
+ /**
21
+ * Rewrites every bundle frame of `stack` to its original source position.
22
+ * JS engines report 1-based columns, so they are shifted to the 0-based
23
+ * columns source maps use; Hermes bytecode frames (`address at`) carry the
24
+ * bytecode offset, which the composed hermes map keys directly.
25
+ */
26
+ function symbolicateStack(stack, consumer) {
27
+ let mapped = 0;
28
+ const text = stack.replace(FRAME_PATTERN, (frame, hermes, _bundle, line, column) => {
29
+ const position = consumer.originalPositionFor({
30
+ line: Number(line),
31
+ column: hermes ? Number(column) : Math.max(0, Number(column) - 1),
32
+ });
33
+ if (!position.source ||
34
+ position.line === null ||
35
+ position.line === undefined) {
36
+ return frame;
37
+ }
38
+ mapped++;
39
+ const original = `${position.source}:${position.line}:${(position.column ?? 0) + 1}`;
40
+ return position.name ? `${original} (${position.name})` : original;
41
+ });
42
+ return { text, mapped };
43
+ }
44
+ async function findVersionByHash(appId, hash) {
45
+ const limit = 100;
46
+ // The list is newest-first; crashes are usually about recent versions.
47
+ for (let offset = 0; offset < 100 * limit; offset += limit) {
48
+ const page = await (0, versions_1.fetchVersions)(appId, offset, limit);
49
+ const found = page.find((version) => version.hash === hash);
50
+ if (found) {
51
+ return found;
52
+ }
53
+ if (page.length < limit) {
54
+ return undefined;
55
+ }
56
+ }
57
+ return undefined;
58
+ }
59
+ async function readStack(source) {
60
+ if (!source || source === '-') {
61
+ return new Promise((resolve, reject) => {
62
+ const chunks = [];
63
+ process.stdin.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
64
+ process.stdin.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
65
+ process.stdin.on('error', reject);
66
+ });
67
+ }
68
+ return fs_1.default.readFileSync(source, 'utf8');
69
+ }
70
+ exports.symbolicateCommands = {
71
+ symbolicate: async ({ args, options, }) => {
72
+ const hash = typeof options.hash === 'string' ? options.hash : '';
73
+ const versionIdOption = typeof options.versionId === 'string' ? options.versionId : '';
74
+ if (!hash && !versionIdOption) {
75
+ throw new Error((0, i18n_1.t)('symbolicateUsage'));
76
+ }
77
+ const platform = await (0, app_1.getPlatform)(typeof options.platform === 'string'
78
+ ? options.platform
79
+ : undefined);
80
+ const appId = typeof options.appId === 'string' && options.appId
81
+ ? options.appId
82
+ : (await (0, app_1.getSelectedApp)(platform, options.config))
83
+ .appId;
84
+ let versionId = versionIdOption;
85
+ if (!versionId) {
86
+ const version = await findVersionByHash(appId, hash);
87
+ if (!version) {
88
+ throw new Error((0, i18n_1.t)('symbolicateVersionNotFound', { hash }));
89
+ }
90
+ versionId = String(version.id);
91
+ }
92
+ const located = await (0, api_1.get)(`/app/${appId}/version/${versionId}/sourceMap`);
93
+ if (!located?.url) {
94
+ throw new Error((0, i18n_1.t)('symbolicateNoSourceMap', { id: versionId }));
95
+ }
96
+ const response = await (0, node_fetch_1.default)(located.url);
97
+ if (!response.ok) {
98
+ throw new Error(`Failed to download source map: HTTP ${response.status}`);
99
+ }
100
+ const rawMap = JSON.parse(await response.text());
101
+ const consumer = new source_map_1.SourceMapConsumer(rawMap);
102
+ const stack = await readStack(args[0]);
103
+ const { text, mapped } = symbolicateStack(stack, consumer);
104
+ if (typeof options.output === 'string' && options.output) {
105
+ fs_1.default.writeFileSync(options.output, text);
106
+ }
107
+ else {
108
+ process.stdout.write(text.endsWith('\n') ? text : `${text}\n`);
109
+ }
110
+ console.error((0, i18n_1.t)('symbolicateDone', {
111
+ count: mapped,
112
+ id: versionId,
113
+ hash: located.hash ?? hash,
114
+ }));
115
+ return { versionId, mapped };
116
+ },
117
+ };
package/lib/types.d.ts CHANGED
@@ -23,6 +23,8 @@ export interface Version {
23
23
  name: string;
24
24
  packages?: Package[];
25
25
  deps?: Record<string, string> | string | null;
26
+ /** storage key of the archived source map (absent when published without one) */
27
+ sourceMapKey?: string;
26
28
  }
27
29
  export interface CommandContext<TOptions extends Record<string, unknown> = Record<string, unknown>> {
28
30
  args: string[];
@@ -55,9 +57,15 @@ export interface BundleOptions {
55
57
  resetCache?: boolean;
56
58
  sentryRelease?: string;
57
59
  sentryDist?: string;
60
+ /** publish to this app instead of the one selected in the config file */
61
+ appId?: string;
62
+ /** selected-app config file (default: update.json) */
63
+ config?: string;
58
64
  }
59
65
  export interface PublishOptions {
60
66
  filePath?: string;
67
+ /** path of the final source map to archive with the version */
68
+ sourcemap?: string;
61
69
  platform?: Platform;
62
70
  name?: string;
63
71
  description?: string;
@@ -90,13 +98,26 @@ export interface UpdateVersionOptions {
90
98
  rollout?: number | string;
91
99
  dryRun?: boolean;
92
100
  }
101
+ export interface SymbolicateOptions {
102
+ /** stack trace file ('-' for stdin) */
103
+ stackFile?: string;
104
+ /** update hash of the running version (from getUpdateMetadata().currentVersion) */
105
+ hash?: string;
106
+ versionId?: string;
107
+ platform?: Platform;
108
+ appId?: string;
109
+ config?: string;
110
+ /** write the symbolicated stack here instead of stdout */
111
+ output?: string;
112
+ }
93
113
  export interface CLIProvider {
94
114
  bundle: (options: BundleOptions) => Promise<CommandResult>;
95
115
  publish: (options: PublishOptions) => Promise<CommandResult>;
116
+ symbolicate: (options: SymbolicateOptions) => Promise<CommandResult>;
96
117
  upload: (options: UploadOptions) => Promise<CommandResult>;
97
118
  createApp: (name: string, platform: Platform) => Promise<CommandResult>;
98
119
  listApps: (platform?: Platform) => Promise<CommandResult>;
99
- getSelectedApp: (platform?: Platform) => Promise<{
120
+ getSelectedApp: (platform?: Platform, config?: string) => Promise<{
100
121
  appId: string;
101
122
  platform: Platform;
102
123
  }>;
@@ -3,7 +3,7 @@ export declare const IS_CRESC: boolean;
3
3
  export declare const ppkBundleFileNames: string[];
4
4
  export declare const isPPKBundleFileName: (fileName: string) => boolean;
5
5
  export declare const credentialFile: string;
6
- export declare const updateJson: string;
6
+ export declare const updateJson = "update.json";
7
7
  export declare const tempDir: string;
8
8
  export declare const pricingPageUrl: string;
9
9
  export declare const defaultEndpoints: string[];
@@ -14,7 +14,9 @@ exports.ppkBundleFileNames = ['index.bundlejs', 'bundle.harmony.js'];
14
14
  const isPPKBundleFileName = (fileName) => exports.ppkBundleFileNames.includes(fileName);
15
15
  exports.isPPKBundleFileName = isPPKBundleFileName;
16
16
  exports.credentialFile = exports.IS_CRESC ? '.cresc.token' : '.update';
17
- exports.updateJson = exports.IS_CRESC ? 'cresc.config.json' : 'update.json';
17
+ // Both brands select apps in update.json: the cresc docs and the client SDK
18
+ // (`import _updateConfig from './update.json'`) read that name too.
19
+ exports.updateJson = 'update.json';
18
20
  exports.tempDir = exports.IS_CRESC ? '.cresc.temp' : '.pushy';
19
21
  exports.pricingPageUrl = exports.IS_CRESC
20
22
  ? 'https://cresc.dev/pricing'
package/lib/versions.js CHANGED
@@ -8,6 +8,7 @@ exports.normalizeDeps = normalizeDeps;
8
8
  exports.fetchVersions = fetchVersions;
9
9
  const chalk_1 = __importDefault(require("chalk"));
10
10
  const compare_versions_1 = require("compare-versions");
11
+ const fs_1 = __importDefault(require("fs"));
11
12
  const api_1 = require("./api");
12
13
  const app_1 = require("./app");
13
14
  const package_1 = require("./package");
@@ -366,20 +367,48 @@ exports.versionCommands = {
366
367
  throw new Error((0, i18n_1.t)('publishUsage'));
367
368
  }
368
369
  const platform = await (0, app_1.getPlatform)(options.platform);
369
- let appId = options.appId;
370
- if (!appId) {
371
- appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
372
- }
370
+ const appId = await (0, app_1.resolveAppId)({ ...options, platform });
373
371
  const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
372
+ // The source map is archived with the version so `pushy symbolicate` can
373
+ // map crashes back to source. An explicit path that does not exist is a
374
+ // publish error; no path at all is a loud warning (custom pipelines that
375
+ // never produced a map keep working).
376
+ const sourcemapPath = typeof options.sourcemap === 'string' && options.sourcemap
377
+ ? options.sourcemap
378
+ : undefined;
379
+ if (sourcemapPath && !fs_1.default.existsSync(sourcemapPath)) {
380
+ throw new Error((0, i18n_1.t)('sourceMapNotFound', { path: sourcemapPath }));
381
+ }
382
+ if (!sourcemapPath) {
383
+ console.log(chalk_1.default.yellow((0, i18n_1.t)('sourceMapMissingWarning')));
384
+ }
374
385
  // Hashing/caching the bundle and asking git for the commit are independent
375
386
  // of the upload, so they overlap with it instead of running afterwards.
376
387
  // describePpkBundle never rejects (best effort); a failed upload still
377
388
  // fails the publish exactly as before.
378
- const [{ hash }, bundleMeta, commit] = await Promise.all([
389
+ // A server that predates source-map archiving (self-hosted, or a SaaS
390
+ // region not yet rolled) rejects the .map upload with 400; that must not
391
+ // fail the publish, only lose the archive.
392
+ let sourceMapUploadError;
393
+ const [{ hash }, bundleMeta, commit, sourceMapUpload] = await Promise.all([
379
394
  (0, api_1.uploadFile)(fn, undefined, appId),
380
395
  describePpkBundle(fn, options.hermesBase),
381
396
  (0, git_1.getCommitInfo)(),
397
+ sourcemapPath
398
+ ? (0, api_1.uploadFile)(sourcemapPath, undefined, appId).catch((error) => {
399
+ sourceMapUploadError = error;
400
+ return undefined;
401
+ })
402
+ : Promise.resolve(undefined),
382
403
  ]);
404
+ const sourceMapKey = sourceMapUpload?.hash;
405
+ if (sourcemapPath && !sourceMapKey) {
406
+ console.log(chalk_1.default.yellow((0, i18n_1.t)('sourceMapUploadFailedWarning', {
407
+ error: sourceMapUploadError instanceof Error
408
+ ? sourceMapUploadError.message
409
+ : String(sourceMapUploadError),
410
+ })));
411
+ }
383
412
  const depVersions = (0, dep_versions_1.getDepVersions)();
384
413
  const versionName = name ||
385
414
  (nonInteractive ? '' : await (0, utils_1.question)((0, i18n_1.t)('versionNameQuestion'))) ||
@@ -395,8 +424,13 @@ exports.versionCommands = {
395
424
  commit,
396
425
  // Hermes delta-mode chain metadata (old servers drop unknown fields)
397
426
  ...bundleMeta,
427
+ // archived source map (old servers drop unknown fields)
428
+ ...(sourceMapKey ? { sourceMapKey } : {}),
398
429
  });
399
430
  console.log((0, i18n_1.t)('packageUploadSuccess', { id }));
431
+ if (sourceMapKey) {
432
+ console.log((0, i18n_1.t)('sourceMapArchived', { id }));
433
+ }
400
434
  const { packageId, packageVersion, packageVersionRange, minPackageVersion, maxPackageVersion, rollout, dryRun, } = options;
401
435
  if (packageId ||
402
436
  packageVersion ||
@@ -407,6 +441,7 @@ exports.versionCommands = {
407
441
  options: {
408
442
  versionId: id,
409
443
  platform,
444
+ appId,
410
445
  packageId,
411
446
  packageVersion,
412
447
  packageVersionRange,
@@ -426,6 +461,7 @@ exports.versionCommands = {
426
461
  options: {
427
462
  versionId: id,
428
463
  platform,
464
+ appId,
429
465
  versionDeps: depVersions,
430
466
  warnDepsChanges: true,
431
467
  },
@@ -435,31 +471,19 @@ exports.versionCommands = {
435
471
  return versionName;
436
472
  },
437
473
  versions: async ({ options }) => {
438
- let appId = options.appId;
439
- if (!appId) {
440
- const platform = await (0, app_1.getPlatform)(options.platform);
441
- appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
442
- }
474
+ const appId = await (0, app_1.resolveAppId)(options);
443
475
  const interactive = !((0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)());
444
- await listVersions(String(appId), interactive);
476
+ await listVersions(appId, interactive);
445
477
  },
446
478
  update: async ({ options }) => {
447
479
  const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
448
- let appId = options.appId;
449
- let platform = options.platform;
450
- if (!appId) {
451
- platform = await (0, app_1.getPlatform)(platform);
452
- appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
453
- }
454
- else if (platform) {
455
- platform = await (0, app_1.getPlatform)(platform);
456
- }
480
+ const appId = await (0, app_1.resolveAppId)(options);
457
481
  let versionId = options.versionId;
458
482
  if (!versionId) {
459
483
  if (nonInteractive) {
460
484
  throw new Error((0, i18n_1.t)('versionIdRequired'));
461
485
  }
462
- versionId = String((await chooseVersion(String(appId))).id);
486
+ versionId = String((await chooseVersion(appId)).id);
463
487
  }
464
488
  if (versionId === 'null') {
465
489
  versionId = null;
@@ -476,7 +500,7 @@ exports.versionCommands = {
476
500
  throw new Error((0, i18n_1.t)('rolloutRangeError'));
477
501
  }
478
502
  }
479
- const allPkgs = await (0, api_1.getAllPackages)(String(appId));
503
+ const allPkgs = await (0, api_1.getAllPackages)(appId);
480
504
  if (!allPkgs) {
481
505
  throw new Error((0, i18n_1.t)('noPackagesFound', { appId }));
482
506
  }
@@ -535,7 +559,7 @@ exports.versionCommands = {
535
559
  throw new Error((0, i18n_1.t)('packageIdRequired'));
536
560
  }
537
561
  // the package list was already fetched above: no second round trip
538
- pkgId = String((await (0, package_1.choosePackage)(String(appId), allPkgs)).id);
562
+ pkgId = String((await (0, package_1.choosePackage)(appId, allPkgs)).id);
539
563
  }
540
564
  if (!pkgId) {
541
565
  throw new Error((0, i18n_1.t)('packageIdRequired'));
@@ -550,14 +574,14 @@ exports.versionCommands = {
550
574
  }
551
575
  if (options.warnDepsChanges && versionId) {
552
576
  await printDepsChangesForPublish({
553
- appId: String(appId),
577
+ appId,
554
578
  versionId: String(versionId),
555
579
  pkgs: pkgsToBind,
556
580
  providedVersionDeps: options.versionDeps,
557
581
  });
558
582
  }
559
583
  await (0, exports.bindVersionToPackages)({
560
- appId: String(appId),
584
+ appId,
561
585
  // keep null as-is: `--versionId null` means unbinding the version
562
586
  versionId: versionId ?? null,
563
587
  pkgs: pkgsToBind,
@@ -567,21 +591,13 @@ exports.versionCommands = {
567
591
  },
568
592
  updateVersionInfo: async ({ options, }) => {
569
593
  const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
570
- let appId = options.appId;
571
- let platform = options.platform;
572
- if (!appId) {
573
- platform = await (0, app_1.getPlatform)(platform);
574
- appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
575
- }
576
- else if (platform) {
577
- await (0, app_1.getPlatform)(platform);
578
- }
594
+ const appId = await (0, app_1.resolveAppId)(options);
579
595
  let versionId = options.versionId;
580
596
  if (!versionId) {
581
597
  if (nonInteractive) {
582
598
  throw new Error((0, i18n_1.t)('versionIdRequired'));
583
599
  }
584
- versionId = String((await chooseVersion(String(appId))).id);
600
+ versionId = String((await chooseVersion(appId)).id);
585
601
  }
586
602
  const updateParams = {};
587
603
  if (options.name)
@@ -590,16 +606,12 @@ exports.versionCommands = {
590
606
  updateParams.description = options.description;
591
607
  if (options.metaInfo)
592
608
  updateParams.metaInfo = options.metaInfo;
593
- await (0, api_1.put)(`/app/${String(appId)}/version/${versionId}`, updateParams);
609
+ await (0, api_1.put)(`/app/${appId}/version/${versionId}`, updateParams);
594
610
  console.log((0, i18n_1.t)('operationSuccess'));
595
611
  },
596
612
  deleteVersion: async ({ options }) => {
597
613
  const nonInteractive = (0, options_1.getBooleanOption)(options, 'no-interactive', false) || (0, utils_1.isNonInteractive)();
598
- let appId = options.appId;
599
- if (!appId) {
600
- const platform = await (0, app_1.getPlatform)(options.platform);
601
- appId = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
602
- }
614
+ const appId = await (0, app_1.resolveAppId)(options);
603
615
  const parsedVersionIds = (0, options_1.getStringListOption)(options, 'versionIds') ??
604
616
  (0, options_1.getStringListOption)(options, 'versionId');
605
617
  let versionIds = parsedVersionIds;
@@ -607,16 +619,16 @@ exports.versionCommands = {
607
619
  if (nonInteractive) {
608
620
  throw new Error((0, i18n_1.t)('versionIdRequired'));
609
621
  }
610
- versionIds = [String((await chooseVersion(String(appId))).id)];
622
+ versionIds = [String((await chooseVersion(appId)).id)];
611
623
  }
612
624
  try {
613
625
  if (versionIds.length === 1) {
614
626
  const [versionId] = versionIds;
615
- await (0, api_1.doDelete)(`/app/${String(appId)}/version/${versionId}`);
627
+ await (0, api_1.doDelete)(`/app/${appId}/version/${versionId}`);
616
628
  console.log((0, i18n_1.t)('deleteVersionSuccess', { versionId }));
617
629
  }
618
630
  else {
619
- await (0, api_1.doDelete)(`/app/${String(appId)}/version`, {
631
+ await (0, api_1.doDelete)(`/app/${appId}/version`, {
620
632
  versionIds: toNumericIds(versionIds),
621
633
  });
622
634
  console.log((0, i18n_1.t)('deleteVersionsSuccess', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.22.9",
3
+ "version": "2.23.1",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "lib/exports.js",
6
6
  "types": "lib/exports.d.ts",
@@ -79,6 +79,7 @@
79
79
  "protobufjs": "^8.7.2",
80
80
  "read": "^4.1.0",
81
81
  "registry-auth-token": "^5.1.1",
82
+ "source-map": "0.6.1",
82
83
  "tty-table": "5.0",
83
84
  "yauzl": "^3.4.0",
84
85
  "yazl": "3.3.1"