@hubspot/local-dev-lib 1.13.1 → 2.0.1

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 (105) hide show
  1. package/api/appsDev.d.ts +6 -5
  2. package/api/appsDev.js +6 -10
  3. package/api/customObjects.d.ts +7 -6
  4. package/api/customObjects.js +13 -16
  5. package/api/designManager.d.ts +3 -2
  6. package/api/designManager.js +5 -8
  7. package/api/developerTestAccounts.d.ts +5 -4
  8. package/api/developerTestAccounts.js +9 -10
  9. package/api/fileManager.d.ts +5 -4
  10. package/api/fileManager.js +9 -9
  11. package/api/fileMapper.d.ts +8 -8
  12. package/api/fileMapper.js +16 -16
  13. package/api/fileTransport.d.ts +4 -3
  14. package/api/fileTransport.js +5 -5
  15. package/api/functions.d.ts +6 -5
  16. package/api/functions.js +11 -14
  17. package/api/github.d.ts +6 -6
  18. package/api/github.js +29 -13
  19. package/api/hubdb.d.ts +9 -8
  20. package/api/hubdb.js +17 -20
  21. package/api/lighthouseScore.d.ts +4 -3
  22. package/api/lighthouseScore.js +7 -10
  23. package/api/localDevAuth.d.ts +5 -4
  24. package/api/localDevAuth.js +8 -9
  25. package/api/marketplaceValidation.d.ts +4 -3
  26. package/api/marketplaceValidation.js +4 -7
  27. package/api/projects.d.ts +31 -30
  28. package/api/projects.js +52 -52
  29. package/api/sandboxHubs.d.ts +5 -4
  30. package/api/sandboxHubs.js +9 -10
  31. package/api/sandboxSync.d.ts +4 -4
  32. package/api/sandboxSync.js +5 -14
  33. package/api/secrets.d.ts +5 -4
  34. package/api/secrets.js +9 -12
  35. package/api/validateHubl.d.ts +2 -1
  36. package/api/validateHubl.js +3 -6
  37. package/config/CLIConfiguration.d.ts +3 -3
  38. package/config/CLIConfiguration.js +22 -20
  39. package/config/configFile.js +7 -14
  40. package/config/config_DEPRECATED.js +5 -2
  41. package/config/index.js +45 -48
  42. package/errors/errors_DEPRECATED.js +2 -2
  43. package/errors/index.d.ts +18 -0
  44. package/errors/index.js +63 -0
  45. package/http/addQueryParams.d.ts +2 -0
  46. package/http/addQueryParams.js +14 -0
  47. package/http/getAxiosConfig.d.ts +2 -2
  48. package/http/getAxiosConfig.js +10 -2
  49. package/http/index.d.ts +9 -14
  50. package/http/index.js +28 -53
  51. package/http/unauthed.d.ts +15 -0
  52. package/http/unauthed.js +38 -0
  53. package/lang/en.json +1 -2
  54. package/lang/lang/en.json +1 -2
  55. package/lib/archive.js +11 -10
  56. package/lib/cms/functions.d.ts +7 -1
  57. package/lib/cms/functions.js +22 -18
  58. package/lib/cms/handleFieldsJS.js +8 -7
  59. package/lib/cms/modules.js +4 -5
  60. package/lib/cms/processFieldsJs.js +8 -7
  61. package/lib/cms/templates.js +2 -3
  62. package/lib/cms/uploadFolder.js +16 -14
  63. package/lib/cms/validate.js +1 -1
  64. package/lib/cms/watch.js +16 -9
  65. package/lib/customObjects.js +4 -15
  66. package/lib/fileManager.js +22 -21
  67. package/lib/fileMapper.js +24 -31
  68. package/lib/fs.js +2 -2
  69. package/lib/github.js +21 -21
  70. package/lib/gitignore.js +2 -2
  71. package/lib/hubdb.d.ts +3 -2
  72. package/lib/hubdb.js +11 -9
  73. package/lib/notify.js +2 -2
  74. package/lib/oauth.d.ts +1 -1
  75. package/lib/oauth.js +8 -17
  76. package/lib/personalAccessKey.js +16 -21
  77. package/lib/portManager.js +2 -2
  78. package/lib/trackUsage.js +3 -3
  79. package/models/FileSystemError.d.ts +6 -0
  80. package/models/FileSystemError.js +47 -0
  81. package/models/HubSpotHttpError.d.ts +24 -0
  82. package/models/HubSpotHttpError.js +197 -0
  83. package/models/OAuth2Manager.d.ts +1 -2
  84. package/models/OAuth2Manager.js +13 -28
  85. package/package.json +2 -1
  86. package/types/Error.d.ts +7 -5
  87. package/types/Files.d.ts +4 -4
  88. package/types/Http.d.ts +6 -10
  89. package/types/Sandbox.d.ts +0 -5
  90. package/utils/PortManagerServer.d.ts +3 -3
  91. package/utils/PortManagerServer.js +9 -9
  92. package/utils/cms/modules.js +2 -2
  93. package/utils/detectPort.js +3 -3
  94. package/errors/apiErrors.d.ts +0 -25
  95. package/errors/apiErrors.js +0 -176
  96. package/errors/fileSystemErrors.d.ts +0 -6
  97. package/errors/fileSystemErrors.js +0 -35
  98. package/errors/standardErrors.d.ts +0 -20
  99. package/errors/standardErrors.js +0 -62
  100. package/lib/developerTestAccounts.d.ts +0 -4
  101. package/lib/developerTestAccounts.js +0 -35
  102. package/lib/sandboxes.d.ts +0 -14
  103. package/lib/sandboxes.js +0 -70
  104. package/models/HubSpotAuthError.d.ts +0 -12
  105. package/models/HubSpotAuthError.js +0 -20
@@ -5,33 +5,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchSandboxHubData = exports.getSandboxUsageLimits = exports.deleteSandbox = exports.createSandbox = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
- const http_1 = __importDefault(require("../http"));
8
+ const http_1 = require("../http");
9
9
  const getAxiosConfig_1 = require("../http/getAxiosConfig");
10
10
  const environments_1 = require("../constants/environments");
11
11
  const api_1 = require("../constants/api");
12
12
  const SANDBOX_API_PATH = 'sandbox-hubs/v1';
13
13
  const SANDBOX_API_PATH_V2 = 'sandbox-hubs/v2';
14
- async function createSandbox(accountId, name, type) {
15
- return http_1.default.post(accountId, {
14
+ function createSandbox(accountId, name, type) {
15
+ return http_1.http.post(accountId, {
16
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
  });
20
20
  }
21
21
  exports.createSandbox = createSandbox;
22
- async function deleteSandbox(parentAccountId, sandboxAccountId) {
23
- return http_1.default.delete(parentAccountId, {
22
+ function deleteSandbox(parentAccountId, sandboxAccountId) {
23
+ return http_1.http.delete(parentAccountId, {
24
24
  url: `${SANDBOX_API_PATH}/${sandboxAccountId}`,
25
25
  });
26
26
  }
27
27
  exports.deleteSandbox = deleteSandbox;
28
- async function getSandboxUsageLimits(parentAccountId) {
29
- return http_1.default.get(parentAccountId, {
28
+ function getSandboxUsageLimits(parentAccountId) {
29
+ return http_1.http.get(parentAccountId, {
30
30
  url: `${SANDBOX_API_PATH}/parent/${parentAccountId}/usage`,
31
31
  });
32
32
  }
33
33
  exports.getSandboxUsageLimits = getSandboxUsageLimits;
34
- async function fetchSandboxHubData(accessToken, accountId, env = environments_1.ENVIRONMENTS.PROD) {
34
+ function fetchSandboxHubData(accessToken, accountId, env = environments_1.ENVIRONMENTS.PROD) {
35
35
  const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
36
36
  env,
37
37
  url: `${SANDBOX_API_PATH}/self`,
@@ -44,7 +44,6 @@ async function fetchSandboxHubData(accessToken, accountId, env = environments_1.
44
44
  Authorization: `Bearer ${accessToken}`,
45
45
  },
46
46
  };
47
- const { data } = await (0, axios_1.default)(reqWithToken);
48
- return data;
47
+ return (0, axios_1.default)(reqWithToken);
49
48
  }
50
49
  exports.fetchSandboxHubData = fetchSandboxHubData;
@@ -1,4 +1,4 @@
1
- import { InitiateSyncResponse, FetchTypesResponse, TaskRequestData, SyncTaskStatusType } from '../types/Sandbox';
2
- export declare function initiateSync(fromHubId: number, toHubId: number, tasks: Array<TaskRequestData>, sandboxHubId: number): Promise<InitiateSyncResponse>;
3
- export declare function fetchTaskStatus(accountId: number, taskId: number): Promise<SyncTaskStatusType>;
4
- export declare function fetchTypes(accountId: number, toHubId: number): Promise<FetchTypesResponse>;
1
+ import { AxiosPromise } from 'axios';
2
+ import { InitiateSyncResponse, FetchTypesResponse, TaskRequestData } from '../types/Sandbox';
3
+ export declare function initiateSync(fromHubId: number, toHubId: number, tasks: Array<TaskRequestData>, sandboxHubId: number): AxiosPromise<InitiateSyncResponse>;
4
+ export declare function fetchTypes(accountId: number, toHubId: number): AxiosPromise<FetchTypesResponse>;
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.fetchTypes = exports.fetchTaskStatus = exports.initiateSync = void 0;
7
- const http_1 = __importDefault(require("../http"));
3
+ exports.fetchTypes = exports.initiateSync = void 0;
4
+ const http_1 = require("../http");
8
5
  const api_1 = require("../constants/api");
9
6
  const SANDBOXES_SYNC_API_PATH = 'sandboxes-sync/v1';
10
- async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
11
- return http_1.default.post(fromHubId, {
7
+ function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
8
+ return http_1.http.post(fromHubId, {
12
9
  data: {
13
10
  command: 'SYNC',
14
11
  fromHubId,
@@ -21,14 +18,8 @@ async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
21
18
  });
22
19
  }
23
20
  exports.initiateSync = initiateSync;
24
- async function fetchTaskStatus(accountId, taskId) {
25
- return http_1.default.get(accountId, {
26
- url: `${SANDBOXES_SYNC_API_PATH}/tasks/${taskId}/status`,
27
- });
28
- }
29
- exports.fetchTaskStatus = fetchTaskStatus;
30
21
  async function fetchTypes(accountId, toHubId) {
31
- return http_1.default.get(accountId, {
22
+ return http_1.http.get(accountId, {
32
23
  url: `${SANDBOXES_SYNC_API_PATH}/types${toHubId ? `?toHubId=${toHubId}` : ''}`,
33
24
  });
34
25
  }
package/api/secrets.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import { AxiosPromise } from 'axios';
1
2
  import { FetchSecretsResponse } from '../types/Secrets';
2
- export declare function addSecret(accountId: number, key: string, value: string): Promise<void>;
3
- export declare function updateSecret(accountId: number, key: string, value: string): Promise<void>;
4
- export declare function deleteSecret(accountId: number, key: string): Promise<void>;
5
- export declare function fetchSecrets(accountId: number): Promise<FetchSecretsResponse>;
3
+ export declare function addSecret(accountId: number, key: string, value: string): AxiosPromise<void>;
4
+ export declare function updateSecret(accountId: number, key: string, value: string): AxiosPromise<void>;
5
+ export declare function deleteSecret(accountId: number, key: string): AxiosPromise<void>;
6
+ export declare function fetchSecrets(accountId: number): AxiosPromise<FetchSecretsResponse>;
package/api/secrets.js CHANGED
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.fetchSecrets = exports.deleteSecret = exports.updateSecret = exports.addSecret = void 0;
7
- const http_1 = __importDefault(require("../http"));
4
+ const http_1 = require("../http");
8
5
  const SECRETS_API_PATH = 'cms/v3/functions/secrets';
9
- async function addSecret(accountId, key, value) {
10
- return http_1.default.post(accountId, {
6
+ function addSecret(accountId, key, value) {
7
+ return http_1.http.post(accountId, {
11
8
  url: SECRETS_API_PATH,
12
9
  data: {
13
10
  key,
@@ -16,8 +13,8 @@ async function addSecret(accountId, key, value) {
16
13
  });
17
14
  }
18
15
  exports.addSecret = addSecret;
19
- async function updateSecret(accountId, key, value) {
20
- return http_1.default.put(accountId, {
16
+ function updateSecret(accountId, key, value) {
17
+ return http_1.http.put(accountId, {
21
18
  url: SECRETS_API_PATH,
22
19
  data: {
23
20
  key,
@@ -26,14 +23,14 @@ async function updateSecret(accountId, key, value) {
26
23
  });
27
24
  }
28
25
  exports.updateSecret = updateSecret;
29
- async function deleteSecret(accountId, key) {
30
- return http_1.default.delete(accountId, {
26
+ function deleteSecret(accountId, key) {
27
+ return http_1.http.delete(accountId, {
31
28
  url: `${SECRETS_API_PATH}/${key}`,
32
29
  });
33
30
  }
34
31
  exports.deleteSecret = deleteSecret;
35
- async function fetchSecrets(accountId) {
36
- return http_1.default.get(accountId, {
32
+ function fetchSecrets(accountId) {
33
+ return http_1.http.get(accountId, {
37
34
  url: `${SECRETS_API_PATH}`,
38
35
  });
39
36
  }
@@ -1,2 +1,3 @@
1
+ import { AxiosPromise } from 'axios';
1
2
  import { Validation, HublValidationOptions } from '../types/HublValidation';
2
- export declare function validateHubl(accountId: number, sourceCode: string, hublValidationOptions?: HublValidationOptions): Promise<Validation>;
3
+ export declare function validateHubl(accountId: number, sourceCode: string, hublValidationOptions?: HublValidationOptions): AxiosPromise<Validation>;
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.validateHubl = void 0;
7
- const http_1 = __importDefault(require("../http"));
4
+ const http_1 = require("../http");
8
5
  const HUBL_VALIDATE_API_PATH = 'cos-rendering/v1/internal/validate';
9
- async function validateHubl(accountId, sourceCode, hublValidationOptions) {
10
- return http_1.default.post(accountId, {
6
+ function validateHubl(accountId, sourceCode, hublValidationOptions) {
7
+ return http_1.http.post(accountId, {
11
8
  url: HUBL_VALIDATE_API_PATH,
12
9
  data: {
13
10
  template_source: sourceCode,
@@ -1,7 +1,7 @@
1
1
  import { CLIConfig_NEW, Environment } from '../types/Config';
2
2
  import { CLIAccount_NEW, FlatAccountFields_NEW, AccountType } from '../types/Accounts';
3
3
  import { CLIOptions } from '../types/CLIOptions';
4
- declare class CLIConfiguration {
4
+ declare class _CLIConfiguration {
5
5
  options: CLIOptions;
6
6
  useEnvConfig: boolean;
7
7
  config: CLIConfig_NEW | null;
@@ -57,5 +57,5 @@ declare class CLIConfiguration {
57
57
  updateAllowUsageTracking(isEnabled: boolean): CLIConfig_NEW | null;
58
58
  isTrackingAllowed(): boolean;
59
59
  }
60
- declare const _default: CLIConfiguration;
61
- export default _default;
60
+ export declare const CLIConfiguration: _CLIConfiguration;
61
+ export {};
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLIConfiguration = void 0;
3
4
  const logger_1 = require("../lib/logger");
4
- const standardErrors_1 = require("../errors/standardErrors");
5
5
  const environment_1 = require("./environment");
6
6
  const environment_2 = require("../lib/environment");
7
7
  const configFile_1 = require("./configFile");
@@ -12,7 +12,7 @@ const config_1 = require("../constants/config");
12
12
  const files_1 = require("../constants/files");
13
13
  const lang_1 = require("../utils/lang");
14
14
  const i18nKey = 'config.cliConfiguration';
15
- class CLIConfiguration {
15
+ class _CLIConfiguration {
16
16
  options;
17
17
  useEnvConfig;
18
18
  config;
@@ -249,7 +249,7 @@ class CLIConfiguration {
249
249
  updateAccount(updatedAccountFields, writeUpdate = true) {
250
250
  const { accountId, accountType, apiKey, authType, clientId, clientSecret, defaultMode, env, name, parentAccountId, personalAccessKey, sandboxAccountType, scopes, tokenInfo, } = updatedAccountFields;
251
251
  if (!accountId) {
252
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateAccount.errors.accountIdRequired`);
252
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.updateAccount.errors.accountIdRequired`));
253
253
  }
254
254
  if (!this.config) {
255
255
  logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.updateAccount.noConfigToUpdate`));
@@ -323,11 +323,11 @@ class CLIConfiguration {
323
323
  */
324
324
  updateDefaultAccount(defaultAccount) {
325
325
  if (!this.config) {
326
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
326
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
327
327
  }
328
328
  if (!defaultAccount ||
329
329
  (typeof defaultAccount !== 'number' && typeof defaultAccount !== 'string')) {
330
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateDefaultAccount.errors.invalidInput`);
330
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.updateDefaultAccount.errors.invalidInput`));
331
331
  }
332
332
  this.config.defaultAccount = defaultAccount;
333
333
  return this.write();
@@ -337,7 +337,7 @@ class CLIConfiguration {
337
337
  */
338
338
  renameAccount(currentName, newName) {
339
339
  if (!this.config) {
340
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
340
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
341
341
  }
342
342
  const accountId = this.getAccountId(currentName);
343
343
  let accountConfigToRename = null;
@@ -345,9 +345,9 @@ class CLIConfiguration {
345
345
  accountConfigToRename = this.getAccount(accountId);
346
346
  }
347
347
  if (!accountConfigToRename) {
348
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.renameAccount.errors.invalidName`, {
348
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.renameAccount.errors.invalidName`, {
349
349
  currentName,
350
- });
350
+ }));
351
351
  }
352
352
  if (accountId) {
353
353
  this.updateAccount({ accountId, name: newName, env: this.getEnv() });
@@ -362,11 +362,13 @@ class CLIConfiguration {
362
362
  */
363
363
  removeAccountFromConfig(nameOrId) {
364
364
  if (!this.config) {
365
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
365
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
366
366
  }
367
367
  const accountId = this.getAccountId(nameOrId);
368
368
  if (!accountId) {
369
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.removeAccountFromConfig.errors.invalidId`, { nameOrId });
369
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.removeAccountFromConfig.errors.invalidId`, {
370
+ nameOrId,
371
+ }));
370
372
  }
371
373
  let removedAccountIsDefault = false;
372
374
  const accountConfig = this.getAccount(accountId);
@@ -386,14 +388,14 @@ class CLIConfiguration {
386
388
  */
387
389
  updateDefaultMode(defaultMode) {
388
390
  if (!this.config) {
389
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
391
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
390
392
  }
391
393
  const ALL_MODES = Object.values(files_1.MODE);
392
394
  if (!defaultMode || !ALL_MODES.find(m => m === defaultMode)) {
393
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateDefaultMode.errors.invalidMode`, {
395
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.updateDefaultMode.errors.invalidMode`, {
394
396
  defaultMode,
395
397
  validModes: (0, text_1.commaSeparatedValues)(ALL_MODES),
396
- });
398
+ }));
397
399
  }
398
400
  this.config.defaultMode = defaultMode;
399
401
  return this.write();
@@ -403,14 +405,14 @@ class CLIConfiguration {
403
405
  */
404
406
  updateHttpTimeout(timeout) {
405
407
  if (!this.config) {
406
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
408
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
407
409
  }
408
410
  const parsedTimeout = parseInt(timeout);
409
411
  if (isNaN(parsedTimeout) || parsedTimeout < config_1.MIN_HTTP_TIMEOUT) {
410
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateHttpTimeout.errors.invalidTimeout`, {
412
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.updateHttpTimeout.errors.invalidTimeout`, {
411
413
  timeout,
412
414
  minTimeout: config_1.MIN_HTTP_TIMEOUT,
413
- });
415
+ }));
414
416
  }
415
417
  this.config.httpTimeout = parsedTimeout;
416
418
  return this.write();
@@ -420,12 +422,12 @@ class CLIConfiguration {
420
422
  */
421
423
  updateAllowUsageTracking(isEnabled) {
422
424
  if (!this.config) {
423
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.noConfigLoaded`);
425
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
424
426
  }
425
427
  if (typeof isEnabled !== 'boolean') {
426
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateAllowUsageTracking.errors.invalidInput`, {
428
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.updateAllowUsageTracking.errors.invalidInput`, {
427
429
  isEnabled: `${isEnabled}`,
428
- });
430
+ }));
429
431
  }
430
432
  this.config.allowUsageTracking = isEnabled;
431
433
  return this.write();
@@ -437,4 +439,4 @@ class CLIConfiguration {
437
439
  return this.config.allowUsageTracking !== false;
438
440
  }
439
441
  }
440
- exports.default = new CLIConfiguration();
442
+ exports.CLIConfiguration = new _CLIConfiguration();
@@ -9,11 +9,10 @@ const path_1 = __importDefault(require("path"));
9
9
  const os_1 = __importDefault(require("os"));
10
10
  const js_yaml_1 = __importDefault(require("js-yaml"));
11
11
  const logger_1 = require("../lib/logger");
12
- const fileSystemErrors_1 = require("../errors/fileSystemErrors");
13
- const standardErrors_1 = require("../errors/standardErrors");
14
12
  const config_1 = require("../constants/config");
15
13
  const configUtils_1 = require("./configUtils");
16
14
  const lang_1 = require("../utils/lang");
15
+ const FileSystemError_1 = require("../models/FileSystemError");
17
16
  const i18nKey = 'config.configFile';
18
17
  function getConfigFilePath() {
19
18
  return path_1.default.join(os_1.default.homedir(), config_1.HUBSPOT_CONFIGURATION_FOLDER, config_1.HUBSPOT_CONFIGURATION_FILE);
@@ -44,9 +43,9 @@ function readConfigFile(configPath) {
44
43
  }
45
44
  catch (err) {
46
45
  logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.errorReading`, { configPath }));
47
- (0, fileSystemErrors_1.throwFileSystemError)(err, {
46
+ throw new FileSystemError_1.FileSystemError({ cause: err }, {
48
47
  filepath: configPath,
49
- read: true,
48
+ operation: 'read',
50
49
  });
51
50
  }
52
51
  return source;
@@ -61,7 +60,7 @@ function parseConfig(configSource) {
61
60
  parsed = js_yaml_1.default.load(configSource);
62
61
  }
63
62
  catch (err) {
64
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.parsing`, {}, err);
63
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.parsing`), { cause: err });
65
64
  }
66
65
  return parsed;
67
66
  }
@@ -86,13 +85,7 @@ exports.loadConfigFromFile = loadConfigFromFile;
86
85
  * @throws {Error}
87
86
  */
88
87
  function writeConfigToFile(config) {
89
- let source;
90
- try {
91
- source = js_yaml_1.default.dump(JSON.parse(JSON.stringify((0, configUtils_1.getOrderedConfig)(config), null, 2)));
92
- }
93
- catch (err) {
94
- (0, standardErrors_1.throwError)(err);
95
- }
88
+ const source = js_yaml_1.default.dump(JSON.parse(JSON.stringify((0, configUtils_1.getOrderedConfig)(config), null, 2)));
96
89
  const configPath = getConfigFilePath();
97
90
  try {
98
91
  fs_extra_1.default.ensureFileSync(configPath);
@@ -100,9 +93,9 @@ function writeConfigToFile(config) {
100
93
  logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.writeSuccess`, { configPath }));
101
94
  }
102
95
  catch (err) {
103
- (0, fileSystemErrors_1.throwFileSystemError)(err, {
96
+ throw new FileSystemError_1.FileSystemError({ cause: err }, {
104
97
  filepath: configPath,
105
- write: true,
98
+ operation: 'write',
106
99
  });
107
100
  }
108
101
  }
@@ -175,7 +175,7 @@ function writeConfig(options = {}) {
175
175
  catch (err) {
176
176
  (0, errors_DEPRECATED_1.logFileSystemErrorInstance)(err, {
177
177
  filepath: configPath || '',
178
- write: true,
178
+ operation: 'write',
179
179
  });
180
180
  }
181
181
  }
@@ -193,7 +193,10 @@ function readConfigFile() {
193
193
  catch (err) {
194
194
  error = err;
195
195
  logger_1.logger.error('Config file could not be read "%s"', _configPath);
196
- (0, errors_DEPRECATED_1.logFileSystemErrorInstance)(error, { filepath: _configPath, read: true });
196
+ (0, errors_DEPRECATED_1.logFileSystemErrorInstance)(error, {
197
+ filepath: _configPath,
198
+ operation: 'read',
199
+ });
197
200
  }
198
201
  return { source: source && source.toString(), error };
199
202
  }