react-native-update-cli 2.16.0 → 2.16.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/cli.json CHANGED
@@ -364,6 +364,15 @@
364
364
  },
365
365
  "acc": {
366
366
  "default": false
367
+ },
368
+ "config": {
369
+ "hasValue": true
370
+ },
371
+ "appId": {
372
+ "hasValue": true
373
+ },
374
+ "appKey": {
375
+ "hasValue": true
367
376
  }
368
377
  }
369
378
  }
package/lib/app.d.ts CHANGED
@@ -6,7 +6,7 @@ interface AppSummary {
6
6
  }
7
7
  export declare function getPlatform(platform?: string): Promise<Platform>;
8
8
  export declare function assertPlatform(platform: string): Platform;
9
- export declare function getSelectedApp(platform: Platform): Promise<{
9
+ export declare function getSelectedApp(platform: Platform, configPath?: string): Promise<{
10
10
  appId: string;
11
11
  appKey: string;
12
12
  platform: Platform;
package/lib/app.js CHANGED
@@ -49,11 +49,11 @@ function assertPlatform(platform) {
49
49
  }
50
50
  return platform;
51
51
  }
52
- async function getSelectedApp(platform) {
52
+ async function getSelectedApp(platform, configPath) {
53
53
  assertPlatform(platform);
54
54
  let updateInfo = {};
55
55
  try {
56
- updateInfo = JSON.parse(await _fs.default.promises.readFile('update.json', 'utf8'));
56
+ updateInfo = JSON.parse(await _fs.default.promises.readFile(configPath || 'update.json', 'utf8'));
57
57
  } catch (e) {
58
58
  if (e.code === 'ENOENT') {
59
59
  throw new Error((0, _i18n.t)('appNotSelected', {
@@ -117,9 +117,10 @@ async function chooseApp(platform) {
117
117
  async function selectApp({ args, options }) {
118
118
  const platform = await getPlatform(options.platform);
119
119
  const id = args[0] ? Number.parseInt(args[0], 10) : (await chooseApp(platform)).id;
120
+ const configPath = options.config;
120
121
  let updateInfo = {};
121
122
  try {
122
- updateInfo = JSON.parse(await _fs.default.promises.readFile('update.json', 'utf8'));
123
+ updateInfo = JSON.parse(await _fs.default.promises.readFile(configPath || 'update.json', 'utf8'));
123
124
  } catch (e) {
124
125
  if (e.code !== 'ENOENT') {
125
126
  console.error((0, _i18n.t)('failedToParseUpdateJson'));
@@ -131,7 +132,7 @@ async function selectApp({ args, options }) {
131
132
  appId: id,
132
133
  appKey
133
134
  };
134
- await _fs.default.promises.writeFile('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
135
+ await _fs.default.promises.writeFile(configPath || 'update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
135
136
  }
136
137
  function getAppCommands() {
137
138
  return {
package/lib/package.d.ts CHANGED
@@ -47,9 +47,11 @@ export declare const packageCommands: {
47
47
  args: string[];
48
48
  options: PackageCommandOptions;
49
49
  }) => Promise<void>;
50
- packages: ({ options }: {
50
+ packages: ({ options, }: {
51
51
  options: {
52
52
  platform: Platform;
53
+ appId?: string;
54
+ config?: string;
53
55
  };
54
56
  }) => Promise<void>;
55
57
  deletePackage: ({ options }: {
package/lib/package.js CHANGED
@@ -127,7 +127,7 @@ async function uploadNativePackage(filePath, options, config) {
127
127
  const selectedApp = options.appId ? {
128
128
  appId: String(options.appId),
129
129
  appKey: typeof options.appKey === 'string' ? options.appKey : undefined
130
- } : await (0, _app.getSelectedApp)(config.platform);
130
+ } : await (0, _app.getSelectedApp)(config.platform, options.config);
131
131
  const { appId, appKey } = selectedApp;
132
132
  if (appIdInPkg && String(appIdInPkg) !== appId) {
133
133
  throw new Error((0, _i18n.t)(config.appIdMismatchKey, {
@@ -320,8 +320,11 @@ const packageCommands = {
320
320
  }));
321
321
  },
322
322
  packages: async ({ options })=>{
323
- const platform = await (0, _app.getPlatform)(options.platform);
324
- const { appId } = await (0, _app.getSelectedApp)(platform);
323
+ let appId = options.appId;
324
+ if (!appId) {
325
+ const platform = await (0, _app.getPlatform)(options.platform);
326
+ appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
327
+ }
325
328
  await listPackage(String(appId));
326
329
  },
327
330
  deletePackage: async ({ options })=>{
@@ -330,7 +333,7 @@ const packageCommands = {
330
333
  let packageIds = (_getStringListOption = (0, _options.getStringListOption)(options, 'packageIds')) != null ? _getStringListOption : (0, _options.getStringListOption)(options, 'packageId');
331
334
  if (!appId) {
332
335
  const platform = await (0, _app.getPlatform)(options.platform);
333
- appId = (await (0, _app.getSelectedApp)(platform)).appId;
336
+ appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
334
337
  }
335
338
  if (!packageIds) {
336
339
  const packageVersions = (0, _options.getStringListOption)(options, 'packageVersion');
package/lib/provider.js CHANGED
@@ -145,7 +145,8 @@ class CLIProviderImpl {
145
145
  platform: options.platform,
146
146
  appId: options.appId,
147
147
  appKey: options.appKey,
148
- version: options.version
148
+ version: options.version,
149
+ config: options.config
149
150
  }, [
150
151
  filePath
151
152
  ]);
package/lib/types.d.ts CHANGED
@@ -63,6 +63,8 @@ export interface PublishOptions {
63
63
  packageVersionRange?: string;
64
64
  rollout?: number | string;
65
65
  dryRun?: boolean;
66
+ appId?: string;
67
+ config?: string;
66
68
  }
67
69
  export interface UploadOptions {
68
70
  platform?: Platform;
@@ -70,6 +72,7 @@ export interface UploadOptions {
70
72
  appId?: string;
71
73
  appKey?: string;
72
74
  version?: string;
75
+ config?: string;
73
76
  }
74
77
  export interface UpdateVersionOptions {
75
78
  platform?: Platform;
package/lib/versions.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import type { Package, Platform, Version } from './types';
2
2
  interface VersionCommandOptions {
3
3
  [key: string]: unknown;
4
+ config?: string;
5
+ appKey?: string;
4
6
  appId?: string;
5
7
  name?: string;
6
8
  description?: string;
package/lib/versions.js CHANGED
@@ -353,7 +353,10 @@ const versionCommands = {
353
353
  throw new Error((0, _i18n.t)('publishUsage'));
354
354
  }
355
355
  const platform = await (0, _app.getPlatform)(options.platform);
356
- const { appId } = await (0, _app.getSelectedApp)(platform);
356
+ let appId = options.appId;
357
+ if (!appId) {
358
+ appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
359
+ }
357
360
  const nonInteractive = (0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)();
358
361
  const { hash } = await (0, _api.uploadFile)(fn);
359
362
  const versionName = name || (nonInteractive ? '' : await (0, _utils.question)((0, _i18n.t)('versionNameQuestion'))) || (0, _i18n.t)('unnamed');
@@ -404,7 +407,7 @@ const versionCommands = {
404
407
  let appId = options.appId;
405
408
  if (!appId) {
406
409
  const platform = await (0, _app.getPlatform)(options.platform);
407
- appId = (await (0, _app.getSelectedApp)(platform)).appId;
410
+ appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
408
411
  }
409
412
  const interactive = !((0, _options.getBooleanOption)(options, 'no-interactive', false) || (0, _utils.isNonInteractive)());
410
413
  await listVersions(String(appId), interactive);
@@ -415,7 +418,7 @@ const versionCommands = {
415
418
  let platform = options.platform;
416
419
  if (!appId) {
417
420
  platform = await (0, _app.getPlatform)(platform);
418
- appId = (await (0, _app.getSelectedApp)(platform)).appId;
421
+ appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
419
422
  } else if (platform) {
420
423
  platform = await (0, _app.getPlatform)(platform);
421
424
  }
@@ -534,7 +537,7 @@ const versionCommands = {
534
537
  let platform = options.platform;
535
538
  if (!appId) {
536
539
  platform = await (0, _app.getPlatform)(platform);
537
- appId = (await (0, _app.getSelectedApp)(platform)).appId;
540
+ appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
538
541
  } else if (platform) {
539
542
  await (0, _app.getPlatform)(platform);
540
543
  }
@@ -558,7 +561,7 @@ const versionCommands = {
558
561
  let appId = options.appId;
559
562
  if (!appId) {
560
563
  const platform = await (0, _app.getPlatform)(options.platform);
561
- appId = (await (0, _app.getSelectedApp)(platform)).appId;
564
+ appId = (await (0, _app.getSelectedApp)(platform, options.config)).appId;
562
565
  }
563
566
  const parsedVersionIds = (_getStringListOption = (0, _options.getStringListOption)(options, 'versionIds')) != null ? _getStringListOption : (0, _options.getStringListOption)(options, 'versionId');
564
567
  let versionIds = parsedVersionIds;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.16.0",
3
+ "version": "2.16.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",
package/src/app.ts CHANGED
@@ -26,13 +26,16 @@ export function assertPlatform(platform: string): Platform {
26
26
 
27
27
  export async function getSelectedApp(
28
28
  platform: Platform,
29
+ configPath?: string,
29
30
  ): Promise<{ appId: string; appKey: string; platform: Platform }> {
30
31
  assertPlatform(platform);
31
32
 
32
33
  let updateInfo: Partial<Record<Platform, { appId: number; appKey: string }>> =
33
34
  {};
34
35
  try {
35
- updateInfo = JSON.parse(await fs.promises.readFile('update.json', 'utf8'));
36
+ updateInfo = JSON.parse(
37
+ await fs.promises.readFile(configPath || 'update.json', 'utf8'),
38
+ );
36
39
  } catch (e: any) {
37
40
  if (e.code === 'ENOENT') {
38
41
  throw new Error(t('appNotSelected', { platform }));
@@ -97,10 +100,13 @@ async function selectApp({
97
100
  ? Number.parseInt(args[0], 10)
98
101
  : (await chooseApp(platform)).id;
99
102
 
103
+ const configPath = (options as any).config as string | undefined;
100
104
  let updateInfo: Partial<Record<Platform, { appId: number; appKey: string }>> =
101
105
  {};
102
106
  try {
103
- updateInfo = JSON.parse(await fs.promises.readFile('update.json', 'utf8'));
107
+ updateInfo = JSON.parse(
108
+ await fs.promises.readFile(configPath || 'update.json', 'utf8'),
109
+ );
104
110
  } catch (e: any) {
105
111
  if (e.code !== 'ENOENT') {
106
112
  console.error(t('failedToParseUpdateJson'));
@@ -113,7 +119,7 @@ async function selectApp({
113
119
  appKey,
114
120
  };
115
121
  await fs.promises.writeFile(
116
- 'update.json',
122
+ configPath || 'update.json',
117
123
  JSON.stringify(updateInfo, null, 4),
118
124
  'utf8',
119
125
  );
package/src/package.ts CHANGED
@@ -118,7 +118,10 @@ async function uploadNativePackage(
118
118
  appId: String(options.appId),
119
119
  appKey: typeof options.appKey === 'string' ? options.appKey : undefined,
120
120
  }
121
- : await getSelectedApp(config.platform);
121
+ : await getSelectedApp(
122
+ config.platform,
123
+ options.config as string | undefined,
124
+ );
122
125
  const { appId, appKey } = selectedApp;
123
126
 
124
127
  if (appIdInPkg && String(appIdInPkg) !== appId) {
@@ -348,9 +351,18 @@ export const packageCommands = {
348
351
 
349
352
  console.log(t('apkExtracted', { output }));
350
353
  },
351
- packages: async ({ options }: { options: { platform: Platform } }) => {
352
- const platform = await getPlatform(options.platform);
353
- const { appId } = await getSelectedApp(platform);
354
+ packages: async ({
355
+ options,
356
+ }: {
357
+ options: { platform: Platform; appId?: string; config?: string };
358
+ }) => {
359
+ let appId = options.appId;
360
+ if (!appId) {
361
+ const platform = await getPlatform(options.platform);
362
+ appId = (
363
+ await getSelectedApp(platform, options.config as string | undefined)
364
+ ).appId;
365
+ }
354
366
  await listPackage(String(appId));
355
367
  },
356
368
  deletePackage: async ({ options }: { options: PackageCommandOptions }) => {
@@ -361,7 +373,9 @@ export const packageCommands = {
361
373
 
362
374
  if (!appId) {
363
375
  const platform = await getPlatform(options.platform);
364
- appId = (await getSelectedApp(platform)).appId;
376
+ appId = (
377
+ await getSelectedApp(platform, options.config as string | undefined)
378
+ ).appId;
365
379
  }
366
380
 
367
381
  if (!packageIds) {
package/src/provider.ts CHANGED
@@ -148,6 +148,7 @@ export class CLIProviderImpl implements CLIProvider {
148
148
  appId: options.appId,
149
149
  appKey: options.appKey,
150
150
  version: options.version,
151
+ config: options.config,
151
152
  },
152
153
  [filePath],
153
154
  );
package/src/types.ts CHANGED
@@ -74,6 +74,8 @@ export interface PublishOptions {
74
74
  packageVersionRange?: string;
75
75
  rollout?: number | string;
76
76
  dryRun?: boolean;
77
+ appId?: string;
78
+ config?: string;
77
79
  }
78
80
 
79
81
  export interface UploadOptions {
@@ -82,6 +84,7 @@ export interface UploadOptions {
82
84
  appId?: string;
83
85
  appKey?: string;
84
86
  version?: string;
87
+ config?: string;
85
88
  }
86
89
 
87
90
  export interface UpdateVersionOptions {
package/src/versions.ts CHANGED
@@ -13,6 +13,8 @@ import { getBooleanOption, getStringListOption } from './utils/options';
13
13
 
14
14
  interface VersionCommandOptions {
15
15
  [key: string]: unknown;
16
+ config?: string;
17
+ appKey?: string;
16
18
  appId?: string;
17
19
  name?: string;
18
20
  description?: string;
@@ -464,7 +466,12 @@ export const versionCommands = {
464
466
  }
465
467
 
466
468
  const platform = await getPlatform(options.platform);
467
- const { appId } = await getSelectedApp(platform);
469
+ let appId = options.appId;
470
+ if (!appId) {
471
+ appId = (
472
+ await getSelectedApp(platform, options.config as string | undefined)
473
+ ).appId;
474
+ }
468
475
  const nonInteractive =
469
476
  getBooleanOption(options, 'no-interactive', false) || isNonInteractive();
470
477
 
@@ -539,7 +546,9 @@ export const versionCommands = {
539
546
  let appId = options.appId;
540
547
  if (!appId) {
541
548
  const platform = await getPlatform(options.platform);
542
- appId = (await getSelectedApp(platform)).appId;
549
+ appId = (
550
+ await getSelectedApp(platform, options.config as string | undefined)
551
+ ).appId;
543
552
  }
544
553
  const interactive = !(
545
554
  getBooleanOption(options, 'no-interactive', false) || isNonInteractive()
@@ -553,7 +562,9 @@ export const versionCommands = {
553
562
  let platform = options.platform;
554
563
  if (!appId) {
555
564
  platform = await getPlatform(platform);
556
- appId = (await getSelectedApp(platform)).appId;
565
+ appId = (
566
+ await getSelectedApp(platform, options.config as string | undefined)
567
+ ).appId;
557
568
  } else if (platform) {
558
569
  platform = await getPlatform(platform);
559
570
  }
@@ -683,7 +694,9 @@ export const versionCommands = {
683
694
  let platform = options.platform;
684
695
  if (!appId) {
685
696
  platform = await getPlatform(platform);
686
- appId = (await getSelectedApp(platform)).appId;
697
+ appId = (
698
+ await getSelectedApp(platform, options.config as string | undefined)
699
+ ).appId;
687
700
  } else if (platform) {
688
701
  await getPlatform(platform);
689
702
  }
@@ -710,7 +723,9 @@ export const versionCommands = {
710
723
  let appId = options.appId;
711
724
  if (!appId) {
712
725
  const platform = await getPlatform(options.platform);
713
- appId = (await getSelectedApp(platform)).appId;
726
+ appId = (
727
+ await getSelectedApp(platform, options.config as string | undefined)
728
+ ).appId;
714
729
  }
715
730
 
716
731
  const parsedVersionIds =