react-native-update-cli 2.10.0 → 2.10.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
@@ -13,6 +13,12 @@ export declare function getSelectedApp(platform: Platform): Promise<{
13
13
  }>;
14
14
  export declare function listApp(platform?: Platform | ''): Promise<AppSummary[]>;
15
15
  export declare function chooseApp(platform: Platform): Promise<AppSummary>;
16
+ declare function selectApp({ args, options, }: {
17
+ args: string[];
18
+ options: {
19
+ platform?: Platform | '';
20
+ };
21
+ }): Promise<void>;
16
22
  export declare const appCommands: {
17
23
  createApp: ({ options, }: {
18
24
  options: {
@@ -32,11 +38,6 @@ export declare const appCommands: {
32
38
  platform?: Platform | "";
33
39
  };
34
40
  }) => Promise<void>;
35
- selectApp: ({ args, options, }: {
36
- args: string[];
37
- options: {
38
- platform?: Platform | "";
39
- };
40
- }) => Promise<void>;
41
+ selectApp: typeof selectApp;
41
42
  };
42
43
  export {};
package/lib/app.js CHANGED
@@ -119,8 +119,27 @@ async function chooseApp(platform) {
119
119
  }
120
120
  }
121
121
  }
122
+ async function selectApp({ args, options }) {
123
+ const platform = await getPlatform(options.platform);
124
+ const id = args[0] ? Number.parseInt(args[0], 10) : (await chooseApp(platform)).id;
125
+ let updateInfo = {};
126
+ try {
127
+ updateInfo = JSON.parse(await _fs.default.promises.readFile('update.json', 'utf8'));
128
+ } catch (e) {
129
+ if (e.code !== 'ENOENT') {
130
+ console.error((0, _i18n.t)('failedToParseUpdateJson'));
131
+ throw e;
132
+ }
133
+ }
134
+ const { appKey } = await (0, _api.get)(`/app/${id}`);
135
+ updateInfo[platform] = {
136
+ appId: id,
137
+ appKey
138
+ };
139
+ await _fs.default.promises.writeFile('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
140
+ }
122
141
  const appCommands = {
123
- createApp: async function({ options }) {
142
+ createApp: async ({ options })=>{
124
143
  const name = options.name || await (0, _utils.question)((0, _i18n.t)('appNameQuestion'));
125
144
  const { downloadUrl } = options;
126
145
  const platform = await getPlatform(options.platform);
@@ -132,9 +151,9 @@ const appCommands = {
132
151
  console.log((0, _i18n.t)('createAppSuccess', {
133
152
  id
134
153
  }));
135
- await this.selectApp({
154
+ await selectApp({
136
155
  args: [
137
- id
156
+ String(id)
138
157
  ],
139
158
  options: {
140
159
  platform
@@ -154,23 +173,5 @@ const appCommands = {
154
173
  const { platform = '' } = options;
155
174
  await listApp(platform);
156
175
  },
157
- selectApp: async ({ args, options })=>{
158
- const platform = await getPlatform(options.platform);
159
- const id = args[0] ? Number.parseInt(args[0]) : (await chooseApp(platform)).id;
160
- let updateInfo = {};
161
- try {
162
- updateInfo = JSON.parse(await _fs.default.promises.readFile('update.json', 'utf8'));
163
- } catch (e) {
164
- if (e.code !== 'ENOENT') {
165
- console.error((0, _i18n.t)('failedToParseUpdateJson'));
166
- throw e;
167
- }
168
- }
169
- const { appKey } = await (0, _api.get)(`/app/${id}`);
170
- updateInfo[platform] = {
171
- appId: id,
172
- appKey
173
- };
174
- await _fs.default.promises.writeFile('update.json', JSON.stringify(updateInfo, null, 4), 'utf8');
175
- }
176
+ selectApp
176
177
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.10.0",
3
+ "version": "2.10.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
@@ -87,19 +87,53 @@ export async function chooseApp(platform: Platform) {
87
87
  }
88
88
  }
89
89
 
90
+ async function selectApp({
91
+ args,
92
+ options,
93
+ }: {
94
+ args: string[];
95
+ options: { platform?: Platform | '' };
96
+ }) {
97
+ const platform = await getPlatform(options.platform);
98
+ const id = args[0]
99
+ ? Number.parseInt(args[0], 10)
100
+ : (await chooseApp(platform)).id;
101
+
102
+ let updateInfo: Partial<Record<Platform, { appId: number; appKey: string }>> =
103
+ {};
104
+ try {
105
+ updateInfo = JSON.parse(await fs.promises.readFile('update.json', 'utf8'));
106
+ } catch (e: any) {
107
+ if (e.code !== 'ENOENT') {
108
+ console.error(t('failedToParseUpdateJson'));
109
+ throw e;
110
+ }
111
+ }
112
+ const { appKey } = await get(`/app/${id}`);
113
+ updateInfo[platform] = {
114
+ appId: id,
115
+ appKey,
116
+ };
117
+ await fs.promises.writeFile(
118
+ 'update.json',
119
+ JSON.stringify(updateInfo, null, 4),
120
+ 'utf8',
121
+ );
122
+ }
123
+
90
124
  export const appCommands = {
91
- createApp: async function ({
125
+ createApp: async ({
92
126
  options,
93
127
  }: {
94
128
  options: { name: string; downloadUrl: string; platform?: Platform | '' };
95
- }) {
129
+ }) => {
96
130
  const name = options.name || (await question(t('appNameQuestion')));
97
131
  const { downloadUrl } = options;
98
132
  const platform = await getPlatform(options.platform);
99
133
  const { id } = await post('/app/create', { name, platform, downloadUrl });
100
134
  console.log(t('createAppSuccess', { id }));
101
- await this.selectApp({
102
- args: [id],
135
+ await selectApp({
136
+ args: [String(id)],
103
137
  options: { platform },
104
138
  });
105
139
  },
@@ -122,40 +156,5 @@ export const appCommands = {
122
156
  const { platform = '' } = options;
123
157
  await listApp(platform);
124
158
  },
125
- selectApp: async ({
126
- args,
127
- options,
128
- }: {
129
- args: string[];
130
- options: { platform?: Platform | '' };
131
- }) => {
132
- const platform = await getPlatform(options.platform);
133
- const id = args[0]
134
- ? Number.parseInt(args[0])
135
- : (await chooseApp(platform)).id;
136
-
137
- let updateInfo: Partial<
138
- Record<Platform, { appId: number; appKey: string }>
139
- > = {};
140
- try {
141
- updateInfo = JSON.parse(
142
- await fs.promises.readFile('update.json', 'utf8'),
143
- );
144
- } catch (e: any) {
145
- if (e.code !== 'ENOENT') {
146
- console.error(t('failedToParseUpdateJson'));
147
- throw e;
148
- }
149
- }
150
- const { appKey } = await get(`/app/${id}`);
151
- updateInfo[platform] = {
152
- appId: id,
153
- appKey,
154
- };
155
- await fs.promises.writeFile(
156
- 'update.json',
157
- JSON.stringify(updateInfo, null, 4),
158
- 'utf8',
159
- );
160
- },
159
+ selectApp,
161
160
  };