@hubspot/cli 3.0.10-beta.6 → 3.0.10

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 (90) hide show
  1. package/README.md +7 -1
  2. package/bin/cli.js +3 -4
  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/auth.js +33 -16
  7. package/commands/config/set/allowUsageTracking.js +17 -33
  8. package/commands/config/set/defaultAccount.js +24 -34
  9. package/commands/config/set/defaultMode.js +25 -44
  10. package/commands/config/set/httpTimeout.js +10 -28
  11. package/commands/config/set.js +4 -1
  12. package/commands/config.js +4 -1
  13. package/commands/create/api-sample.js +20 -14
  14. package/commands/create/function.js +3 -1
  15. package/commands/create/index.js +0 -1
  16. package/commands/create/module.js +20 -7
  17. package/commands/create/template.js +22 -5
  18. package/commands/create/website-theme.js +12 -1
  19. package/commands/create.js +23 -8
  20. package/commands/customObject/create.js +22 -24
  21. package/commands/customObject/schema/create.js +30 -28
  22. package/commands/customObject/schema/delete.js +20 -20
  23. package/commands/customObject/schema/fetch-all.js +17 -24
  24. package/commands/customObject/schema/fetch.js +29 -24
  25. package/commands/customObject/schema/list.js +8 -17
  26. package/commands/customObject/schema/update.js +31 -29
  27. package/commands/customObject/schema.js +4 -1
  28. package/commands/customObject.js +10 -21
  29. package/commands/fetch.js +15 -30
  30. package/commands/filemanager/fetch.js +13 -25
  31. package/commands/filemanager/upload.js +47 -35
  32. package/commands/filemanager.js +4 -1
  33. package/commands/functions/deploy.js +34 -37
  34. package/commands/functions/list.js +9 -24
  35. package/commands/functions/server.js +13 -29
  36. package/commands/functions.js +4 -1
  37. package/commands/hubdb/clear.js +25 -21
  38. package/commands/hubdb/create.js +25 -22
  39. package/commands/hubdb/delete.js +19 -20
  40. package/commands/hubdb/fetch.js +15 -20
  41. package/commands/hubdb.js +4 -1
  42. package/commands/init.js +25 -13
  43. package/commands/lint.js +14 -23
  44. package/commands/list.js +19 -25
  45. package/commands/logs.js +23 -44
  46. package/commands/mv.js +21 -25
  47. package/commands/open.js +9 -7
  48. package/commands/project/create.js +26 -42
  49. package/commands/project/deploy.js +35 -36
  50. package/commands/project/listBuilds.js +160 -0
  51. package/commands/project/logs.js +87 -79
  52. package/commands/project/upload.js +74 -78
  53. package/commands/project/watch.js +103 -0
  54. package/commands/project.js +5 -6
  55. package/commands/remove.js +12 -20
  56. package/commands/sandbox/create.js +18 -13
  57. package/commands/secrets/addSecret.js +19 -22
  58. package/commands/secrets/deleteSecret.js +18 -21
  59. package/commands/secrets/listSecrets.js +10 -19
  60. package/commands/secrets/updateSecret.js +19 -22
  61. package/commands/secrets.js +4 -1
  62. package/commands/server.js +15 -6
  63. package/commands/{marketplaceValidate/validateTheme.js → theme/marketplace-validate.js} +26 -24
  64. package/commands/theme.js +5 -3
  65. package/commands/upload.js +66 -45
  66. package/commands/watch.js +33 -55
  67. package/lib/commonOpts.js +14 -11
  68. package/lib/enums/exitCodes.js +14 -0
  69. package/lib/links.js +0 -10
  70. package/lib/projects.js +121 -77
  71. package/lib/{createApiSamplePrompt.js → prompts/createApiSamplePrompt.js} +10 -11
  72. package/lib/{createFunctionPrompt.js → prompts/createFunctionPrompt.js} +27 -21
  73. package/lib/{createModulePrompt.js → prompts/createModulePrompt.js} +12 -9
  74. package/lib/prompts/createProjectPrompt.js +68 -0
  75. package/lib/{createTemplatePrompt.js → prompts/createTemplatePrompt.js} +7 -4
  76. package/lib/prompts/folderOverwritePrompt.js +17 -0
  77. package/lib/{prompts.js → prompts/personalAccessKeyPrompt.js} +25 -42
  78. package/lib/prompts/promptUtils.js +10 -0
  79. package/lib/prompts/sandboxesPrompt.js +24 -0
  80. package/lib/prompts/secretPrompt.js +25 -0
  81. package/lib/serverlessLogs.js +4 -3
  82. package/lib/ui.js +48 -0
  83. package/lib/validation.js +4 -3
  84. package/package.json +8 -7
  85. package/commands/app/deploy.js +0 -116
  86. package/commands/app.js +0 -14
  87. package/commands/create/project.js +0 -25
  88. package/lib/prompts/projects.js +0 -40
  89. package/lib/prompts/sandboxes.js +0 -22
  90. package/lib/secretPrompt.js +0 -22
@@ -1,9 +1,4 @@
1
1
  const { deleteFile } = require('@hubspot/cli-lib/api/fileMapper');
2
- const {
3
- loadConfig,
4
- validateConfig,
5
- checkAndWarnGitInclusion,
6
- } = require('@hubspot/cli-lib');
7
2
  const { logger } = require('@hubspot/cli-lib/logger');
8
3
  const {
9
4
  logApiErrorInstance,
@@ -14,26 +9,21 @@ 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');
16
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
17
+
18
+ const i18nKey = 'cli.commands.remove';
23
19
 
24
20
  exports.command = 'remove <path>';
25
- exports.describe = 'Delete a file or folder from HubSpot';
21
+ exports.describe = i18n(`${i18nKey}.describe`);
26
22
 
27
23
  exports.handler = async options => {
28
- setLogLevel(options);
29
- logDebugInfo(options);
30
- const { config: configPath, path: hsPath } = options;
31
- loadConfig(configPath, options);
32
- checkAndWarnGitInclusion();
24
+ const { path: hsPath } = options;
33
25
 
34
- if (!(validateConfig() && (await validateAccount(options)))) {
35
- process.exit(1);
36
- }
26
+ await loadAndValidateOptions(options);
37
27
 
38
28
  const accountId = getAccountId(options);
39
29
 
@@ -41,9 +31,11 @@ exports.handler = async options => {
41
31
 
42
32
  try {
43
33
  await deleteFile(accountId, hsPath);
44
- logger.log(`Deleted "${hsPath}" from account ${accountId}`);
34
+ logger.log(i18n(`${i18nKey}.deleted`, { accountId, path: hsPath }));
45
35
  } catch (error) {
46
- logger.error(`Deleting "${hsPath}" from account ${accountId} failed`);
36
+ logger.error(
37
+ i18n(`${i18nKey}.errors.deleteFailed`, { accountId, path: hsPath })
38
+ );
47
39
  logApiErrorInstance(
48
40
  error,
49
41
  new ApiErrorContext({
@@ -59,7 +51,7 @@ exports.builder = yargs => {
59
51
  addAccountOptions(yargs, true);
60
52
  addUseEnvironmentOptions(yargs, true);
61
53
  yargs.positional('path', {
62
- describe: 'Remote hubspot path',
54
+ describe: i18n(`${i18nKey}.positionals.path.describe`),
63
55
  type: 'string',
64
56
  });
65
57
  return yargs;
@@ -9,13 +9,16 @@ const { logger } = require('@hubspot/cli-lib/logger');
9
9
 
10
10
  const { createSandbox } = require('@hubspot/cli-lib/sandboxes');
11
11
  const { loadAndValidateOptions } = require('../../lib/validation');
12
- const { createSandbox: prompt } = require('../../lib/prompts/sandboxes');
12
+ const { createSandboxPrompt } = require('../../lib/prompts/sandboxesPrompt');
13
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
14
+
15
+ const i18nKey = 'cli.commands.sandbox.subcommands.create';
13
16
 
14
17
  exports.command = 'create [name]';
15
18
  exports.describe = false;
16
19
 
17
20
  exports.handler = async options => {
18
- loadAndValidateOptions(options);
21
+ await loadAndValidateOptions(options);
19
22
 
20
23
  const { name } = options;
21
24
  const accountId = getAccountId(options);
@@ -24,36 +27,38 @@ exports.handler = async options => {
24
27
  trackCommandUsage('sandbox-create', {}, accountId);
25
28
 
26
29
  if (!name) {
27
- namePrompt = await prompt();
30
+ namePrompt = await createSandboxPrompt();
28
31
  }
29
32
 
30
33
  const sandboxName = name || namePrompt.name;
31
34
 
32
- logger.debug(`Creating sandbox '${sandboxName}'`);
35
+ logger.debug(
36
+ i18n(`${i18nKey}.debug.creating`, {
37
+ name: sandboxName,
38
+ })
39
+ );
33
40
 
34
41
  return createSandbox(accountId, sandboxName).then(
35
42
  ({ name, sandboxHubId }) => {
36
43
  logger.success(
37
- `Sandbox '${name}' with portalId '${sandboxHubId}' created successfully.`
38
- );
39
- logger.info(
40
- `Run 'hs auth' to authenticate with the new sandbox account.`
44
+ i18n(`${i18nKey}.describe`, {
45
+ name,
46
+ sandboxHubId,
47
+ })
41
48
  );
49
+ logger.info(i18n(`${i18nKey}.info.auth`));
42
50
  }
43
51
  );
44
52
  };
45
53
 
46
54
  exports.builder = yargs => {
47
55
  yargs.positional('name', {
48
- describe: 'Name to use for created sandbox',
56
+ describe: i18n(`${i18nKey}.positionals.name.describe`),
49
57
  type: 'string',
50
58
  });
51
59
 
52
60
  yargs.example([
53
- [
54
- '$0 sandbox create MySandboxAccount',
55
- 'Create a sandbox account named MySandboxAccount.',
56
- ],
61
+ ['$0 sandbox create MySandboxAccount', i18n(`${i18nKey}.examples.default`)],
57
62
  ]);
58
63
 
59
64
  addConfigOptions(yargs, true);
@@ -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 { addSecret } = 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
- const { secretValuePrompt } = require('../../lib/secretPrompt');
17
+ const { secretValuePrompt } = require('../../lib/prompts/secretPrompt');
18
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
19
+
20
+ const i18nKey = 'cli.commands.secrets.subcommands.add';
25
21
 
26
22
  exports.command = 'add <name>';
27
- exports.describe = 'Add a HubSpot secret';
23
+ exports.describe = i18n(`${i18nKey}.describe`);
28
24
 
29
25
  exports.handler = async options => {
30
- const { config: configPath, name: secretName } = 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-add', {}, accountId);
42
32
 
@@ -44,11 +34,18 @@ exports.handler = async options => {
44
34
  const { secretValue } = await secretValuePrompt();
45
35
 
46
36
  await addSecret(accountId, secretName, secretValue);
47
- logger.log(
48
- `The secret "${secretName}" was added to the HubSpot account: ${accountId}`
37
+ logger.success(
38
+ i18n(`${i18nKey}.success.add`, {
39
+ accountId,
40
+ secretName,
41
+ })
49
42
  );
50
43
  } catch (e) {
51
- logger.error(`The secret "${secretName}" was not added`);
44
+ logger.error(
45
+ i18n(`${i18nKey}.errors.add`, {
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',
65
+ describe: i18n(`${i18nKey}.positionals.name.describe`),
69
66
  type: 'string',
70
67
  });
71
68
  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,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
- const { secretValuePrompt } = require('../../lib/secretPrompt');
17
+ const { secretValuePrompt } = require('../../lib/prompts/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);
@@ -5,6 +5,7 @@ const {
5
5
  loadConfig,
6
6
  validateConfig,
7
7
  checkAndWarnGitInclusion,
8
+ getConfigPath,
8
9
  } = require('@hubspot/cli-lib');
9
10
  const { logger } = require('@hubspot/cli-lib/logger');
10
11
  const { getCwd } = require('@hubspot/cli-lib/path');
@@ -21,11 +22,15 @@ const {
21
22
  getAccountId,
22
23
  } = require('../lib/commonOpts');
23
24
  const { logDebugInfo } = require('../lib/debugInfo');
25
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
26
+
27
+ const i18nKey = 'cli.commands.server';
28
+ const { EXIT_CODES } = require('../lib/enums/exitCodes');
24
29
 
25
30
  function configureServerCommand(program) {
26
31
  program
27
32
  .version(version)
28
- .description('Run the CMS HubL server')
33
+ .description(i18n(`${i18nKey}.description`))
29
34
  .option('--serverConfig <serverConfig>')
30
35
  .option('--contextDir [contextDir]')
31
36
  .arguments('<src>')
@@ -34,16 +39,16 @@ function configureServerCommand(program) {
34
39
  logDebugInfo(options);
35
40
  const { config: configPath, serverConfig, contextDir } = options;
36
41
  loadConfig(configPath, options);
37
- checkAndWarnGitInclusion();
42
+ checkAndWarnGitInclusion(getConfigPath());
38
43
 
39
44
  if (!validateConfig()) {
40
- process.exit(1);
45
+ process.exit(EXIT_CODES.ERROR);
41
46
  }
42
47
 
43
48
  const accountId = getAccountId(options);
44
49
 
45
50
  // TODO: add flag to bypass
46
- logger.log(`Fetching account data for ${accountId} to update context`);
51
+ logger.log(i18n(`${i18nKey}.fetching`, { accountId }));
47
52
  await updateServerContext(accountId, path.join(getCwd(), contextDir));
48
53
 
49
54
  const cwd = getCwd();
@@ -55,8 +60,12 @@ function configureServerCommand(program) {
55
60
  hubspot/local-cms-server
56
61
  `;
57
62
 
58
- logger.log('Starting HubSpot CMS HubL server');
59
- logger.debug(`Running: ${cmd}`);
63
+ logger.log(i18n(`${i18nKey}.startingServer`));
64
+ logger.debug(
65
+ i18n(`${i18nKey}.runningServer`, {
66
+ cmd,
67
+ })
68
+ );
60
69
  shell.exec(cmd, { async: true });
61
70
  });
62
71
 
@@ -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(2);
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);