1- import { BaseCommand } from "../../base-command" ;
21import { cliux , flags } from "@contentstack/cli-utilities" ;
2+
3+ import { AppCLIBaseCommand } from "../../app-cli-base-coomand" ;
34import { $t , commonMsg , installAppMsg } from "../../messages" ;
45import {
56 getOrg ,
@@ -10,7 +11,7 @@ import {
1011 fetchStack ,
1112} from "../../util" ;
1213
13- export default class Install extends BaseCommand < typeof Install > {
14+ export default class Install extends AppCLIBaseCommand {
1415 static description : string | undefined =
1516 "Install an app from the marketplace" ;
1617
@@ -32,6 +33,8 @@ export default class Install extends BaseCommand<typeof Install> {
3233 async run ( ) : Promise < void > {
3334 try {
3435 let app , stack , appType ;
36+ this . start ( ) ;
37+ this . flags [ "app-uid" ] = this . manifestData ?. uid ?? this . flags [ "app-uid" ] ; //manifest file first preference
3538
3639 // validating user given stack, as installation API doesn't return appropriate errors if stack-api-key is invalid
3740 // validating this first, as orgUid is not required for fetching stack
@@ -43,10 +46,12 @@ export default class Install extends BaseCommand<typeof Install> {
4346 }
4447
4548 // get organization to be used
46- this . sharedConfig . org = await getOrg ( this . flags , {
47- managementSdk : this . managementSdk ,
48- log : this . log ,
49- } ) ;
49+ this . sharedConfig . org =
50+ this . manifestData ?. organization_uid ??
51+ ( await getOrg ( this . flags , {
52+ managementSdk : this . managementSdk ,
53+ log : this . log ,
54+ } ) ) ;
5055
5156 // fetch app details
5257 if ( ! this . flags [ "app-uid" ] ) {
@@ -114,9 +119,22 @@ export default class Install extends BaseCommand<typeof Install> {
114119 } ) ,
115120 "info"
116121 ) ;
122+
123+ this . displayStackUrl ( ) ;
117124 } catch ( error : any ) {
118125 this . log ( error ?. errorMessage || error ?. message || error , "error" ) ;
119126 this . exit ( 1 ) ;
120127 }
121128 }
129+
130+ /**
131+ * @method displayStackUrl - show guid to stack after installing app successfully in the stack
132+ */
133+ displayStackUrl ( ) : void {
134+ const stackPath = `${ this . uiHost } /#!/stack/${ this . flags [ "stack-api-key" ] } /dashboard` ;
135+ this . log (
136+ `Start using the stack using the following url: ${ stackPath } ` ,
137+ "info"
138+ ) ;
139+ }
122140}
0 commit comments