File tree Expand file tree Collapse file tree 7 files changed +21
-10
lines changed
Expand file tree Collapse file tree 7 files changed +21
-10
lines changed Original file line number Diff line number Diff line change 11import Command from "../../core/command" ;
22import {
33 flags ,
4- FlagInput ,
54 managementSDKClient ,
65 cliux ,
76 printFlagDeprecation ,
7+ authenticationHandler ,
88} from "@contentstack/cli-utilities" ;
99import buildOutput from "../../core/content-type/audit" ;
1010import { getStack , getUsers , getContentType } from "../../utils" ;
@@ -53,7 +53,20 @@ export default class AuditCommand extends Command {
5353 async run ( ) {
5454 try {
5555 const { flags } = await this . parse ( AuditCommand ) ;
56- await this . setup ( flags ) ;
56+ await authenticationHandler . getAuthDetails ( ) ;
57+ const authToken = authenticationHandler . accessToken ;
58+ if ( ! authToken ) {
59+ this . error (
60+ "You're not logged in. Run auth:login to sign in. Use auth:login --help for more details." ,
61+ {
62+ exit : 2 ,
63+ suggestions : [
64+ "https://www.contentstack.com/docs/developers/cli/authentication/" ,
65+ ] ,
66+ }
67+ ) ;
68+ }
69+ this . setup ( flags , authToken ) ;
5770
5871 this . contentTypeManagementClient = await managementSDKClient ( {
5972 host : this . cmaHost ,
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export default class CompareRemoteCommand extends Command {
4444 async run ( ) {
4545 try {
4646 const { flags } = await this . parse ( CompareRemoteCommand ) ;
47- await this . setup ( { alias : undefined , stack : flags [ "origin-stack" ] } ) ;
47+ this . setup ( { alias : undefined , stack : flags [ "origin-stack" ] } ) ;
4848 this . contentTypeManagementClient = await managementSDKClient ( {
4949 host : this . cmaHost ,
5050 "X-CS-CLI" : this . context ?. analyticsInfo ,
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ export default class CompareCommand extends Command {
6868 async run ( ) {
6969 try {
7070 const { flags } = await this . parse ( CompareCommand ) ;
71- await this . setup ( flags ) ;
71+ this . setup ( flags ) ;
7272 this . contentTypeManagementClient = await managementSDKClient ( {
7373 host : this . cmaHost ,
7474 "X-CS-CLI" : this . context ?. analyticsInfo ,
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ export default class DetailsCommand extends Command {
6262 async run ( ) {
6363 try {
6464 const { flags } = await this . parse ( DetailsCommand ) ;
65- await this . setup ( flags ) ;
65+ this . setup ( flags ) ;
6666 this . contentTypeManagementClient = await managementSDKClient ( {
6767 host : this . cmaHost ,
6868 "X-CS-CLI" : this . context ?. analyticsInfo ,
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ export default class DiagramCommand extends Command {
8484 host : this . cmaHost ,
8585 "X-CS-CLI" : this . context ?. analyticsInfo ,
8686 } ) ;
87- await this . setup ( flags ) ;
87+ this . setup ( flags ) ;
8888
8989 const outputPath = flags . output ;
9090
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ export default class ListCommand extends Command {
5555 async run ( ) {
5656 try {
5757 const { flags } = await this . parse ( ListCommand ) ;
58- await this . setup ( flags ) ;
58+ this . setup ( flags ) ;
5959 this . contentTypeManagementClient = await managementSDKClient ( {
6060 host : this . cmaHost ,
6161 "X-CS-CLI" : this . context ?. analyticsInfo ,
Original file line number Diff line number Diff line change @@ -12,9 +12,7 @@ export default class ContentTypeCommand extends Command {
1212
1313 protected contentTypeManagementClient : any ;
1414
15- async setup ( flags : any ) {
16- await authenticationHandler . getAuthDetails ( ) ;
17- const authToken = authenticationHandler . accessToken ;
15+ setup ( flags : any , authToken ?: string ) {
1816 if ( ! authToken ) {
1917 this . error (
2018 "You're not logged in. Run auth:login to sign in. Use auth:login --help for more details." ,
You can’t perform that action at this time.
0 commit comments