@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,46 +1,45 @@
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 { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
8
3
  const { deleteTable } = require('@hubspot/cli-lib/api/hubdb');
9
- const { validateAccount } = require('../../lib/validation');
4
+ const { loadAndValidateOptions } = require('../../lib/validation');
10
5
  const { trackCommandUsage } = require('../../lib/usageTracking');
11
6
 
12
7
  const {
13
8
  addConfigOptions,
14
9
  addAccountOptions,
15
10
  addUseEnvironmentOptions,
16
- setLogLevel,
17
11
  getAccountId,
18
12
  } = require('../../lib/commonOpts');
19
- const { logDebugInfo } = require('../../lib/debugInfo');
13
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
14
+
15
+ const i18nKey = 'cli.commands.hubdb.subcommands.delete';
20
16
 
21
17
  exports.command = 'delete <tableId>';
22
- exports.describe = 'delete a HubDB table';
18
+ exports.describe = i18n(`${i18nKey}.describe`);
23
19
 
24
20
  exports.handler = async options => {
25
- const { config: configPath, tableId } = options;
21
+ const { tableId } = options;
26
22
 
27
- setLogLevel(options);
28
- logDebugInfo(options);
29
- loadConfig(configPath, options);
30
- checkAndWarnGitInclusion();
23
+ await loadAndValidateOptions(options);
31
24
 
32
- if (!(validateConfig() && (await validateAccount(options)))) {
33
- process.exit(1);
34
- }
35
25
  const accountId = getAccountId(options);
36
26
 
37
27
  trackCommandUsage('hubdb-delete', {}, accountId);
38
28
 
39
29
  try {
40
30
  await deleteTable(accountId, tableId);
41
- logger.log(`The table ${tableId} was deleted from ${accountId}`);
31
+ logger.success(
32
+ i18n(`${i18nKey}.success.delete`, {
33
+ accountId,
34
+ tableId,
35
+ })
36
+ );
42
37
  } catch (e) {
43
- logger.error(`Deleting the table ${tableId} failed`);
38
+ logger.error(
39
+ i18n(`${i18nKey}.errors.delete`, {
40
+ tableId,
41
+ })
42
+ );
44
43
  logErrorInstance(e);
45
44
  }
46
45
  };
@@ -51,7 +50,7 @@ exports.builder = yargs => {
51
50
  addUseEnvironmentOptions(yargs, true);
52
51
 
53
52
  yargs.positional('tableId', {
54
- describe: 'HubDB Table ID',
53
+ describe: i18n(`${i18nKey}.positionals.tableId.describe`),
55
54
  type: 'string',
56
55
  });
57
56
  };
@@ -1,38 +1,28 @@
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 { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
8
3
  const { downloadHubDbTable } = require('@hubspot/cli-lib/hubdb');
9
4
 
10
- const { validateAccount } = require('../../lib/validation');
5
+ const { loadAndValidateOptions } = require('../../lib/validation');
11
6
  const { trackCommandUsage } = require('../../lib/usageTracking');
12
7
 
13
8
  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');
14
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
15
+
16
+ const i18nKey = 'cli.commands.hubdb.subcommands.fetch';
21
17
 
22
18
  exports.command = 'fetch <tableId> [dest]';
23
- exports.describe = 'fetch a HubDB table';
19
+ exports.describe = i18n(`${i18nKey}.describe`);
24
20
 
25
21
  exports.handler = async options => {
26
- const { config: configPath, tableId, dest } = options;
22
+ const { tableId, dest } = options;
27
23
 
28
- setLogLevel(options);
29
- logDebugInfo(options);
30
- loadConfig(configPath, options);
31
- checkAndWarnGitInclusion();
24
+ await loadAndValidateOptions(options);
32
25
 
33
- if (!(validateConfig() && (await validateAccount(options)))) {
34
- process.exit(1);
35
- }
36
26
  const accountId = getAccountId(options);
37
27
 
38
28
  trackCommandUsage('hubdb-fetch', {}, accountId);
@@ -40,7 +30,12 @@ exports.handler = async options => {
40
30
  try {
41
31
  const { filePath } = await downloadHubDbTable(accountId, tableId, dest);
42
32
 
43
- logger.log(`Downloaded HubDB table ${tableId} to ${filePath}`);
33
+ logger.success(
34
+ i18n(`${i18nKey}.success.fetch`, {
35
+ path: filePath,
36
+ tableId,
37
+ })
38
+ );
44
39
  } catch (e) {
45
40
  logErrorInstance(e);
46
41
  }
@@ -52,12 +47,12 @@ exports.builder = yargs => {
52
47
  addUseEnvironmentOptions(yargs, true);
53
48
 
54
49
  yargs.positional('tableId', {
55
- describe: 'HubDB Table ID',
50
+ describe: i18n(`${i18nKey}.positionals.tableId.describe`),
56
51
  type: 'string',
57
52
  });
58
53
 
59
54
  yargs.positional('dest', {
60
- describe: 'Local destination folder to fetch table to',
55
+ describe: i18n(`${i18nKey}.positionals.dest.describe`),
61
56
  type: 'string',
62
57
  });
63
58
  };
package/commands/hubdb.js CHANGED
@@ -3,9 +3,12 @@ const createCommand = require('./hubdb/create');
3
3
  const fetchCommand = require('./hubdb/fetch');
4
4
  const deleteCommand = require('./hubdb/delete');
5
5
  const clearCommand = require('./hubdb/clear');
6
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
7
+
8
+ const i18nKey = 'cli.commands.hubdb';
6
9
 
7
10
  exports.command = 'hubdb';
8
- exports.describe = 'Manage HubDB tables';
11
+ exports.describe = i18n(`${i18nKey}.describe`);
9
12
 
10
13
  exports.builder = yargs => {
11
14
  addConfigOptions(yargs, true);
package/commands/init.js CHANGED
@@ -18,6 +18,7 @@ const {
18
18
  API_KEY_AUTH_METHOD,
19
19
  ENVIRONMENTS,
20
20
  } = require('@hubspot/cli-lib/lib/constants');
21
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
21
22
  const { logger } = require('@hubspot/cli-lib/logger');
22
23
  const {
23
24
  updateConfigWithPersonalAccessKey,
@@ -25,15 +26,18 @@ const {
25
26
  const { getCwd } = require('@hubspot/cli-lib/path');
26
27
  const { trackCommandUsage, trackAuthAction } = require('../lib/usageTracking');
27
28
  const { setLogLevel, addTestingOptions } = require('../lib/commonOpts');
29
+ const { promptUser } = require('../lib/prompts/promptUtils');
28
30
  const {
29
31
  OAUTH_FLOW,
30
32
  API_KEY_FLOW,
31
33
  ACCOUNT_NAME,
32
34
  personalAccessKeyPrompt,
33
- promptUser,
34
- } = require('../lib/prompts');
35
+ } = require('../lib/prompts/personalAccessKeyPrompt');
35
36
  const { logDebugInfo } = require('../lib/debugInfo');
36
37
  const { authenticateWithOauth } = require('../lib/oauth');
38
+ const { EXIT_CODES } = require('../lib/enums/exitCodes');
39
+
40
+ const i18nKey = 'cli.commands.init';
37
41
 
38
42
  const TRACKING_STATUS = {
39
43
  STARTED: 'started',
@@ -82,7 +86,9 @@ const CONFIG_CREATION_FLOWS = {
82
86
  };
83
87
 
84
88
  exports.command = 'init';
85
- exports.describe = `initialize ${DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME} for a HubSpot account`;
89
+ exports.describe = i18n(`${i18nKey}.describe`, {
90
+ configName: DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
91
+ });
86
92
 
87
93
  exports.handler = async options => {
88
94
  const { auth: authType = PERSONAL_ACCESS_KEY_AUTH_METHOD.value, c } = options;
@@ -95,11 +101,13 @@ exports.handler = async options => {
95
101
  const env = options.qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
96
102
 
97
103
  if (fs.existsSync(configPath)) {
98
- logger.error(`The config file '${configPath}' already exists.`);
99
- logger.info(
100
- 'To update an existing config file, use the "hs auth" command.'
104
+ logger.error(
105
+ i18n(`${i18nKey}.errors.configFileExists`, {
106
+ configPath,
107
+ })
101
108
  );
102
- process.exit(1);
109
+ logger.info(i18n(`${i18nKey}.info.updateConfig`));
110
+ process.exit(EXIT_CODES.ERROR);
103
111
  }
104
112
 
105
113
  trackAuthAction('init', authType, TRACKING_STATUS.STARTED);
@@ -111,12 +119,15 @@ exports.handler = async options => {
111
119
  const configPath = getConfigPath();
112
120
 
113
121
  logger.success(
114
- `The config file "${configPath}" was created using "${authType}" for account ${name ||
115
- accountId}.`
122
+ i18n(`${i18nKey}.success.configFileCreated`, {
123
+ configPath,
124
+ authType,
125
+ account: name || accountId,
126
+ })
116
127
  );
117
128
 
118
129
  trackAuthAction('init', authType, TRACKING_STATUS.COMPLETE, accountId);
119
- process.exit();
130
+ process.exit(EXIT_CODES.SUCCESS);
120
131
  } catch (err) {
121
132
  logErrorInstance(err);
122
133
  trackAuthAction('init', authType, TRACKING_STATUS.ERROR);
@@ -125,8 +136,7 @@ exports.handler = async options => {
125
136
 
126
137
  exports.builder = yargs => {
127
138
  yargs.option('auth', {
128
- describe:
129
- 'specify auth method to use ["personalaccesskey", "oauth2", "apikey"]',
139
+ describe: i18n(`${i18nKey}.options.auth.describe`),
130
140
  type: 'string',
131
141
  choices: [
132
142
  `${PERSONAL_ACCESS_KEY_AUTH_METHOD.value}`,
@@ -134,7 +144,9 @@ exports.builder = yargs => {
134
144
  `${API_KEY_AUTH_METHOD.value}`,
135
145
  ],
136
146
  default: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
137
- defaultDescription: `"${PERSONAL_ACCESS_KEY_AUTH_METHOD.value}": \nAn access token tied to a specific user account. This is the recommended way of authenticating with local development tools.`,
147
+ defaultDescription: i18n(`${i18nKey}.options.auth.defaultDescription`, {
148
+ defaultType: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
149
+ }),
138
150
  });
139
151
 
140
152
  addConfigOptions(yargs, true);
package/commands/lint.js CHANGED
@@ -2,36 +2,21 @@ const {
2
2
  lint,
3
3
  printHublValidationResult,
4
4
  } = require('@hubspot/cli-lib/validate');
5
- const {
6
- loadConfig,
7
- validateConfig,
8
- checkAndWarnGitInclusion,
9
- } = require('@hubspot/cli-lib');
10
5
  const { logger } = require('@hubspot/cli-lib/logger');
11
6
  const { logErrorInstance } = require('@hubspot/cli-lib/errorHandlers');
12
7
 
13
8
  const {
14
9
  addConfigOptions,
15
10
  addAccountOptions,
16
- setLogLevel,
17
11
  getAccountId,
18
12
  } = require('../lib/commonOpts');
19
- const { logDebugInfo } = require('../lib/debugInfo');
20
13
  const { resolveLocalPath } = require('../lib/filesystem');
21
- const { validateAccount } = require('../lib/validation');
22
14
  const { trackCommandUsage } = require('../lib/usageTracking');
15
+ const { loadAndValidateOptions } = require('../lib/validation');
16
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
23
17
 
24
- const loadAndValidateOptions = async options => {
25
- setLogLevel(options);
26
- logDebugInfo(options);
27
- const { config: configPath } = options;
28
- loadConfig(configPath);
29
- checkAndWarnGitInclusion();
30
-
31
- if (!(validateConfig() && (await validateAccount(options)))) {
32
- process.exit(1);
33
- }
34
- };
18
+ const i18nKey = 'cli.commands.lint';
19
+ const { EXIT_CODES } = require('../lib/enums/exitCodes');
35
20
 
36
21
  exports.command = 'lint <path>';
37
22
  // Hiding since this command is still experimental
@@ -44,7 +29,9 @@ exports.handler = async options => {
44
29
 
45
30
  const accountId = getAccountId(options);
46
31
  const localPath = resolveLocalPath(lintPath);
47
- const groupName = `Linting "${localPath}"`;
32
+ const groupName = i18n(`${i18nKey}.groupName`, {
33
+ path: localPath,
34
+ });
48
35
 
49
36
  trackCommandUsage('lint', {}, accountId);
50
37
 
@@ -57,17 +44,21 @@ exports.handler = async options => {
57
44
  } catch (err) {
58
45
  logger.groupEnd(groupName);
59
46
  logErrorInstance(err, { accountId });
60
- process.exit(1);
47
+ process.exit(EXIT_CODES.ERROR);
61
48
  }
62
49
  logger.groupEnd(groupName);
63
- logger.log(`${count} issues found`);
50
+ logger.log(
51
+ i18n(`${i18nKey}.issuesFound`, {
52
+ count,
53
+ })
54
+ );
64
55
  };
65
56
 
66
57
  exports.builder = yargs => {
67
58
  addConfigOptions(yargs, true);
68
59
  addAccountOptions(yargs, true);
69
60
  yargs.positional('path', {
70
- describe: 'Local folder to lint',
61
+ describe: i18n(`${i18nKey}.positionals.path.describe`),
71
62
  type: 'string',
72
63
  });
73
64
  return yargs;
package/commands/list.js CHANGED
@@ -2,19 +2,12 @@ const chalk = require('chalk');
2
2
  const {
3
3
  addAccountOptions,
4
4
  addConfigOptions,
5
- setLogLevel,
6
5
  getAccountId,
7
6
  addUseEnvironmentOptions,
8
7
  } = require('../lib/commonOpts');
9
8
  const { trackCommandUsage } = require('../lib/usageTracking');
10
- const { logDebugInfo } = require('../lib/debugInfo');
11
- const { validateAccount } = require('../lib/validation');
12
9
  const { isPathFolder } = require('../lib/filesystem');
13
- const {
14
- loadConfig,
15
- validateConfig,
16
- checkAndWarnGitInclusion,
17
- } = require('@hubspot/cli-lib');
10
+
18
11
  const { logger } = require('@hubspot/cli-lib/logger');
19
12
  const {
20
13
  logApiErrorInstance,
@@ -27,24 +20,17 @@ const {
27
20
  HUBSPOT_FOLDER,
28
21
  MARKETPLACE_FOLDER,
29
22
  } = require('@hubspot/cli-lib/lib/constants');
23
+ const { loadAndValidateOptions } = require('../lib/validation');
24
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
30
25
 
31
- const loadAndValidateOptions = async options => {
32
- setLogLevel(options);
33
- logDebugInfo(options);
34
- const { config: configPath } = options;
35
- loadConfig(configPath, options);
36
- checkAndWarnGitInclusion();
37
-
38
- if (!(validateConfig() && (await validateAccount(options)))) {
39
- process.exit(1);
40
- }
41
- };
26
+ const i18nKey = 'cli.commands.list';
27
+ const { EXIT_CODES } = require('../lib/enums/exitCodes');
42
28
 
43
29
  exports.command = 'list [path]';
44
- exports.describe = 'list remote contents of a directory';
30
+ exports.describe = i18n(`${i18nKey}.describe`);
45
31
 
46
32
  exports.handler = async options => {
47
- loadAndValidateOptions(options);
33
+ await loadAndValidateOptions(options);
48
34
 
49
35
  const { path } = options;
50
36
  const directoryPath = path || '/';
@@ -53,7 +39,11 @@ exports.handler = async options => {
53
39
 
54
40
  trackCommandUsage('list', {}, accountId);
55
41
 
56
- logger.debug(`Getting contents of ${directoryPath}`);
42
+ logger.debug(
43
+ i18n(`${i18nKey}.gettingPathContents`, {
44
+ path: directoryPath,
45
+ })
46
+ );
57
47
 
58
48
  try {
59
49
  contentsResp = await getDirectoryContentsByPath(accountId, directoryPath);
@@ -63,7 +53,7 @@ exports.handler = async options => {
63
53
  e,
64
54
  new ApiErrorContext({ accountId, directoryPath })
65
55
  );
66
- process.exit();
56
+ process.exit(EXIT_CODES.SUCCESS);
67
57
  }
68
58
 
69
59
  if (contentsResp.children.length) {
@@ -98,13 +88,17 @@ exports.handler = async options => {
98
88
 
99
89
  logger.log(folderContentsOutput);
100
90
  } else {
101
- logger.info(`No files found in ${directoryPath}`);
91
+ logger.info(
92
+ i18n(`${i18nKey}.noFilesFoundInPath`, {
93
+ path: directoryPath,
94
+ })
95
+ );
102
96
  }
103
97
  };
104
98
 
105
99
  exports.builder = yargs => {
106
100
  yargs.positional('path', {
107
- describe: 'Remote directory to list contents',
101
+ describe: i18n(`${i18nKey}.positionals.path.describe`),
108
102
  type: 'string',
109
103
  });
110
104
  yargs.example([['$0 list'], ['$0 list /'], ['$0 list serverless']]);
package/commands/logs.js CHANGED
@@ -2,42 +2,29 @@ const Spinnies = require('spinnies');
2
2
  const {
3
3
  addAccountOptions,
4
4
  addConfigOptions,
5
- setLogLevel,
6
5
  getAccountId,
7
6
  addUseEnvironmentOptions,
8
7
  } = require('../lib/commonOpts');
9
8
  const { trackCommandUsage } = require('../lib/usageTracking');
10
- const { logDebugInfo } = require('../lib/debugInfo');
11
- const {
12
- loadConfig,
13
- validateConfig,
14
- checkAndWarnGitInclusion,
15
- } = require('@hubspot/cli-lib');
16
9
  const { logger } = require('@hubspot/cli-lib/logger');
17
10
  const { outputLogs } = require('@hubspot/cli-lib/lib/logs');
18
11
  const {
19
12
  getFunctionLogs,
20
13
  getLatestFunctionLog,
21
14
  } = require('@hubspot/cli-lib/api/results');
22
- const { validateAccount } = require('../lib/validation');
23
15
  const { tailLogs } = require('../lib/serverlessLogs');
16
+ const { loadAndValidateOptions } = require('../lib/validation');
17
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
24
18
 
25
- const loadAndValidateOptions = async options => {
26
- setLogLevel(options);
27
- logDebugInfo(options);
28
- const { config: configPath } = options;
29
- loadConfig(configPath, options);
30
- checkAndWarnGitInclusion();
31
-
32
- if (!(validateConfig() && (await validateAccount(options)))) {
33
- process.exit(1);
34
- }
35
- };
19
+ const i18nKey = 'cli.commands.logs';
36
20
 
37
21
  const handleLogsError = (e, accountId, functionPath) => {
38
22
  if (e.statusCode === 404) {
39
23
  logger.error(
40
- `No logs were found for the function path '${functionPath}' in account ${accountId}.`
24
+ i18n(`${i18nKey}.errors.noLogsFound`, {
25
+ accountId,
26
+ functionPath,
27
+ })
41
28
  );
42
29
  }
43
30
  };
@@ -46,9 +33,10 @@ const endpointLog = async (accountId, options) => {
46
33
  const { latest, follow, compact, endpoint: functionPath } = options;
47
34
 
48
35
  logger.debug(
49
- `Getting ${
50
- latest ? 'latest ' : ''
51
- }logs for function with path: ${functionPath}`
36
+ i18n(`${i18nKey}.gettingLogs`, {
37
+ latest,
38
+ functionPath,
39
+ })
52
40
  );
53
41
 
54
42
  let logsResp;
@@ -57,13 +45,13 @@ const endpointLog = async (accountId, options) => {
57
45
  const spinnies = new Spinnies();
58
46
 
59
47
  spinnies.add('tailLogs', {
60
- text: `Waiting for log entries for '${functionPath}' on account '${accountId}'.\n`,
48
+ text: i18n(`${i18nKey}.tailLogs`),
61
49
  });
62
50
  const tailCall = after =>
63
51
  getFunctionLogs(accountId, functionPath, { after });
64
52
  const fetchLatest = () => {
65
53
  try {
66
- getLatestFunctionLog(accountId, functionPath);
54
+ return getLatestFunctionLog(accountId, functionPath);
67
55
  } catch (e) {
68
56
  handleLogsError(e, accountId, functionPath);
69
57
  }
@@ -96,10 +84,10 @@ const endpointLog = async (accountId, options) => {
96
84
  };
97
85
 
98
86
  exports.command = 'logs [endpoint]';
99
- exports.describe = 'get logs for a function';
87
+ exports.describe = i18n(`${i18nKey}.describe`);
100
88
 
101
89
  exports.handler = async options => {
102
- loadAndValidateOptions(options);
90
+ await loadAndValidateOptions(options);
103
91
 
104
92
  const { latest } = options;
105
93
 
@@ -112,28 +100,28 @@ exports.handler = async options => {
112
100
 
113
101
  exports.builder = yargs => {
114
102
  yargs.positional('endpoint', {
115
- describe: 'Serverless function endpoint',
103
+ describe: i18n(`${i18nKey}.positionals.endpoint.describe`),
116
104
  type: 'string',
117
105
  });
118
106
  yargs
119
107
  .options({
120
108
  latest: {
121
109
  alias: 'l',
122
- describe: 'retrieve most recent log only',
110
+ describe: i18n(`${i18nKey}.options.latest.describe`),
123
111
  type: 'boolean',
124
112
  },
125
113
  compact: {
126
- describe: 'output compact logs',
114
+ describe: i18n(`${i18nKey}.options.compact.describe`),
127
115
  type: 'boolean',
128
116
  },
129
117
  follow: {
130
118
  alias: ['t', 'tail', 'f'],
131
- describe: 'follow logs',
119
+ describe: i18n(`${i18nKey}.options.follow.describe`),
132
120
  type: 'boolean',
133
121
  },
134
122
  limit: {
135
123
  alias: ['limit', 'n', 'max-count'],
136
- describe: 'limit the number of logs to output',
124
+ describe: i18n(`${i18nKey}.options.limit.describe`),
137
125
  type: 'number',
138
126
  },
139
127
  })
@@ -141,18 +129,9 @@ exports.builder = yargs => {
141
129
  .conflicts('functionName', 'endpoint');
142
130
 
143
131
  yargs.example([
144
- [
145
- '$0 logs my-endpoint',
146
- 'Get 5 most recent logs for function residing at /_hcms/api/my-endpoint',
147
- ],
148
- [
149
- '$0 logs my-endpoint --limit=10',
150
- 'Get 10 most recent logs for function residing at /_hcms/api/my-endpoint',
151
- ],
152
- [
153
- '$0 logs my-endpoint --follow',
154
- 'Poll for and output logs for function residing at /_hcms/api/my-endpoint immediately upon new execution',
155
- ],
132
+ ['$0 logs my-endpoint', i18n(`${i18nKey}.examples.default`)],
133
+ ['$0 logs my-endpoint --limit=10', i18n(`${i18nKey}.examples.limit`)],
134
+ ['$0 logs my-endpoint --follow', i18n(`${i18nKey}.examples.follow`)],
156
135
  ]);
157
136
 
158
137
  addConfigOptions(yargs, true);
package/commands/mv.js CHANGED
@@ -1,9 +1,4 @@
1
1
  const { moveFile } = 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,25 +9,14 @@ 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');
22
14
  const { trackCommandUsage } = require('../lib/usageTracking');
23
15
  const { isPathFolder } = require('../lib/filesystem');
16
+ const { loadAndValidateOptions } = require('../lib/validation');
17
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
24
18
 
25
- const loadAndValidateOptions = async options => {
26
- setLogLevel(options);
27
- logDebugInfo(options);
28
- const { config: configPath } = options;
29
- loadConfig(configPath, options);
30
- checkAndWarnGitInclusion();
31
-
32
- if (!(validateConfig() && (await validateAccount(options)))) {
33
- process.exit(1);
34
- }
35
- };
19
+ const i18nKey = 'cli.commands.mv';
36
20
 
37
21
  const getCorrectedDestPath = (srcPath, destPath) => {
38
22
  if (!isPathFolder(srcPath)) {
@@ -44,11 +28,10 @@ const getCorrectedDestPath = (srcPath, destPath) => {
44
28
  };
45
29
 
46
30
  exports.command = 'mv <srcPath> <destPath>';
47
- exports.describe =
48
- 'Move a remote file or folder in HubSpot. This feature is currently in beta and the CLI contract is subject to change';
31
+ exports.describe = i18n(`${i18nKey}.describe`);
49
32
 
50
33
  exports.handler = async options => {
51
- loadAndValidateOptions(options);
34
+ await loadAndValidateOptions(options);
52
35
 
53
36
  const { srcPath, destPath } = options;
54
37
  const accountId = getAccountId(options);
@@ -58,14 +41,27 @@ exports.handler = async options => {
58
41
  try {
59
42
  await moveFile(accountId, srcPath, getCorrectedDestPath(srcPath, destPath));
60
43
  logger.success(
61
- `Moved "${srcPath}" to "${destPath}" in account ${accountId}`
44
+ i18n(`${i18nKey}.move`, {
45
+ accountId,
46
+ destPath,
47
+ srcPath,
48
+ })
62
49
  );
63
50
  } catch (error) {
64
51
  logger.error(
65
- `Moving "${srcPath}" to "${destPath}" in account ${accountId} failed`
52
+ i18n(`${i18nKey}.errors.moveFailed`, {
53
+ accountId,
54
+ destPath,
55
+ srcPath,
56
+ })
66
57
  );
67
58
  if (error.statusCode === 409) {
68
- logger.error(`The folder "${srcPath}" already exists in "${destPath}".`);
59
+ logger.error(
60
+ i18n(`${i18nKey}.errors.sourcePathExists`, {
61
+ destPath,
62
+ srcPath,
63
+ })
64
+ );
69
65
  } else {
70
66
  logApiErrorInstance(
71
67
  error,