@hubspot/local-dev-lib 0.0.9 → 0.0.10
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/config/config_DEPRECATED.d.ts +1 -1
- package/config/index.d.ts +1 -1
- package/errors/fileSystemErrors.d.ts +3 -0
- package/errors/fileSystemErrors.js +3 -0
- package/lib/cms/functions.js +5 -2
- package/lib/environment.js +1 -1
- package/lib/logging/logger.d.ts +1 -1
- package/lib/logging/logger.js +1 -1
- package/lib/text.d.ts +1 -1
- package/lib/trackUsage.d.ts +1 -1
- package/lib/trackUsage.js +5 -2
- package/lib/validate.js +2 -2
- package/models/OAuth2Manager.js +3 -1
- package/package.json +1 -1
- package/utils/objectUtils.d.ts +1 -1
- package/utils/objectUtils.js +3 -3
|
@@ -26,7 +26,7 @@ export declare function loadConfig(path?: string, options?: CLIOptions): CLIConf
|
|
|
26
26
|
export declare function isTrackingAllowed(): boolean;
|
|
27
27
|
export declare function getAndLoadConfigIfNeeded(options?: {}): Partial<CLIConfig_DEPRECATED>;
|
|
28
28
|
export declare function findConfig(directory: string): string | null;
|
|
29
|
-
export declare function getEnv(nameOrId
|
|
29
|
+
export declare function getEnv(nameOrId?: string | number): Environment;
|
|
30
30
|
export declare function getAccountConfig(accountId: number | undefined): CLIAccount_DEPRECATED | undefined;
|
|
31
31
|
export declare function getAccountId(nameOrId?: string | number): number | undefined;
|
|
32
32
|
/**
|
package/config/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare function updateAllowUsageTracking(isEnabled: boolean): void;
|
|
|
26
26
|
export declare function deleteConfigFile(): void;
|
|
27
27
|
export declare function isConfigFlagEnabled(flag: keyof CLIConfig): boolean;
|
|
28
28
|
export declare function isTrackingAllowed(): boolean;
|
|
29
|
-
export declare function getEnv(nameOrId
|
|
29
|
+
export declare function getEnv(nameOrId?: string | number): import("../types/Config").Environment;
|
|
30
30
|
export declare const getConfigAccounts: typeof config_DEPRECATED.getConfigAccounts;
|
|
31
31
|
export declare const getConfigDefaultAccount: typeof config_DEPRECATED.getConfigDefaultAccount;
|
|
32
32
|
export declare const getConfigAccountId: typeof config_DEPRECATED.getConfigAccountId;
|
|
@@ -4,6 +4,9 @@ exports.throwFileSystemError = void 0;
|
|
|
4
4
|
const lang_1 = require("../utils/lang");
|
|
5
5
|
const standardErrors_1 = require("./standardErrors");
|
|
6
6
|
const i18nKey = 'errors.fileSystemErrors';
|
|
7
|
+
/**
|
|
8
|
+
* @throws
|
|
9
|
+
*/
|
|
7
10
|
function throwFileSystemError(error, context) {
|
|
8
11
|
let fileAction = '';
|
|
9
12
|
if (context.read) {
|
package/lib/cms/functions.js
CHANGED
|
@@ -10,10 +10,13 @@ const findup_sync_1 = __importDefault(require("findup-sync"));
|
|
|
10
10
|
const path_2 = require("../path");
|
|
11
11
|
const github_1 = require("../github");
|
|
12
12
|
const logger_1 = require("../../utils/logger");
|
|
13
|
-
const objectUtils_1 = require("../../utils/objectUtils");
|
|
14
13
|
const standardErrors_1 = require("../../errors/standardErrors");
|
|
15
14
|
const fileSystemErrors_1 = require("../../errors/fileSystemErrors");
|
|
16
15
|
const i18nKey = 'lib.cms.functions';
|
|
16
|
+
function isObjectOrFunction(value) {
|
|
17
|
+
const type = typeof value;
|
|
18
|
+
return value != null && (type === 'object' || type === 'function');
|
|
19
|
+
}
|
|
17
20
|
function createEndpoint(endpointMethod, filename) {
|
|
18
21
|
return {
|
|
19
22
|
method: endpointMethod || 'GET',
|
|
@@ -62,7 +65,7 @@ function updateExistingConfig(configFilePath, { endpointPath, endpointMethod, fu
|
|
|
62
65
|
read: true,
|
|
63
66
|
});
|
|
64
67
|
}
|
|
65
|
-
if (!(
|
|
68
|
+
if (!isObjectOrFunction(config)) {
|
|
66
69
|
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.updateExistingConfig.errors.configIsNotObjectError`, { configFilePath });
|
|
67
70
|
}
|
|
68
71
|
if (config.endpoints) {
|
package/lib/environment.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getValidEnv = void 0;
|
|
4
4
|
const environments_1 = require("../constants/environments");
|
|
5
5
|
function getValidEnv(env, maskedProductionValue) {
|
|
6
|
-
const prodValue = maskedProductionValue
|
|
6
|
+
const prodValue = typeof maskedProductionValue === 'string'
|
|
7
7
|
? maskedProductionValue
|
|
8
8
|
: environments_1.ENVIRONMENTS.PROD;
|
|
9
9
|
const returnVal = typeof env &&
|
package/lib/logging/logger.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare class Logger {
|
|
|
30
30
|
}
|
|
31
31
|
export declare function setLogger(logger: Logger): void;
|
|
32
32
|
export declare function setLogLevel(level: number): void;
|
|
33
|
-
export declare function shouldLog(level: number):
|
|
33
|
+
export declare function shouldLog(level: number): boolean;
|
|
34
34
|
export declare function getLogLevel(): number;
|
|
35
35
|
export declare const logger: {
|
|
36
36
|
error(...args: any[]): void;
|
package/lib/logging/logger.js
CHANGED
package/lib/text.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function commaSeparatedValues(arr: Array<string>, conjunction?: string, ifempty?: string): string;
|
|
1
|
+
export declare function commaSeparatedValues(arr: Array<string>, conjunction?: null | string, ifempty?: string): string;
|
package/lib/trackUsage.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function trackUsage(eventName: string, eventClass: string, meta
|
|
1
|
+
export declare function trackUsage(eventName: string, eventClass: string, meta?: {}, accountId?: number): Promise<void>;
|
package/lib/trackUsage.js
CHANGED
|
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.trackUsage = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const getAxiosConfig_1 = require("../http/getAxiosConfig");
|
|
7
9
|
const logger_1 = require("../utils/logger");
|
|
8
10
|
const http_1 = __importDefault(require("../http"));
|
|
9
11
|
const config_1 = require("../config");
|
|
@@ -42,12 +44,13 @@ async function trackUsage(eventName, eventClass, meta = {}, accountId) {
|
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
const env = (0, config_1.getEnv)(accountId);
|
|
45
|
-
(0,
|
|
46
|
-
http_1.default.post(accountId, {
|
|
47
|
+
const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
|
|
47
48
|
env,
|
|
48
49
|
url: path,
|
|
49
50
|
data: usageEvent,
|
|
50
51
|
resolveWithFullResponse: true,
|
|
51
52
|
});
|
|
53
|
+
(0, logger_1.debug)(`${i18nKey}.sendingEventUnauthenticated`);
|
|
54
|
+
(0, axios_1.default)({ ...axiosConfig, method: 'post' });
|
|
52
55
|
}
|
|
53
56
|
exports.trackUsage = trackUsage;
|
package/lib/validate.js
CHANGED
|
@@ -7,8 +7,8 @@ exports.lint = void 0;
|
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const extensions_1 = require("../constants/extensions");
|
|
9
9
|
const validateHubl_1 = require("../api/validateHubl");
|
|
10
|
-
const fs_1 = require("
|
|
11
|
-
const path_1 = require("
|
|
10
|
+
const fs_1 = require("./fs");
|
|
11
|
+
const path_1 = require("./path");
|
|
12
12
|
async function lint(accountId, filepath, callback) {
|
|
13
13
|
const stats = await fs_extra_1.default.stat(filepath);
|
|
14
14
|
const files = stats.isDirectory() ? await (0, fs_1.walk)(filepath) : [filepath];
|
package/models/OAuth2Manager.js
CHANGED
|
@@ -20,7 +20,9 @@ class OAuth2Manager {
|
|
|
20
20
|
this.writeTokenInfo = writeTokenInfo;
|
|
21
21
|
this.refreshTokenRequest = null;
|
|
22
22
|
this.account = account;
|
|
23
|
-
|
|
23
|
+
if (this.account.env) {
|
|
24
|
+
this.account.env = (0, environment_1.getValidEnv)(this.account.env, '');
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
async accessToken() {
|
|
26
28
|
if (!this.account.auth.tokenInfo?.refreshToken) {
|
package/package.json
CHANGED
package/utils/objectUtils.d.ts
CHANGED
package/utils/objectUtils.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeDeep = exports.isObject = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
function isObject(item) {
|
|
6
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
7
7
|
}
|
|
8
8
|
exports.isObject = isObject;
|
|
9
9
|
function mergeDeep(
|