@hubspot/cli 3.0.10-beta.11 → 3.0.10-beta.15

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 (40) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +0 -2
  3. package/bin/hubspot +3 -0
  4. package/commands/auth.js +3 -3
  5. package/commands/config/set/allowUsageTracking.js +2 -2
  6. package/commands/config/set/defaultAccount.js +2 -2
  7. package/commands/config/set/defaultMode.js +2 -2
  8. package/commands/create/api-sample.js +6 -2
  9. package/commands/create/function.js +3 -1
  10. package/commands/create/index.js +0 -1
  11. package/commands/create/module.js +1 -1
  12. package/commands/create/template.js +3 -1
  13. package/commands/functions/deploy.js +1 -1
  14. package/commands/init.js +2 -2
  15. package/commands/open.js +2 -2
  16. package/commands/project/create.js +4 -54
  17. package/commands/project/listBuilds.js +2 -2
  18. package/commands/project/logs.js +63 -51
  19. package/commands/sandbox/create.js +2 -2
  20. package/commands/secrets/addSecret.js +1 -1
  21. package/commands/secrets/updateSecret.js +1 -1
  22. package/commands/server.js +2 -1
  23. package/lib/projects.js +4 -3
  24. package/lib/{createApiSamplePrompt.js → prompts/createApiSamplePrompt.js} +10 -11
  25. package/lib/{createFunctionPrompt.js → prompts/createFunctionPrompt.js} +27 -21
  26. package/lib/{createModulePrompt.js → prompts/createModulePrompt.js} +12 -9
  27. package/lib/prompts/createProjectPrompt.js +68 -0
  28. package/lib/{createTemplatePrompt.js → prompts/createTemplatePrompt.js} +7 -4
  29. package/lib/prompts/folderOverwritePrompt.js +17 -0
  30. package/lib/{prompts.js → prompts/personalAccessKeyPrompt.js} +10 -26
  31. package/lib/prompts/promptUtils.js +10 -0
  32. package/lib/prompts/{sandboxes.js → sandboxesPrompt.js} +5 -6
  33. package/lib/prompts/secretPrompt.js +25 -0
  34. package/lib/validation.js +2 -2
  35. package/package.json +4 -4
  36. package/commands/app/deploy.js +0 -110
  37. package/commands/app.js +0 -14
  38. package/commands/create/project.js +0 -32
  39. package/lib/prompts/projects.js +0 -43
  40. 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/bin/hubspot ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('./cli');
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
  ]);
@@ -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';
@@ -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');
@@ -38,7 +39,7 @@ function configureServerCommand(program) {
38
39
  logDebugInfo(options);
39
40
  const { config: configPath, serverConfig, contextDir } = options;
40
41
  loadConfig(configPath, options);
41
- checkAndWarnGitInclusion();
42
+ checkAndWarnGitInclusion(getConfigPath());
42
43
 
43
44
  if (!validateConfig()) {
44
45
  process.exit(EXIT_CODES.ERROR);
package/lib/projects.js CHANGED
@@ -3,7 +3,6 @@ const path = require('path');
3
3
 
4
4
  const chalk = require('chalk');
5
5
  const findup = require('findup-sync');
6
- const { prompt } = require('inquirer');
7
6
  const Spinnies = require('spinnies');
8
7
  const { logger } = require('@hubspot/cli-lib/logger');
9
8
  const { getEnv } = require('@hubspot/cli-lib/lib/config');
@@ -29,6 +28,7 @@ const {
29
28
  ApiErrorContext,
30
29
  } = require('@hubspot/cli-lib/errorHandlers');
31
30
  const { getCwd } = require('@hubspot/cli-lib/path');
31
+ const { promptUser } = require('./prompts/promptUtils');
32
32
  const { EXIT_CODES } = require('./enums/exitCodes');
33
33
  const { uiLine, uiAccountDescription } = require('../lib/ui');
34
34
 
@@ -103,7 +103,7 @@ const createProjectConfig = async (projectPath, projectName, template) => {
103
103
  : `Found an existing project definition in ${projectDir}.`
104
104
  );
105
105
 
106
- const { shouldContinue } = await prompt([
106
+ const { shouldContinue } = await promptUser([
107
107
  {
108
108
  name: 'shouldContinue',
109
109
  message: () => {
@@ -182,7 +182,7 @@ const ensureProjectExists = async (accountId, projectName, forceCreate) => {
182
182
  let shouldCreateProject = forceCreate;
183
183
 
184
184
  if (!shouldCreateProject) {
185
- const promptResult = await prompt([
185
+ const promptResult = await promptUser([
186
186
  {
187
187
  name: 'shouldCreateProject',
188
188
  message: `The project ${projectName} does not exist in ${uiAccountDescription(
@@ -271,6 +271,7 @@ const makeGetTaskStatus = taskType => {
271
271
  const spinnies = new Spinnies({
272
272
  succeedColor: 'white',
273
273
  failColor: 'white',
274
+ failPrefix: chalk.bold('!'),
274
275
  });
275
276
 
276
277
  spinnies.add('overallTaskStatus', { text: 'Beginning' });
@@ -1,9 +1,12 @@
1
- const inquirer = require('inquirer');
1
+ const { promptUser } = require('./promptUtils');
2
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
3
+
4
+ const i18nKey = 'cli.lib.prompts.createApiSamplePrompt';
2
5
 
3
6
  const getSampleTypesPrompt = choices => ({
4
7
  type: 'rawlist',
5
8
  name: 'sampleType',
6
- message: 'Please, select API sample app',
9
+ message: i18n(`${i18nKey}.selectApiSampleApp`),
7
10
  choices: choices.map(choice => ({
8
11
  name: `${choice.name} - ${choice.description}`,
9
12
  value: choice.id,
@@ -13,7 +16,7 @@ const getSampleTypesPrompt = choices => ({
13
16
  if (input.length > 0) {
14
17
  resolve(true);
15
18
  }
16
- reject('Please select API sample app');
19
+ reject(i18n(`${i18nKey}.errors.apiSampleAppRequired`));
17
20
  });
18
21
  },
19
22
  });
@@ -21,7 +24,7 @@ const getSampleTypesPrompt = choices => ({
21
24
  const getLanguagesPrompt = choices => ({
22
25
  type: 'rawlist',
23
26
  name: 'sampleLanguage',
24
- message: "Please, select sample app's language",
27
+ message: i18n(`${i18nKey}.selectLanguage`),
25
28
  choices: choices.map(choice => ({
26
29
  name: choice,
27
30
  value: choice,
@@ -31,7 +34,7 @@ const getLanguagesPrompt = choices => ({
31
34
  if (input.length > 0) {
32
35
  resolve(true);
33
36
  }
34
- reject("Please select API sample app's language");
37
+ reject(i18n(`${i18nKey}.errors.languageRequired`));
35
38
  });
36
39
  },
37
40
  });
@@ -39,16 +42,12 @@ const getLanguagesPrompt = choices => ({
39
42
  const createApiSamplePrompt = async samplesConfig => {
40
43
  try {
41
44
  const { samples } = samplesConfig;
42
- const sampleTypeAnswer = await inquirer.prompt(
43
- getSampleTypesPrompt(samples)
44
- );
45
+ const sampleTypeAnswer = await promptUser(getSampleTypesPrompt(samples));
45
46
  const chosenSample = samples.find(
46
47
  sample => sample.id === sampleTypeAnswer.sampleType
47
48
  );
48
49
  const { languages } = chosenSample;
49
- const languagesAnswer = await inquirer.prompt(
50
- getLanguagesPrompt(languages)
51
- );
50
+ const languagesAnswer = await promptUser(getLanguagesPrompt(languages));
52
51
  return {
53
52
  ...sampleTypeAnswer,
54
53
  ...languagesAnswer,