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

Enhance package command options to include packageId and packageVersion; improve package selection logic with error handling for missing packages.

This commit is contained in:
sunny.ll
2025-09-10 16:18:34 +08:00
parent f82bab887a
commit ac13464d4d
2 changed files with 16 additions and 4 deletions

View File

@@ -66,6 +66,12 @@
"options": { "options": {
"appId": { "appId": {
"hasValue": true "hasValue": true
},
"packageVersion": {
"hasValue": true
},
"packageId": {
"hasValue": true
} }
} }
}, },

View File

@@ -217,10 +217,9 @@ export const packageCommands = {
options, options,
}: { }: {
args: string[]; args: string[];
options: { appId?: string }; options: { appId?: string, packageId?: string, packageVersion?: string };
}) => { }) => {
let packageId = args[0]; let { appId, packageId, packageVersion } = options;
let { appId } = options;
if (!appId) { if (!appId) {
const platform = await getPlatform(); const platform = await getPlatform();
@@ -229,7 +228,14 @@ export const packageCommands = {
// If no packageId provided as argument, let user choose from list // If no packageId provided as argument, let user choose from list
if (!packageId) { if (!packageId) {
const selectedPackage = await choosePackage(appId); const allPkgs = await getAllPackages(appId);
if (!allPkgs) {
throw new Error(t('noPackagesFound', { appId }));
}
const selectedPackage = allPkgs.find((pkg) => pkg.version === packageVersion);
if (!selectedPackage) {
throw new Error(t('packageNotFound', { packageVersion }));
}
packageId = selectedPackage.id; packageId = selectedPackage.id;
} }