From 6661e303a03172b7c42df7bf0717df120101959e Mon Sep 17 00:00:00 2001 From: Camden Phalen Date: Mon, 4 Dec 2023 11:43:34 -0500 Subject: [PATCH] Clean up things, use i18n in buildLogCallbacks --- packages/cli/commands/init.js | 11 +++++++++-- packages/cli/commands/project/download.js | 4 ++-- packages/cli/lang/en.lyaml | 3 +++ packages/cli/lib/logCallbacks.js | 3 ++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/cli/commands/init.js b/packages/cli/commands/init.js index a857562b7..199a10185 100644 --- a/packages/cli/commands/init.js +++ b/packages/cli/commands/init.js @@ -11,7 +11,10 @@ const { handleExit } = require('../lib/process'); const { checkAndAddConfigToGitignore, } = require('@hubspot/local-dev-lib/gitignore'); -const { logErrorInstance } = require('../lib/errorHandlers/standardErrors'); +const { + logErrorInstance, + debugErrorAndContext, +} = require('../lib/errorHandlers/standardErrors'); const { DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME, PERSONAL_ACCESS_KEY_AUTH_METHOD, @@ -119,7 +122,11 @@ exports.handler = async options => { ); const configPath = getConfigPath(); - checkAndAddConfigToGitignore(configPath); + try { + checkAndAddConfigToGitignore(configPath); + } catch (e) { + debugErrorAndContext(e); + } logger.log(''); logger.success( diff --git a/packages/cli/commands/project/download.js b/packages/cli/commands/project/download.js index 6216c341f..36a5d8b12 100644 --- a/packages/cli/commands/project/download.js +++ b/packages/cli/commands/project/download.js @@ -30,8 +30,8 @@ const i18nKey = 'cli.commands.project.subcommands.download'; const { EXIT_CODES } = require('../../lib/enums/exitCodes'); const archiveLogCallbacks = buildLogCallbacks({ - init: 'Extracting project source...', - copy: 'Copying project source...', + init: `${i18nKey}.archiveLogCallbacks.init`, + copy: `${i18nKey}.archiveLogCallbacks.copy`, }); exports.command = 'download [--project]'; diff --git a/packages/cli/lang/en.lyaml b/packages/cli/lang/en.lyaml index 0501affd0..c603cb476 100644 --- a/packages/cli/lang/en.lyaml +++ b/packages/cli/lang/en.lyaml @@ -631,6 +631,9 @@ en: describe: "The name of the project to download" dest: describe: "Destination folder for the project" + archiveLogCallbacks: + init: "Extracting project source..." + copy: "Copying project source..." open: describe: "Open the specified project's details page in the browser" options: diff --git a/packages/cli/lib/logCallbacks.js b/packages/cli/lib/logCallbacks.js index 28b376b8d..9608c95cc 100644 --- a/packages/cli/lib/logCallbacks.js +++ b/packages/cli/lib/logCallbacks.js @@ -1,9 +1,10 @@ const { logger } = require('@hubspot/cli-lib/logger'); +const { i18n } = require('./lang'); function buildLogCallbacks(logData) { const callbacksObject = {}; for (let key in logData) { - callbacksObject[key] = () => logger.log(logData[key]); + callbacksObject[key] = () => logger.log(i18n(logData[key])); } return callbacksObject; }