@hubspot/cli 3.0.10-beta.12 → 3.0.10-beta.16

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 (41) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +0 -2
  3. package/commands/auth.js +3 -3
  4. package/commands/config/set/allowUsageTracking.js +2 -2
  5. package/commands/config/set/defaultAccount.js +2 -2
  6. package/commands/config/set/defaultMode.js +2 -2
  7. package/commands/create/api-sample.js +6 -2
  8. package/commands/create/function.js +3 -1
  9. package/commands/create/index.js +0 -1
  10. package/commands/create/module.js +1 -1
  11. package/commands/create/template.js +3 -1
  12. package/commands/functions/deploy.js +1 -1
  13. package/commands/init.js +2 -2
  14. package/commands/open.js +2 -2
  15. package/commands/project/create.js +4 -54
  16. package/commands/project/listBuilds.js +2 -2
  17. package/commands/project/logs.js +63 -51
  18. package/commands/project/watch.js +103 -0
  19. package/commands/project.js +2 -0
  20. package/commands/sandbox/create.js +2 -2
  21. package/commands/secrets/addSecret.js +1 -1
  22. package/commands/secrets/updateSecret.js +1 -1
  23. package/commands/server.js +2 -1
  24. package/lib/projects.js +3 -3
  25. package/lib/{createApiSamplePrompt.js → prompts/createApiSamplePrompt.js} +10 -11
  26. package/lib/{createFunctionPrompt.js → prompts/createFunctionPrompt.js} +27 -21
  27. package/lib/{createModulePrompt.js → prompts/createModulePrompt.js} +12 -9
  28. package/lib/prompts/createProjectPrompt.js +68 -0
  29. package/lib/{createTemplatePrompt.js → prompts/createTemplatePrompt.js} +7 -4
  30. package/lib/prompts/folderOverwritePrompt.js +17 -0
  31. package/lib/{prompts.js → prompts/personalAccessKeyPrompt.js} +10 -26
  32. package/lib/prompts/promptUtils.js +10 -0
  33. package/lib/prompts/{sandboxes.js → sandboxesPrompt.js} +5 -6
  34. package/lib/prompts/secretPrompt.js +25 -0
  35. package/lib/validation.js +2 -2
  36. package/package.json +4 -4
  37. package/commands/app/deploy.js +0 -110
  38. package/commands/app.js +0 -14
  39. package/commands/create/project.js +0 -32
  40. package/lib/prompts/projects.js +0 -43
  41. package/lib/secretPrompt.js +0 -22
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @hubspot/cli
2
2
 
3
- Provides an `hs` command for interacting with the HubSpot. [Learn more about building on HubSpot](https://developers.hubspot.com).
3
+ Provides an `hs` command for interacting with HubSpot. [Learn more about building on HubSpot](https://developers.hubspot.com).
4
4
 
5
5
  ## Getting started
6
6
 
package/bin/cli.js CHANGED
@@ -10,7 +10,6 @@ const { setLogLevel, getCommandName } = require('../lib/commonOpts');
10
10
  const { trackHelpUsage } = require('../lib/usageTracking');
11
11
  const pkg = require('../package.json');
12
12
 
13
- const appCommand = require('../commands/app');
14
13
  const removeCommand = require('../commands/remove');
15
14
  const initCommand = require('../commands/init');
16
15
  const logsCommand = require('../commands/logs');
@@ -75,7 +74,6 @@ const argv = yargs
75
74
  describe: 'set log level to debug',
76
75
  type: 'boolean',
77
76
  })
78
- .command(appCommand)
79
77
  .command(authCommand)
80
78
  .command(initCommand)
81
79
  .command(logsCommand)
package/commands/auth.js CHANGED
@@ -18,13 +18,13 @@ const {
18
18
  getConfigPath,
19
19
  } = require('@hubspot/cli-lib/lib/config');
20
20
  const { commaSeparatedValues } = require('@hubspot/cli-lib/lib/text');
21
+ const { promptUser } = require('../lib/prompts/promptUtils');
21
22
  const {
22
- promptUser,
23
23
  personalAccessKeyPrompt,
24
24
  OAUTH_FLOW,
25
25
  API_KEY_FLOW,
26
26
  ACCOUNT_NAME,
27
- } = require('../lib/prompts');
27
+ } = require('../lib/prompts/personalAccessKeyPrompt');
28
28
  const {
29
29
  addConfigOptions,
30
30
  setLogLevel,
@@ -85,7 +85,7 @@ exports.handler = async options => {
85
85
 
86
86
  const env = qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
87
87
  loadConfig(configPath);
88
- checkAndWarnGitInclusion();
88
+ checkAndWarnGitInclusion(getConfigPath());
89
89
 
90
90
  trackCommandUsage('auth');
91
91
 
@@ -1,9 +1,9 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
2
  const { updateAllowUsageTracking } = require('@hubspot/cli-lib/lib/config');
3
- const inquirer = require('inquirer');
4
3
 
5
4
  const { getAccountId } = require('../../../lib/commonOpts');
6
5
  const { trackCommandUsage } = require('../../../lib/usageTracking');
6
+ const { promptUser } = require('../../../lib/prompts/promptUtils');
7
7
  const { loadAndValidateOptions } = require('../../../lib/validation');
8
8
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
9
9
 
@@ -11,7 +11,7 @@ const i18nKey =
11
11
  'cli.commands.config.subcommands.set.subcommands.allowUsageTracking';
12
12
 
13
13
  const enableOrDisableUsageTracking = async () => {
14
- const { isEnabled } = await inquirer.prompt([
14
+ const { isEnabled } = await promptUser([
15
15
  {
16
16
  type: 'list',
17
17
  look: false,
@@ -4,18 +4,18 @@ const {
4
4
  getConfigPath,
5
5
  updateDefaultAccount,
6
6
  } = require('@hubspot/cli-lib/lib/config');
7
- const inquirer = require('inquirer');
8
7
  const { loadAndValidateOptions } = require('../../../lib/validation');
9
8
 
10
9
  const { getAccountId } = require('../../../lib/commonOpts');
11
10
  const { trackCommandUsage } = require('../../../lib/usageTracking');
11
+ const { promptUser } = require('../../../lib/prompts/promptUtils');
12
12
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
13
13
 
14
14
  const i18nKey =
15
15
  'cli.commands.config.subcommands.set.subcommands.defaultAccount';
16
16
 
17
17
  const selectAccountFromConfig = async config => {
18
- const { default: selectedDefault } = await inquirer.prompt([
18
+ const { default: selectedDefault } = await promptUser([
19
19
  {
20
20
  type: 'list',
21
21
  look: false,
@@ -1,11 +1,11 @@
1
1
  const { logger } = require('@hubspot/cli-lib/logger');
2
2
  const { updateDefaultMode } = require('@hubspot/cli-lib/lib/config');
3
- const inquirer = require('inquirer');
4
3
  const { Mode } = require('@hubspot/cli-lib');
5
4
  const { commaSeparatedValues } = require('@hubspot/cli-lib/lib/text');
6
5
 
7
6
  const { getAccountId } = require('../../../lib/commonOpts');
8
7
  const { trackCommandUsage } = require('../../../lib/usageTracking');
8
+ const { promptUser } = require('../../../lib/prompts/promptUtils');
9
9
  const { loadAndValidateOptions } = require('../../../lib/validation');
10
10
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
11
11
 
@@ -14,7 +14,7 @@ const i18nKey = 'cli.commands.config.subcommands.set.subcommands.defaultMode';
14
14
  const ALL_MODES = Object.values(Mode);
15
15
 
16
16
  const selectMode = async () => {
17
- const { mode } = await inquirer.prompt([
17
+ const { mode } = await promptUser([
18
18
  {
19
19
  type: 'list',
20
20
  look: false,
@@ -1,5 +1,9 @@
1
- const { createApiSamplePrompt } = require('../../lib/createApiSamplePrompt');
2
- const { folderOverwritePrompt } = require('../../lib/prompts');
1
+ const {
2
+ createApiSamplePrompt,
3
+ } = require('../../lib/prompts/createApiSamplePrompt');
4
+ const {
5
+ folderOverwritePrompt,
6
+ } = require('../../lib/prompts/folderOverwritePrompt');
3
7
  const { logger } = require('@hubspot/cli-lib/logger');
4
8
  const path = require('path');
5
9
  const fs = require('fs-extra');
@@ -1,5 +1,7 @@
1
1
  const { createFunction } = require('@hubspot/cli-lib/functions');
2
- const { createFunctionPrompt } = require('../../lib/createFunctionPrompt');
2
+ const {
3
+ createFunctionPrompt,
4
+ } = require('../../lib/prompts/createFunctionPrompt');
3
5
 
4
6
  module.exports = {
5
7
  dest: ({ name }) => name,
@@ -3,7 +3,6 @@ module.exports = {
3
3
  app: require('./app'),
4
4
  function: require('./function'),
5
5
  module: require('./module'),
6
- project: require('./project'),
7
6
  'react-app': require('./react-app'),
8
7
  template: require('./template'),
9
8
  'vue-app': require('./vue-app'),
@@ -1,5 +1,5 @@
1
1
  const path = require('path');
2
- const { createModulePrompt } = require('../../lib/createModulePrompt');
2
+ const { createModulePrompt } = require('../../lib/prompts/createModulePrompt');
3
3
  const fs = require('fs-extra');
4
4
  const { logger } = require('@hubspot/cli-lib/logger');
5
5
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
@@ -1,4 +1,6 @@
1
- const { createTemplatePrompt } = require('../../lib/createTemplatePrompt');
1
+ const {
2
+ createTemplatePrompt,
3
+ } = require('../../lib/prompts/createTemplatePrompt');
2
4
  const { logger } = require('@hubspot/cli-lib/logger');
3
5
  const path = require('path');
4
6
  const fs = require('fs-extra');
@@ -83,7 +83,7 @@ exports.handler = async options => {
83
83
  spinner.stop();
84
84
  await outputBuildLog(successResp.cdnUrl);
85
85
  logger.success(
86
- i18n(`${i18nKey}.success.deploy`, {
86
+ i18n(`${i18nKey}.success.deployed`, {
87
87
  accountId,
88
88
  buildTimeSeconds,
89
89
  functionPath,
package/commands/init.js CHANGED
@@ -26,13 +26,13 @@ const {
26
26
  const { getCwd } = require('@hubspot/cli-lib/path');
27
27
  const { trackCommandUsage, trackAuthAction } = require('../lib/usageTracking');
28
28
  const { setLogLevel, addTestingOptions } = require('../lib/commonOpts');
29
+ const { promptUser } = require('../lib/prompts/promptUtils');
29
30
  const {
30
31
  OAUTH_FLOW,
31
32
  API_KEY_FLOW,
32
33
  ACCOUNT_NAME,
33
34
  personalAccessKeyPrompt,
34
- promptUser,
35
- } = require('../lib/prompts');
35
+ } = require('../lib/prompts/personalAccessKeyPrompt');
36
36
  const { logDebugInfo } = require('../lib/debugInfo');
37
37
  const { authenticateWithOauth } = require('../lib/oauth');
38
38
  const { EXIT_CODES } = require('../lib/enums/exitCodes');
package/commands/open.js CHANGED
@@ -6,14 +6,14 @@ const {
6
6
  } = require('../lib/commonOpts');
7
7
  const { trackCommandUsage } = require('../lib/usageTracking');
8
8
  const { logSiteLinks, getSiteLinksAsArray, openLink } = require('../lib/links');
9
- const inquirer = require('inquirer');
9
+ const { promptUser } = require('../lib/prompts/promptUtils');
10
10
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
11
11
 
12
12
  const i18nKey = 'cli.commands.open';
13
13
 
14
14
  const separator = ' => ';
15
15
  const createListPrompt = async accountId =>
16
- inquirer.prompt([
16
+ promptUser([
17
17
  {
18
18
  type: 'rawlist',
19
19
  look: false,
@@ -8,9 +8,10 @@ const { trackCommandUsage } = require('../../lib/usageTracking');
8
8
  const { loadAndValidateOptions } = require('../../lib/validation');
9
9
  const { getCwd } = require('@hubspot/cli-lib/path');
10
10
  const path = require('path');
11
- const { prompt } = require('inquirer');
11
+ const {
12
+ createProjectPrompt,
13
+ } = require('../../lib/prompts/createProjectPrompt');
12
14
  const { createProjectConfig } = require('../../lib/projects');
13
- const { PROJECT_TEMPLATES } = require('@hubspot/cli-lib/lib/constants');
14
15
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
15
16
 
16
17
  const i18nKey = 'cli.commands.project.subcommands.create';
@@ -23,58 +24,7 @@ exports.handler = async options => {
23
24
 
24
25
  const accountId = getAccountId(options);
25
26
 
26
- const { name, template, location } = await prompt([
27
- {
28
- name: 'name',
29
- message: '[--name] Give your project a name:',
30
- when: !options.name,
31
- validate: input => {
32
- if (!input) {
33
- return 'A project name is required';
34
- }
35
- return true;
36
- },
37
- },
38
- {
39
- name: 'location',
40
- message: '[--location] Where should the project be created?',
41
- when: !options.location,
42
- default: answers => {
43
- return path.resolve(getCwd(), answers.name || options.name);
44
- },
45
- validate: input => {
46
- if (!input) {
47
- return 'A project location is required';
48
- }
49
- return true;
50
- },
51
- },
52
- {
53
- name: 'template',
54
- message: () => {
55
- return options.template &&
56
- !PROJECT_TEMPLATES.find(t => t.name === options.template)
57
- ? `[--template] Could not find template ${options.template}. Please choose an available template.`
58
- : '[--template] Start from a template?';
59
- },
60
- when:
61
- !options.template ||
62
- !PROJECT_TEMPLATES.find(t => t.name === options.template),
63
- type: 'list',
64
- choices: [
65
- {
66
- name: 'No template',
67
- value: 'none',
68
- },
69
- ...PROJECT_TEMPLATES.map(template => {
70
- return {
71
- name: template.label,
72
- value: template.name,
73
- };
74
- }),
75
- ],
76
- },
77
- ]);
27
+ const { name, template, location } = await createProjectPrompt(options);
78
28
 
79
29
  trackCommandUsage('project-create', { projectName: name }, accountId);
80
30
 
@@ -29,7 +29,7 @@ const {
29
29
  validateProjectConfig,
30
30
  } = require('../../lib/projects');
31
31
  const moment = require('moment');
32
- const { prompt } = require('inquirer');
32
+ const { promptUser } = require('../../lib/prompts/promptUtils');
33
33
 
34
34
  exports.command = 'list-builds [path]';
35
35
  exports.describe = false;
@@ -111,7 +111,7 @@ exports.handler = async options => {
111
111
  );
112
112
  }
113
113
  if (paging && paging.next) {
114
- await prompt({
114
+ await promptUser({
115
115
  name: 'more',
116
116
  message: 'Press <enter> to load more, or ctrl+c to exit',
117
117
  });
@@ -13,9 +13,14 @@ const {
13
13
  getProjectAppFunctionLogs,
14
14
  getLatestProjectAppFunctionLog,
15
15
  } = require('@hubspot/cli-lib/api/functions');
16
+ const {
17
+ getFunctionLogs,
18
+ getLatestFunctionLog,
19
+ } = require('@hubspot/cli-lib/api/results');
16
20
  const { getProjectConfig } = require('../../lib/projects');
17
21
  const { loadAndValidateOptions } = require('../../lib/validation');
18
22
  const { tailLogs } = require('../../lib/serverlessLogs');
23
+ const { uiAccountDescription } = require('../../lib/ui');
19
24
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
20
25
 
21
26
  const i18nKey = 'cli.commands.project.subcommands.logs';
@@ -24,17 +29,23 @@ const { EXIT_CODES } = require('../../lib/enums/exitCodes');
24
29
  const handleLogsError = (e, accountId, projectName, appPath, functionName) => {
25
30
  if (e.statusCode === 404) {
26
31
  logger.error(
27
- i18n(`${i18nKey}.errors.logs`, {
28
- accountId,
29
- appPath,
30
- functionName,
31
- projectName,
32
- })
32
+ appPath
33
+ ? i18n(`${i18nKey}.errors.noAppFunctionLogs`, {
34
+ accountId,
35
+ appPath,
36
+ functionName,
37
+ projectName,
38
+ })
39
+ : i18n(`${i18nKey}.errors.noEndpointLogs`, {
40
+ accountId,
41
+ functionName,
42
+ projectName,
43
+ })
33
44
  );
34
45
  }
35
46
  };
36
47
 
37
- const appFunctionLog = async (accountId, options) => {
48
+ const functionLog = async (accountId, options) => {
38
49
  const {
39
50
  latest,
40
51
  follow,
@@ -46,28 +57,43 @@ const appFunctionLog = async (accountId, options) => {
46
57
 
47
58
  let logsResp;
48
59
 
60
+ const tailCall = async after => {
61
+ try {
62
+ return appPath
63
+ ? getProjectAppFunctionLogs(
64
+ accountId,
65
+ functionName,
66
+ projectName,
67
+ appPath,
68
+ {
69
+ after,
70
+ }
71
+ )
72
+ : getFunctionLogs(accountId, functionName, { after });
73
+ } catch (e) {
74
+ handleLogsError(e, accountId, projectName, appPath, functionName);
75
+ }
76
+ };
77
+ const fetchLatest = async () => {
78
+ return appPath
79
+ ? getLatestProjectAppFunctionLog(
80
+ accountId,
81
+ functionName,
82
+ projectName,
83
+ appPath
84
+ )
85
+ : getLatestFunctionLog(accountId, functionName);
86
+ };
87
+
49
88
  if (follow) {
50
89
  const spinnies = new Spinnies();
51
90
 
52
91
  spinnies.add('tailLogs', {
53
- text: i18n(`${i18nKey}.loading`),
92
+ text: i18n(`${i18nKey}.loading`, {
93
+ functionName,
94
+ accountId: uiAccountDescription(accountId),
95
+ }),
54
96
  });
55
- const tailCall = after =>
56
- getProjectAppFunctionLogs(accountId, functionName, projectName, appPath, {
57
- after,
58
- });
59
- const fetchLatest = () => {
60
- try {
61
- return getLatestProjectAppFunctionLog(
62
- accountId,
63
- functionName,
64
- projectName,
65
- appPath
66
- );
67
- } catch (e) {
68
- handleLogsError(e, accountId, projectName, appPath, functionName);
69
- }
70
- };
71
97
 
72
98
  await tailLogs({
73
99
  accountId,
@@ -78,24 +104,13 @@ const appFunctionLog = async (accountId, options) => {
78
104
  });
79
105
  } else if (latest) {
80
106
  try {
81
- logsResp = await getLatestProjectAppFunctionLog(
82
- accountId,
83
- functionName,
84
- projectName,
85
- appPath
86
- );
107
+ logsResp = await fetchLatest();
87
108
  } catch (e) {
88
109
  handleLogsError(e, accountId, projectName, appPath, functionName);
89
110
  }
90
111
  } else {
91
112
  try {
92
- logsResp = await getProjectAppFunctionLogs(
93
- accountId,
94
- functionName,
95
- projectName,
96
- appPath,
97
- {}
98
- );
113
+ logsResp = await tailCall();
99
114
  } catch (e) {
100
115
  handleLogsError(e, accountId, projectName, appPath, functionName);
101
116
  }
@@ -106,50 +121,47 @@ const appFunctionLog = async (accountId, options) => {
106
121
  }
107
122
  };
108
123
 
109
- exports.command = 'logs [functionName]';
124
+ exports.command = 'logs';
110
125
  exports.describe = i18n(`${i18nKey}.describe`);
111
126
 
112
127
  exports.handler = async options => {
113
128
  await loadAndValidateOptions(options);
114
129
 
115
- const { latest, functionName, appPath } = options;
130
+ const { latest, functionName } = options;
116
131
  let projectName = options.projectName;
117
132
 
118
133
  if (!functionName) {
119
134
  logger.error(i18n(`${i18nKey}.errors.functionNameRequired`));
120
135
  process.exit(EXIT_CODES.ERROR);
121
136
  } else if (!projectName) {
122
- const projectConfig = await getProjectConfig(getCwd());
137
+ const { projectConfig } = await getProjectConfig(getCwd());
123
138
  if (projectConfig && projectConfig.name) {
124
139
  projectName = projectConfig.name;
125
140
  } else {
126
141
  logger.error(i18n(`${i18nKey}.errors.projectNameRequired`));
127
142
  process.exit(EXIT_CODES.ERROR);
128
143
  }
129
- } else if (!appPath) {
130
- logger.error(i18n(`${i18nKey}.errors.appPathRequired`));
131
- process.exit(EXIT_CODES.ERROR);
132
144
  }
133
145
 
134
146
  const accountId = getAccountId(options);
135
147
 
136
148
  trackCommandUsage('project-logs', { latest }, accountId);
137
149
 
138
- appFunctionLog(accountId, { ...options, projectName });
150
+ functionLog(accountId, { ...options, projectName });
139
151
  };
140
152
 
141
153
  exports.builder = yargs => {
142
- yargs.positional('functionName', {
143
- describe: i18n(`${i18nKey}.positionals.functionName.describe`),
144
- type: 'string',
145
- demandOption: true,
146
- });
147
154
  yargs
148
155
  .options({
156
+ functionName: {
157
+ alias: 'function',
158
+ describe: i18n(`${i18nKey}.positionals.functionName.describe`),
159
+ type: 'string',
160
+ demandOption: true,
161
+ },
149
162
  appPath: {
150
163
  describe: i18n(`${i18nKey}.options.appPath.describe`),
151
164
  type: 'string',
152
- demandOption: true,
153
165
  },
154
166
  projectName: {
155
167
  describe: i18n(`${i18nKey}.options.projectName.describe`),
@@ -179,7 +191,7 @@ exports.builder = yargs => {
179
191
 
180
192
  yargs.example([
181
193
  [
182
- '$0 project logs my-function --appName="app" --projectName="my-project"',
194
+ '$0 project logs --function=my-function --appPath="app" --projectName="my-project"',
183
195
  i18n(`${i18nKey}.examples.default`),
184
196
  ],
185
197
  ]);
@@ -0,0 +1,103 @@
1
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
2
+ const { createWatcher } = require('@hubspot/cli-lib/projectsWatch');
3
+ const { cancelStagedBuild } = require('@hubspot/cli-lib/api/dfs');
4
+ const {
5
+ logApiErrorInstance,
6
+ ApiErrorContext,
7
+ } = require('@hubspot/cli-lib/errorHandlers');
8
+ const { logger } = require('@hubspot/cli-lib/logger');
9
+ const {
10
+ addAccountOptions,
11
+ addConfigOptions,
12
+ getAccountId,
13
+ addUseEnvironmentOptions,
14
+ } = require('../../lib/commonOpts');
15
+ const { trackCommandUsage } = require('../../lib/usageTracking');
16
+ const {
17
+ getProjectConfig,
18
+ validateProjectConfig,
19
+ pollBuildStatus,
20
+ pollDeployStatus,
21
+ } = require('../../lib/projects');
22
+ const { loadAndValidateOptions } = require('../../lib/validation');
23
+ const { EXIT_CODES } = require('../../lib/enums/exitCodes');
24
+
25
+ const i18nKey = 'cli.commands.project.subcommands.watch';
26
+
27
+ exports.command = 'watch [path]';
28
+ exports.describe = false;
29
+
30
+ const handleBuildStatus = async (accountId, projectName, buildId) => {
31
+ const {
32
+ isAutoDeployEnabled,
33
+ deployStatusTaskLocator,
34
+ } = await pollBuildStatus(accountId, projectName, buildId);
35
+
36
+ if (isAutoDeployEnabled && deployStatusTaskLocator) {
37
+ await pollDeployStatus(
38
+ accountId,
39
+ projectName,
40
+ deployStatusTaskLocator.id,
41
+ buildId
42
+ );
43
+ }
44
+ };
45
+
46
+ const handleSigInt = (accountId, projectName, currentBuildId) => {
47
+ process.removeAllListeners('SIGINT');
48
+ process.on('SIGINT', async () => {
49
+ if (currentBuildId) {
50
+ try {
51
+ await cancelStagedBuild(accountId, projectName);
52
+ logger.debug(i18n(`${i18nKey}.debug.buildCancelled`));
53
+ process.exit(EXIT_CODES.SUCCESS);
54
+ } catch (err) {
55
+ logApiErrorInstance(
56
+ err,
57
+ new ApiErrorContext({ accountId, projectName: projectName })
58
+ );
59
+ process.exit(EXIT_CODES.ERROR);
60
+ }
61
+ } else {
62
+ process.exit(EXIT_CODES.SUCCESS);
63
+ }
64
+ });
65
+ };
66
+
67
+ exports.handler = async options => {
68
+ await loadAndValidateOptions(options);
69
+
70
+ const { path: projectPath } = options;
71
+ const accountId = getAccountId(options);
72
+
73
+ trackCommandUsage('project-watch', { projectPath }, accountId);
74
+
75
+ const { projectConfig, projectDir } = await getProjectConfig(projectPath);
76
+
77
+ validateProjectConfig(projectConfig, projectDir);
78
+
79
+ await createWatcher(
80
+ accountId,
81
+ projectConfig,
82
+ projectDir,
83
+ handleBuildStatus,
84
+ handleSigInt
85
+ );
86
+ };
87
+
88
+ exports.builder = yargs => {
89
+ yargs.positional('path', {
90
+ describe: i18n(`${i18nKey}.describe`),
91
+ type: 'string',
92
+ });
93
+
94
+ yargs.example([
95
+ ['$0 project watch myProjectFolder', i18n(`${i18nKey}.examples.default`)],
96
+ ]);
97
+
98
+ addConfigOptions(yargs, true);
99
+ addAccountOptions(yargs, true);
100
+ addUseEnvironmentOptions(yargs, true);
101
+
102
+ return yargs;
103
+ };
@@ -4,6 +4,7 @@ const create = require('./project/create');
4
4
  const upload = require('./project/upload');
5
5
  const listBuilds = require('./project/listBuilds');
6
6
  const logs = require('./project/logs');
7
+ const watch = require('./project/watch');
7
8
 
8
9
  exports.command = 'project';
9
10
  exports.describe = false; //'Commands for working with projects';
@@ -16,6 +17,7 @@ exports.builder = yargs => {
16
17
  yargs.command(deploy).demandCommand(1, '');
17
18
  yargs.command(create).demandCommand(0, '');
18
19
  yargs.command(upload).demandCommand(0, '');
20
+ yargs.command(watch).demandCommand(0, '');
19
21
  yargs.command(listBuilds).demandCommand(0, '');
20
22
  yargs.command(logs).demandCommand(1, '');
21
23
 
@@ -9,7 +9,7 @@ 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
13
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
14
14
 
15
15
  const i18nKey = 'cli.commands.sandbox.subcommands.create';
@@ -27,7 +27,7 @@ exports.handler = async options => {
27
27
  trackCommandUsage('sandbox-create', {}, accountId);
28
28
 
29
29
  if (!name) {
30
- namePrompt = await prompt();
30
+ namePrompt = await createSandboxPrompt();
31
31
  }
32
32
 
33
33
  const sandboxName = name || namePrompt.name;
@@ -14,7 +14,7 @@ const {
14
14
  addUseEnvironmentOptions,
15
15
  getAccountId,
16
16
  } = require('../../lib/commonOpts');
17
- const { secretValuePrompt } = require('../../lib/secretPrompt');
17
+ const { secretValuePrompt } = require('../../lib/prompts/secretPrompt');
18
18
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
19
19
 
20
20
  const i18nKey = 'cli.commands.secrets.subcommands.add';
@@ -14,7 +14,7 @@ const {
14
14
  addUseEnvironmentOptions,
15
15
  getAccountId,
16
16
  } = require('../../lib/commonOpts');
17
- const { secretValuePrompt } = require('../../lib/secretPrompt');
17
+ const { secretValuePrompt } = require('../../lib/prompts/secretPrompt');
18
18
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
19
19
 
20
20
  const i18nKey = 'cli.commands.secrets.subcommands.update';