react-native-update-cli 2.23.0 → 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/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/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
@@ -48,6 +51,8 @@ function normalizeBundleOptions(translatedOptions, platform) {
48
51
  verifyHermesBase: (0, options_1.getBooleanOption)(translatedOptions, 'verifyHermesBase', true),
49
52
  resetCache: (0, options_1.getBooleanOption)(translatedOptions, 'resetCache', true),
50
53
  cacheMaxMb: parseCacheMaxMb(translatedOptions.cacheMaxMb),
54
+ appId: (0, options_1.getOptionalStringOption)(translatedOptions, 'appId'),
55
+ config: (0, options_1.getOptionalStringOption)(translatedOptions, 'config'),
51
56
  name: (0, options_1.getOptionalStringOption)(translatedOptions, 'name'),
52
57
  description: (0, options_1.getOptionalStringOption)(translatedOptions, 'description'),
53
58
  metaInfo: (0, options_1.getOptionalStringOption)(translatedOptions, 'metaInfo'),
@@ -62,6 +67,7 @@ function normalizeBundleOptions(translatedOptions, platform) {
62
67
  sentryDist: getAliasedOptionalStringOption(translatedOptions, 'sentry-dist', 'sentryDist'),
63
68
  };
64
69
  }
70
+ /** Upload generated Sentry artifacts when the detected plugin requires them. */
65
71
  async function uploadSentryArtifactsIfNeeded(shouldUpload, bundleName, intermediaDir, sourcemapOutput, platform, sentryOptions) {
66
72
  if (!shouldUpload) {
67
73
  return;
@@ -69,6 +75,7 @@ async function uploadSentryArtifactsIfNeeded(shouldUpload, bundleName, intermedi
69
75
  await (0, bundle_runner_1.copyDebugidForSentry)(bundleName, intermediaDir, sourcemapOutput);
70
76
  await (0, bundle_runner_1.uploadSourcemapForSentry)(bundleName, intermediaDir, sourcemapOutput, platform, sentryOptions);
71
77
  }
78
+ /** Publish a packed bundle through the version command implementation. */
72
79
  async function publishBundleVersion(outputPath, platform, payload) {
73
80
  return versions_1.versionCommands.publish({
74
81
  args: [outputPath],
@@ -79,6 +86,7 @@ async function publishBundleVersion(outputPath, platform, payload) {
79
86
  });
80
87
  }
81
88
  exports.bundleCommands = {
89
+ /** Build a bundle and optionally publish it to one operation-scoped app. */
82
90
  bundle: async ({ options, }) => {
83
91
  const platform = await (0, app_1.getPlatform)(typeof options.platform === 'string' ? options.platform : undefined);
84
92
  const translatedOptions = (0, utils_1.translateOptions)({
@@ -87,29 +95,51 @@ exports.bundleCommands = {
87
95
  platform,
88
96
  });
89
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
+ }
90
131
  (0, check_lockfile_1.checkLockFiles)();
91
132
  (0, add_gitignore_1.addGitIgnore)();
92
- 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
+ ]);
93
137
  const sourcemapOutput = path_1.default.join(normalized.intermediaDir, `${normalized.bundleName}.map`);
94
138
  const realOutput = normalized.output.replace(/\$\{time\}/g, `${Date.now()}`);
95
139
  if (!platform) {
96
140
  throw new Error((0, i18n_1.t)('platformRequired'));
97
141
  }
98
142
  console.log((0, i18n_1.t)('bundlingWithRN', { version: dep_versions_1.depVersions['react-native'] }));
99
- await (0, hermes_base_1.cleanStaleTmp)().catch(() => { });
100
- // the hermes base lookup needs the app; resolve it up front but never
101
- // fail the bundle over it (publishing resolves it again and reports)
102
- let appIdForBase = typeof options.appId === 'string' && options.appId
103
- ? options.appId
104
- : undefined;
105
- if (!appIdForBase && normalized.hermesBase === 'auto') {
106
- try {
107
- appIdForBase = (await (0, app_1.getSelectedApp)(platform, options.config)).appId;
108
- }
109
- catch {
110
- appIdForBase = undefined;
111
- }
112
- }
113
143
  const hermesResult = await (0, bundle_runner_1.runReactNativeBundleCommand)({
114
144
  bundleName: normalized.bundleName,
115
145
  dev: normalized.dev,
@@ -118,14 +148,7 @@ exports.bundleCommands = {
118
148
  platform,
119
149
  sourcemapOutput: normalized.sourcemap || bundleParams.sourcemap ? sourcemapOutput : '',
120
150
  forceHermes: normalized.hermes,
121
- hermesBase: normalized.dev === 'true'
122
- ? undefined
123
- : {
124
- option: normalized.hermesBase,
125
- appId: appIdForBase,
126
- verify: normalized.verifyHermesBase,
127
- cacheMaxMb: normalized.cacheMaxMb,
128
- },
151
+ hermesBase: hermesBase ? { ...hermesBase, appId } : undefined,
129
152
  resetCache: normalized.resetCache,
130
153
  cli: {
131
154
  taro: normalized.taro,
@@ -140,6 +163,7 @@ exports.bundleCommands = {
140
163
  : undefined;
141
164
  if (normalized.name) {
142
165
  await publishBundleVersion(realOutput, platform, {
166
+ appId: await getAppId(),
143
167
  name: normalized.name,
144
168
  description: normalized.description,
145
169
  metaInfo: normalized.metaInfo,
@@ -165,6 +189,7 @@ exports.bundleCommands = {
165
189
  const v = await (0, utils_1.question)((0, i18n_1.t)('uploadBundlePrompt'));
166
190
  if (v.toLowerCase() === 'y') {
167
191
  await publishBundleVersion(realOutput, platform, {
192
+ appId: await getAppId(),
168
193
  hermesBase: baseMeta,
169
194
  sourcemap: normalized.sourcemap || bundleParams.sourcemap
170
195
  ? sourcemapOutput
@@ -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;
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',
@@ -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;
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 编译',
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
@@ -10,7 +10,7 @@ export declare class CLIProviderImpl implements CLIProvider {
10
10
  publish(options: PublishOptions): Promise<CommandResult>;
11
11
  symbolicate(options: SymbolicateOptions): Promise<CommandResult>;
12
12
  upload(options: UploadOptions): Promise<CommandResult>;
13
- getSelectedApp(platform?: Platform): Promise<{
13
+ getSelectedApp(platform?: Platform, config?: string): Promise<{
14
14
  appId: string;
15
15
  platform: Platform;
16
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);
@@ -164,9 +166,9 @@ class CLIProviderImpl {
164
166
  await uploadHandler(context);
165
167
  }, 'Unknown error during upload', 'File uploaded successfully');
166
168
  }
167
- async getSelectedApp(platform) {
169
+ async getSelectedApp(platform, config) {
168
170
  const resolvedPlatform = await this.getPlatform(platform);
169
- return (0, app_1.getSelectedApp)(resolvedPlatform);
171
+ return (0, app_1.getSelectedApp)(resolvedPlatform, config);
170
172
  }
171
173
  async listApps(platform) {
172
174
  return this.runDataCommand(async () => {
package/lib/types.d.ts CHANGED
@@ -57,6 +57,10 @@ export interface BundleOptions {
57
57
  resetCache?: boolean;
58
58
  sentryRelease?: string;
59
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;
60
64
  }
61
65
  export interface PublishOptions {
62
66
  filePath?: string;
@@ -113,7 +117,7 @@ export interface CLIProvider {
113
117
  upload: (options: UploadOptions) => Promise<CommandResult>;
114
118
  createApp: (name: string, platform: Platform) => Promise<CommandResult>;
115
119
  listApps: (platform?: Platform) => Promise<CommandResult>;
116
- getSelectedApp: (platform?: Platform) => Promise<{
120
+ getSelectedApp: (platform?: Platform, config?: string) => Promise<{
117
121
  appId: string;
118
122
  platform: Platform;
119
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'