react-native-update-cli 2.0.1 → 2.1.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
@@ -62,6 +62,19 @@
62
62
  }
63
63
  }
64
64
  },
65
+ "deletePackage": {
66
+ "options": {
67
+ "appId": {
68
+ "hasValue": true
69
+ },
70
+ "packageVersion": {
71
+ "hasValue": true
72
+ },
73
+ "packageId": {
74
+ "hasValue": true
75
+ }
76
+ }
77
+ },
65
78
  "publish": {
66
79
  "options": {
67
80
  "platform": {
package/lib/locales/en.js CHANGED
@@ -114,5 +114,9 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
114
114
  updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
115
115
  unnamed: '(Unnamed)',
116
116
  dryRun: 'Below is the dry-run result, no actual operation will be performed:',
117
- usingCustomVersion: 'Using custom version: {{version}}'
117
+ usingCustomVersion: 'Using custom version: {{version}}',
118
+ confirmDeletePackage: 'Confirm delete native package {{packageId}}? This operation cannot be undone (Y/N):',
119
+ deletePackageSuccess: 'Native package {{packageId}} deleted successfully',
120
+ deletePackageError: 'Failed to delete native package {{packageId}}: {{error}}',
121
+ usageDeletePackage: 'Usage: cresc deletePackage [packageId] --appId [appId]'
118
122
  };
package/lib/locales/zh.js CHANGED
@@ -113,5 +113,9 @@ const _default = {
113
113
  updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
114
114
  unnamed: '(未命名)',
115
115
  dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
116
- usingCustomVersion: '使用自定义版本:{{version}}'
116
+ usingCustomVersion: '使用自定义版本:{{version}}',
117
+ confirmDeletePackage: '确认删除原生包 {{packageId}}? 此操作不可撤销 (Y/N):',
118
+ deletePackageSuccess: '原生包 {{packageId}} 删除成功',
119
+ deletePackageError: '删除原生包 {{packageId}} 失败: {{error}}',
120
+ usageDeletePackage: '使用方法: pushy deletePackage [packageId] --appId [appId]'
117
121
  };
@@ -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
@@ -239,5 +239,50 @@ const packageCommands = {
239
239
  const platform = await (0, _app.getPlatform)(options.platform);
240
240
  const { appId } = await (0, _app.getSelectedApp)(platform);
241
241
  await listPackage(appId);
242
+ },
243
+ deletePackage: async ({ args, options })=>{
244
+ let { appId, packageId, packageVersion } = options;
245
+ if (!appId) {
246
+ const platform = await (0, _app.getPlatform)();
247
+ appId = (await (0, _app.getSelectedApp)(platform)).appId;
248
+ }
249
+ // If no packageId provided as argument, let user choose from list
250
+ if (!packageId) {
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.version === packageVersion);
258
+ if (!selectedPackage) {
259
+ throw new Error((0, _i18n.t)('packageNotFound', {
260
+ packageVersion
261
+ }));
262
+ }
263
+ packageId = selectedPackage.id;
264
+ }
265
+ // Confirm deletion
266
+ // const confirmDelete = await question(
267
+ // t('confirmDeletePackage', { packageId }),
268
+ // );
269
+ // if (
270
+ // confirmDelete.toLowerCase() !== 'y' &&
271
+ // confirmDelete.toLowerCase() !== 'yes'
272
+ // ) {
273
+ // console.log(t('cancelled'));
274
+ // return;
275
+ // }
276
+ try {
277
+ await (0, _api.doDelete)(`/app/${appId}/package/${packageId}`);
278
+ console.log((0, _i18n.t)('deletePackageSuccess', {
279
+ packageId
280
+ }));
281
+ } catch (error) {
282
+ throw new Error((0, _i18n.t)('deletePackageError', {
283
+ packageId,
284
+ error: error.message
285
+ }));
286
+ }
242
287
  }
243
288
  };
@@ -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.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/locales/en.ts CHANGED
@@ -131,4 +131,10 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
131
131
  unnamed: '(Unnamed)',
132
132
  dryRun: 'Below is the dry-run result, no actual operation will be performed:',
133
133
  usingCustomVersion: 'Using custom version: {{version}}',
134
+ confirmDeletePackage:
135
+ 'Confirm delete native package {{packageId}}? This operation cannot be undone (Y/N):',
136
+ deletePackageSuccess: 'Native package {{packageId}} deleted successfully',
137
+ deletePackageError:
138
+ 'Failed to delete native package {{packageId}}: {{error}}',
139
+ usageDeletePackage: 'Usage: cresc deletePackage [packageId] --appId [appId]',
134
140
  };
package/src/locales/zh.ts CHANGED
@@ -124,4 +124,9 @@ export default {
124
124
  unnamed: '(未命名)',
125
125
  dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
126
126
  usingCustomVersion: '使用自定义版本:{{version}}',
127
+ confirmDeletePackage: '确认删除原生包 {{packageId}}? 此操作不可撤销 (Y/N):',
128
+ deletePackageSuccess: '原生包 {{packageId}} 删除成功',
129
+ deletePackageError: '删除原生包 {{packageId}} 失败: {{error}}',
130
+ usageDeletePackage:
131
+ '使用方法: pushy deletePackage [packageId] --appId [appId]',
127
132
  };
@@ -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
@@ -1,4 +1,4 @@
1
- import { get, getAllPackages, post, uploadFile } from './api';
1
+ import { get, getAllPackages, post, uploadFile, doDelete } from './api';
2
2
  import { question, saveToLocal } from './utils';
3
3
  import { t } from './utils/i18n';
4
4
 
@@ -212,4 +212,53 @@ export const packageCommands = {
212
212
  const { appId } = await getSelectedApp(platform);
213
213
  await listPackage(appId);
214
214
  },
215
+ deletePackage: async ({
216
+ args,
217
+ options,
218
+ }: {
219
+ args: string[];
220
+ options: { appId?: string, packageId?: string, packageVersion?: string };
221
+ }) => {
222
+ let { appId, packageId, packageVersion } = options;
223
+
224
+ if (!appId) {
225
+ const platform = await getPlatform();
226
+ appId = (await getSelectedApp(platform)).appId as string;
227
+ }
228
+
229
+ // If no packageId provided as argument, let user choose from list
230
+ if (!packageId) {
231
+ const allPkgs = await getAllPackages(appId);
232
+ if (!allPkgs) {
233
+ throw new Error(t('noPackagesFound', { appId }));
234
+ }
235
+ const selectedPackage = allPkgs.find((pkg) => pkg.version === packageVersion);
236
+ if (!selectedPackage) {
237
+ throw new Error(t('packageNotFound', { packageVersion }));
238
+ }
239
+ packageId = selectedPackage.id;
240
+ }
241
+
242
+ // Confirm deletion
243
+ // const confirmDelete = await question(
244
+ // t('confirmDeletePackage', { packageId }),
245
+ // );
246
+
247
+ // if (
248
+ // confirmDelete.toLowerCase() !== 'y' &&
249
+ // confirmDelete.toLowerCase() !== 'yes'
250
+ // ) {
251
+ // console.log(t('cancelled'));
252
+ // return;
253
+ // }
254
+
255
+ try {
256
+ await doDelete(`/app/${appId}/package/${packageId}`);
257
+ console.log(t('deletePackageSuccess', { packageId }));
258
+ } catch (error: any) {
259
+ throw new Error(
260
+ t('deletePackageError', { packageId, error: error.message }),
261
+ );
262
+ }
263
+ },
215
264
  };
@@ -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 });