@hubspot/local-dev-lib 3.5.6 → 3.6.0
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/CLIConfiguration.d.ts +4 -0
- package/config/CLIConfiguration.js +23 -11
- package/config/config_DEPRECATED.d.ts +5 -0
- package/config/config_DEPRECATED.js +28 -16
- package/config/index.d.ts +1 -0
- package/config/index.js +10 -1
- package/config/migrate.js +11 -1
- package/constants/config.d.ts +1 -0
- package/constants/config.js +2 -1
- package/package.json +1 -1
- package/types/Config.d.ts +2 -0
|
@@ -54,6 +54,10 @@ declare class _CLIConfiguration {
|
|
|
54
54
|
* @throws {Error}
|
|
55
55
|
*/
|
|
56
56
|
updateHttpTimeout(timeout: string): CLIConfig_NEW | null;
|
|
57
|
+
/**
|
|
58
|
+
* @throws {Error}
|
|
59
|
+
*/
|
|
60
|
+
updateAllowAutoUpdates(enabled: boolean): CLIConfig_NEW | null;
|
|
57
61
|
/**
|
|
58
62
|
* @throws {Error}
|
|
59
63
|
*/
|
|
@@ -157,22 +157,24 @@ class _CLIConfiguration {
|
|
|
157
157
|
if (!nameOrIdToCheck) {
|
|
158
158
|
return null;
|
|
159
159
|
}
|
|
160
|
-
if (typeof nameOrIdToCheck === '
|
|
161
|
-
accountId = nameOrIdToCheck;
|
|
162
|
-
}
|
|
163
|
-
else if (/^\d+$/.test(nameOrIdToCheck)) {
|
|
164
|
-
accountId = parseInt(nameOrIdToCheck, 10);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
160
|
+
if (typeof nameOrIdToCheck === 'string') {
|
|
167
161
|
name = nameOrIdToCheck;
|
|
162
|
+
if (/^\d+$/.test(nameOrIdToCheck)) {
|
|
163
|
+
accountId = parseInt(nameOrIdToCheck, 10);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else if (typeof nameOrIdToCheck === 'number') {
|
|
167
|
+
accountId = nameOrIdToCheck;
|
|
168
168
|
}
|
|
169
|
+
let account = null;
|
|
169
170
|
if (name) {
|
|
170
|
-
|
|
171
|
+
account = this.config.accounts.find(a => a.name === name) || null;
|
|
171
172
|
}
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
if (accountId && !account) {
|
|
174
|
+
account =
|
|
175
|
+
this.config.accounts.find(a => accountId === a.accountId) || null;
|
|
174
176
|
}
|
|
175
|
-
return
|
|
177
|
+
return account;
|
|
176
178
|
}
|
|
177
179
|
isConfigFlagEnabled(flag, defaultValue = false) {
|
|
178
180
|
if (this.config && typeof this.config[flag] !== 'undefined') {
|
|
@@ -477,6 +479,16 @@ class _CLIConfiguration {
|
|
|
477
479
|
this.config.httpTimeout = parsedTimeout;
|
|
478
480
|
return this.write();
|
|
479
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* @throws {Error}
|
|
484
|
+
*/
|
|
485
|
+
updateAllowAutoUpdates(enabled) {
|
|
486
|
+
if (!this.config) {
|
|
487
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
|
|
488
|
+
}
|
|
489
|
+
this.config.allowAutoUpdates = enabled;
|
|
490
|
+
return this.write();
|
|
491
|
+
}
|
|
480
492
|
/**
|
|
481
493
|
* @throws {Error}
|
|
482
494
|
*/
|
|
@@ -14,6 +14,7 @@ export declare function accountNameExistsInConfig(name: string): boolean;
|
|
|
14
14
|
export declare function getOrderedAccount(unorderedAccount: CLIAccount_DEPRECATED): CLIAccount_DEPRECATED;
|
|
15
15
|
export declare function getOrderedConfig(unorderedConfig: CLIConfig_DEPRECATED): {
|
|
16
16
|
portals: CLIAccount_DEPRECATED[];
|
|
17
|
+
allowAutoUpdates?: boolean | undefined;
|
|
17
18
|
defaultMode?: CmsPublishMode | undefined;
|
|
18
19
|
env?: Environment | undefined;
|
|
19
20
|
httpUseLocalhost?: boolean | undefined;
|
|
@@ -51,6 +52,10 @@ export declare function updateDefaultCmsPublishMode(defaultCmsPublishMode: CmsPu
|
|
|
51
52
|
* @throws {Error}
|
|
52
53
|
*/
|
|
53
54
|
export declare function updateHttpTimeout(timeout: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* @throws {Error}
|
|
57
|
+
*/
|
|
58
|
+
export declare function updateAllowAutoUpdates(enabled: boolean): void;
|
|
54
59
|
/**
|
|
55
60
|
* @throws {Error}
|
|
56
61
|
*/
|
|
@@ -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.isConfigFlagEnabled = exports.loadConfigFromEnvironment = exports.deleteConfigFile = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.deleteAccount = exports.renameAccount = exports.updateAllowUsageTracking = exports.updateHttpTimeout = exports.updateDefaultCmsPublishMode = exports.updateDefaultAccount = exports.updateAccountConfig = exports.removeSandboxAccountFromConfig = exports.getAccountId = exports.getAccountConfig = exports.getAccountType = exports.getEnv = exports.findConfig = exports.getAndLoadConfigIfNeeded = exports.isTrackingAllowed = exports.loadConfig = exports.writeConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.accountNameExistsInConfig = exports.validateConfig = exports.getConfigPath = exports.setConfigPath = exports.getConfigAccountId = exports.getConfigDefaultAccount = exports.getConfigAccounts = exports.setConfig = exports.getConfig = void 0;
|
|
6
|
+
exports.isConfigFlagEnabled = exports.loadConfigFromEnvironment = exports.deleteConfigFile = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.deleteAccount = exports.renameAccount = exports.updateAllowUsageTracking = exports.updateAllowAutoUpdates = exports.updateHttpTimeout = exports.updateDefaultCmsPublishMode = exports.updateDefaultAccount = exports.updateAccountConfig = exports.removeSandboxAccountFromConfig = exports.getAccountId = exports.getAccountConfig = exports.getAccountType = exports.getEnv = exports.findConfig = exports.getAndLoadConfigIfNeeded = exports.isTrackingAllowed = exports.loadConfig = exports.writeConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.accountNameExistsInConfig = exports.validateConfig = exports.getConfigPath = exports.setConfigPath = exports.getConfigAccountId = exports.getConfigDefaultAccount = exports.getConfigAccounts = exports.setConfig = exports.getConfig = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
9
9
|
const findup_sync_1 = __importDefault(require("findup-sync"));
|
|
@@ -331,14 +331,14 @@ function getAccountId(nameOrId) {
|
|
|
331
331
|
let accountId = undefined;
|
|
332
332
|
let account = undefined;
|
|
333
333
|
function setNameOrAccountFromSuppliedValue(suppliedValue) {
|
|
334
|
-
if (typeof suppliedValue === '
|
|
335
|
-
accountId = suppliedValue;
|
|
336
|
-
}
|
|
337
|
-
else if (/^\d+$/.test(suppliedValue)) {
|
|
338
|
-
accountId = parseInt(suppliedValue, 10);
|
|
339
|
-
}
|
|
340
|
-
else {
|
|
334
|
+
if (typeof suppliedValue === 'string') {
|
|
341
335
|
name = suppliedValue;
|
|
336
|
+
if (/^\d+$/.test(suppliedValue)) {
|
|
337
|
+
accountId = parseInt(suppliedValue, 10);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else if (typeof suppliedValue === 'number') {
|
|
341
|
+
accountId = suppliedValue;
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
if (!nameOrId) {
|
|
@@ -351,14 +351,16 @@ function getAccountId(nameOrId) {
|
|
|
351
351
|
setNameOrAccountFromSuppliedValue(nameOrId);
|
|
352
352
|
}
|
|
353
353
|
const accounts = getConfigAccounts(config);
|
|
354
|
-
if (
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
354
|
+
if (accounts) {
|
|
355
|
+
if (name) {
|
|
356
|
+
account = accounts.find(p => p.name === name);
|
|
357
|
+
}
|
|
358
|
+
if (accountId && !account) {
|
|
359
|
+
account = accounts.find(p => accountId === p.portalId);
|
|
360
|
+
}
|
|
361
|
+
if (account) {
|
|
362
|
+
return account.portalId;
|
|
363
|
+
}
|
|
362
364
|
}
|
|
363
365
|
return undefined;
|
|
364
366
|
}
|
|
@@ -492,6 +494,16 @@ function updateHttpTimeout(timeout) {
|
|
|
492
494
|
writeConfig();
|
|
493
495
|
}
|
|
494
496
|
exports.updateHttpTimeout = updateHttpTimeout;
|
|
497
|
+
/**
|
|
498
|
+
* @throws {Error}
|
|
499
|
+
*/
|
|
500
|
+
function updateAllowAutoUpdates(enabled) {
|
|
501
|
+
const config = getAndLoadConfigIfNeeded();
|
|
502
|
+
config.allowAutoUpdates = enabled;
|
|
503
|
+
setDefaultConfigPathIfUnset();
|
|
504
|
+
writeConfig();
|
|
505
|
+
}
|
|
506
|
+
exports.updateAllowAutoUpdates = updateAllowAutoUpdates;
|
|
495
507
|
/**
|
|
496
508
|
* @throws {Error}
|
|
497
509
|
*/
|
package/config/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare function getAccountId(nameOrId?: string | number): number | null;
|
|
|
24
24
|
export declare function removeSandboxAccountFromConfig(nameOrId: string | number): boolean;
|
|
25
25
|
export declare function deleteAccount(accountName: string): Promise<void | boolean>;
|
|
26
26
|
export declare function updateHttpTimeout(timeout: string): void;
|
|
27
|
+
export declare function updateAllowAutoUpdates(enabled: boolean): void;
|
|
27
28
|
export declare function updateAllowUsageTracking(isEnabled: boolean): void;
|
|
28
29
|
export declare function deleteConfigFile(): void;
|
|
29
30
|
export declare function isConfigFlagEnabled(flag: keyof CLIConfig): boolean;
|
package/config/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.findConfig = exports.setConfigPath = exports.setConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.getConfigAccountId = exports.getDefaultAccountOverrideFilePath = exports.getCWDAccountOverride = exports.updateDefaultCmsPublishMode = exports.getConfigAccounts = exports.getDisplayDefaultAccount = exports.getConfigDefaultAccount = exports.getAccountType = exports.getEnv = exports.isTrackingAllowed = exports.isConfigFlagEnabled = exports.deleteConfigFile = exports.updateAllowUsageTracking = exports.updateHttpTimeout = exports.deleteAccount = exports.removeSandboxAccountFromConfig = exports.getAccountId = exports.renameAccount = exports.updateDefaultAccount = exports.updateAccountConfig = exports.accountNameExistsInConfig = exports.getAccountConfig = exports.configFileExists = exports.getConfigPath = exports.writeConfig = exports.getConfig = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.loadConfigFromEnvironment = exports.validateConfig = exports.getAndLoadConfigIfNeeded = exports.loadConfig = void 0;
|
|
26
|
+
exports.findConfig = exports.setConfigPath = exports.setConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.getConfigAccountId = exports.getDefaultAccountOverrideFilePath = exports.getCWDAccountOverride = exports.updateDefaultCmsPublishMode = exports.getConfigAccounts = exports.getDisplayDefaultAccount = exports.getConfigDefaultAccount = exports.getAccountType = exports.getEnv = exports.isTrackingAllowed = exports.isConfigFlagEnabled = exports.deleteConfigFile = exports.updateAllowUsageTracking = exports.updateAllowAutoUpdates = exports.updateHttpTimeout = exports.deleteAccount = exports.removeSandboxAccountFromConfig = exports.getAccountId = exports.renameAccount = exports.updateDefaultAccount = exports.updateAccountConfig = exports.accountNameExistsInConfig = exports.getAccountConfig = exports.configFileExists = exports.getConfigPath = exports.writeConfig = exports.getConfig = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.loadConfigFromEnvironment = exports.validateConfig = exports.getAndLoadConfigIfNeeded = exports.loadConfig = void 0;
|
|
27
27
|
const config_DEPRECATED = __importStar(require("./config_DEPRECATED"));
|
|
28
28
|
const CLIConfiguration_1 = require("./CLIConfiguration");
|
|
29
29
|
const configFile_1 = require("./configFile");
|
|
@@ -184,6 +184,15 @@ function updateHttpTimeout(timeout) {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
exports.updateHttpTimeout = updateHttpTimeout;
|
|
187
|
+
function updateAllowAutoUpdates(enabled) {
|
|
188
|
+
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
189
|
+
CLIConfiguration_1.CLIConfiguration.updateAllowAutoUpdates(enabled);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
config_DEPRECATED.updateAllowAutoUpdates(enabled);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.updateAllowAutoUpdates = updateAllowAutoUpdates;
|
|
187
196
|
function updateAllowUsageTracking(isEnabled) {
|
|
188
197
|
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
189
198
|
CLIConfiguration_1.CLIConfiguration.updateAllowUsageTracking(isEnabled);
|
package/config/migrate.js
CHANGED
|
@@ -22,6 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.mergeExistingConfigs = exports.mergeConfigProperties = exports.migrateConfig = exports.getConfigPath = exports.configFileExists = exports.getGlobalConfig = exports.getDeprecatedConfig = void 0;
|
|
27
30
|
const config_DEPRECATED = __importStar(require("./config_DEPRECATED"));
|
|
@@ -30,6 +33,8 @@ const index_1 = require("./index");
|
|
|
30
33
|
const configFile_1 = require("./configFile");
|
|
31
34
|
const config_1 = require("../constants/config");
|
|
32
35
|
const lang_1 = require("../utils/lang");
|
|
36
|
+
const fs_1 = __importDefault(require("fs"));
|
|
37
|
+
const path_1 = __importDefault(require("path"));
|
|
33
38
|
const i18nKey = 'config.migrate';
|
|
34
39
|
function getDeprecatedConfig(configPath) {
|
|
35
40
|
return config_DEPRECATED.loadConfig(configPath);
|
|
@@ -63,7 +68,12 @@ function writeGlobalConfigFile(updatedConfig, isMigrating = false) {
|
|
|
63
68
|
(0, index_1.loadConfig)('');
|
|
64
69
|
try {
|
|
65
70
|
(0, index_1.writeConfig)({ source: updatedConfigJson });
|
|
66
|
-
config_DEPRECATED.
|
|
71
|
+
const oldConfigPath = config_DEPRECATED.getConfigPath();
|
|
72
|
+
if (oldConfigPath) {
|
|
73
|
+
const dir = path_1.default.dirname(oldConfigPath);
|
|
74
|
+
const newConfigPath = path_1.default.join(dir, config_1.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME);
|
|
75
|
+
fs_1.default.renameSync(oldConfigPath, newConfigPath);
|
|
76
|
+
}
|
|
67
77
|
}
|
|
68
78
|
catch (error) {
|
|
69
79
|
(0, index_1.deleteEmptyConfigFile)();
|
package/constants/config.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = "hubspot.config.yml";
|
|
2
|
+
export declare const ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME = "archived.hubspot.config.yml";
|
|
2
3
|
export declare const HUBSPOT_CONFIGURATION_FOLDER = ".hscli";
|
|
3
4
|
export declare const HUBSPOT_CONFIGURATION_FILE = "config.yml";
|
|
4
5
|
export declare const GLOBAL_CONFIG_PATH: string;
|
package/constants/config.js
CHANGED
|
@@ -3,11 +3,12 @@ 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.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.DEFAULT_PORTAL = exports.DEFAULT_ACCOUNT = exports.ALLOW_USAGE_TRACKING = exports.HTTP_USE_LOCALHOST = exports.ENV = exports.HTTP_TIMEOUT = exports.DEFAULT_CMS_PUBLISH_MODE = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = exports.GLOBAL_CONFIG_PATH = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
|
|
6
|
+
exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.DEFAULT_PORTAL = exports.DEFAULT_ACCOUNT = exports.ALLOW_USAGE_TRACKING = exports.HTTP_USE_LOCALHOST = exports.ENV = exports.HTTP_TIMEOUT = exports.DEFAULT_CMS_PUBLISH_MODE = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = exports.GLOBAL_CONFIG_PATH = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
|
|
7
7
|
const lang_1 = require("../utils/lang");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const os_1 = __importDefault(require("os"));
|
|
10
10
|
exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
|
|
11
|
+
exports.ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME = 'archived.hubspot.config.yml';
|
|
11
12
|
exports.HUBSPOT_CONFIGURATION_FOLDER = '.hscli';
|
|
12
13
|
exports.HUBSPOT_CONFIGURATION_FILE = 'config.yml';
|
|
13
14
|
exports.GLOBAL_CONFIG_PATH = path_1.default.join(os_1.default.homedir(), exports.HUBSPOT_CONFIGURATION_FOLDER, exports.HUBSPOT_CONFIGURATION_FILE);
|
package/package.json
CHANGED
package/types/Config.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ValueOf } from './Utils';
|
|
|
5
5
|
export interface CLIConfig_NEW {
|
|
6
6
|
accounts: Array<CLIAccount_NEW>;
|
|
7
7
|
allowUsageTracking?: boolean;
|
|
8
|
+
allowAutoUpdates?: boolean;
|
|
8
9
|
defaultAccount?: string | number;
|
|
9
10
|
defaultMode?: CmsPublishMode;
|
|
10
11
|
defaultCmsPublishMode?: CmsPublishMode;
|
|
@@ -15,6 +16,7 @@ export interface CLIConfig_NEW {
|
|
|
15
16
|
export interface CLIConfig_DEPRECATED {
|
|
16
17
|
portals: Array<CLIAccount_DEPRECATED>;
|
|
17
18
|
allowUsageTracking?: boolean;
|
|
19
|
+
allowAutoUpdates?: boolean;
|
|
18
20
|
defaultPortal?: string | number;
|
|
19
21
|
defaultMode?: CmsPublishMode;
|
|
20
22
|
defaultCmsPublishMode?: CmsPublishMode;
|