Skip to content

Commit ca03a0f

Browse files
Fixed PR comments
1 parent 992d062 commit ca03a0f

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

.talismanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fileignoreconfig:
5454
- filename: packages/contentstack-export/src/export/modules/assets.ts
5555
checksum: c7f19e6c4a212329d981cebce9a9a8393923dd7c85feb762ddcdca678f7a9349
5656
- filename: packages/contentstack-seed/src/seed/index.ts
57-
checksum: db1ae8b5d8c338ad0369d441b11978dc6850d0f09f338b331e12478ebc18ff65
57+
checksum: 23b30ba6c75200c21a8d4b8a1cd176b6302942e13f865fbaef36eeff995b85d1
5858
- filename: packages/contentstack-seed/src/seed/compassAppHelper.ts
5959
checksum: 59001d937245a8d1062a4a53206e1bb2d6d1a85633165e6e6749f1d5fc1bd817
6060
- filename: packages/contentstack/README.md

packages/contentstack-seed/src/seed/index.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as tmp from 'tmp';
22
import { cliux } from '@contentstack/cli-utilities';
33

44
import * as importer from '../seed/importer';
5-
import ContentstackClient, { Organization, Stack } from '../seed/contentstack/client';
5+
import ContentstackClient, { Organization } from '../seed/contentstack/client';
66
import {
77
inquireOrganization,
88
inquireProceed,
@@ -12,7 +12,7 @@ import {
1212
} from '../seed/interactive';
1313
import GitHubClient from './github/client';
1414
import GithubError from './github/error';
15-
import { shouldProceedForCompassApp, ENGLISH_LOCALE } from './compassAppHelper';
15+
import { shouldProceedForCompassApp, ENGLISH_LOCALE } from './utils/compassAppHelper';
1616

1717
const DEFAULT_OWNER = 'contentstack';
1818
const 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) {

packages/contentstack-seed/src/seed/compassAppHelper.ts renamed to packages/contentstack-seed/src/seed/utils/compassAppHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cliux } from '@contentstack/cli-utilities';
2-
import ContentstackClient from '../seed/contentstack/client';
2+
import ContentstackClient from '../contentstack/client';
33

44
export const COMPASS_REPO = 'compass-starter-stack';
55
export const ENGLISH_LOCALE = 'en-us';
@@ -51,7 +51,7 @@ export async function shouldProceedForCompassApp({
5151

5252
if (masterLocale !== stackDetails.master_locale) {
5353
cliux.print(
54-
`Compass app requires the master locale to be set to English (en-us).`,
54+
`Compass app requires the master locale to be set to English (${masterLocale}).`,
5555
{
5656
color: 'yellow',
5757
bold: true,

0 commit comments

Comments
 (0)