@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.
- package/api/appsDev.d.ts +6 -5
- package/api/appsDev.js +6 -10
- package/api/customObjects.d.ts +7 -6
- package/api/customObjects.js +13 -16
- package/api/designManager.d.ts +3 -2
- package/api/designManager.js +5 -8
- package/api/developerTestAccounts.d.ts +5 -4
- package/api/developerTestAccounts.js +9 -10
- package/api/fileManager.d.ts +5 -4
- package/api/fileManager.js +9 -9
- package/api/fileMapper.d.ts +8 -8
- package/api/fileMapper.js +16 -16
- package/api/fileTransport.d.ts +4 -3
- package/api/fileTransport.js +5 -5
- package/api/functions.d.ts +6 -5
- package/api/functions.js +11 -14
- package/api/github.d.ts +6 -6
- package/api/github.js +29 -13
- package/api/hubdb.d.ts +9 -8
- package/api/hubdb.js +17 -20
- package/api/lighthouseScore.d.ts +4 -3
- package/api/lighthouseScore.js +7 -10
- package/api/localDevAuth.d.ts +5 -4
- package/api/localDevAuth.js +8 -9
- package/api/marketplaceValidation.d.ts +4 -3
- package/api/marketplaceValidation.js +4 -7
- package/api/projects.d.ts +31 -30
- package/api/projects.js +52 -52
- package/api/sandboxHubs.d.ts +5 -4
- package/api/sandboxHubs.js +9 -10
- package/api/sandboxSync.d.ts +4 -4
- package/api/sandboxSync.js +5 -14
- package/api/secrets.d.ts +5 -4
- package/api/secrets.js +9 -12
- package/api/validateHubl.d.ts +2 -1
- package/api/validateHubl.js +3 -6
- package/config/CLIConfiguration.d.ts +3 -3
- package/config/CLIConfiguration.js +22 -20
- package/config/configFile.js +7 -14
- package/config/config_DEPRECATED.js +5 -2
- package/config/index.js +45 -48
- package/errors/errors_DEPRECATED.js +2 -2
- package/errors/index.d.ts +18 -0
- package/errors/index.js +63 -0
- package/http/addQueryParams.d.ts +2 -0
- package/http/addQueryParams.js +14 -0
- package/http/getAxiosConfig.d.ts +2 -2
- package/http/getAxiosConfig.js +10 -2
- package/http/index.d.ts +9 -14
- package/http/index.js +28 -53
- package/http/unauthed.d.ts +15 -0
- package/http/unauthed.js +38 -0
- package/lang/en.json +1 -2
- package/lang/lang/en.json +1 -2
- package/lib/archive.js +11 -10
- package/lib/cms/functions.d.ts +7 -1
- package/lib/cms/functions.js +22 -18
- package/lib/cms/handleFieldsJS.js +8 -7
- package/lib/cms/modules.js +4 -5
- package/lib/cms/processFieldsJs.js +8 -7
- package/lib/cms/templates.js +2 -3
- package/lib/cms/uploadFolder.js +16 -14
- package/lib/cms/validate.js +1 -1
- package/lib/cms/watch.js +16 -9
- package/lib/customObjects.js +4 -15
- package/lib/fileManager.js +22 -21
- package/lib/fileMapper.js +24 -31
- package/lib/fs.js +2 -2
- package/lib/github.js +21 -21
- package/lib/gitignore.js +2 -2
- package/lib/hubdb.d.ts +3 -2
- package/lib/hubdb.js +11 -9
- package/lib/notify.js +2 -2
- package/lib/oauth.d.ts +1 -1
- package/lib/oauth.js +8 -17
- package/lib/personalAccessKey.js +16 -21
- package/lib/portManager.js +2 -2
- package/lib/trackUsage.js +3 -3
- package/models/FileSystemError.d.ts +6 -0
- package/models/FileSystemError.js +47 -0
- package/models/HubSpotHttpError.d.ts +24 -0
- package/models/HubSpotHttpError.js +197 -0
- package/models/OAuth2Manager.d.ts +1 -2
- package/models/OAuth2Manager.js +13 -28
- package/package.json +2 -1
- package/types/Error.d.ts +7 -5
- package/types/Files.d.ts +4 -4
- package/types/Http.d.ts +6 -10
- package/types/Sandbox.d.ts +0 -5
- package/utils/PortManagerServer.d.ts +3 -3
- package/utils/PortManagerServer.js +9 -9
- package/utils/cms/modules.js +2 -2
- package/utils/detectPort.js +3 -3
- package/errors/apiErrors.d.ts +0 -25
- package/errors/apiErrors.js +0 -176
- package/errors/fileSystemErrors.d.ts +0 -6
- package/errors/fileSystemErrors.js +0 -35
- package/errors/standardErrors.d.ts +0 -20
- package/errors/standardErrors.js +0 -62
- package/lib/developerTestAccounts.d.ts +0 -4
- package/lib/developerTestAccounts.js +0 -35
- package/lib/sandboxes.d.ts +0 -14
- package/lib/sandboxes.js +0 -70
- package/models/HubSpotAuthError.d.ts +0 -12
- package/models/HubSpotAuthError.js +0 -20
package/api/sandboxHubs.js
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
15
|
-
return http_1.
|
|
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
|
-
|
|
23
|
-
return http_1.
|
|
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
|
-
|
|
29
|
-
return http_1.
|
|
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
|
-
|
|
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
|
-
|
|
48
|
-
return data;
|
|
47
|
+
return (0, axios_1.default)(reqWithToken);
|
|
49
48
|
}
|
|
50
49
|
exports.fetchSandboxHubData = fetchSandboxHubData;
|
package/api/sandboxSync.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function fetchTypes(accountId: number, toHubId: number):
|
|
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>;
|
package/api/sandboxSync.js
CHANGED
|
@@ -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.
|
|
7
|
-
const http_1 =
|
|
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
|
-
|
|
11
|
-
return http_1.
|
|
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.
|
|
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):
|
|
3
|
-
export declare function updateSecret(accountId: number, key: string, value: string):
|
|
4
|
-
export declare function deleteSecret(accountId: number, key: string):
|
|
5
|
-
export declare function fetchSecrets(accountId: number):
|
|
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 =
|
|
4
|
+
const http_1 = require("../http");
|
|
8
5
|
const SECRETS_API_PATH = 'cms/v3/functions/secrets';
|
|
9
|
-
|
|
10
|
-
return http_1.
|
|
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
|
-
|
|
20
|
-
return http_1.
|
|
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
|
-
|
|
30
|
-
return http_1.
|
|
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
|
-
|
|
36
|
-
return http_1.
|
|
32
|
+
function fetchSecrets(accountId) {
|
|
33
|
+
return http_1.http.get(accountId, {
|
|
37
34
|
url: `${SECRETS_API_PATH}`,
|
|
38
35
|
});
|
|
39
36
|
}
|
package/api/validateHubl.d.ts
CHANGED
|
@@ -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):
|
|
3
|
+
export declare function validateHubl(accountId: number, sourceCode: string, hublValidationOptions?: HublValidationOptions): AxiosPromise<Validation>;
|
package/api/validateHubl.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.validateHubl = void 0;
|
|
7
|
-
const http_1 =
|
|
4
|
+
const http_1 = require("../http");
|
|
8
5
|
const HUBL_VALIDATE_API_PATH = 'cos-rendering/v1/internal/validate';
|
|
9
|
-
|
|
10
|
-
return http_1.
|
|
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
|
|
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
|
|
61
|
-
export
|
|
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
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
425
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
|
|
424
426
|
}
|
|
425
427
|
if (typeof isEnabled !== 'boolean') {
|
|
426
|
-
(0,
|
|
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.
|
|
442
|
+
exports.CLIConfiguration = new _CLIConfiguration();
|
package/config/configFile.js
CHANGED
|
@@ -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
|
-
|
|
46
|
+
throw new FileSystemError_1.FileSystemError({ cause: err }, {
|
|
48
47
|
filepath: configPath,
|
|
49
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
96
|
+
throw new FileSystemError_1.FileSystemError({ cause: err }, {
|
|
104
97
|
filepath: configPath,
|
|
105
|
-
|
|
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
|
-
|
|
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, {
|
|
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
|
}
|