@hubspot/cli 4.0.1-beta.1 → 4.0.1-beta.2

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.
@@ -0,0 +1,53 @@
1
+ const { logger } = require('@hubspot/cli-lib/logger');
2
+ const { getAccountConfig } = require('@hubspot/cli-lib/lib/config');
3
+ const { getAccessToken } = require('@hubspot/cli-lib/personalAccessKey.js');
4
+ const {
5
+ getAccountId,
6
+ addAccountOptions,
7
+ addConfigOptions,
8
+ } = require('../../lib/commonOpts');
9
+ const { loadAndValidateOptions } = require('../../lib/validation');
10
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
11
+
12
+ const i18nKey = 'cli.commands.accounts.subcommands.info';
13
+ exports.describe = i18n(`${i18nKey}.describe`);
14
+
15
+ exports.command = 'info [--account]';
16
+
17
+ exports.handler = async options => {
18
+ await loadAndValidateOptions(options);
19
+
20
+ let accountId = getAccountId(options);
21
+ const config = getAccountConfig(accountId);
22
+
23
+ // check if the provided account is using a personal access key, if not, show an error
24
+ if (config.authType === 'personalaccesskey') {
25
+ const { name, personalAccessKey, env } = config;
26
+
27
+ const response = await getAccessToken(personalAccessKey, env, accountId);
28
+
29
+ let scopeGroups = response.scopeGroups.join('\n');
30
+
31
+ logger.log(i18n(`${i18nKey}.name`, { name }));
32
+ logger.log(i18n(`${i18nKey}.accountId`, { accountId }));
33
+ logger.log(i18n(`${i18nKey}.scopeGroups`, { scopeGroups }));
34
+ } else {
35
+ logger.log(i18n(`${i18nKey}.errors.notUsingPersonalAccessKey`));
36
+ }
37
+ };
38
+
39
+ exports.builder = yargs => {
40
+ addConfigOptions(yargs, true);
41
+ addAccountOptions(yargs, true);
42
+
43
+ yargs.example([
44
+ ['$0 accounts info', i18n(`${i18nKey}.examples.default`)],
45
+ [
46
+ '$0 accounts info --account=MyAccount',
47
+ i18n(`${i18nKey}.examples.nameBased`),
48
+ ],
49
+ ['$0 accounts info --account=1234567', i18n(`${i18nKey}.examples.idBased`)],
50
+ ]);
51
+
52
+ return yargs;
53
+ };
@@ -19,6 +19,54 @@ const i18nKey = 'cli.commands.accounts.subcommands.list';
19
19
  exports.command = 'list';
20
20
  exports.describe = i18n(`${i18nKey}.describe`);
21
21
 
22
+ const sortAndMapPortals = portals => {
23
+ const mappedPortalData = {};
24
+ portals
25
+ .sort((a, b) => {
26
+ if (a.sandboxAccountType === null && b.sandboxAccountType !== null) {
27
+ return -1;
28
+ }
29
+ if (a.sandboxAccountType !== null && b.sandboxAccountType === null) {
30
+ return 1;
31
+ }
32
+ return 0;
33
+ })
34
+ .forEach(portal => {
35
+ if (
36
+ portal.sandboxAccountType !== undefined &&
37
+ portal.sandboxAccountType === null
38
+ ) {
39
+ mappedPortalData[portal.portalId] = [portal];
40
+ } else if (portal.sandboxAccountType && portal.parentAccountId) {
41
+ mappedPortalData[portal.parentAccountId] = [
42
+ ...(mappedPortalData[portal.parentAccountId] || []),
43
+ portal,
44
+ ];
45
+ } else {
46
+ mappedPortalData[portal.portalId] = [portal];
47
+ }
48
+ });
49
+ return mappedPortalData;
50
+ };
51
+
52
+ const getPortalData = mappedPortalData => {
53
+ const portalData = [];
54
+ Object.values(mappedPortalData).forEach(set => {
55
+ set.forEach((portal, i) => {
56
+ if (i === 0) {
57
+ portalData.push([portal.name, portal.portalId, portal.authType]);
58
+ } else {
59
+ portalData.push([
60
+ `↳ ${portal.name} [sandbox]`,
61
+ portal.portalId,
62
+ portal.authType,
63
+ ]);
64
+ }
65
+ });
66
+ });
67
+ return portalData;
68
+ };
69
+
22
70
  exports.handler = async options => {
23
71
  await loadAndValidateOptions(options);
24
72
 
@@ -28,9 +76,8 @@ exports.handler = async options => {
28
76
 
29
77
  const config = getConfig();
30
78
  const configPath = getConfigPath();
31
- const portalData = config.portals.map(portal => {
32
- return [portal.name, portal.portalId, portal.authType];
33
- });
79
+ const mappedPortalData = sortAndMapPortals(config.portals);
80
+ const portalData = getPortalData(mappedPortalData);
34
81
  portalData.unshift(
35
82
  getTableHeader([
36
83
  i18n(`${i18nKey}.labels.name`),
@@ -3,6 +3,7 @@ const { i18n } = require('@hubspot/cli-lib/lib/lang');
3
3
  const list = require('./accounts/list');
4
4
  const rename = require('./accounts/rename');
5
5
  const use = require('./accounts/use');
6
+ const info = require('./accounts/info');
6
7
 
7
8
  const i18nKey = 'cli.commands.accounts';
8
9
 
@@ -20,6 +21,7 @@ exports.builder = yargs => {
20
21
  })
21
22
  .command(rename)
22
23
  .command(use)
24
+ .command(info)
23
25
  .demandCommand(1, '');
24
26
 
25
27
  return yargs;
@@ -157,6 +157,8 @@ exports.handler = async options => {
157
157
  url,
158
158
  })
159
159
  );
160
+ } else {
161
+ logger.error(err.error.message);
160
162
  }
161
163
  process.exit(EXIT_CODES.ERROR);
162
164
  }
@@ -0,0 +1,41 @@
1
+ const {
2
+ addAccountOptions,
3
+ addConfigOptions,
4
+ addUseEnvironmentOptions,
5
+ } = require('../../lib/commonOpts');
6
+ const { logger } = require('@hubspot/cli-lib/logger');
7
+
8
+ const { loadAndValidateOptions } = require('../../lib/validation');
9
+ const { i18n } = require('@hubspot/cli-lib/lib/lang');
10
+
11
+ const i18nKey = 'cli.commands.sandbox.subcommands.delete';
12
+
13
+ exports.command = 'delete';
14
+ exports.describe = i18n(`${i18nKey}.describe`);
15
+
16
+ exports.handler = async options => {
17
+ await loadAndValidateOptions(options);
18
+
19
+ logger.log('');
20
+ logger.log(i18n(`${i18nKey}.temporaryMessage`));
21
+ };
22
+
23
+ exports.builder = yargs => {
24
+ yargs.option('account', {
25
+ describe: i18n(`${i18nKey}.options.account.describe`),
26
+ type: 'string',
27
+ });
28
+
29
+ yargs.example([
30
+ [
31
+ '$0 sandbox delete --account=MySandboxAccount',
32
+ i18n(`${i18nKey}.examples.default`),
33
+ ],
34
+ ]);
35
+
36
+ addConfigOptions(yargs, true);
37
+ addAccountOptions(yargs, true);
38
+ addUseEnvironmentOptions(yargs, true);
39
+
40
+ return yargs;
41
+ };
@@ -1,5 +1,6 @@
1
1
  const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
2
2
  const create = require('./sandbox/create');
3
+ const del = require('./sandbox/delete');
3
4
 
4
5
  // const i18nKey = 'cli.commands.sandbox';
5
6
 
@@ -10,7 +11,10 @@ exports.builder = yargs => {
10
11
  addConfigOptions(yargs, true);
11
12
  addAccountOptions(yargs, true);
12
13
 
13
- yargs.command(create).demandCommand(1, '');
14
+ yargs
15
+ .command(create)
16
+ .command(del)
17
+ .demandCommand(1, '');
14
18
 
15
19
  return yargs;
16
20
  };
package/lib/projects.js CHANGED
@@ -449,6 +449,14 @@ const makePollTaskStatusFunc = ({
449
449
  } with the following error ---`
450
450
  );
451
451
  logger.error(subTask.errorMessage);
452
+
453
+ // Log nested errors
454
+ if (subTask.standardError && subTask.standardError.errors) {
455
+ logger.log();
456
+ subTask.standardError.errors.forEach(error => {
457
+ logger.log(error.message);
458
+ });
459
+ }
452
460
  });
453
461
  }
454
462
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "4.0.1-beta.1",
3
+ "version": "4.0.1-beta.2",
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.1-beta.1",
12
- "@hubspot/serverless-dev-runtime": "4.0.1-beta.1",
11
+ "@hubspot/cli-lib": "4.0.1-beta.2",
12
+ "@hubspot/serverless-dev-runtime": "4.0.1-beta.2",
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": "eb69a779b705cb7cd43f2c2930fb09f2121283b1"
40
+ "gitHead": "c8b5dbfe4753fc1b71c038801d5f641313712e71"
41
41
  }