1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-09-16 01:41:37 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Add deletePackage command with confirmation and error handling; update version to 2.1.0 and enhance localization for delete operations

This commit is contained in:
sunny.ll
2025-09-09 12:21:57 +08:00
parent cd890347d1
commit a4467717bc
6 changed files with 65 additions and 3 deletions

View File

@@ -62,6 +62,13 @@
}
}
},
"deletePackage": {
"options": {
"appId": {
"hasValue": true
}
}
},
"publish": {
"options": {
"platform": {

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-update-cli",
"version": "2.0.1",
"version": "2.1.0",
"description": "command line tool for react-native-update (remote updates for react native)",
"main": "index.js",
"bin": {

View File

@@ -131,4 +131,10 @@ This can reduce the risk of inconsistent dependencies and supply chain attacks.
unnamed: '(Unnamed)',
dryRun: 'Below is the dry-run result, no actual operation will be performed:',
usingCustomVersion: 'Using custom version: {{version}}',
confirmDeletePackage:
'Confirm delete native package {{packageId}}? This operation cannot be undone (Y/N):',
deletePackageSuccess: 'Native package {{packageId}} deleted successfully',
deletePackageError:
'Failed to delete native package {{packageId}}: {{error}}',
usageDeletePackage: 'Usage: cresc deletePackage [packageId] --appId [appId]',
};

View File

@@ -124,4 +124,9 @@ export default {
unnamed: '(未命名)',
dryRun: '以下是 dry-run 模拟运行结果,不会实际执行任何操作:',
usingCustomVersion: '使用自定义版本:{{version}}',
confirmDeletePackage: '确认删除原生包 {{packageId}}? 此操作不可撤销 (Y/N):',
deletePackageSuccess: '原生包 {{packageId}} 删除成功',
deletePackageError: '删除原生包 {{packageId}} 失败: {{error}}',
usageDeletePackage:
'使用方法: pushy deletePackage [packageId] --appId [appId]',
};

View File

@@ -1,4 +1,4 @@
import { get, getAllPackages, post, uploadFile } from './api';
import { get, getAllPackages, post, uploadFile, doDelete } from './api';
import { question, saveToLocal } from './utils';
import { t } from './utils/i18n';
@@ -212,4 +212,47 @@ export const packageCommands = {
const { appId } = await getSelectedApp(platform);
await listPackage(appId);
},
deletePackage: async ({
args,
options,
}: {
args: string[];
options: { appId?: string };
}) => {
let packageId = args[0];
let { appId } = options;
if (!appId) {
const platform = await getPlatform();
appId = (await getSelectedApp(platform)).appId as string;
}
// If no packageId provided as argument, let user choose from list
if (!packageId) {
const selectedPackage = await choosePackage(appId);
packageId = selectedPackage.id;
}
// Confirm deletion
// const confirmDelete = await question(
// t('confirmDeletePackage', { packageId }),
// );
// if (
// confirmDelete.toLowerCase() !== 'y' &&
// confirmDelete.toLowerCase() !== 'yes'
// ) {
// console.log(t('cancelled'));
// return;
// }
try {
await doDelete(`/app/${appId}/package/${packageId}`);
console.log(t('deletePackageSuccess', { packageId }));
} catch (error: any) {
throw new Error(
t('deletePackageError', { packageId, error: error.message }),
);
}
},
};

View File

@@ -4,7 +4,8 @@
"target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": [
"ESNext"
"ESNext",
"DOM"
] /* Specify library files to be included in the compilation. */,
"allowJs": true /* Allow javascript files to be compiled. */,
// "checkJs": true /* Report errors in .js files. */,