Skip to content

Commit ac13464

Browse files
committed
Enhance package command options to include packageId and packageVersion; improve package selection logic with error handling for missing packages.
1 parent f82bab8 commit ac13464

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

cli.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
"options": {
6767
"appId": {
6868
"hasValue": true
69+
},
70+
"packageVersion": {
71+
"hasValue": true
72+
},
73+
"packageId": {
74+
"hasValue": true
6975
}
7076
}
7177
},

src/package.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,9 @@ export const packageCommands = {
217217
options,
218218
}: {
219219
args: string[];
220-
options: { appId?: string };
220+
options: { appId?: string, packageId?: string, packageVersion?: string };
221221
}) => {
222-
let packageId = args[0];
223-
let { appId } = options;
222+
let { appId, packageId, packageVersion } = options;
224223

225224
if (!appId) {
226225
const platform = await getPlatform();
@@ -229,7 +228,14 @@ export const packageCommands = {
229228

230229
// If no packageId provided as argument, let user choose from list
231230
if (!packageId) {
232-
const selectedPackage = await choosePackage(appId);
231+
const allPkgs = await getAllPackages(appId);
232+
if (!allPkgs) {
233+
throw new Error(t('noPackagesFound', { appId }));
234+
}
235+
const selectedPackage = allPkgs.find((pkg) => pkg.version === packageVersion);
236+
if (!selectedPackage) {
237+
throw new Error(t('packageNotFound', { packageVersion }));
238+
}
233239
packageId = selectedPackage.id;
234240
}
235241

0 commit comments

Comments
 (0)