@hubspot/local-dev-lib 0.0.7 → 0.0.9

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 (81) hide show
  1. package/api/customObjects.js +3 -3
  2. package/api/fileMapper.d.ts +2 -0
  3. package/api/fileMapper.js +3 -2
  4. package/api/functions.js +1 -1
  5. package/api/hubdb.js +4 -4
  6. package/api/lighthouseScore.d.ts +2 -2
  7. package/api/lighthouseScore.js +2 -2
  8. package/api/localDevAuth.d.ts +5 -1
  9. package/api/localDevAuth.js +1 -1
  10. package/api/marketplaceValidation.d.ts +2 -2
  11. package/api/marketplaceValidation.js +2 -2
  12. package/api/projects.js +2 -2
  13. package/api/sandboxHubs.js +1 -1
  14. package/api/sandboxSync.js +1 -1
  15. package/api/secrets.js +2 -2
  16. package/api/validateHubl.js +1 -1
  17. package/config/CLIConfiguration.js +20 -18
  18. package/config/configFile.js +1 -2
  19. package/config/configUtils.js +2 -1
  20. package/config/config_DEPRECATED.js +27 -24
  21. package/config/environment.js +4 -3
  22. package/constants/ports.d.ts +3 -0
  23. package/constants/ports.js +6 -0
  24. package/errors/apiErrors.d.ts +1 -1
  25. package/errors/apiErrors.js +13 -13
  26. package/errors/errors_DEPRECATED.js +2 -2
  27. package/errors/fileSystemErrors.js +1 -1
  28. package/errors/standardErrors.d.ts +4 -3
  29. package/errors/standardErrors.js +2 -2
  30. package/http/index.js +8 -4
  31. package/lang/en.json +383 -0
  32. package/lang/lang/en.json +383 -0
  33. package/lib/archive.js +10 -9
  34. package/lib/cms/functions.js +13 -13
  35. package/lib/cms/handleFieldsJS.js +8 -6
  36. package/lib/cms/modules.js +5 -4
  37. package/lib/cms/processFieldsJs.js +6 -8
  38. package/lib/cms/templates.js +10 -5
  39. package/lib/cms/uploadFolder.js +11 -7
  40. package/lib/cms/watch.js +33 -21
  41. package/lib/customObjects.d.ts +4 -4
  42. package/lib/customObjects.js +21 -4
  43. package/lib/fileMapper.js +28 -21
  44. package/lib/github.js +15 -11
  45. package/lib/gitignore.js +2 -1
  46. package/lib/hubdb.d.ts +1 -1
  47. package/lib/hubdb.js +5 -4
  48. package/lib/logging/git.js +1 -1
  49. package/lib/logging/logs.js +5 -1
  50. package/lib/oauth.js +5 -4
  51. package/lib/personalAccessKey.d.ts +1 -1
  52. package/lib/personalAccessKey.js +6 -5
  53. package/lib/portManager.d.ts +13 -0
  54. package/lib/portManager.js +45 -0
  55. package/lib/sandboxes.js +7 -7
  56. package/lib/trackUsage.js +3 -3
  57. package/models/HubSpotAuthError.d.ts +1 -1
  58. package/models/HubSpotAuthError.js +2 -2
  59. package/models/OAuth2Manager.d.ts +1 -1
  60. package/models/OAuth2Manager.js +5 -5
  61. package/package.json +7 -2
  62. package/types/Error.d.ts +3 -3
  63. package/types/Http.d.ts +8 -11
  64. package/types/Hubdb.d.ts +27 -17
  65. package/types/Lang.d.ts +7 -0
  66. package/types/Lang.js +2 -0
  67. package/types/PortManager.d.ts +4 -0
  68. package/types/PortManager.js +2 -0
  69. package/types/Schemas.d.ts +18 -33
  70. package/types/Utils.d.ts +5 -0
  71. package/utils/PortManagerServer.d.ts +29 -0
  72. package/utils/PortManagerServer.js +158 -0
  73. package/utils/cms/modules.js +2 -1
  74. package/utils/detectPort.d.ts +1 -0
  75. package/utils/detectPort.js +102 -0
  76. package/utils/lang.d.ts +2 -4
  77. package/utils/lang.js +12 -14
  78. package/utils/logger.d.ts +4 -3
  79. package/utils/logger.js +4 -3
  80. package/utils/notify.js +2 -1
  81. package/lang/en.lyaml +0 -247
@@ -10,21 +10,21 @@ const SCHEMA_API_PATH = 'crm-object-schemas/v3/schemas';
10
10
  async function batchCreateObjects(accountId, objectTypeId, objects) {
11
11
  http_1.default.post(accountId, {
12
12
  url: `${CUSTOM_OBJECTS_API_PATH}/${objectTypeId}/batch/create`,
13
- body: objects,
13
+ data: objects,
14
14
  });
15
15
  }
16
16
  exports.batchCreateObjects = batchCreateObjects;
17
17
  async function createObjectSchema(accountId, schema) {
18
18
  return http_1.default.post(accountId, {
19
19
  url: SCHEMA_API_PATH,
20
- body: schema,
20
+ data: schema,
21
21
  });
22
22
  }
23
23
  exports.createObjectSchema = createObjectSchema;
24
24
  async function updateObjectSchema(accountId, schemaObjectType, schema) {
25
25
  return http_1.default.patch(accountId, {
26
26
  url: `${SCHEMA_API_PATH}/${schemaObjectType}`,
27
- body: schema,
27
+ data: schema,
28
28
  });
29
29
  }
30
30
  exports.updateObjectSchema = updateObjectSchema;
@@ -1,5 +1,7 @@
1
+ import { AxiosResponse } from 'axios';
1
2
  import { FileMapperNode, FileMapperOptions, FileTree } from '../types/Files';
2
3
  export declare const FILE_MAPPER_API_PATH = "content/filemapper/v1";
4
+ export declare function createFileMapperNodeFromStreamResponse(filePath: string, response: Partial<AxiosResponse>): FileMapperNode;
3
5
  export declare function upload(accountId: number, src: string, dest: string, options?: FileMapperOptions): Promise<void>;
4
6
  export declare function fetchModule(accountId: number, moduleId: number, options?: FileMapperOptions): Promise<FileTree>;
5
7
  export declare function fetchFileStream(accountId: number, filePath: string, destination: string, options?: FileMapperOptions): Promise<FileMapperNode>;
package/api/fileMapper.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getDirectoryContentsByPath = exports.moveFile = exports.deleteFile = exports.downloadDefault = exports.download = exports.fetchFileStream = exports.fetchModule = exports.upload = exports.FILE_MAPPER_API_PATH = void 0;
6
+ exports.getDirectoryContentsByPath = exports.moveFile = exports.deleteFile = exports.downloadDefault = exports.download = exports.fetchFileStream = exports.fetchModule = exports.upload = exports.createFileMapperNodeFromStreamResponse = exports.FILE_MAPPER_API_PATH = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const content_disposition_1 = __importDefault(require("content-disposition"));
@@ -37,6 +37,7 @@ function createFileMapperNodeFromStreamResponse(filePath, response) {
37
37
  updatedAt: parseInt(parameters['modification-date'], 10) || 0,
38
38
  };
39
39
  }
40
+ exports.createFileMapperNodeFromStreamResponse = createFileMapperNodeFromStreamResponse;
40
41
  async function upload(accountId, src, dest, options = {}) {
41
42
  return http_1.default.post(accountId, {
42
43
  url: `${exports.FILE_MAPPER_API_PATH}/upload/${encodeURIComponent(dest)}`,
@@ -55,7 +56,7 @@ async function fetchModule(accountId, moduleId, options = {}) {
55
56
  });
56
57
  }
57
58
  exports.fetchModule = fetchModule;
58
- //Fetch a file by file path.
59
+ // Fetch a file by file path.
59
60
  async function fetchFileStream(accountId, filePath, destination, options = {}) {
60
61
  const response = await http_1.default.getOctetStream(accountId, {
61
62
  url: `${exports.FILE_MAPPER_API_PATH}/stream/${encodeURIComponent(filePath)}`,
package/api/functions.js CHANGED
@@ -18,7 +18,7 @@ async function buildPackage(accountId, folderPath) {
18
18
  headers: {
19
19
  Accept: 'text/plain',
20
20
  },
21
- body: {
21
+ data: {
22
22
  folderPath,
23
23
  },
24
24
  });
package/api/hubdb.js CHANGED
@@ -15,14 +15,14 @@ exports.fetchTable = fetchTable;
15
15
  async function createTable(accountId, schema) {
16
16
  return http_1.default.post(accountId, {
17
17
  url: `${HUBDB_API_PATH}/tables`,
18
- body: schema,
18
+ data: schema,
19
19
  });
20
20
  }
21
21
  exports.createTable = createTable;
22
22
  async function updateTable(accountId, tableId, schema) {
23
23
  return http_1.default.patch(accountId, {
24
24
  url: `${HUBDB_API_PATH}/tables/${tableId}/draft`,
25
- body: schema,
25
+ data: schema,
26
26
  });
27
27
  }
28
28
  exports.updateTable = updateTable;
@@ -41,7 +41,7 @@ exports.deleteTable = deleteTable;
41
41
  async function createRows(accountId, tableId, rows) {
42
42
  return http_1.default.post(accountId, {
43
43
  url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/create`,
44
- body: { inputs: rows },
44
+ data: { inputs: rows },
45
45
  });
46
46
  }
47
47
  exports.createRows = createRows;
@@ -55,7 +55,7 @@ exports.fetchRows = fetchRows;
55
55
  async function deleteRows(accountId, tableId, rowIds) {
56
56
  return http_1.default.post(accountId, {
57
57
  url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/purge`,
58
- body: { inputs: rowIds },
58
+ data: { inputs: rowIds },
59
59
  });
60
60
  }
61
61
  exports.deleteRows = deleteRows;
@@ -1,5 +1,5 @@
1
- import { Body, QueryParams } from '../types/Http';
1
+ import { Data, QueryParams } from '../types/Http';
2
2
  import { GetLighthouseScoreResponse, RequestLighthouseScoreResponse } from '../types/Lighthouse';
3
- export declare function requestLighthouseScore(accountId: number, body?: Body): Promise<RequestLighthouseScoreResponse>;
3
+ export declare function requestLighthouseScore(accountId: number, data?: Data): Promise<RequestLighthouseScoreResponse>;
4
4
  export declare function getLighthouseScoreStatus(accountId: number, query?: QueryParams): Promise<string>;
5
5
  export declare function getLighthouseScore(accountId: number, query?: QueryParams): Promise<GetLighthouseScoreResponse>;
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getLighthouseScore = exports.getLighthouseScoreStatus = exports.requestLighthouseScore = void 0;
7
7
  const http_1 = __importDefault(require("../http"));
8
8
  const LIGHTHOUSE_SCORE_API_BASE = 'quality-engine/v1/lighthouse';
9
- async function requestLighthouseScore(accountId, body = {}) {
9
+ async function requestLighthouseScore(accountId, data = {}) {
10
10
  return http_1.default.post(accountId, {
11
11
  url: `${LIGHTHOUSE_SCORE_API_BASE}/request`,
12
- body,
12
+ data,
13
13
  });
14
14
  }
15
15
  exports.requestLighthouseScore = requestLighthouseScore;
@@ -2,10 +2,14 @@ import { Environment } from '../types/Config';
2
2
  import { ScopeData } from '../types/Accounts';
3
3
  type AccessTokenResponse = {
4
4
  hubId: number;
5
+ userId: number;
5
6
  oauthAccessToken: string;
6
7
  expiresAtMillis: number;
8
+ enabledFeatures?: {
9
+ [key: string]: number;
10
+ };
7
11
  scopeGroups: Array<string>;
8
- encodedOauthRefreshToken: string;
12
+ encodedOAuthRefreshToken: string;
9
13
  };
10
14
  export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): Promise<AccessTokenResponse>;
11
15
  export declare function fetchScopeData(accountId: number, scopeGroup: string): Promise<ScopeData>;
@@ -15,7 +15,7 @@ async function fetchAccessToken(personalAccessKey, env = environments_1.ENVIRONM
15
15
  env,
16
16
  localHostOverride: true,
17
17
  url: `${LOCALDEVAUTH_API_AUTH_PATH}/refresh`,
18
- body: {
18
+ data: {
19
19
  encodedOAuthRefreshToken: personalAccessKey,
20
20
  },
21
21
  params: query,
@@ -1,5 +1,5 @@
1
- import { Body, QueryParams } from '../types/Http';
1
+ import { Data, QueryParams } from '../types/Http';
2
2
  import { GetValidationResultsResponse } from '../types/MarketplaceValidation';
3
- export declare function requestValidation(accountId: number, body?: Body): Promise<number>;
3
+ export declare function requestValidation(accountId: number, data?: Data): Promise<number>;
4
4
  export declare function getValidationStatus(accountId: number, query?: QueryParams): Promise<string>;
5
5
  export declare function getValidationResults(accountId: number, query?: QueryParams): Promise<GetValidationResultsResponse>;
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getValidationResults = exports.getValidationStatus = exports.requestValidation = void 0;
7
7
  const http_1 = __importDefault(require("../http"));
8
8
  const VALIDATION_API_BASE = 'quality-engine/v1/validation';
9
- function requestValidation(accountId, body = {}) {
9
+ function requestValidation(accountId, data = {}) {
10
10
  return http_1.default.post(accountId, {
11
11
  url: `${VALIDATION_API_BASE}/request`,
12
- body,
12
+ data,
13
13
  });
14
14
  }
15
15
  exports.requestValidation = requestValidation;
package/api/projects.js CHANGED
@@ -18,7 +18,7 @@ exports.fetchProjects = fetchProjects;
18
18
  async function createProject(accountId, name) {
19
19
  return http_1.default.post(accountId, {
20
20
  url: PROJECTS_API_PATH,
21
- body: {
21
+ data: {
22
22
  name,
23
23
  },
24
24
  });
@@ -87,7 +87,7 @@ exports.getBuildStructure = getBuildStructure;
87
87
  async function deployProject(accountId, projectName, buildId) {
88
88
  return http_1.default.post(accountId, {
89
89
  url: `${PROJECTS_DEPLOY_API_PATH}/deploys/queue/async`,
90
- body: {
90
+ data: {
91
91
  projectName,
92
92
  buildId,
93
93
  },
@@ -13,7 +13,7 @@ const SANDBOX_API_PATH = 'sandbox-hubs/v1';
13
13
  const SANDBOX_API_PATH_V2 = 'sandbox-hubs/v2';
14
14
  async function createSandbox(accountId, name, type) {
15
15
  return http_1.default.post(accountId, {
16
- body: { name, type, generatePersonalAccessKey: true },
16
+ data: { name, type, generatePersonalAccessKey: true },
17
17
  timeout: api_1.SANDBOX_TIMEOUT,
18
18
  url: SANDBOX_API_PATH_V2, // Create uses v2 for sandbox type and PAK generation support
19
19
  });
@@ -9,7 +9,7 @@ const api_1 = require("../constants/api");
9
9
  const SANDBOXES_SYNC_API_PATH = 'sandboxes-sync/v1';
10
10
  async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
11
11
  return http_1.default.post(fromHubId, {
12
- body: {
12
+ data: {
13
13
  command: 'SYNC',
14
14
  fromHubId,
15
15
  toHubId,
package/api/secrets.js CHANGED
@@ -9,7 +9,7 @@ const SECRETS_API_PATH = 'cms/v3/functions/secrets';
9
9
  async function addSecret(accountId, key, value) {
10
10
  return http_1.default.post(accountId, {
11
11
  url: SECRETS_API_PATH,
12
- body: {
12
+ data: {
13
13
  key,
14
14
  secret: value,
15
15
  },
@@ -19,7 +19,7 @@ exports.addSecret = addSecret;
19
19
  async function updateSecret(accountId, key, value) {
20
20
  return http_1.default.put(accountId, {
21
21
  url: SECRETS_API_PATH,
22
- body: {
22
+ data: {
23
23
  key,
24
24
  secret: value,
25
25
  },
@@ -9,7 +9,7 @@ const HUBL_VALIDATE_API_PATH = 'cos-rendering/v1/internal/validate';
9
9
  async function validateHubl(accountId, sourceCode, hublValidationOptions) {
10
10
  return http_1.default.post(accountId, {
11
11
  url: HUBL_VALIDATE_API_PATH,
12
- body: {
12
+ data: {
13
13
  template_source: sourceCode,
14
14
  ...hublValidationOptions,
15
15
  },
@@ -98,7 +98,7 @@ class CLIConfiguration {
98
98
  return this.config;
99
99
  }
100
100
  validate(logCallbacks) {
101
- const validateLogger = (0, logger_1.makeTypedLogger)(logCallbacks, 'config.cliConfiguration.validate');
101
+ const validateLogger = (0, logger_1.makeTypedLogger)(logCallbacks);
102
102
  if (!this.config) {
103
103
  validateLogger('noConfig');
104
104
  return false;
@@ -119,20 +119,20 @@ class CLIConfiguration {
119
119
  return false;
120
120
  }
121
121
  if (accountIdsMap[accountConfig.accountId]) {
122
- validateLogger('duplicateAccountIds', {
122
+ validateLogger('duplicateAccountIds', `${i18nKey}.validate.duplicateAccountIds`, {
123
123
  accountId: accountConfig.accountId,
124
124
  });
125
125
  return false;
126
126
  }
127
127
  if (accountConfig.name) {
128
128
  if (accountNamesMap[accountConfig.name]) {
129
- validateLogger('duplicateAccountNames', {
129
+ validateLogger('duplicateAccountNames', `${i18nKey}.validate.duplicateAccountNames`, {
130
130
  accountName: accountConfig.name,
131
131
  });
132
132
  return false;
133
133
  }
134
134
  if (/\s+/.test(accountConfig.name)) {
135
- validateLogger('nameContainsSpaces', {
135
+ validateLogger('nameContainsSpaces', `${i18nKey}.validate.nameContainsSpaces`, {
136
136
  accountName: accountConfig.name,
137
137
  });
138
138
  return false;
@@ -236,7 +236,7 @@ class CLIConfiguration {
236
236
  updateAccount(updatedAccountFields, writeUpdate = true) {
237
237
  const { accountId, apiKey, authType, clientId, clientSecret, defaultMode, env, name, parentAccountId, personalAccessKey, sandboxAccountType, scopes, tokenInfo, } = updatedAccountFields;
238
238
  if (!accountId) {
239
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateAccount`);
239
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateAccount.errors.accountIdRequired`);
240
240
  }
241
241
  if (!this.config) {
242
242
  (0, logger_1.debug)(`${i18nKey}.updateAccount.noConfigToUpdate`);
@@ -308,11 +308,11 @@ class CLIConfiguration {
308
308
  */
309
309
  updateDefaultAccount(defaultAccount) {
310
310
  if (!this.config) {
311
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.noConfigLoaded`);
311
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
312
312
  }
313
313
  if (!defaultAccount ||
314
314
  (typeof defaultAccount !== 'number' && typeof defaultAccount !== 'string')) {
315
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateDefaultAccount`);
315
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateDefaultAccount.errors.invalidInput`);
316
316
  }
317
317
  this.config.defaultAccount = defaultAccount;
318
318
  return this.write();
@@ -322,7 +322,7 @@ class CLIConfiguration {
322
322
  */
323
323
  renameAccount(currentName, newName) {
324
324
  if (!this.config) {
325
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.noConfigLoaded`);
325
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
326
326
  }
327
327
  const accountId = this.getAccountId(currentName);
328
328
  let accountConfigToRename = null;
@@ -330,7 +330,9 @@ class CLIConfiguration {
330
330
  accountConfigToRename = this.getAccount(accountId);
331
331
  }
332
332
  if (!accountConfigToRename) {
333
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.renameAccount`, { currentName });
333
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.renameAccount.errors.invalidName`, {
334
+ currentName,
335
+ });
334
336
  }
335
337
  if (accountId) {
336
338
  this.updateAccount({ accountId, name: newName, env: this.getEnv() });
@@ -344,16 +346,16 @@ class CLIConfiguration {
344
346
  */
345
347
  removeAccountFromConfig(nameOrId) {
346
348
  if (!this.config) {
347
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.noConfigLoaded`);
349
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
348
350
  }
349
351
  const accountId = this.getAccountId(nameOrId);
350
352
  if (!accountId) {
351
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.removeAccountFromConfig`, { nameOrId });
353
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.removeAccountFromConfig.errors.invalidId`, { nameOrId });
352
354
  }
353
355
  let removedAccountIsDefault = false;
354
356
  const accountConfig = this.getAccount(accountId);
355
357
  if (accountConfig) {
356
- (0, logger_1.debug)(`${i18nKey}.removeAccountFromConfig`, { accountId });
358
+ (0, logger_1.debug)(`${i18nKey}.removeAccountFromConfig.deleting`, { accountId });
357
359
  const index = this.getConfigAccountIndex(accountId);
358
360
  this.config.accounts.splice(index, 1);
359
361
  if (this.getDefaultAccount() === accountConfig.name) {
@@ -368,11 +370,11 @@ class CLIConfiguration {
368
370
  */
369
371
  updateDefaultMode(defaultMode) {
370
372
  if (!this.config) {
371
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.noConfigLoaded`);
373
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
372
374
  }
373
375
  const ALL_MODES = Object.values(files_1.MODE);
374
376
  if (!defaultMode || !ALL_MODES.find(m => m === defaultMode)) {
375
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateDefaultMode`, {
377
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateDefaultMode.errors.invalidMode`, {
376
378
  defaultMode,
377
379
  validModes: (0, text_1.commaSeparatedValues)(ALL_MODES),
378
380
  });
@@ -385,11 +387,11 @@ class CLIConfiguration {
385
387
  */
386
388
  updateHttpTimeout(timeout) {
387
389
  if (!this.config) {
388
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.noConfigLoaded`);
390
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
389
391
  }
390
392
  const parsedTimeout = parseInt(timeout);
391
393
  if (isNaN(parsedTimeout) || parsedTimeout < config_1.MIN_HTTP_TIMEOUT) {
392
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateHttpTimeout`, {
394
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateHttpTimeout.errors.invalidTimeout`, {
393
395
  timeout,
394
396
  minTimeout: config_1.MIN_HTTP_TIMEOUT,
395
397
  });
@@ -402,10 +404,10 @@ class CLIConfiguration {
402
404
  */
403
405
  updateAllowUsageTracking(isEnabled) {
404
406
  if (!this.config) {
405
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.noConfigLoaded`);
407
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
406
408
  }
407
409
  if (typeof isEnabled !== 'boolean') {
408
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateAllowUsageTracking`, {
410
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateAllowUsageTracking.errors.invalidInput`, {
409
411
  isEnabled: `${isEnabled}`,
410
412
  });
411
413
  }
@@ -60,7 +60,7 @@ function parseConfig(configSource) {
60
60
  parsed = js_yaml_1.default.load(configSource);
61
61
  }
62
62
  catch (err) {
63
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.parsing`, {}, err);
63
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.parsing`, {}, err);
64
64
  }
65
65
  return parsed;
66
66
  }
@@ -77,7 +77,6 @@ function loadConfigFromFile() {
77
77
  }
78
78
  return parseConfig(source);
79
79
  }
80
- // TODO: Maybe use log callbacks here
81
80
  (0, logger_1.debug)(`${i18nKey}.errorLoading`, { configPath });
82
81
  return null;
83
82
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateConfig = exports.getOrderedConfig = exports.getOrderedAccount = void 0;
4
4
  const logger_1 = require("../utils/logger");
5
5
  const auth_1 = require("../constants/auth");
6
+ const i18nKey = 'config.configUtils';
6
7
  function getOrderedAccount(unorderedAccount) {
7
8
  const { name, accountId, env, authType, ...rest } = unorderedAccount;
8
9
  return {
@@ -74,7 +75,7 @@ function generateConfig(type, options) {
74
75
  configAccount = generateOauthAccountConfig(options);
75
76
  break;
76
77
  default:
77
- (0, logger_1.debug)('config.configUtils.unknownType', { type });
78
+ (0, logger_1.debug)(`${i18nKey}.unknownType`, { type });
78
79
  return null;
79
80
  }
80
81
  if (configAccount) {
@@ -13,6 +13,7 @@ const environments_1 = require("../constants/environments");
13
13
  const auth_1 = require("../constants/auth");
14
14
  const files_1 = require("../constants/files");
15
15
  const environment_1 = require("../lib/environment");
16
+ const logger_1 = require("../lib/logging/logger");
16
17
  const git_1 = require("../utils/git");
17
18
  const errors_DEPRECATED_1 = require("../errors/errors_DEPRECATED");
18
19
  const ALL_MODES = Object.values(files_1.MODE);
@@ -69,37 +70,37 @@ exports.getConfigPath = getConfigPath;
69
70
  function validateConfig() {
70
71
  const config = (0, exports.getConfig)();
71
72
  if (!config) {
72
- console.error('No config was found');
73
+ logger_1.logger.error('No config was found');
73
74
  return false;
74
75
  }
75
76
  const accounts = getConfigAccounts();
76
77
  if (!Array.isArray(accounts)) {
77
- console.error('config.portals[] is not defined');
78
+ logger_1.logger.error('config.portals[] is not defined');
78
79
  return false;
79
80
  }
80
81
  const accountIdsHash = {};
81
82
  const accountNamesHash = {};
82
83
  return accounts.every(cfg => {
83
84
  if (!cfg) {
84
- console.error('config.portals[] has an empty entry');
85
+ logger_1.logger.error('config.portals[] has an empty entry');
85
86
  return false;
86
87
  }
87
88
  const accountId = getConfigAccountId(cfg);
88
89
  if (!accountId) {
89
- console.error('config.portals[] has an entry missing portalId');
90
+ logger_1.logger.error('config.portals[] has an entry missing portalId');
90
91
  return false;
91
92
  }
92
93
  if (accountIdsHash[accountId]) {
93
- console.error(`config.portals[] has multiple entries with portalId=${accountId}`);
94
+ logger_1.logger.error(`config.portals[] has multiple entries with portalId=${accountId}`);
94
95
  return false;
95
96
  }
96
97
  if (cfg.name) {
97
98
  if (accountNamesHash[cfg.name]) {
98
- console.error(`config.name has multiple entries with portalId=${accountId}`);
99
+ logger_1.logger.error(`config.name has multiple entries with portalId=${accountId}`);
99
100
  return false;
100
101
  }
101
102
  if (/\s+/.test(cfg.name)) {
102
- console.error(`config.name '${cfg.name}' cannot contain spaces`);
103
+ logger_1.logger.error(`config.name '${cfg.name}' cannot contain spaces`);
103
104
  return false;
104
105
  }
105
106
  accountNamesHash[cfg.name] = cfg;
@@ -158,7 +159,7 @@ function writeConfig(options = {}) {
158
159
  }
159
160
  const configPath = options.path || _configPath;
160
161
  try {
161
- console.debug(`Writing current config to ${configPath}`);
162
+ logger_1.logger.debug(`Writing current config to ${configPath}`);
162
163
  fs_extra_1.default.ensureFileSync(configPath || '');
163
164
  fs_extra_1.default.writeFileSync(configPath || '', source);
164
165
  setConfig(parseConfig(source).parsed);
@@ -183,7 +184,7 @@ function readConfigFile() {
183
184
  }
184
185
  catch (err) {
185
186
  error = err;
186
- console.error('Config file could not be read "%s"', _configPath);
187
+ logger_1.logger.error('Config file could not be read "%s"', _configPath);
187
188
  (0, errors_DEPRECATED_1.logFileSystemErrorInstance)(error, { filepath: _configPath, read: true });
188
189
  }
189
190
  return { source: source && source.toString(), error };
@@ -199,7 +200,7 @@ function parseConfig(configSource) {
199
200
  }
200
201
  catch (err) {
201
202
  error = err;
202
- console.error('Config file could not be parsed "%s"', _configPath);
203
+ logger_1.logger.error('Config file could not be parsed "%s"', _configPath);
203
204
  (0, errors_DEPRECATED_1.logErrorInstance)(err);
204
205
  }
205
206
  return { parsed, error };
@@ -208,14 +209,14 @@ function loadConfigFromFile(path, options = {}) {
208
209
  setConfigPath(getConfigPath(path));
209
210
  if (!_configPath) {
210
211
  if (!options.silenceErrors) {
211
- console.error(`A ${config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME} file could not be found. To create a new config file, use the "hs init" command.`);
212
+ logger_1.logger.error(`A ${config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME} file could not be found. To create a new config file, use the "hs init" command.`);
212
213
  }
213
214
  else {
214
- console.debug(`A ${config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME} file could not be found`);
215
+ logger_1.logger.debug(`A ${config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME} file could not be found`);
215
216
  }
216
217
  return;
217
218
  }
218
- console.debug(`Reading config from ${_configPath}`);
219
+ logger_1.logger.debug(`Reading config from ${_configPath}`);
219
220
  const { source, error: sourceError } = readConfigFile();
220
221
  if (sourceError)
221
222
  return;
@@ -224,8 +225,8 @@ function loadConfigFromFile(path, options = {}) {
224
225
  return;
225
226
  setConfig(parsed);
226
227
  if (!(0, exports.getConfig)()) {
227
- console.debug('The config file was empty config');
228
- console.debug('Initializing an empty config');
228
+ logger_1.logger.debug('The config file was empty config');
229
+ logger_1.logger.debug('Initializing an empty config');
229
230
  setConfig({ portals: [] });
230
231
  }
231
232
  return (0, exports.getConfig)();
@@ -234,11 +235,11 @@ function loadConfig(path, options = {
234
235
  useEnv: false,
235
236
  }) {
236
237
  if (options.useEnv && loadEnvironmentVariableConfig(options)) {
237
- console.debug('Loaded environment variable config');
238
+ logger_1.logger.debug('Loaded environment variable config');
238
239
  environmentVariableConfigLoaded = true;
239
240
  }
240
241
  else {
241
- path && console.debug(`Loading config from ${path}`);
242
+ path && logger_1.logger.debug(`Loading config from ${path}`);
242
243
  loadConfigFromFile(path, options);
243
244
  environmentVariableConfigLoaded = false;
244
245
  }
@@ -349,7 +350,7 @@ function removeSandboxAccountFromConfig(nameOrId) {
349
350
  }
350
351
  const accounts = getConfigAccounts(config);
351
352
  if (accountConfig && accounts) {
352
- console.debug(`Deleting config for ${accountId}`);
353
+ logger_1.logger.debug(`Deleting config for ${accountId}`);
353
354
  const index = accounts.indexOf(accountConfig);
354
355
  accounts.splice(index, 1);
355
356
  }
@@ -377,7 +378,9 @@ function updateAccountConfig(configOptions) {
377
378
  tokenInfo,
378
379
  };
379
380
  }
380
- const env = (0, environment_1.getValidEnv)(environment || (accountConfig && accountConfig.env), undefined);
381
+ const env = (0, environment_1.getValidEnv)(environment ||
382
+ (configOptions && configOptions.env) ||
383
+ (accountConfig && accountConfig.env));
381
384
  const mode = defaultMode && defaultMode.toLowerCase();
382
385
  const nextAccountConfig = {
383
386
  ...accountConfig,
@@ -394,12 +397,12 @@ function updateAccountConfig(configOptions) {
394
397
  };
395
398
  let accounts = getConfigAccounts(config);
396
399
  if (accountConfig && accounts) {
397
- console.debug(`Updating config for ${portalId}`);
400
+ logger_1.logger.debug(`Updating config for ${portalId}`);
398
401
  const index = accounts.indexOf(accountConfig);
399
402
  accounts[index] = nextAccountConfig;
400
403
  }
401
404
  else {
402
- console.debug(`Adding config entry for ${portalId}`);
405
+ logger_1.logger.debug(`Adding config entry for ${portalId}`);
403
406
  if (accounts) {
404
407
  accounts.push(nextAccountConfig);
405
408
  }
@@ -599,7 +602,7 @@ function loadConfigFromEnvironment({ useEnv = false, } = {}) {
599
602
  const { apiKey, clientId, clientSecret, personalAccessKey, portalId, refreshToken, env, } = getConfigVariablesFromEnv();
600
603
  const unableToLoadEnvConfigError = 'Unable to load config from environment variables.';
601
604
  if (!portalId) {
602
- useEnv && console.error(unableToLoadEnvConfigError);
605
+ useEnv && logger_1.logger.error(unableToLoadEnvConfigError);
603
606
  return;
604
607
  }
605
608
  if (personalAccessKey) {
@@ -612,7 +615,7 @@ function loadConfigFromEnvironment({ useEnv = false, } = {}) {
612
615
  return generateApiKeyConfig(portalId, apiKey, env);
613
616
  }
614
617
  else {
615
- useEnv && console.error(unableToLoadEnvConfigError);
618
+ useEnv && logger_1.logger.error(unableToLoadEnvConfigError);
616
619
  return;
617
620
  }
618
621
  }
@@ -623,7 +626,7 @@ function loadEnvironmentVariableConfig(options) {
623
626
  return null;
624
627
  }
625
628
  const { portalId } = getConfigVariablesFromEnv();
626
- console.debug(`Loaded config from environment variables for account ${portalId}`);
629
+ logger_1.logger.debug(`Loaded config from environment variables for account ${portalId}`);
627
630
  return setConfig(envConfig);
628
631
  }
629
632
  function isConfigFlagEnabled(flag) {
@@ -6,6 +6,7 @@ const environments_1 = require("../constants/environments");
6
6
  const auth_1 = require("../constants/auth");
7
7
  const configUtils_1 = require("./configUtils");
8
8
  const environment_1 = require("../lib/environment");
9
+ const i18nKey = 'config.environment';
9
10
  function getConfigVariablesFromEnv() {
10
11
  const env = process.env;
11
12
  return {
@@ -21,11 +22,11 @@ function getConfigVariablesFromEnv() {
21
22
  function loadConfigFromEnvironment() {
22
23
  const { apiKey, clientId, clientSecret, personalAccessKey, accountId, refreshToken, env, } = getConfigVariablesFromEnv();
23
24
  if (!accountId) {
24
- (0, logger_1.debug)('environment.loadConfig.missingAccountId');
25
+ (0, logger_1.debug)(`${i18nKey}.loadConfig.missingAccountId`);
25
26
  return null;
26
27
  }
27
28
  if (!env) {
28
- (0, logger_1.debug)('environment.loadConfig.missingEnv');
29
+ (0, logger_1.debug)(`${i18nKey}.loadConfig.missingEnv`);
29
30
  return null;
30
31
  }
31
32
  if (personalAccessKey) {
@@ -52,7 +53,7 @@ function loadConfigFromEnvironment() {
52
53
  env,
53
54
  });
54
55
  }
55
- (0, logger_1.debug)('environment.loadConfig.unknownAuthType');
56
+ (0, logger_1.debug)(`${i18nKey}.loadConfig.unknownAuthType`);
56
57
  return null;
57
58
  }
58
59
  exports.loadConfigFromEnvironment = loadConfigFromEnvironment;
@@ -0,0 +1,3 @@
1
+ export declare const MIN_PORT_NUMBER = 1024;
2
+ export declare const MAX_PORT_NUMBER = 65535;
3
+ export declare const PORT_MANAGER_SERVER_PORT = 8080;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PORT_MANAGER_SERVER_PORT = exports.MAX_PORT_NUMBER = exports.MIN_PORT_NUMBER = void 0;
4
+ exports.MIN_PORT_NUMBER = 1024;
5
+ exports.MAX_PORT_NUMBER = 65535;
6
+ exports.PORT_MANAGER_SERVER_PORT = 8080;