react-native-update-cli 2.0.0 → 2.1.0

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/package.js CHANGED
@@ -82,13 +82,13 @@ async function choosePackage(appId) {
82
82
  }
83
83
  }
84
84
  const packageCommands = {
85
- uploadIpa: async ({ args })=>{
85
+ uploadIpa: async ({ args, options })=>{
86
86
  const fn = args[0];
87
87
  if (!fn || !fn.endsWith('.ipa')) {
88
88
  throw new Error((0, _i18n.t)('usageUploadIpa'));
89
89
  }
90
90
  const ipaInfo = await (0, _utils.getIpaInfo)(fn);
91
- const { versionName, buildTime } = ipaInfo;
91
+ const { versionName: extractedVersionName, buildTime } = ipaInfo;
92
92
  const appIdInPkg = ipaInfo.appId;
93
93
  const appKeyInPkg = ipaInfo.appKey;
94
94
  const { appId, appKey } = await (0, _app.getSelectedApp)('ios');
@@ -104,6 +104,13 @@ const packageCommands = {
104
104
  appKey
105
105
  }));
106
106
  }
107
+ // Use custom version if provided, otherwise use extracted version
108
+ const versionName = options.version || extractedVersionName;
109
+ if (options.version) {
110
+ console.log((0, _i18n.t)('usingCustomVersion', {
111
+ version: versionName
112
+ }));
113
+ }
107
114
  const { hash } = await (0, _api.uploadFile)(fn);
108
115
  const { id } = await (0, _api.post)(`/app/${appId}/package/create`, {
109
116
  name: versionName,
@@ -119,13 +126,13 @@ const packageCommands = {
119
126
  buildTime
120
127
  }));
121
128
  },
122
- uploadApk: async ({ args })=>{
129
+ uploadApk: async ({ args, options })=>{
123
130
  const fn = args[0];
124
131
  if (!fn || !fn.endsWith('.apk')) {
125
132
  throw new Error((0, _i18n.t)('usageUploadApk'));
126
133
  }
127
134
  const apkInfo = await (0, _utils.getApkInfo)(fn);
128
- const { versionName, buildTime } = apkInfo;
135
+ const { versionName: extractedVersionName, buildTime } = apkInfo;
129
136
  const appIdInPkg = apkInfo.appId;
130
137
  const appKeyInPkg = apkInfo.appKey;
131
138
  const { appId, appKey } = await (0, _app.getSelectedApp)('android');
@@ -141,6 +148,13 @@ const packageCommands = {
141
148
  appKey
142
149
  }));
143
150
  }
151
+ // Use custom version if provided, otherwise use extracted version
152
+ const versionName = options.version || extractedVersionName;
153
+ if (options.version) {
154
+ console.log((0, _i18n.t)('usingCustomVersion', {
155
+ version: versionName
156
+ }));
157
+ }
144
158
  const { hash } = await (0, _api.uploadFile)(fn);
145
159
  const { id } = await (0, _api.post)(`/app/${appId}/package/create`, {
146
160
  name: versionName,
@@ -156,13 +170,13 @@ const packageCommands = {
156
170
  buildTime
157
171
  }));
158
172
  },
159
- uploadApp: async ({ args })=>{
173
+ uploadApp: async ({ args, options })=>{
160
174
  const fn = args[0];
161
175
  if (!fn || !fn.endsWith('.app')) {
162
176
  throw new Error((0, _i18n.t)('usageUploadApp'));
163
177
  }
164
178
  const appInfo = await (0, _utils.getAppInfo)(fn);
165
- const { versionName, buildTime } = appInfo;
179
+ const { versionName: extractedVersionName, buildTime } = appInfo;
166
180
  const appIdInPkg = appInfo.appId;
167
181
  const appKeyInPkg = appInfo.appKey;
168
182
  const { appId, appKey } = await (0, _app.getSelectedApp)('harmony');
@@ -178,6 +192,13 @@ const packageCommands = {
178
192
  appKey
179
193
  }));
180
194
  }
195
+ // Use custom version if provided, otherwise use extracted version
196
+ const versionName = options.version || extractedVersionName;
197
+ if (options.version) {
198
+ console.log((0, _i18n.t)('usingCustomVersion', {
199
+ version: versionName
200
+ }));
201
+ }
181
202
  const { hash } = await (0, _api.uploadFile)(fn);
182
203
  const { id } = await (0, _api.post)(`/app/${appId}/package/create`, {
183
204
  name: versionName,
@@ -218,5 +239,40 @@ const packageCommands = {
218
239
  const platform = await (0, _app.getPlatform)(options.platform);
219
240
  const { appId } = await (0, _app.getSelectedApp)(platform);
220
241
  await listPackage(appId);
242
+ },
243
+ deletePackage: async ({ args, options })=>{
244
+ let packageId = args[0];
245
+ let { appId } = options;
246
+ if (!appId) {
247
+ const platform = await (0, _app.getPlatform)();
248
+ appId = (await (0, _app.getSelectedApp)(platform)).appId;
249
+ }
250
+ // If no packageId provided as argument, let user choose from list
251
+ if (!packageId) {
252
+ const selectedPackage = await choosePackage(appId);
253
+ packageId = selectedPackage.id;
254
+ }
255
+ // Confirm deletion
256
+ // const confirmDelete = await question(
257
+ // t('confirmDeletePackage', { packageId }),
258
+ // );
259
+ // if (
260
+ // confirmDelete.toLowerCase() !== 'y' &&
261
+ // confirmDelete.toLowerCase() !== 'yes'
262
+ // ) {
263
+ // console.log(t('cancelled'));
264
+ // return;
265
+ // }
266
+ try {
267
+ await (0, _api.doDelete)(`/app/${appId}/package/${packageId}`);
268
+ console.log((0, _i18n.t)('deletePackageSuccess', {
269
+ packageId
270
+ }));
271
+ } catch (error) {
272
+ throw new Error((0, _i18n.t)('deletePackageError', {
273
+ packageId,
274
+ error: error.message
275
+ }));
276
+ }
221
277
  }
222
278
  };
package/lib/provider.js CHANGED
@@ -135,7 +135,8 @@ class CLIProviderImpl {
135
135
  ],
136
136
  options: {
137
137
  platform,
138
- appId
138
+ appId,
139
+ version: options.version
139
140
  }
140
141
  };
141
142
  const { packageCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./package")));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
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
@@ -130,4 +130,11 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
130
130
  updateNativePackageQuestion: 'Bind to native package now?(Y/N)',
131
131
  unnamed: '(Unnamed)',
132
132
  dryRun: 'Below is the dry-run result, no actual operation will be performed:',
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]',
133
140
  };
package/src/locales/zh.ts CHANGED
@@ -123,4 +123,10 @@ export default {
123
123
  updateNativePackageQuestion: '是否现在将此热更应用到原生包上?(Y/N)',
124
124
  unnamed: '(未命名)',
125
125
  dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
126
+ usingCustomVersion: '使用自定义版本:{{version}}',
127
+ confirmDeletePackage: '确认删除原生包 {{packageId}}? 此操作不可撤销 (Y/N):',
128
+ deletePackageSuccess: '原生包 {{packageId}} 删除成功',
129
+ deletePackageError: '删除原生包 {{packageId}} 失败: {{error}}',
130
+ usageDeletePackage:
131
+ '使用方法: pushy deletePackage [packageId] --appId [appId]',
126
132
  };
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
 
@@ -23,9 +23,9 @@ export async function listPackage(appId: string) {
23
23
  let versionInfo = '';
24
24
  if (version) {
25
25
  const versionObj = version as any;
26
- versionInfo = t('boundTo', {
27
- name: versionObj.name || version,
28
- id: versionObj.id || version
26
+ versionInfo = t('boundTo', {
27
+ name: versionObj.name || version,
28
+ id: versionObj.id || version,
29
29
  });
30
30
  }
31
31
  let output = pkg.name;
@@ -57,16 +57,19 @@ export async function choosePackage(appId: string) {
57
57
  }
58
58
 
59
59
  export const packageCommands = {
60
- uploadIpa: async ({ args }: { args: string[] }) => {
60
+ uploadIpa: async ({
61
+ args,
62
+ options,
63
+ }: {
64
+ args: string[];
65
+ options: Record<string, any>;
66
+ }) => {
61
67
  const fn = args[0];
62
68
  if (!fn || !fn.endsWith('.ipa')) {
63
69
  throw new Error(t('usageUploadIpa'));
64
70
  }
65
71
  const ipaInfo = await getIpaInfo(fn);
66
- const {
67
- versionName,
68
- buildTime,
69
- } = ipaInfo;
72
+ const { versionName: extractedVersionName, buildTime } = ipaInfo;
70
73
  const appIdInPkg = (ipaInfo as any).appId;
71
74
  const appKeyInPkg = (ipaInfo as any).appKey;
72
75
  const { appId, appKey } = await getSelectedApp('ios');
@@ -79,6 +82,12 @@ export const packageCommands = {
79
82
  throw new Error(t('appKeyMismatchIpa', { appKeyInPkg, appKey }));
80
83
  }
81
84
 
85
+ // Use custom version if provided, otherwise use extracted version
86
+ const versionName = options.version || extractedVersionName;
87
+ if (options.version) {
88
+ console.log(t('usingCustomVersion', { version: versionName }));
89
+ }
90
+
82
91
  const { hash } = await uploadFile(fn);
83
92
 
84
93
  const { id } = await post(`/app/${appId}/package/create`, {
@@ -89,20 +98,21 @@ export const packageCommands = {
89
98
  commit: await getCommitInfo(),
90
99
  });
91
100
  saveToLocal(fn, `${appId}/package/${id}.ipa`);
92
- console.log(
93
- t('ipaUploadSuccess', { id, version: versionName, buildTime }),
94
- );
101
+ console.log(t('ipaUploadSuccess', { id, version: versionName, buildTime }));
95
102
  },
96
- uploadApk: async ({ args }: { args: string[] }) => {
103
+ uploadApk: async ({
104
+ args,
105
+ options,
106
+ }: {
107
+ args: string[];
108
+ options: Record<string, any>;
109
+ }) => {
97
110
  const fn = args[0];
98
111
  if (!fn || !fn.endsWith('.apk')) {
99
112
  throw new Error(t('usageUploadApk'));
100
113
  }
101
114
  const apkInfo = await getApkInfo(fn);
102
- const {
103
- versionName,
104
- buildTime,
105
- } = apkInfo;
115
+ const { versionName: extractedVersionName, buildTime } = apkInfo;
106
116
  const appIdInPkg = (apkInfo as any).appId;
107
117
  const appKeyInPkg = (apkInfo as any).appKey;
108
118
  const { appId, appKey } = await getSelectedApp('android');
@@ -115,6 +125,12 @@ export const packageCommands = {
115
125
  throw new Error(t('appKeyMismatchApk', { appKeyInPkg, appKey }));
116
126
  }
117
127
 
128
+ // Use custom version if provided, otherwise use extracted version
129
+ const versionName = options.version || extractedVersionName;
130
+ if (options.version) {
131
+ console.log(t('usingCustomVersion', { version: versionName }));
132
+ }
133
+
118
134
  const { hash } = await uploadFile(fn);
119
135
 
120
136
  const { id } = await post(`/app/${appId}/package/create`, {
@@ -125,20 +141,21 @@ export const packageCommands = {
125
141
  commit: await getCommitInfo(),
126
142
  });
127
143
  saveToLocal(fn, `${appId}/package/${id}.apk`);
128
- console.log(
129
- t('apkUploadSuccess', { id, version: versionName, buildTime }),
130
- );
144
+ console.log(t('apkUploadSuccess', { id, version: versionName, buildTime }));
131
145
  },
132
- uploadApp: async ({ args }: { args: string[] }) => {
146
+ uploadApp: async ({
147
+ args,
148
+ options,
149
+ }: {
150
+ args: string[];
151
+ options: Record<string, any>;
152
+ }) => {
133
153
  const fn = args[0];
134
154
  if (!fn || !fn.endsWith('.app')) {
135
155
  throw new Error(t('usageUploadApp'));
136
156
  }
137
157
  const appInfo = await getAppInfo(fn);
138
- const {
139
- versionName,
140
- buildTime,
141
- } = appInfo;
158
+ const { versionName: extractedVersionName, buildTime } = appInfo;
142
159
  const appIdInPkg = (appInfo as any).appId;
143
160
  const appKeyInPkg = (appInfo as any).appKey;
144
161
  const { appId, appKey } = await getSelectedApp('harmony');
@@ -151,6 +168,12 @@ export const packageCommands = {
151
168
  throw new Error(t('appKeyMismatchApp', { appKeyInPkg, appKey }));
152
169
  }
153
170
 
171
+ // Use custom version if provided, otherwise use extracted version
172
+ const versionName = options.version || extractedVersionName;
173
+ if (options.version) {
174
+ console.log(t('usingCustomVersion', { version: versionName }));
175
+ }
176
+
154
177
  const { hash } = await uploadFile(fn);
155
178
 
156
179
  const { id } = await post(`/app/${appId}/package/create`, {
@@ -161,9 +184,7 @@ export const packageCommands = {
161
184
  commit: await getCommitInfo(),
162
185
  });
163
186
  saveToLocal(fn, `${appId}/package/${id}.app`);
164
- console.log(
165
- t('appUploadSuccess', { id, version: versionName, buildTime }),
166
- );
187
+ console.log(t('appUploadSuccess', { id, version: versionName, buildTime }));
167
188
  },
168
189
  parseApp: async ({ args }: { args: string[] }) => {
169
190
  const fn = args[0];
@@ -191,4 +212,47 @@ export const packageCommands = {
191
212
  const { appId } = await getSelectedApp(platform);
192
213
  await listPackage(appId);
193
214
  },
215
+ deletePackage: async ({
216
+ args,
217
+ options,
218
+ }: {
219
+ args: string[];
220
+ options: { appId?: string };
221
+ }) => {
222
+ let packageId = args[0];
223
+ let { appId } = options;
224
+
225
+ if (!appId) {
226
+ const platform = await getPlatform();
227
+ appId = (await getSelectedApp(platform)).appId as string;
228
+ }
229
+
230
+ // If no packageId provided as argument, let user choose from list
231
+ if (!packageId) {
232
+ const selectedPackage = await choosePackage(appId);
233
+ packageId = selectedPackage.id;
234
+ }
235
+
236
+ // Confirm deletion
237
+ // const confirmDelete = await question(
238
+ // t('confirmDeletePackage', { packageId }),
239
+ // );
240
+
241
+ // if (
242
+ // confirmDelete.toLowerCase() !== 'y' &&
243
+ // confirmDelete.toLowerCase() !== 'yes'
244
+ // ) {
245
+ // console.log(t('cancelled'));
246
+ // return;
247
+ // }
248
+
249
+ try {
250
+ await doDelete(`/app/${appId}/package/${packageId}`);
251
+ console.log(t('deletePackageSuccess', { packageId }));
252
+ } catch (error: any) {
253
+ throw new Error(
254
+ t('deletePackageError', { packageId, error: error.message }),
255
+ );
256
+ }
257
+ },
194
258
  };
package/src/provider.ts CHANGED
@@ -110,7 +110,7 @@ export class CLIProviderImpl implements CLIProvider {
110
110
 
111
111
  const context: CommandContext = {
112
112
  args: [filePath],
113
- options: { platform, appId },
113
+ options: { platform, appId, version: options.version },
114
114
  };
115
115
 
116
116
  const { packageCommands } = await import('./package');
package/src/types.ts CHANGED
@@ -85,6 +85,7 @@ export interface UploadOptions {
85
85
  platform?: Platform;
86
86
  filePath: string;
87
87
  appId?: string;
88
+ version?: string;
88
89
  }
89
90
 
90
91
  export interface WorkflowStep {