@hubspot/cli 3.0.9 → 3.0.10-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +6 -0
  2. package/bin/cli.js +3 -2
  3. package/commands/accounts/list.js +18 -26
  4. package/commands/accounts/rename.js +13 -24
  5. package/commands/accounts.js +4 -1
  6. package/commands/app/deploy.js +22 -28
  7. package/commands/auth.js +30 -13
  8. package/commands/config/set/allowUsageTracking.js +15 -31
  9. package/commands/config/set/defaultAccount.js +22 -32
  10. package/commands/config/set/defaultMode.js +23 -42
  11. package/commands/config/set/httpTimeout.js +10 -28
  12. package/commands/config/set.js +4 -1
  13. package/commands/config.js +4 -1
  14. package/commands/create/api-sample.js +14 -12
  15. package/commands/create/module.js +19 -6
  16. package/commands/create/project.js +8 -1
  17. package/commands/create/template.js +19 -4
  18. package/commands/create.js +23 -8
  19. package/commands/customObject/create.js +22 -24
  20. package/commands/customObject/schema/create.js +30 -28
  21. package/commands/customObject/schema/delete.js +20 -20
  22. package/commands/customObject/schema/fetch-all.js +17 -24
  23. package/commands/customObject/schema/fetch.js +29 -24
  24. package/commands/customObject/schema/list.js +8 -17
  25. package/commands/customObject/schema/update.js +31 -29
  26. package/commands/customObject/schema.js +4 -1
  27. package/commands/customObject.js +10 -21
  28. package/commands/fetch.js +15 -30
  29. package/commands/filemanager/fetch.js +13 -25
  30. package/commands/filemanager/upload.js +47 -35
  31. package/commands/filemanager.js +4 -1
  32. package/commands/functions/deploy.js +34 -37
  33. package/commands/functions/list.js +9 -24
  34. package/commands/functions/server.js +13 -29
  35. package/commands/functions.js +4 -1
  36. package/commands/hubdb/clear.js +25 -21
  37. package/commands/hubdb/create.js +25 -22
  38. package/commands/hubdb/delete.js +19 -20
  39. package/commands/hubdb/fetch.js +15 -20
  40. package/commands/hubdb.js +4 -1
  41. package/commands/init.js +23 -11
  42. package/commands/lint.js +14 -23
  43. package/commands/list.js +19 -25
  44. package/commands/logs.js +41 -135
  45. package/commands/mv.js +21 -25
  46. package/commands/open.js +7 -5
  47. package/commands/project/create.js +111 -0
  48. package/commands/project/deploy.js +30 -34
  49. package/commands/project/listBuilds.js +160 -0
  50. package/commands/project/logs.js +192 -0
  51. package/commands/project/upload.js +108 -55
  52. package/commands/project.js +7 -8
  53. package/commands/remove.js +12 -20
  54. package/commands/sandbox/create.js +16 -11
  55. package/commands/secrets/addSecret.js +18 -21
  56. package/commands/secrets/deleteSecret.js +18 -21
  57. package/commands/secrets/listSecrets.js +10 -19
  58. package/commands/secrets/updateSecret.js +18 -21
  59. package/commands/secrets.js +4 -1
  60. package/commands/server.js +13 -5
  61. package/commands/{marketplaceValidate/validateTheme.js → theme/marketplace-validate.js} +26 -24
  62. package/commands/theme.js +5 -3
  63. package/commands/upload.js +66 -45
  64. package/commands/watch.js +33 -55
  65. package/lib/__tests__/serverlessLogs.js +8 -9
  66. package/lib/commonOpts.js +14 -11
  67. package/lib/enums/exitCodes.js +14 -0
  68. package/lib/projects.js +246 -235
  69. package/lib/prompts/projects.js +8 -5
  70. package/lib/prompts/sandboxes.js +5 -2
  71. package/lib/prompts.js +26 -27
  72. package/lib/serverlessLogs.js +11 -12
  73. package/lib/ui.js +48 -0
  74. package/lib/validation.js +2 -1
  75. package/package.json +9 -7
  76. package/commands/project/init.js +0 -108
@@ -1,8 +1,3 @@
1
- const {
2
- loadConfig,
3
- validateConfig,
4
- checkAndWarnGitInclusion,
5
- } = require('@hubspot/cli-lib');
6
1
  const { logger } = require('@hubspot/cli-lib/logger');
7
2
  const {
8
3
  logServerlessFunctionApiErrorInstance,
@@ -10,42 +5,44 @@ const {
10
5
  } = require('@hubspot/cli-lib/errorHandlers');
11
6
  const { deleteSecret } = require('@hubspot/cli-lib/api/secrets');
12
7
 
13
- const { validateAccount } = require('../../lib/validation');
8
+ const { loadAndValidateOptions } = require('../../lib/validation');
14
9
  const { trackCommandUsage } = require('../../lib/usageTracking');
15
10
 
16
11
  const {
17
12
  addConfigOptions,
18
13
  addAccountOptions,
19
14
  addUseEnvironmentOptions,
20
- setLogLevel,
21
15
  getAccountId,
22
16
  } = require('../../lib/commonOpts');
23
- const { logDebugInfo } = require('../../lib/debugInfo');
17
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
18
+
19
+ const i18nKey = 'cli.commands.secrets.subcommands.delete';
24
20
 
25
21
  exports.command = 'delete <name>';
26
- exports.describe = 'Delete a HubSpot secret';
22
+ exports.describe = i18n(`${i18nKey}.describe`);
27
23
 
28
24
  exports.handler = async options => {
29
- const { config: configPath, name: secretName } = options;
25
+ const { name: secretName } = options;
30
26
 
31
- setLogLevel(options);
32
- logDebugInfo(options);
33
- loadConfig(configPath, options);
34
- checkAndWarnGitInclusion();
27
+ await loadAndValidateOptions(options);
35
28
 
36
- if (!(validateConfig() && (await validateAccount(options)))) {
37
- process.exit(1);
38
- }
39
29
  const accountId = getAccountId(options);
40
30
  trackCommandUsage('secrets-delete', {}, accountId);
41
31
 
42
32
  try {
43
33
  await deleteSecret(accountId, secretName);
44
- logger.log(
45
- `The secret "${secretName}" was deleted from the HubSpot account: ${accountId}`
34
+ logger.success(
35
+ i18n(`${i18nKey}.success.delete`, {
36
+ accountId,
37
+ secretName,
38
+ })
46
39
  );
47
40
  } catch (e) {
48
- logger.error(`The secret "${secretName}" was not deleted`);
41
+ logger.error(
42
+ i18n(`${i18nKey}.errors.delete`, {
43
+ secretName,
44
+ })
45
+ );
49
46
  await logServerlessFunctionApiErrorInstance(
50
47
  accountId,
51
48
  e,
@@ -62,7 +59,7 @@ exports.builder = yargs => {
62
59
  addAccountOptions(yargs, true);
63
60
  addUseEnvironmentOptions(yargs, true);
64
61
  yargs.positional('name', {
65
- describe: 'Name of the secret',
62
+ describe: i18n(`${i18nKey}.positionals.name.describe`),
66
63
  type: 'string',
67
64
  });
68
65
  return yargs;
@@ -1,8 +1,3 @@
1
- const {
2
- loadConfig,
3
- validateConfig,
4
- checkAndWarnGitInclusion,
5
- } = require('@hubspot/cli-lib');
6
1
  const { logger } = require('@hubspot/cli-lib/logger');
7
2
  const {
8
3
  logServerlessFunctionApiErrorInstance,
@@ -10,42 +5,38 @@ const {
10
5
  } = require('@hubspot/cli-lib/errorHandlers');
11
6
  const { fetchSecrets } = require('@hubspot/cli-lib/api/secrets');
12
7
 
13
- const { validateAccount } = require('../../lib/validation');
8
+ const { loadAndValidateOptions } = require('../../lib/validation');
14
9
  const { trackCommandUsage } = require('../../lib/usageTracking');
15
10
 
16
11
  const {
17
12
  addConfigOptions,
18
13
  addAccountOptions,
19
14
  addUseEnvironmentOptions,
20
- setLogLevel,
21
15
  getAccountId,
22
16
  } = require('../../lib/commonOpts');
23
- const { logDebugInfo } = require('../../lib/debugInfo');
17
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
18
+
19
+ const i18nKey = 'cli.commands.secrets.subcommands.list';
24
20
 
25
21
  exports.command = 'list';
26
- exports.describe = 'List all HubSpot secrets';
22
+ exports.describe = i18n(`${i18nKey}.describe`);
27
23
 
28
24
  exports.handler = async options => {
29
- setLogLevel(options);
30
- logDebugInfo(options);
31
- const { config: configPath } = options;
32
- loadConfig(configPath, options);
33
- checkAndWarnGitInclusion();
25
+ await loadAndValidateOptions(options);
34
26
 
35
- if (!(validateConfig() && (await validateAccount(options)))) {
36
- process.exit(1);
37
- }
38
27
  const accountId = getAccountId(options);
39
28
  trackCommandUsage('secrets-list', {}, accountId);
40
29
 
41
30
  try {
42
31
  const { results } = await fetchSecrets(accountId);
43
- const groupLabel = `Secrets for account ${accountId}:`;
32
+ const groupLabel = i18n(`${i18nKey}.groupLabel`, {
33
+ accountId,
34
+ });
44
35
  logger.group(groupLabel);
45
36
  results.forEach(secret => logger.log(secret));
46
37
  logger.groupEnd(groupLabel);
47
38
  } catch (e) {
48
- logger.error('The secrets could not be listed');
39
+ logger.error(i18n(`${i18nKey}.errors.list`));
49
40
  await logServerlessFunctionApiErrorInstance(
50
41
  accountId,
51
42
  e,
@@ -1,8 +1,3 @@
1
- const {
2
- loadConfig,
3
- validateConfig,
4
- checkAndWarnGitInclusion,
5
- } = require('@hubspot/cli-lib');
6
1
  const { logger } = require('@hubspot/cli-lib/logger');
7
2
  const {
8
3
  logServerlessFunctionApiErrorInstance,
@@ -10,33 +5,28 @@ const {
10
5
  } = require('@hubspot/cli-lib/errorHandlers');
11
6
  const { updateSecret } = require('@hubspot/cli-lib/api/secrets');
12
7
 
13
- const { validateAccount } = require('../../lib/validation');
8
+ const { loadAndValidateOptions } = require('../../lib/validation');
14
9
  const { trackCommandUsage } = require('../../lib/usageTracking');
15
10
 
16
11
  const {
17
12
  addConfigOptions,
18
13
  addAccountOptions,
19
14
  addUseEnvironmentOptions,
20
- setLogLevel,
21
15
  getAccountId,
22
16
  } = require('../../lib/commonOpts');
23
- const { logDebugInfo } = require('../../lib/debugInfo');
24
17
  const { secretValuePrompt } = require('../../lib/secretPrompt');
18
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
19
+
20
+ const i18nKey = 'cli.commands.secrets.subcommands.update';
25
21
 
26
22
  exports.command = 'update <name>';
27
- exports.describe = 'Update an existing HubSpot secret';
23
+ exports.describe = i18n(`${i18nKey}.describe`);
28
24
 
29
25
  exports.handler = async options => {
30
- const { name: secretName, config: configPath } = options;
26
+ const { name: secretName } = options;
31
27
 
32
- setLogLevel(options);
33
- logDebugInfo(options);
34
- loadConfig(configPath, options);
35
- checkAndWarnGitInclusion();
28
+ await loadAndValidateOptions(options);
36
29
 
37
- if (!(validateConfig() && (await validateAccount(options)))) {
38
- process.exit(1);
39
- }
40
30
  const accountId = getAccountId(options);
41
31
  trackCommandUsage('secrets-update', {}, accountId);
42
32
 
@@ -44,11 +34,18 @@ exports.handler = async options => {
44
34
  const { secretValue } = await secretValuePrompt();
45
35
 
46
36
  await updateSecret(accountId, secretName, secretValue);
47
- logger.log(
48
- `The secret "${secretName}" was updated in the HubSpot account: ${accountId}`
37
+ logger.success(
38
+ i18n(`${i18nKey}.success.update`, {
39
+ accountId,
40
+ secretName,
41
+ })
49
42
  );
50
43
  } catch (e) {
51
- logger.error(`The secret "${secretName}" was not updated`);
44
+ logger.error(
45
+ i18n(`${i18nKey}.errors.update`, {
46
+ secretName,
47
+ })
48
+ );
52
49
  await logServerlessFunctionApiErrorInstance(
53
50
  accountId,
54
51
  e,
@@ -65,7 +62,7 @@ exports.builder = yargs => {
65
62
  addAccountOptions(yargs, true);
66
63
  addUseEnvironmentOptions(yargs, true);
67
64
  yargs.positional('name', {
68
- describe: 'Name of the secret to be updated',
65
+ describe: i18n(`${i18nKey}.positionals.name.describe`),
69
66
  type: 'string',
70
67
  });
71
68
  return yargs;
@@ -4,9 +4,12 @@ const addSecretCommand = require('./secrets/addSecret');
4
4
  const listSecretsCommand = require('./secrets/listSecrets');
5
5
  const deleteSecretCommand = require('./secrets/deleteSecret');
6
6
  const updateSecretCommand = require('./secrets/updateSecret');
7
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
8
+
9
+ const i18nKey = 'cli.commands.secrets';
7
10
 
8
11
  exports.command = 'secrets';
9
- exports.describe = 'Manage HubSpot secrets';
12
+ exports.describe = i18n(`${i18nKey}.describe`);
10
13
 
11
14
  exports.builder = yargs => {
12
15
  addConfigOptions(yargs, true);
@@ -21,11 +21,15 @@ const {
21
21
  getAccountId,
22
22
  } = require('../lib/commonOpts');
23
23
  const { logDebugInfo } = require('../lib/debugInfo');
24
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
25
+
26
+ const i18nKey = 'cli.commands.server';
27
+ const { EXIT_CODES } = require('../lib/enums/exitCodes');
24
28
 
25
29
  function configureServerCommand(program) {
26
30
  program
27
31
  .version(version)
28
- .description('Run the CMS HubL server')
32
+ .description(i18n(`${i18nKey}.description`))
29
33
  .option('--serverConfig <serverConfig>')
30
34
  .option('--contextDir [contextDir]')
31
35
  .arguments('<src>')
@@ -37,13 +41,13 @@ function configureServerCommand(program) {
37
41
  checkAndWarnGitInclusion();
38
42
 
39
43
  if (!validateConfig()) {
40
- process.exit(1);
44
+ process.exit(EXIT_CODES.ERROR);
41
45
  }
42
46
 
43
47
  const accountId = getAccountId(options);
44
48
 
45
49
  // TODO: add flag to bypass
46
- logger.log(`Fetching account data for ${accountId} to update context`);
50
+ logger.log(i18n(`${i18nKey}.fetching`, { accountId }));
47
51
  await updateServerContext(accountId, path.join(getCwd(), contextDir));
48
52
 
49
53
  const cwd = getCwd();
@@ -55,8 +59,12 @@ function configureServerCommand(program) {
55
59
  hubspot/local-cms-server
56
60
  `;
57
61
 
58
- logger.log('Starting HubSpot CMS HubL server');
59
- logger.debug(`Running: ${cmd}`);
62
+ logger.log(i18n(`${i18nKey}.startingServer`));
63
+ logger.debug(
64
+ i18n(`${i18nKey}.runningServer`, {
65
+ cmd,
66
+ })
67
+ );
60
68
  shell.exec(cmd, { async: true });
61
69
  });
62
70
 
@@ -1,11 +1,6 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
- const {
5
- loadConfig,
6
- validateConfig,
7
- checkAndWarnGitInclusion,
8
- } = require('@hubspot/cli-lib');
9
4
  const { getCwd } = require('@hubspot/cli-lib/path');
10
5
  const { logger } = require('@hubspot/cli-lib/logger');
11
6
  const { walk } = require('@hubspot/cli-lib');
@@ -14,11 +9,9 @@ const {
14
9
  addConfigOptions,
15
10
  addAccountOptions,
16
11
  addUseEnvironmentOptions,
17
- setLogLevel,
18
12
  getAccountId,
19
13
  } = require('../../lib/commonOpts');
20
- const { logDebugInfo } = require('../../lib/debugInfo');
21
- const { validateAccount } = require('../../lib/validation');
14
+ const { loadAndValidateOptions } = require('../../lib/validation');
22
15
  const { trackCommandUsage } = require('../../lib/usageTracking');
23
16
  const {
24
17
  logValidatorResults,
@@ -26,20 +19,18 @@ const {
26
19
  const { applyValidators } = require('../../lib/validators/applyValidators');
27
20
  const MARKETPLACE_VALIDATORS = require('../../lib/validators');
28
21
  const { VALIDATION_RESULT } = require('../../lib/validators/constants');
22
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
23
+
24
+ const i18nKey = 'cli.commands.theme.subcommands.marketplaceValidate';
25
+ const { EXIT_CODES } = require('../../lib/enums/exitCodes');
29
26
 
30
27
  exports.command = 'marketplace-validate <src>';
31
- exports.describe = 'Validate a theme for the marketplace';
28
+ exports.describe = i18n(`${i18nKey}.describe`);
32
29
 
33
30
  exports.handler = async options => {
34
- const { src, config: configPath } = options;
35
- setLogLevel(options);
36
- logDebugInfo(options);
37
- loadConfig(configPath, options);
38
- checkAndWarnGitInclusion();
31
+ const { src } = options;
39
32
 
40
- if (!(validateConfig() && (await validateAccount(options)))) {
41
- process.exit(1);
42
- }
33
+ await loadAndValidateOptions(options);
43
34
 
44
35
  const accountId = getAccountId(options);
45
36
  const absoluteSrcPath = path.resolve(getCwd(), src);
@@ -47,16 +38,28 @@ exports.handler = async options => {
47
38
  try {
48
39
  stats = fs.statSync(absoluteSrcPath);
49
40
  if (!stats.isDirectory()) {
50
- logger.error(`The path "${src}" is not a path to a folder`);
41
+ logger.error(
42
+ i18n(`${i18nKey}.errors.invalidPath`, {
43
+ path: src,
44
+ })
45
+ );
51
46
  return;
52
47
  }
53
48
  } catch (e) {
54
- logger.error(`The path "${src}" is not a path to a folder`);
49
+ logger.error(
50
+ i18n(`${i18nKey}.errors.invalidPath`, {
51
+ path: src,
52
+ })
53
+ );
55
54
  return;
56
55
  }
57
56
 
58
57
  if (!options.json) {
59
- logger.log(`Validating theme "${src}" \n`);
58
+ logger.log(
59
+ i18n(`${i18nKey}.logs.validatingTheme`, {
60
+ path: src,
61
+ })
62
+ );
60
63
  }
61
64
  trackCommandUsage('validate', {}, accountId);
62
65
 
@@ -75,7 +78,7 @@ exports.handler = async options => {
75
78
  .flat()
76
79
  .some(result => result.result === VALIDATION_RESULT.FATAL)
77
80
  ) {
78
- process.exit(1);
81
+ process.exit(EXIT_CODES.WARNING);
79
82
  }
80
83
  });
81
84
  };
@@ -87,13 +90,12 @@ exports.builder = yargs => {
87
90
 
88
91
  yargs.options({
89
92
  json: {
90
- describe: 'Output raw json data',
93
+ describe: i18n(`${i18nKey}.options.json.describe`),
91
94
  type: 'boolean',
92
95
  },
93
96
  });
94
97
  yargs.positional('src', {
95
- describe:
96
- 'Path to the local theme, relative to your current working directory.',
98
+ describe: i18n(`${i18nKey}.positionals.src.describe`),
97
99
  type: 'string',
98
100
  });
99
101
  return yargs;
package/commands/theme.js CHANGED
@@ -1,9 +1,11 @@
1
- const marketplaceValidate = require('./marketplaceValidate/validateTheme');
1
+ const marketplaceValidate = require('./theme/marketplace-validate');
2
2
  const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
3
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
4
+
5
+ const i18nKey = 'cli.commands.theme';
3
6
 
4
7
  exports.command = 'theme';
5
- exports.describe =
6
- 'Commands for working with themes, including marketplace validation with the marketplace-validate subcommand';
8
+ exports.describe = i18n(`${i18nKey}.describe`);
7
9
 
8
10
  exports.builder = yargs => {
9
11
  addConfigOptions(yargs, true);
@@ -1,12 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
- const {
5
- loadConfig,
6
- uploadFolder,
7
- validateConfig,
8
- checkAndWarnGitInclusion,
9
- } = require('@hubspot/cli-lib');
4
+ const { uploadFolder } = require('@hubspot/cli-lib');
10
5
  const { getFileMapperQueryValues } = require('@hubspot/cli-lib/fileMapper');
11
6
  const { upload } = require('@hubspot/cli-lib/api/fileMapper');
12
7
  const {
@@ -28,45 +23,39 @@ const {
28
23
  addAccountOptions,
29
24
  addModeOptions,
30
25
  addUseEnvironmentOptions,
31
- setLogLevel,
32
26
  getAccountId,
33
27
  getMode,
34
28
  } = require('../lib/commonOpts');
35
- const { logDebugInfo } = require('../lib/debugInfo');
36
- const { validateAccount, validateMode } = require('../lib/validation');
29
+ const { validateMode, loadAndValidateOptions } = require('../lib/validation');
37
30
  const { trackCommandUsage } = require('../lib/usageTracking');
38
31
  const { getThemePreviewUrl } = require('@hubspot/cli-lib/lib/files');
32
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
33
+
34
+ const i18nKey = 'cli.commands.upload';
35
+ const { EXIT_CODES } = require('../lib/enums/exitCodes');
39
36
 
40
37
  exports.command = 'upload <src> <dest>';
41
- exports.describe =
42
- 'Upload a folder or file from your computer to the HubSpot CMS';
38
+ exports.describe = i18n(`${i18nKey}.describe`);
43
39
 
44
40
  const logThemePreview = (filePath, accountId) => {
45
41
  const previewUrl = getThemePreviewUrl(filePath, accountId);
46
42
  // Only log if we are actually in a theme
47
43
  if (previewUrl) {
48
- logger.log(`
49
- To preview this theme, visit:
50
- ${previewUrl}
51
- `);
44
+ logger.log(
45
+ i18n(`${i18nKey}.previewUrl`, {
46
+ previewUrl,
47
+ })
48
+ );
52
49
  }
53
50
  };
54
51
 
55
52
  exports.handler = async options => {
56
- const { src, dest, config: configPath } = options;
57
- setLogLevel(options);
58
- logDebugInfo(options);
59
- loadConfig(configPath, options);
60
- checkAndWarnGitInclusion();
53
+ const { src, dest } = options;
61
54
 
62
- if (
63
- !(
64
- validateConfig() &&
65
- (await validateAccount(options)) &&
66
- validateMode(options)
67
- )
68
- ) {
69
- process.exit(1);
55
+ await loadAndValidateOptions(options);
56
+
57
+ if (!validateMode(options)) {
58
+ process.exit(EXIT_CODES.ERROR);
70
59
  }
71
60
 
72
61
  const accountId = getAccountId(options);
@@ -76,16 +65,24 @@ exports.handler = async options => {
76
65
  try {
77
66
  stats = fs.statSync(absoluteSrcPath);
78
67
  if (!stats.isFile() && !stats.isDirectory()) {
79
- logger.error(`The path "${src}" is not a path to a file or folder`);
68
+ logger.error(
69
+ i18n(`${i18nKey}.errors.invalidPath`, {
70
+ path: src,
71
+ })
72
+ );
80
73
  return;
81
74
  }
82
75
  } catch (e) {
83
- logger.error(`The path "${src}" is not a path to a file or folder`);
76
+ logger.error(
77
+ i18n(`${i18nKey}.errors.invalidPath`, {
78
+ path: src,
79
+ })
80
+ );
84
81
  return;
85
82
  }
86
83
 
87
84
  if (!dest) {
88
- logger.error('A destination path needs to be passed');
85
+ logger.error(i18n(`${i18nKey}.errors.destinationRequired`));
89
86
  return;
90
87
  }
91
88
  const normalizedDest = convertToUnixPath(dest);
@@ -101,16 +98,24 @@ exports.handler = async options => {
101
98
 
102
99
  if (srcDestIssues.length) {
103
100
  srcDestIssues.forEach(({ message }) => logger.error(message));
104
- process.exit(1);
101
+ process.exit(EXIT_CODES.ERROR);
105
102
  }
106
103
  if (stats.isFile()) {
107
104
  if (!isAllowedExtension(src)) {
108
- logger.error(`The file "${src}" does not have a valid extension`);
105
+ logger.error(
106
+ i18n(`${i18nKey}.errors.invalidPath`, {
107
+ path: src,
108
+ })
109
+ );
109
110
  return;
110
111
  }
111
112
 
112
113
  if (shouldIgnoreFile(absoluteSrcPath)) {
113
- logger.error(`The file "${src}" is being ignored via an .hsignore rule`);
114
+ logger.error(
115
+ i18n(`${i18nKey}.errors.fileIgnored`, {
116
+ path: src,
117
+ })
118
+ );
114
119
  return;
115
120
  }
116
121
 
@@ -122,15 +127,21 @@ exports.handler = async options => {
122
127
  )
123
128
  .then(() => {
124
129
  logger.success(
125
- 'Uploaded file from "%s" to "%s" in the Design Manager of account %s',
126
- src,
127
- normalizedDest,
128
- accountId
130
+ i18n(`${i18nKey}.success.fileUploaded`, {
131
+ accountId,
132
+ dest: normalizedDest,
133
+ src,
134
+ })
129
135
  );
130
136
  logThemePreview(src, accountId);
131
137
  })
132
138
  .catch(error => {
133
- logger.error('Uploading file "%s" to "%s" failed', src, normalizedDest);
139
+ logger.error(
140
+ i18n(`${i18nKey}.errors.uploadFailed`, {
141
+ dest: normalizedDest,
142
+ src,
143
+ })
144
+ );
134
145
  logApiUploadErrorInstance(
135
146
  error,
136
147
  new ApiErrorContext({
@@ -142,19 +153,30 @@ exports.handler = async options => {
142
153
  });
143
154
  } else {
144
155
  logger.log(
145
- `Uploading files from "${src}" to "${dest}" in the Design Manager of account ${accountId}`
156
+ i18n(`${i18nKey}.uploading`, {
157
+ accountId,
158
+ dest,
159
+ src,
160
+ })
146
161
  );
147
162
  uploadFolder(accountId, absoluteSrcPath, dest, {
148
163
  mode,
149
164
  })
150
165
  .then(() => {
151
166
  logger.success(
152
- `Uploading files to "${dest}" in the Design Manager is complete`
167
+ i18n(`${i18nKey}.success.uploadComplete`, {
168
+ dest,
169
+ })
153
170
  );
154
171
  logThemePreview(src, accountId);
155
172
  })
156
173
  .catch(error => {
157
- logger.error('Uploading failed');
174
+ logger.error(
175
+ i18n(`${i18nKey}.errors.uploadFailed`, {
176
+ dest,
177
+ src,
178
+ })
179
+ );
158
180
  logErrorInstance(error, {
159
181
  accountId,
160
182
  });
@@ -169,12 +191,11 @@ exports.builder = yargs => {
169
191
  addUseEnvironmentOptions(yargs, true);
170
192
 
171
193
  yargs.positional('src', {
172
- describe:
173
- 'Path to the local file, relative to your current working directory.',
194
+ describe: i18n(`${i18nKey}.positionals.src.describe`),
174
195
  type: 'string',
175
196
  });
176
197
  yargs.positional('dest', {
177
- describe: 'Path in HubSpot Design Tools, can be a net new path.',
198
+ describe: i18n(`${i18nKey}.positionals.dest.describe`),
178
199
  type: 'string',
179
200
  });
180
201
  return yargs;