@@ -18,6 +18,7 @@ import {
1818 Flags ,
1919 loglevel ,
2020 orgApiVersionFlagWithDeprecations ,
21+ requiredHubFlagWithDeprecations ,
2122 requiredOrgFlagWithDeprecations ,
2223 SfCommand ,
2324} from '@salesforce/sf-plugins-core' ;
@@ -45,11 +46,7 @@ export class PackageBundlesInstall extends SfCommand<BundleSObjects.PkgBundleVer
4546 } ) ,
4647 'target-org' : requiredOrgFlagWithDeprecations ,
4748 'api-version' : orgApiVersionFlagWithDeprecations ,
48- 'target-dev-hub' : Flags . string ( {
49- char : 'v' ,
50- summary : messages . getMessage ( 'flags.target-dev-hub.summary' ) ,
51- required : true ,
52- } ) ,
49+ 'target-dev-hub' : requiredHubFlagWithDeprecations ,
5350 wait : Flags . integer ( {
5451 char : 'w' ,
5552 summary : messages . getMessage ( 'flags.wait.summary' ) ,
@@ -65,28 +62,15 @@ export class PackageBundlesInstall extends SfCommand<BundleSObjects.PkgBundleVer
6562
6663 // Get the target org connection
6764 const targetOrg = flags [ 'target-org' ] ;
68- const targetDevHubFlag = flags [ 'target-dev-hub' ] ;
65+ const targetDevHub = flags [ 'target-dev-hub' ] ;
6966 const connection = targetOrg . getConnection ( flags [ 'api-version' ] ) ;
70-
71- // Check if targetDevHub is already a valid org ID (starts with 00D and is 18 characters)
72- const orgIdRegex = / ^ 0 0 D [ a - z A - Z 0 - 9 ] { 15 } $ / ;
73- let targetDevHub : string ;
74-
75- if ( orgIdRegex . test ( targetDevHubFlag ) ) {
76- // It's already an org ID, use it directly
77- targetDevHub = targetDevHubFlag ;
78- } else {
79- // It's a username/alias, resolve it to an org and get the org ID
80- const { Org } = await import ( '@salesforce/core' ) ;
81- const devHubOrg = await Org . create ( { aliasOrUsername : targetDevHubFlag , isDevHub : true } ) ;
82- targetDevHub = devHubOrg . getOrgId ( ) ;
83- }
67+ const devHubOrgId = targetDevHub . getOrgId ( ) ;
8468
8569 const options : BundleInstallOptions = {
8670 connection,
8771 project : this . project ! ,
8872 PackageBundleVersion : flags . bundle ,
89- DevelopmentOrganization : targetDevHub ,
73+ DevelopmentOrganization : devHubOrgId ,
9074 } ;
9175
9276 // Set up lifecycle events for progress tracking
@@ -114,10 +98,9 @@ export class PackageBundlesInstall extends SfCommand<BundleSObjects.PkgBundleVer
11498
11599 const result = await PackageBundleInstall . installBundle ( connection , this . project ! , {
116100 ...options ,
117- polling : {
118- timeout : Duration . minutes ( flags . wait ) ,
119- frequency : Duration . seconds ( 5 ) ,
120- } ,
101+ ...( flags . wait && flags . wait > 0
102+ ? { polling : { timeout : Duration . minutes ( flags . wait ) , frequency : Duration . seconds ( 5 ) } }
103+ : undefined ) ,
121104 } ) ;
122105
123106 const finalStatusMsg = messages . getMessage ( 'bundleInstallFinalStatus' , [ result . InstallStatus ] ) ;
0 commit comments