@@ -2,7 +2,7 @@ import * as tmp from 'tmp';
22import { cliux } from '@contentstack/cli-utilities' ;
33
44import * as importer from '../seed/importer' ;
5- import ContentstackClient , { Organization , Stack } from '../seed/contentstack/client' ;
5+ import ContentstackClient , { Organization } from '../seed/contentstack/client' ;
66import {
77 inquireOrganization ,
88 inquireProceed ,
@@ -12,7 +12,7 @@ import {
1212} from '../seed/interactive' ;
1313import GitHubClient from './github/client' ;
1414import GithubError from './github/error' ;
15- import { shouldProceedForCompassApp , ENGLISH_LOCALE } from './compassAppHelper' ;
15+ import { shouldProceedForCompassApp , ENGLISH_LOCALE } from './utils/ compassAppHelper' ;
1616
1717const DEFAULT_OWNER = 'contentstack' ;
1818const DEFAULT_STACK_PATTERN = 'stack-' ;
@@ -102,9 +102,17 @@ export default class ContentModelSeeder {
102102
103103 let repoExists = false ;
104104 let repoResponseData : any = { } ;
105- const repoCheckResult = await this . ghClient . makeGetApiCall ( this . ghRepo as string ) ;
106- repoExists = repoCheckResult . statusCode === 200 ;
107- repoResponseData = { status : repoCheckResult . statusCode , statusMessage : repoCheckResult . statusMessage } ;
105+ let repoCheckResult ;
106+ try {
107+ repoCheckResult = await this . ghClient . makeGetApiCall ( this . ghRepo as string ) ;
108+ repoExists = repoCheckResult . statusCode === 200 ;
109+ repoResponseData = { status : repoCheckResult . statusCode , statusMessage : repoCheckResult . statusMessage } ;
110+ } catch ( error ) {
111+ const errorMessage = error instanceof Error ? error . message : 'Unknown error' ;
112+ cliux . error ( `Failed to fetch GitHub repository details: ${ errorMessage } ` ) ;
113+ if ( this . parent ) this . parent . exit ( 1 ) ;
114+ throw error ; // Re-throw the error instead of returning false
115+ }
108116
109117 if ( repoExists === false ) {
110118 cliux . error (
@@ -139,7 +147,7 @@ export default class ContentModelSeeder {
139147 } else {
140148 const organizations = await this . csClient . getOrganizations ( ) ;
141149 if ( ! organizations || organizations . length === 0 ) {
142- throw new Error ( 'You do not have access to any organizations.' ) ;
150+ throw new Error ( 'You do not have access to any organizations. Please try again or ask an Administrator for assistance. ' ) ;
143151 }
144152 organizationResponse = await inquireOrganization ( organizations ) ;
145153 }
@@ -148,7 +156,10 @@ export default class ContentModelSeeder {
148156 stackResponse = await inquireStack ( stacks , this . options . stackName ) ;
149157 }
150158
151- return { organizationResponse : organizationResponse ! , stackResponse } ;
159+ if ( ! organizationResponse ) {
160+ throw new Error ( 'Organization response is undefined. Ensure an organization is selected or provided.' ) ;
161+ }
162+ return { organizationResponse, stackResponse } ;
152163 }
153164
154165 async createStack ( organization : Organization , stackName : string ) {
0 commit comments