mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-16 01:41:37 +08:00
Enhance package command options to include packageId and packageVersion; improve package selection logic with error handling for missing packages.
This commit is contained in:
6
cli.json
6
cli.json
@@ -66,6 +66,12 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"appId": {
|
"appId": {
|
||||||
"hasValue": true
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"packageVersion": {
|
||||||
|
"hasValue": true
|
||||||
|
},
|
||||||
|
"packageId": {
|
||||||
|
"hasValue": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user