diff --git a/lang/en.lyaml b/lang/en.lyaml index fd4f17732..e036e8990 100644 --- a/lang/en.lyaml +++ b/lang/en.lyaml @@ -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:" diff --git a/lib/prompts/createProjectPrompt.ts b/lib/prompts/createProjectPrompt.ts index dfae0cad5..e85eec2c3 100644 --- a/lib/prompts/createProjectPrompt.ts +++ b/lib/prompts/createProjectPrompt.ts @@ -50,11 +50,17 @@ async function createTemplateOptions( ? DEFAULT_PROJECT_TEMPLATE_BRANCH : githubRef; - const config = await fetchFileFromRepository( - templateSource || HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, - 'config.json', - branch - ); + let config: ProjectTemplateRepoConfig; + try { + config = await fetchFileFromRepository( + 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`));