@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,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;
package/commands/watch.js CHANGED
@@ -1,12 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
- const {
5
- watch,
6
- loadConfig,
7
- validateConfig,
8
- checkAndWarnGitInclusion,
9
- } = require('@hubspot/cli-lib');
4
+ const { watch } = require('@hubspot/cli-lib');
10
5
  const { getCwd } = require('@hubspot/cli-lib/path');
11
6
  const { logger } = require('@hubspot/cli-lib/logger');
12
7
 
@@ -15,42 +10,26 @@ const {
15
10
  addAccountOptions,
16
11
  addModeOptions,
17
12
  addUseEnvironmentOptions,
18
- setLogLevel,
19
13
  getAccountId,
20
14
  getMode,
21
15
  } = require('../lib/commonOpts');
22
- const { logDebugInfo } = require('../lib/debugInfo');
23
- const { validateAccount, validateMode } = require('../lib/validation');
16
+ const { validateMode, loadAndValidateOptions } = require('../lib/validation');
24
17
  const { trackCommandUsage } = require('../lib/usageTracking');
18
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
19
+
20
+ const i18nKey = 'cli.commands.watch';
21
+ const { EXIT_CODES } = require('../lib/enums/exitCodes');
25
22
 
26
23
  exports.command = 'watch <src> <dest>';
27
- exports.describe =
28
- 'Watch a directory on your computer for changes and upload the changed files to the HubSpot CMS';
24
+ exports.describe = i18n(`${i18nKey}.describe`);
29
25
 
30
26
  exports.handler = async options => {
31
- const {
32
- src,
33
- dest,
34
- config: configPath,
35
- remove,
36
- initialUpload,
37
- disableInitial,
38
- notify,
39
- } = options;
40
-
41
- setLogLevel(options);
42
- logDebugInfo(options);
43
- loadConfig(configPath, options);
44
- checkAndWarnGitInclusion();
45
-
46
- if (
47
- !(
48
- validateConfig() &&
49
- (await validateAccount(options)) &&
50
- validateMode(options)
51
- )
52
- ) {
53
- process.exit(1);
27
+ const { src, dest, remove, initialUpload, disableInitial, notify } = options;
28
+
29
+ await loadAndValidateOptions(options);
30
+
31
+ if (!validateMode(options)) {
32
+ process.exit(EXIT_CODES.ERROR);
54
33
  }
55
34
 
56
35
  const accountId = getAccountId(options);
@@ -60,32 +39,34 @@ exports.handler = async options => {
60
39
  try {
61
40
  const stats = fs.statSync(absoluteSrcPath);
62
41
  if (!stats.isDirectory()) {
63
- logger.log(`The "${src}" is not a path to a directory`);
42
+ logger.log(
43
+ i18n(`${i18nKey}.errors.invalidPath`, {
44
+ path: src,
45
+ })
46
+ );
64
47
  return;
65
48
  }
66
49
  } catch (e) {
67
- logger.log(`The "${src}" is not a path to a directory`);
50
+ logger.log(
51
+ i18n(`${i18nKey}.errors.invalidPath`, {
52
+ path: src,
53
+ })
54
+ );
68
55
  return;
69
56
  }
70
57
 
71
58
  if (!dest) {
72
- logger.log('A destination directory needs to be passed');
59
+ logger.log(i18n(`${i18nKey}.errors.destinationRequired`));
73
60
  return;
74
61
  }
75
62
 
76
63
  if (disableInitial) {
77
- logger.info(
78
- 'Passing the "--disable-initial" option is no longer necessary. Running "hs watch" no longer uploads the watched directory by default.'
79
- );
64
+ logger.info(i18n(`${i18nKey}.warnings.disableInitial`));
80
65
  } else {
81
- logger.info(
82
- `The "watch" command no longer uploads the watched directory when started. The directory "${src}" was not uploaded.`
83
- );
66
+ logger.info(i18n(`${i18nKey}.warnings.notUploaded`, { path: src }));
84
67
 
85
68
  if (!initialUpload) {
86
- logger.info(
87
- 'To upload the directory run "hs upload" beforehand or add the "--initial-upload" option when running "hs watch".'
88
- );
69
+ logger.info(i18n(`${i18nKey}.warnings.initialUpload`));
89
70
  }
90
71
  }
91
72
 
@@ -105,35 +86,32 @@ exports.builder = yargs => {
105
86
  addUseEnvironmentOptions(yargs, true);
106
87
 
107
88
  yargs.positional('src', {
108
- describe:
109
- 'Path to the local directory your files are in, relative to your current working directory',
89
+ describe: i18n(`${i18nKey}.positionals.src.describe`),
110
90
  type: 'string',
111
91
  });
112
92
  yargs.positional('dest', {
113
- describe: 'Path in HubSpot Design Tools. Can be a net new path',
93
+ describe: i18n(`${i18nKey}.positionals.dest.describe`),
114
94
  type: 'string',
115
95
  });
116
96
  yargs.option('remove', {
117
97
  alias: 'r',
118
- describe:
119
- 'Will cause watch to delete files in your HubSpot account that are not found locally.',
98
+ describe: i18n(`${i18nKey}.options.remove.describe`),
120
99
  type: 'boolean',
121
100
  });
122
101
  yargs.option('initial-upload', {
123
102
  alias: 'i',
124
- describe: 'Upload directory before watching for updates',
103
+ describe: i18n(`${i18nKey}.options.initialUpload.describe`),
125
104
  type: 'boolean',
126
105
  });
127
106
  yargs.option('disable-initial', {
128
107
  alias: 'd',
129
- describe: 'Disable the initial upload when watching a directory (default)',
108
+ describe: i18n(`${i18nKey}.options.disableInitial.describe`),
130
109
  type: 'boolean',
131
110
  hidden: true,
132
111
  });
133
112
  yargs.option('notify', {
134
113
  alias: 'n',
135
- describe:
136
- 'Log to specified file when a watch task is triggered and after workers have gone idle. Ex. --notify path/to/file',
114
+ describe: i18n(`${i18nKey}.options.notify.describe`),
137
115
  type: 'string',
138
116
  requiresArg: true,
139
117
  });
package/lib/commonOpts.js CHANGED
@@ -6,48 +6,51 @@ const {
6
6
  DEFAULT_MODE,
7
7
  Mode,
8
8
  } = require('@hubspot/cli-lib');
9
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
10
+
11
+ const i18nKey = 'cli.lib.commonOpts';
9
12
  const { LOG_LEVEL } = Logger;
10
13
 
11
14
  const addAccountOptions = program =>
12
15
  program.option('portal', {
13
16
  alias: ['p', 'account', 'a'],
14
- describe: 'HubSpot portal id or name from config',
17
+ describe: i18n(`${i18nKey}.options.portal.describe`),
15
18
  type: 'string',
16
19
  });
17
20
 
18
21
  const addConfigOptions = yargs =>
19
22
  yargs.option('config', {
20
23
  alias: 'c',
21
- describe: 'path to a config file',
24
+ describe: i18n(`${i18nKey}.options.config.describe`),
22
25
  type: 'string',
23
26
  });
24
27
 
25
28
  const addOverwriteOptions = yargs =>
26
29
  yargs.option('overwrite', {
27
30
  alias: 'o',
28
- describe: 'overwrite existing files',
31
+ describe: i18n(`${i18nKey}.options.overwrite.describe`),
29
32
  type: 'boolean',
30
33
  default: false,
31
34
  });
32
35
 
33
36
  const addModeOptions = (yargs, { read, write }) => {
34
37
  const modes = `<${Object.values(Mode).join(' | ')}>`;
35
- const help = read
36
- ? `read from ${modes}`
37
- : write
38
- ? `write to ${modes}`
39
- : `${modes}`;
40
38
 
41
39
  return yargs.option('mode', {
42
40
  alias: 'm',
43
- describe: help,
41
+ describe: i18n(
42
+ `${i18nKey}.options.modes.describe.${
43
+ read ? 'read' : write ? 'write' : 'default'
44
+ }`,
45
+ { modes }
46
+ ),
44
47
  type: 'string',
45
48
  });
46
49
  };
47
50
 
48
51
  const addTestingOptions = yargs =>
49
52
  yargs.option('qa', {
50
- describe: 'run command in qa mode',
53
+ describe: i18n(`${i18nKey}.options.qa.describe`),
51
54
  type: 'boolean',
52
55
  default: false,
53
56
  hidden: true,
@@ -55,7 +58,7 @@ const addTestingOptions = yargs =>
55
58
 
56
59
  const addUseEnvironmentOptions = yargs =>
57
60
  yargs.option('use-env', {
58
- describe: 'use environment variable config',
61
+ describe: i18n(`${i18nKey}.options.useEnv.describe`),
59
62
  type: 'boolean',
60
63
  default: false,
61
64
  });
@@ -0,0 +1,14 @@
1
+ /*
2
+ * 0: Successful run
3
+ * 1: Config problem or internal error
4
+ * 2: Warnings or validation issues
5
+ */
6
+ const EXIT_CODES = {
7
+ SUCCESS: 0,
8
+ ERROR: 1,
9
+ WARNING: 2,
10
+ };
11
+
12
+ module.exports = {
13
+ EXIT_CODES,
14
+ };
package/lib/links.js CHANGED
@@ -1,4 +1,3 @@
1
- const supportsHyperlinks = require('supports-hyperlinks');
2
1
  const { getEnv } = require('@hubspot/cli-lib/lib/config');
3
2
  const { ENVIRONMENTS } = require('@hubspot/cli-lib/lib/constants');
4
3
  const { getHubSpotWebsiteOrigin } = require('@hubspot/cli-lib/lib/urls');
@@ -121,18 +120,9 @@ const openLink = (accountId, shortcut) => {
121
120
  logger.success(`We opened ${match.url} in your browser`);
122
121
  };
123
122
 
124
- const link = (linkText, url) => {
125
- if (supportsHyperlinks.stdout) {
126
- return ['\u001B]8;;', url, '\u0007', linkText, '\u001B]8;;\u0007'].join('');
127
- } else {
128
- return `${linkText}: ${url}`;
129
- }
130
- };
131
-
132
123
  module.exports = {
133
124
  getSiteLinks,
134
125
  getSiteLinksAsArray,
135
126
  logSiteLinks,
136
127
  openLink,
137
- link,
138
128
  };