react-native-update-cli 2.1.0 → 2.1.2

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
@@ -66,6 +66,12 @@
66
66
  "options": {
67
67
  "appId": {
68
68
  "hasValue": true
69
+ },
70
+ "packageVersion": {
71
+ "hasValue": true
72
+ },
73
+ "packageId": {
74
+ "hasValue": true
69
75
  }
70
76
  }
71
77
  },
@@ -36,7 +36,9 @@ class ModuleManager {
36
36
  if (module.init) {
37
37
  module.init(this.provider);
38
38
  }
39
- console.log(`Module '${module.name}' (v${module.version}) registered successfully`);
39
+ // console.log(
40
+ // `Module '${module.name}' (v${module.version}) registered successfully`,
41
+ // );
40
42
  }
41
43
  unregisterModule(moduleName) {
42
44
  const module = this.modules.get(moduleName);
package/lib/package.js CHANGED
@@ -241,15 +241,25 @@ const packageCommands = {
241
241
  await listPackage(appId);
242
242
  },
243
243
  deletePackage: async ({ args, options })=>{
244
- let packageId = args[0];
245
- let { appId } = options;
244
+ let { appId, packageId, packageVersion } = options;
246
245
  if (!appId) {
247
246
  const platform = await (0, _app.getPlatform)();
248
247
  appId = (await (0, _app.getSelectedApp)(platform)).appId;
249
248
  }
250
249
  // If no packageId provided as argument, let user choose from list
251
250
  if (!packageId) {
252
- const selectedPackage = await choosePackage(appId);
251
+ const allPkgs = await (0, _api.getAllPackages)(appId);
252
+ if (!allPkgs) {
253
+ throw new Error((0, _i18n.t)('noPackagesFound', {
254
+ appId
255
+ }));
256
+ }
257
+ const selectedPackage = allPkgs.find((pkg)=>pkg.name === packageVersion);
258
+ if (!selectedPackage) {
259
+ throw new Error((0, _i18n.t)('packageNotFound', {
260
+ packageVersion
261
+ }));
262
+ }
253
263
  packageId = selectedPackage.id;
254
264
  }
255
265
  // Confirm deletion
@@ -8,7 +8,12 @@ Object.defineProperty(exports, "depVersions", {
8
8
  return depVersions;
9
9
  }
10
10
  });
11
- const currentPackage = require(`${process.cwd()}/package.json`);
11
+ let currentPackage = null;
12
+ try {
13
+ currentPackage = require(`${process.cwd()}/package.json`);
14
+ } catch (e) {
15
+ // console.warn('No package.json file were found');
16
+ }
12
17
  const _depVersions = {};
13
18
  if (currentPackage) {
14
19
  const depKeys = currentPackage.dependencies ? Object.keys(currentPackage.dependencies) : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -39,9 +39,9 @@ export class ModuleManager {
39
39
  module.init(this.provider);
40
40
  }
41
41
 
42
- console.log(
43
- `Module '${module.name}' (v${module.version}) registered successfully`,
44
- );
42
+ // console.log(
43
+ // `Module '${module.name}' (v${module.version}) registered successfully`,
44
+ // );
45
45
  }
46
46
 
47
47
  unregisterModule(moduleName: string): void {
package/src/package.ts CHANGED
@@ -217,10 +217,9 @@ export const packageCommands = {
217
217
  options,
218
218
  }: {
219
219
  args: string[];
220
- options: { appId?: string };
220
+ options: { appId?: string, packageId?: string, packageVersion?: string };
221
221
  }) => {
222
- let packageId = args[0];
223
- let { appId } = options;
222
+ let { appId, packageId, packageVersion } = options;
224
223
 
225
224
  if (!appId) {
226
225
  const platform = await getPlatform();
@@ -229,7 +228,14 @@ export const packageCommands = {
229
228
 
230
229
  // If no packageId provided as argument, let user choose from list
231
230
  if (!packageId) {
232
- const selectedPackage = await choosePackage(appId);
231
+ const allPkgs = await getAllPackages(appId);
232
+ if (!allPkgs) {
233
+ throw new Error(t('noPackagesFound', { appId }));
234
+ }
235
+ const selectedPackage = allPkgs.find((pkg) => pkg.name === packageVersion);
236
+ if (!selectedPackage) {
237
+ throw new Error(t('packageNotFound', { packageVersion }));
238
+ }
233
239
  packageId = selectedPackage.id;
234
240
  }
235
241
 
@@ -1,4 +1,9 @@
1
- const currentPackage = require(`${process.cwd()}/package.json`);
1
+ let currentPackage = null;
2
+ try {
3
+ currentPackage = require(`${process.cwd()}/package.json`);
4
+ } catch (e) {
5
+ // console.warn('No package.json file were found');
6
+ }
2
7
 
3
8
  const _depVersions: Record<string, string> = {};
4
9
 
@@ -24,12 +29,9 @@ if (currentPackage) {
24
29
 
25
30
  export const depVersions = Object.keys(_depVersions)
26
31
  .sort() // Sort the keys alphabetically
27
- .reduce(
28
- (obj, key) => {
29
- obj[key] = _depVersions[key]; // Rebuild the object with sorted keys
30
- return obj;
31
- },
32
- {} as Record<string, string>,
33
- );
32
+ .reduce((obj, key) => {
33
+ obj[key] = _depVersions[key]; // Rebuild the object with sorted keys
34
+ return obj;
35
+ }, {} as Record<string, string>);
34
36
 
35
37
  // console.log({ depVersions });