@hubspot/cli 4.0.2-beta.5 → 4.0.2-beta.7

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.
@@ -12,6 +12,7 @@ const {
12
12
  } = require('../../lib/commonOpts');
13
13
  const { trackCommandUsage } = require('../../lib/usageTracking');
14
14
  const { loadAndValidateOptions } = require('../../lib/validation');
15
+ const { getSandboxType } = require('../../lib/prompts/sandboxesPrompt');
15
16
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
16
17
 
17
18
  const i18nKey = 'cli.commands.accounts.subcommands.list';
@@ -57,7 +58,9 @@ const getPortalData = mappedPortalData => {
57
58
  portalData.push([portal.name, portal.portalId, portal.authType]);
58
59
  } else {
59
60
  portalData.push([
60
- `↳ ${portal.name} [sandbox]`,
61
+ `↳ ${portal.name} [${getSandboxType(
62
+ portal.sandboxAccountType
63
+ )} sandbox]`,
61
64
  portal.portalId,
62
65
  portal.authType,
63
66
  ]);
@@ -15,7 +15,7 @@ const { loadAndValidateOptions } = require('../../lib/validation');
15
15
  const { getProjectConfig, pollDeployStatus } = require('../../lib/projects');
16
16
  const { projectNamePrompt } = require('../../lib/prompts/projectNamePrompt');
17
17
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
18
- // const { getAccountConfig } = require('@hubspot/cli-lib');
18
+ const { getAccountConfig } = require('@hubspot/cli-lib');
19
19
 
20
20
  const i18nKey = 'cli.commands.project.subcommands.deploy';
21
21
  const { EXIT_CODES } = require('../../lib/enums/exitCodes');
@@ -27,11 +27,11 @@ exports.handler = async options => {
27
27
  await loadAndValidateOptions(options);
28
28
 
29
29
  const accountId = getAccountId(options);
30
- // const accountConfig = getAccountConfig(accountId);
30
+ const accountConfig = getAccountConfig(accountId);
31
31
  const { project, buildId } = options;
32
- // const sandboxType = accountConfig && accountConfig.sandboxAccountType;
32
+ const sandboxType = accountConfig && accountConfig.sandboxAccountType;
33
33
 
34
- trackCommandUsage('project-deploy', null, accountId);
34
+ trackCommandUsage('project-deploy', { type: sandboxType }, accountId);
35
35
 
36
36
  const { projectConfig } = await getProjectConfig();
37
37
 
@@ -19,7 +19,7 @@ const {
19
19
  validateProjectConfig,
20
20
  } = require('../../lib/projects');
21
21
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
22
- // const { getAccountConfig } = require('@hubspot/cli-lib');
22
+ const { getAccountConfig } = require('@hubspot/cli-lib');
23
23
  const { EXIT_CODES } = require('../../lib/enums/exitCodes');
24
24
 
25
25
  const i18nKey = 'cli.commands.project.subcommands.upload';
@@ -32,10 +32,10 @@ exports.handler = async options => {
32
32
 
33
33
  const { forceCreate, path: projectPath } = options;
34
34
  const accountId = getAccountId(options);
35
- // const accountConfig = getAccountConfig(accountId);
36
- // const sandboxType = accountConfig && accountConfig.sandboxAccountType;
35
+ const accountConfig = getAccountConfig(accountId);
36
+ const sandboxType = accountConfig && accountConfig.sandboxAccountType;
37
37
 
38
- trackCommandUsage('project-upload', null, accountId);
38
+ trackCommandUsage('project-upload', { type: sandboxType }, accountId);
39
39
 
40
40
  const { projectConfig, projectDir } = await getProjectConfig(projectPath);
41
41
 
@@ -5,6 +5,7 @@ const {
5
5
  ApiErrorContext,
6
6
  } = require('@hubspot/cli-lib/errorHandlers');
7
7
  const { logger } = require('@hubspot/cli-lib/logger');
8
+ const { ERROR_TYPES } = require('@hubspot/cli-lib/lib/constants');
8
9
  const {
9
10
  addAccountOptions,
10
11
  addConfigOptions,
@@ -61,11 +62,15 @@ const handleUserInput = (accountId, projectName, currentBuildId) => {
61
62
  await cancelStagedBuild(accountId, projectName);
62
63
  process.exit(EXIT_CODES.SUCCESS);
63
64
  } catch (err) {
64
- logApiErrorInstance(
65
- err,
66
- new ApiErrorContext({ accountId, projectName: projectName })
67
- );
68
- process.exit(EXIT_CODES.ERROR);
65
+ if (err.error.subCategory === ERROR_TYPES.BUILD_NOT_IN_PROGRESS) {
66
+ process.exit(EXIT_CODES.SUCCESS);
67
+ } else {
68
+ logApiErrorInstance(
69
+ err,
70
+ new ApiErrorContext({ accountId, projectName: projectName })
71
+ );
72
+ process.exit(EXIT_CODES.ERROR);
73
+ }
69
74
  }
70
75
  } else {
71
76
  process.exit(EXIT_CODES.SUCCESS);
@@ -124,6 +124,9 @@ exports.handler = async options => {
124
124
 
125
125
  let namePrompt;
126
126
 
127
+ logger.log(i18n(`${i18nKey}.sandboxLimitation`));
128
+ logger.log('');
129
+
127
130
  if (!name) {
128
131
  namePrompt = await createSandboxPrompt();
129
132
  }
@@ -151,6 +154,8 @@ exports.handler = async options => {
151
154
  } catch (err) {
152
155
  debugErrorAndContext(err);
153
156
 
157
+ trackCommandUsage('sandbox-create', { successful: false }, accountId);
158
+
154
159
  spinnies.fail('sandboxCreate', {
155
160
  text: i18n(`${i18nKey}.loading.fail`, {
156
161
  sandboxName,
@@ -49,6 +49,9 @@ exports.handler = async options => {
49
49
  account: account || accountPrompt.account,
50
50
  });
51
51
 
52
+ const isDefaultAccount =
53
+ sandboxAccountId === getAccountId(config.defaultPortal);
54
+
52
55
  trackCommandUsage('sandbox-delete', null, sandboxAccountId);
53
56
 
54
57
  let parentAccountId;
@@ -91,6 +94,14 @@ exports.handler = async options => {
91
94
  })
92
95
  );
93
96
 
97
+ if (isDefaultAccount) {
98
+ logger.log(
99
+ i18n(`${i18nKey}.defaultAccountWarning`, {
100
+ account: account || accountPrompt.account,
101
+ })
102
+ );
103
+ }
104
+
94
105
  try {
95
106
  const { confirmSandboxDeletePrompt: confirmed } = await promptUser([
96
107
  {
@@ -107,9 +118,12 @@ exports.handler = async options => {
107
118
 
108
119
  await deleteSandbox(parentAccountId, sandboxAccountId);
109
120
 
121
+ const deleteKey = isDefaultAccount
122
+ ? `${i18nKey}.success.deleteDefault`
123
+ : `${i18nKey}.success.delete`;
110
124
  logger.log('');
111
125
  logger.success(
112
- i18n(`${i18nKey}.success.delete`, {
126
+ i18n(deleteKey, {
113
127
  account: account || accountPrompt.account,
114
128
  sandboxHubId: sandboxAccountId,
115
129
  })
@@ -120,12 +134,18 @@ exports.handler = async options => {
120
134
  sandboxAccountId
121
135
  );
122
136
  if (promptDefaultAccount) {
123
- await selectAndSetAsDefaultAccountPrompt(config);
137
+ await selectAndSetAsDefaultAccountPrompt(getConfig());
124
138
  }
125
139
  process.exit(EXIT_CODES.SUCCESS);
126
140
  } catch (err) {
127
141
  debugErrorAndContext(err);
128
142
 
143
+ trackCommandUsage(
144
+ 'sandbox-delete',
145
+ { successful: false },
146
+ sandboxAccountId
147
+ );
148
+
129
149
  if (
130
150
  err.error &&
131
151
  err.error.category === OBJECT_NOT_FOUND &&
@@ -143,7 +163,7 @@ exports.handler = async options => {
143
163
  sandboxAccountId
144
164
  );
145
165
  if (promptDefaultAccount) {
146
- await selectAndSetAsDefaultAccountPrompt(config);
166
+ await selectAndSetAsDefaultAccountPrompt(getConfig());
147
167
  }
148
168
  process.exit(EXIT_CODES.SUCCESS);
149
169
  } else {
@@ -14,6 +14,7 @@ const {
14
14
  addUseEnvironmentOptions,
15
15
  getAccountId,
16
16
  } = require('../../lib/commonOpts');
17
+ const { uiAccountDescription } = require('../../lib/ui');
17
18
  const { secretValuePrompt } = require('../../lib/prompts/secretPrompt');
18
19
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
19
20
 
@@ -36,7 +37,7 @@ exports.handler = async options => {
36
37
  await addSecret(accountId, secretName, secretValue);
37
38
  logger.success(
38
39
  i18n(`${i18nKey}.success.add`, {
39
- accountId,
40
+ accountIdentifier: uiAccountDescription(accountId),
40
41
  secretName,
41
42
  })
42
43
  );
@@ -7,6 +7,7 @@ const { deleteSecret } = require('@hubspot/cli-lib/api/secrets');
7
7
 
8
8
  const { loadAndValidateOptions } = require('../../lib/validation');
9
9
  const { trackCommandUsage } = require('../../lib/usageTracking');
10
+ const { uiAccountDescription } = require('../../lib/ui');
10
11
 
11
12
  const {
12
13
  addConfigOptions,
@@ -33,7 +34,7 @@ exports.handler = async options => {
33
34
  await deleteSecret(accountId, secretName);
34
35
  logger.success(
35
36
  i18n(`${i18nKey}.success.delete`, {
36
- accountId,
37
+ accountIdentifier: uiAccountDescription(accountId),
37
38
  secretName,
38
39
  })
39
40
  );
@@ -7,6 +7,7 @@ const { fetchSecrets } = require('@hubspot/cli-lib/api/secrets');
7
7
 
8
8
  const { loadAndValidateOptions } = require('../../lib/validation');
9
9
  const { trackCommandUsage } = require('../../lib/usageTracking');
10
+ const { uiAccountDescription } = require('../../lib/ui');
10
11
 
11
12
  const {
12
13
  addConfigOptions,
@@ -30,7 +31,7 @@ exports.handler = async options => {
30
31
  try {
31
32
  const { results } = await fetchSecrets(accountId);
32
33
  const groupLabel = i18n(`${i18nKey}.groupLabel`, {
33
- accountId,
34
+ accountIdentifier: uiAccountDescription(accountId),
34
35
  });
35
36
  logger.group(groupLabel);
36
37
  results.forEach(secret => logger.log(secret));
@@ -7,6 +7,7 @@ const { updateSecret } = require('@hubspot/cli-lib/api/secrets');
7
7
 
8
8
  const { loadAndValidateOptions } = require('../../lib/validation');
9
9
  const { trackCommandUsage } = require('../../lib/usageTracking');
10
+ const { uiAccountDescription } = require('../../lib/ui');
10
11
 
11
12
  const {
12
13
  addConfigOptions,
@@ -36,10 +37,11 @@ exports.handler = async options => {
36
37
  await updateSecret(accountId, secretName, secretValue);
37
38
  logger.success(
38
39
  i18n(`${i18nKey}.success.update`, {
39
- accountId,
40
+ accountIdentifier: uiAccountDescription(accountId),
40
41
  secretName,
41
42
  })
42
43
  );
44
+ logger.log(i18n(`${i18nKey}.success.updateReupload`));
43
45
  } catch (e) {
44
46
  logger.error(
45
47
  i18n(`${i18nKey}.errors.update`, {
@@ -78,13 +78,16 @@ exports.handler = async options => {
78
78
  logger.error(i18n(`${i18nKey}.errors.destinationRequired`));
79
79
  return;
80
80
  }
81
- // The theme.json file must always be at the root of the project - so we look for that and determine the root path based on it.
82
- const projectRoot = path.dirname(getThemeJSONPath(absoluteSrcPath));
83
- const processFieldsJs = isProcessableFieldsJs(
84
- projectRoot,
85
- absoluteSrcPath,
86
- options.processFieldsJs
87
- );
81
+ // Check for theme.json file and determine the root path for the project based on it if it exists
82
+ const themeJsonPath = getThemeJSONPath(absoluteSrcPath);
83
+ const projectRoot = themeJsonPath && path.dirname(themeJsonPath);
84
+ const processFieldsJs =
85
+ projectRoot &&
86
+ isProcessableFieldsJs(
87
+ projectRoot,
88
+ absoluteSrcPath,
89
+ options.processFieldsJs
90
+ );
88
91
  let fieldsJs;
89
92
  if (processFieldsJs) {
90
93
  fieldsJs = await new FieldsJs(
package/lib/projects.js CHANGED
@@ -387,7 +387,7 @@ const makePollTaskStatusFunc = ({
387
387
  const subTaskName = subTask[statusText.SUBTASK_NAME_KEY];
388
388
 
389
389
  spinnies.add(subTaskName, {
390
- text: `${chalk.bold(subTaskName)} #${displayId} ${
390
+ text: `${chalk.bold(subTaskName)} ${
391
391
  statusText.STATUS_TEXT[statusText.STATES.ENQUEUED]
392
392
  }\n`,
393
393
  indent: 2,
@@ -410,7 +410,7 @@ const makePollTaskStatusFunc = ({
410
410
  return;
411
411
  }
412
412
 
413
- const updatedText = `${chalk.bold(subTaskName)} #${displayId} ${
413
+ const updatedText = `${chalk.bold(subTaskName)} ${
414
414
  statusText.STATUS_TEXT[subTask.status]
415
415
  }\n`;
416
416
 
@@ -1,6 +1,7 @@
1
1
  const { updateDefaultAccount } = require('@hubspot/cli-lib/lib/config');
2
2
  const { promptUser } = require('./promptUtils');
3
3
  const { i18n } = require('@hubspot/cli-lib/lib/lang');
4
+ const { mapAccountChoices } = require('./sandboxesPrompt');
4
5
 
5
6
  const i18nKey = 'cli.commands.accounts.subcommands.use';
6
7
 
@@ -12,10 +13,7 @@ const selectAccountFromConfig = async config => {
12
13
  name: 'default',
13
14
  pageSize: 20,
14
15
  message: i18n(`${i18nKey}.promptMessage`),
15
- choices: config.portals.map(p => ({
16
- name: `${p.name} (${p.portalId})`,
17
- value: p.name || p.portalId,
18
- })),
16
+ choices: mapAccountChoices(config.portals),
19
17
  default: config.defaultPortal,
20
18
  },
21
19
  ]);
@@ -31,10 +29,7 @@ const selectAndSetAsDefaultAccountPrompt = async config => {
31
29
  name: 'default',
32
30
  pageSize: 20,
33
31
  message: i18n(`${i18nKey}.promptMessage`),
34
- choices: config.portals.map(p => ({
35
- name: `${p.name} (${p.portalId})`,
36
- value: p.name || p.portalId,
37
- })),
32
+ choices: mapAccountChoices(config.portals),
38
33
  default: config.defaultPortal,
39
34
  },
40
35
  ]);
@@ -3,6 +3,19 @@ const { i18n } = require('@hubspot/cli-lib/lib/lang');
3
3
 
4
4
  const i18nKey = 'cli.lib.prompts.sandboxesPrompt';
5
5
 
6
+ const getSandboxType = type =>
7
+ type === 'DEVELOPER' ? 'development' : 'standard';
8
+
9
+ const mapAccountChoices = portals =>
10
+ portals.map(p => {
11
+ const isSandbox = p.sandboxAccountType !== null;
12
+ const sandboxName = `[${getSandboxType(p.sandboxAccountType)} sandbox] `;
13
+ return {
14
+ name: `${p.name} ${isSandbox ? sandboxName : ''}(${p.portalId})`,
15
+ value: p.name || p.portalId,
16
+ };
17
+ });
18
+
6
19
  const createSandboxPrompt = () => {
7
20
  return promptUser([
8
21
  {
@@ -31,7 +44,7 @@ const deleteSandboxPrompt = (config, promptParentAccount = false) => {
31
44
  type: 'list',
32
45
  look: false,
33
46
  pageSize: 20,
34
- choices: config.portals.map(p => p.name || p.portalId),
47
+ choices: mapAccountChoices(config.portals),
35
48
  default: config.defaultPortal,
36
49
  },
37
50
  ]);
@@ -40,4 +53,6 @@ const deleteSandboxPrompt = (config, promptParentAccount = false) => {
40
53
  module.exports = {
41
54
  createSandboxPrompt,
42
55
  deleteSandboxPrompt,
56
+ getSandboxType,
57
+ mapAccountChoices,
43
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "4.0.2-beta.5",
3
+ "version": "4.0.2-beta.7",
4
4
  "description": "CLI for working with HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,8 +8,8 @@
8
8
  "url": "https://github.com/HubSpot/hubspot-cms-tools"
9
9
  },
10
10
  "dependencies": {
11
- "@hubspot/cli-lib": "4.0.2-beta.5",
12
- "@hubspot/serverless-dev-runtime": "4.0.2-beta.5",
11
+ "@hubspot/cli-lib": "4.0.2-beta.7",
12
+ "@hubspot/serverless-dev-runtime": "4.0.2-beta.7",
13
13
  "archiver": "^5.3.0",
14
14
  "chalk": "^4.1.2",
15
15
  "express": "^4.17.1",
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "3c4cd0095cfd6b115da0c91def008240386b52a5"
40
+ "gitHead": "0fe48550b57c3f8326262ed19decaeb4930f8c3a"
41
41
  }