Skip to content

Commit eb14680

Browse files
committed
Add deleteVersion command and update localization for version deletion success and error messages; bump version to 2.6.0 in package.json.
1 parent 7259efb commit eb14680

File tree

5 files changed

+44
-2
lines changed

5 files changed

+44
-2
lines changed

cli.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@
173173
}
174174
}
175175
},
176+
"deleteVersion": {
177+
"options": {
178+
"platform": {
179+
"hasValue": true
180+
},
181+
"versionId": {
182+
"hasValue": true
183+
},
184+
"appId": {
185+
"hasValue": true
186+
}
187+
}
188+
},
176189
"build": {
177190
"description": "Bundle javascript and copy assets."
178191
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update-cli",
3-
"version": "2.5.0",
3+
"version": "2.6.0",
44
"description": "command line tool for react-native-update (remote updates for react native)",
55
"main": "index.js",
66
"bin": {

src/locales/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
138138
deletePackageError:
139139
'Failed to delete native package {{packageId}}: {{error}}',
140140
usageDeletePackage: 'Usage: cresc deletePackage [packageId] --appId [appId]',
141+
deleteVersionSuccess: 'Version {{versionId}} deleted successfully',
142+
deleteVersionError: 'Failed to delete version {{versionId}}: {{error}}',
141143
bundleFileNotFound:
142144
'Bundle file not found! Please use default bundle file name and path.',
143145
diffPackageGenerated: '{{- output}} generated.',

src/locales/zh.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ export default {
130130
deletePackageError: '删除原生包 {{packageId}} 失败: {{error}}',
131131
usageDeletePackage:
132132
'使用方法: pushy deletePackage [packageId] --appId [appId]',
133+
deleteVersionSuccess: '热更包 {{versionId}} 删除成功',
134+
deleteVersionError: '删除热更包 {{versionId}} 失败: {{error}}',
133135
bundleFileNotFound: '未找到 bundle 文件!请使用默认的 bundle 文件名和路径。',
134136
diffPackageGenerated: '{{- output}} 已生成。',
135137
nodeBsdiffRequired:

src/versions.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { get, getAllPackages, post, put, uploadFile } from './api';
1+
import { get, getAllPackages, post, put, uploadFile, doDelete } from './api';
22
import { question, saveToLocal } from './utils';
33
import { t } from './utils/i18n';
44

@@ -343,4 +343,29 @@ export const versionCommands = {
343343
await put(`/app/${appId}/version/${versionId}`, updateParams);
344344
console.log(t('operationSuccess'));
345345
},
346+
deleteVersion: async ({
347+
options,
348+
}: {
349+
options: VersionCommandOptions;
350+
}) => {
351+
let appId = options.appId;
352+
if (!appId) {
353+
const platform = await getPlatform(options.platform);
354+
appId = (await getSelectedApp(platform)).appId;
355+
}
356+
357+
let versionId = options.versionId;
358+
if (!versionId) {
359+
versionId = (await chooseVersion(appId as string)).id;
360+
}
361+
362+
try {
363+
await doDelete(`/app/${appId}/version/${versionId}`);
364+
console.log(t('deleteVersionSuccess', { versionId }));
365+
} catch (error: any) {
366+
throw new Error(
367+
t('deleteVersionError', { versionId, error: error.message }),
368+
);
369+
}
370+
},
346371
};

0 commit comments

Comments
 (0)