@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
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
  });
@@ -11,15 +11,15 @@ const ACCOUNT_ID = 123;
11
11
  describe('@hubspot/cli/lib/serverlessLogs', () => {
12
12
  describe('tailLogs()', () => {
13
13
  let stdinMock;
14
- let spinner;
14
+ let spinnies;
15
15
 
16
16
  beforeEach(() => {
17
17
  jest.spyOn(process, 'exit').mockImplementation(() => {});
18
18
  stdinMock = mockStdIn.stdin();
19
- spinner = {
20
- start: jest.fn(),
21
- stop: jest.fn(),
22
- clear: jest.fn(),
19
+ spinnies = {
20
+ succeed: jest.fn(),
21
+ fail: jest.fn(),
22
+ stopAll: jest.fn(),
23
23
  };
24
24
  });
25
25
 
@@ -56,7 +56,7 @@ describe('@hubspot/cli/lib/serverlessLogs', () => {
56
56
  await tailLogs({
57
57
  accountId: ACCOUNT_ID,
58
58
  compact,
59
- spinner,
59
+ spinnies,
60
60
  fetchLatest,
61
61
  tailCall,
62
62
  });
@@ -114,7 +114,7 @@ describe('@hubspot/cli/lib/serverlessLogs', () => {
114
114
  await tailLogs({
115
115
  accountId: ACCOUNT_ID,
116
116
  compact,
117
- spinner,
117
+ spinnies,
118
118
  fetchLatest,
119
119
  tailCall,
120
120
  });
@@ -123,7 +123,6 @@ describe('@hubspot/cli/lib/serverlessLogs', () => {
123
123
  latestLogResponse,
124
124
  expect.objectContaining({ compact })
125
125
  );
126
- expect(spinner.clear).toHaveBeenCalled();
127
126
  expect(tailCall).toHaveBeenCalledTimes(2);
128
127
  });
129
128
  it('handles no logs', async () => {
@@ -147,7 +146,7 @@ describe('@hubspot/cli/lib/serverlessLogs', () => {
147
146
  await tailLogs({
148
147
  accountId: ACCOUNT_ID,
149
148
  compact,
150
- spinner,
149
+ spinnies,
151
150
  fetchLatest,
152
151
  tailCall,
153
152
  });
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
+ };