Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update generic error message when repo doe not contain config.json file #1347

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,7 @@ en:
invalidCharacters: "The selected destination contains invalid characters. Please provide a new path and try again."
invalidTemplate: "[--template] Could not find template {{ template }}. Please choose an available template."
noProjectsInConfig: "Please ensure that there is a config.json file that contains a \"projects\" field."
missingConfigFileTemplateSource: "Please ensure that there is a config.json file in the repository used as the --template-source"
missingPropertiesInConfig: "Please ensure that each of the projects in your config.json file contain the following properties: [\"name\", \"label\", \"path\", \"insertPath\"]."
selectPublicAppPrompt:
selectAppIdMigrate: "[--appId] Choose an app under {{ accountName }} to migrate:"
Expand Down
16 changes: 11 additions & 5 deletions lib/prompts/createProjectPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ async function createTemplateOptions(
? DEFAULT_PROJECT_TEMPLATE_BRANCH
: githubRef;

const config = await fetchFileFromRepository<ProjectTemplateRepoConfig>(
templateSource || HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH,
'config.json',
branch
);
let config: ProjectTemplateRepoConfig;
try {
config = await fetchFileFromRepository<ProjectTemplateRepoConfig>(
templateSource || HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH,
'config.json',
branch
);
} catch (e) {
logger.error(i18n(`${i18nKey}.errors.missingConfigFileTemplateSource`));
process.exit(EXIT_CODES.ERROR);
}

if (!config || !config[PROJECT_COMPONENT_TYPES.PROJECTS]) {
logger.error(i18n(`${i18nKey}.errors.noProjectsInConfig`));
Expand Down
Loading