@hubspot/local-dev-lib 0.2.2-experimental.0 → 0.2.3-experimental.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/configFile.js +3 -1
- package/config/index.d.ts +2 -1
- package/config/index.js +14 -3
- package/constants/config.d.ts +0 -7
- package/constants/config.js +1 -13
- package/lang/en.json +0 -6
- package/package.json +3 -4
- package/config/migrate.d.ts +0 -20
- package/config/migrate.js +0 -150
package/config/configFile.js
CHANGED
|
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.writeConfigToFile = exports.loadConfigFromFile = exports.parseConfig = exports.readConfigFile = exports.deleteConfigFile = exports.configFileIsBlank = exports.configFileExists = exports.getConfigFilePath = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
8
10
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
9
11
|
const logger_1 = require("../lib/logger");
|
|
10
12
|
const config_1 = require("../constants/config");
|
|
@@ -13,7 +15,7 @@ const lang_1 = require("../utils/lang");
|
|
|
13
15
|
const FileSystemError_1 = require("../models/FileSystemError");
|
|
14
16
|
const i18nKey = 'config.configFile';
|
|
15
17
|
function getConfigFilePath() {
|
|
16
|
-
return config_1.
|
|
18
|
+
return path_1.default.join(os_1.default.homedir(), config_1.HUBSPOT_CONFIGURATION_FOLDER, config_1.HUBSPOT_CONFIGURATION_FILE);
|
|
17
19
|
}
|
|
18
20
|
exports.getConfigFilePath = getConfigFilePath;
|
|
19
21
|
function configFileExists() {
|
package/config/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function deleteEmptyConfigFile(): void;
|
|
|
14
14
|
export declare function getConfig(): CLIConfig | null;
|
|
15
15
|
export declare function writeConfig(options?: WriteConfigOptions): void;
|
|
16
16
|
export declare function getConfigPath(path?: string, useHiddenConfig?: boolean): string | null;
|
|
17
|
-
export declare function configFileExists(useHiddenConfig?: boolean
|
|
17
|
+
export declare function configFileExists(useHiddenConfig?: boolean): boolean;
|
|
18
18
|
export declare function getAccountConfig(accountId?: number): CLIAccount | null;
|
|
19
19
|
export declare function accountNameExistsInConfig(name: string): boolean;
|
|
20
20
|
export declare function updateAccountConfig(configOptions: Partial<FlatAccountFields>): FlatAccountFields | null;
|
|
@@ -31,6 +31,7 @@ export declare function isTrackingAllowed(): boolean;
|
|
|
31
31
|
export declare function getEnv(nameOrId?: string | number): import("../types/Config").Environment;
|
|
32
32
|
export declare function getAccountType(accountType?: AccountType, sandboxAccountType?: string | null): AccountType;
|
|
33
33
|
export declare function getConfigDefaultAccount(): string | number | null | undefined;
|
|
34
|
+
export declare function getDisplayDefaultAccount(isOverride: boolean): string | number | null | undefined;
|
|
34
35
|
export declare function getConfigAccounts(): Array<CLIAccount_NEW> | Array<CLIAccount_DEPRECATED> | null | undefined;
|
|
35
36
|
export declare function updateDefaultCmsPublishMode(cmsPublishMode: CmsPublishMode): void | CLIConfig_NEW | null;
|
|
36
37
|
export declare function getCWDAccountOverride(): string | number | null | undefined;
|
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.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.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");
|
|
@@ -100,10 +100,10 @@ function getConfigPath(path, useHiddenConfig = false) {
|
|
|
100
100
|
return config_DEPRECATED.getConfigPath(path);
|
|
101
101
|
}
|
|
102
102
|
exports.getConfigPath = getConfigPath;
|
|
103
|
-
function configFileExists(useHiddenConfig
|
|
103
|
+
function configFileExists(useHiddenConfig) {
|
|
104
104
|
return useHiddenConfig
|
|
105
105
|
? (0, configFile_1.configFileExists)()
|
|
106
|
-
: Boolean(config_DEPRECATED.getConfigPath(
|
|
106
|
+
: Boolean(config_DEPRECATED.getConfigPath());
|
|
107
107
|
}
|
|
108
108
|
exports.configFileExists = configFileExists;
|
|
109
109
|
function getAccountConfig(accountId) {
|
|
@@ -237,6 +237,17 @@ function getConfigDefaultAccount() {
|
|
|
237
237
|
return config_DEPRECATED.getConfigDefaultAccount();
|
|
238
238
|
}
|
|
239
239
|
exports.getConfigDefaultAccount = getConfigDefaultAccount;
|
|
240
|
+
function getDisplayDefaultAccount(isOverride) {
|
|
241
|
+
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
242
|
+
return isOverride
|
|
243
|
+
? CLIConfiguration_1.CLIConfiguration.getCWDAccountOverride()
|
|
244
|
+
: CLIConfiguration_1.CLIConfiguration.config?.defaultAccount;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
return config_DEPRECATED.getConfigDefaultAccount();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
exports.getDisplayDefaultAccount = getDisplayDefaultAccount;
|
|
240
251
|
function getConfigAccounts() {
|
|
241
252
|
if (CLIConfiguration_1.CLIConfiguration.isActive()) {
|
|
242
253
|
return CLIConfiguration_1.CLIConfiguration.getConfigAccounts();
|
package/constants/config.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
export declare const DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = "hubspot.config.yml";
|
|
2
2
|
export declare const HUBSPOT_CONFIGURATION_FOLDER = ".hscli";
|
|
3
3
|
export declare const HUBSPOT_CONFIGURATION_FILE = "config.yml";
|
|
4
|
-
export declare const GLOBAL_CONFIG_PATH: string;
|
|
5
4
|
export declare const DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = ".hsaccount";
|
|
6
5
|
export declare const DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = "DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID";
|
|
7
6
|
export declare const DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = "DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND";
|
|
8
|
-
export declare const DEFAULT_CMS_PUBLISH_MODE = "defaultCmsPublishMode";
|
|
9
|
-
export declare const HTTP_TIMEOUT = "httpTimeout";
|
|
10
|
-
export declare const ENV = "env";
|
|
11
|
-
export declare const HTTP_USE_LOCALHOST = "httpUseLocalhost";
|
|
12
|
-
export declare const DEFAULT_ACCOUNT = "defaultAccount";
|
|
13
|
-
export declare const DEFAULT_PORTAL = "defaultPortal";
|
|
14
7
|
export declare const MIN_HTTP_TIMEOUT = 3000;
|
|
15
8
|
export declare const HUBSPOT_ACCOUNT_TYPES: {
|
|
16
9
|
readonly DEVELOPMENT_SANDBOX: "DEVELOPMENT_SANDBOX";
|
package/constants/config.js
CHANGED
|
@@ -1,25 +1,13 @@
|
|
|
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.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.
|
|
3
|
+
exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
|
|
7
4
|
const lang_1 = require("../utils/lang");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const os_1 = __importDefault(require("os"));
|
|
10
5
|
exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
|
|
11
6
|
exports.HUBSPOT_CONFIGURATION_FOLDER = '.hscli';
|
|
12
7
|
exports.HUBSPOT_CONFIGURATION_FILE = 'config.yml';
|
|
13
|
-
exports.GLOBAL_CONFIG_PATH = path_1.default.join(os_1.default.homedir(), exports.HUBSPOT_CONFIGURATION_FOLDER, exports.HUBSPOT_CONFIGURATION_FILE);
|
|
14
8
|
exports.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME = '.hsaccount';
|
|
15
9
|
exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID = 'DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID';
|
|
16
10
|
exports.DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND = 'DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND';
|
|
17
|
-
exports.DEFAULT_CMS_PUBLISH_MODE = 'defaultCmsPublishMode';
|
|
18
|
-
exports.HTTP_TIMEOUT = 'httpTimeout';
|
|
19
|
-
exports.ENV = 'env';
|
|
20
|
-
exports.HTTP_USE_LOCALHOST = 'httpUseLocalhost';
|
|
21
|
-
exports.DEFAULT_ACCOUNT = 'defaultAccount';
|
|
22
|
-
exports.DEFAULT_PORTAL = 'defaultPortal';
|
|
23
11
|
exports.MIN_HTTP_TIMEOUT = 3000;
|
|
24
12
|
exports.HUBSPOT_ACCOUNT_TYPES = {
|
|
25
13
|
DEVELOPMENT_SANDBOX: 'DEVELOPMENT_SANDBOX',
|
package/lang/en.json
CHANGED
|
@@ -311,12 +311,6 @@
|
|
|
311
311
|
"missingEnv": "Unable to load config from environment variables: Missing env",
|
|
312
312
|
"unknownAuthType": "Unable to load config from environment variables: Unknown auth type"
|
|
313
313
|
}
|
|
314
|
-
},
|
|
315
|
-
"migrate": {
|
|
316
|
-
"errors": {
|
|
317
|
-
"writeConfig": "Unable to write global configuration file at {{ configPath }}.",
|
|
318
|
-
"noDeprecatedConfig": "No deprecated configuration file found. Skipping migration to global config."
|
|
319
|
-
}
|
|
320
314
|
}
|
|
321
315
|
},
|
|
322
316
|
"models": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/local-dev-lib",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3-experimental.0",
|
|
4
4
|
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"./http": "./http/index.js",
|
|
51
51
|
"./http/*": "./http/*.js",
|
|
52
52
|
"./config/getAccountIdentifier": "./config/getAccountIdentifier.js",
|
|
53
|
-
"./config/migrate": "./config/migrate.js",
|
|
54
53
|
"./config": "./config/index.js",
|
|
55
54
|
"./constants/*": "./constants/*.js",
|
|
56
55
|
"./models/*": "./models/*.js",
|
|
@@ -58,13 +57,13 @@
|
|
|
58
57
|
},
|
|
59
58
|
"dependencies": {
|
|
60
59
|
"address": "2.0.2",
|
|
61
|
-
"axios": "1.
|
|
60
|
+
"axios": "1.8.3",
|
|
62
61
|
"chalk": "2.4.2",
|
|
63
62
|
"chokidar": "3.6.0",
|
|
64
63
|
"content-disposition": "0.5.4",
|
|
65
64
|
"cors": "2.8.5",
|
|
66
65
|
"debounce": "1.2.1",
|
|
67
|
-
"express": "4.
|
|
66
|
+
"express": "4.21.2",
|
|
68
67
|
"extract-zip": "2.0.1",
|
|
69
68
|
"findup-sync": "5.0.0",
|
|
70
69
|
"fs-extra": "11.2.0",
|
package/config/migrate.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { CLIConfig, CLIConfig_DEPRECATED, CLIConfig_NEW, Environment } from '../types/Config';
|
|
2
|
-
import { CmsPublishMode } from '../types/Files';
|
|
3
|
-
export declare function getConfig(useHiddenConfig?: boolean, configPath?: string): Partial<CLIConfig> | null;
|
|
4
|
-
export declare function getConfigPath(configPath?: string, useHiddenConfig?: boolean): string | null;
|
|
5
|
-
export declare function migrateConfig(deprecatedConfig: CLIConfig_DEPRECATED | null): void;
|
|
6
|
-
type ConflictValue = boolean | string | number | CmsPublishMode | Environment;
|
|
7
|
-
export type ConflictProperty = {
|
|
8
|
-
property: keyof CLIConfig_NEW;
|
|
9
|
-
oldValue: ConflictValue;
|
|
10
|
-
newValue: ConflictValue;
|
|
11
|
-
};
|
|
12
|
-
export declare function mergeConfigProperties(globalConfig: CLIConfig_NEW, deprecatedConfig: CLIConfig_DEPRECATED, force?: boolean): {
|
|
13
|
-
initialConfig: CLIConfig_NEW;
|
|
14
|
-
conflicts: Array<ConflictProperty>;
|
|
15
|
-
};
|
|
16
|
-
export declare function mergeExistingConfigs(globalConfig: CLIConfig_NEW, deprecatedConfig: CLIConfig_DEPRECATED): {
|
|
17
|
-
finalConfig: CLIConfig_NEW;
|
|
18
|
-
skippedAccountIds: Array<string | number>;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
package/config/migrate.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.mergeExistingConfigs = exports.mergeConfigProperties = exports.migrateConfig = exports.getConfigPath = exports.getConfig = void 0;
|
|
27
|
-
const config_DEPRECATED = __importStar(require("./config_DEPRECATED"));
|
|
28
|
-
const CLIConfiguration_1 = require("./CLIConfiguration");
|
|
29
|
-
const index_1 = require("./index");
|
|
30
|
-
const configFile_1 = require("./configFile");
|
|
31
|
-
const config_1 = require("../constants/config");
|
|
32
|
-
const lang_1 = require("../utils/lang");
|
|
33
|
-
const i18nKey = 'config.migrate';
|
|
34
|
-
function getConfig(useHiddenConfig, configPath) {
|
|
35
|
-
if (useHiddenConfig) {
|
|
36
|
-
return CLIConfiguration_1.CLIConfiguration.config;
|
|
37
|
-
}
|
|
38
|
-
return config_DEPRECATED.loadConfig(configPath);
|
|
39
|
-
}
|
|
40
|
-
exports.getConfig = getConfig;
|
|
41
|
-
function getConfigPath(configPath, useHiddenConfig = false) {
|
|
42
|
-
if (useHiddenConfig) {
|
|
43
|
-
return (0, configFile_1.getConfigFilePath)();
|
|
44
|
-
}
|
|
45
|
-
return config_DEPRECATED.getConfigPath(configPath);
|
|
46
|
-
}
|
|
47
|
-
exports.getConfigPath = getConfigPath;
|
|
48
|
-
function writeGlobalConfigFile(updatedConfig, isMigrating = false) {
|
|
49
|
-
const updatedConfigJson = JSON.stringify(updatedConfig);
|
|
50
|
-
if (isMigrating) {
|
|
51
|
-
(0, index_1.createEmptyConfigFile)({}, true);
|
|
52
|
-
}
|
|
53
|
-
(0, index_1.loadConfig)('');
|
|
54
|
-
try {
|
|
55
|
-
(0, index_1.writeConfig)({ source: updatedConfigJson });
|
|
56
|
-
config_DEPRECATED.deleteConfigFile();
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
(0, index_1.deleteEmptyConfigFile)();
|
|
60
|
-
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.writeConfig`, { configPath: config_1.GLOBAL_CONFIG_PATH }), { cause: error });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function migrateConfig(deprecatedConfig) {
|
|
64
|
-
if (!deprecatedConfig) {
|
|
65
|
-
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noDeprecatedConfig`));
|
|
66
|
-
}
|
|
67
|
-
const { defaultPortal, portals, ...rest } = deprecatedConfig;
|
|
68
|
-
const updatedConfig = {
|
|
69
|
-
...rest,
|
|
70
|
-
defaultAccount: defaultPortal,
|
|
71
|
-
accounts: portals
|
|
72
|
-
.filter(({ portalId }) => portalId !== undefined)
|
|
73
|
-
.map(({ portalId, ...rest }) => ({
|
|
74
|
-
...rest,
|
|
75
|
-
accountId: portalId,
|
|
76
|
-
})),
|
|
77
|
-
};
|
|
78
|
-
writeGlobalConfigFile(updatedConfig, true);
|
|
79
|
-
}
|
|
80
|
-
exports.migrateConfig = migrateConfig;
|
|
81
|
-
function mergeConfigProperties(globalConfig, deprecatedConfig, force) {
|
|
82
|
-
const propertiesToCheck = [
|
|
83
|
-
config_1.DEFAULT_CMS_PUBLISH_MODE,
|
|
84
|
-
config_1.HTTP_TIMEOUT,
|
|
85
|
-
config_1.ENV,
|
|
86
|
-
config_1.HTTP_USE_LOCALHOST,
|
|
87
|
-
];
|
|
88
|
-
const conflicts = [];
|
|
89
|
-
propertiesToCheck.forEach(prop => {
|
|
90
|
-
if (prop in globalConfig && prop in deprecatedConfig) {
|
|
91
|
-
if (force || globalConfig[prop] === deprecatedConfig[prop]) {
|
|
92
|
-
// @ts-expect-error Cannot reconcile CLIConfig_NEW and CLIConfig_DEPRECATED types
|
|
93
|
-
globalConfig[prop] = deprecatedConfig[prop];
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
conflicts.push({
|
|
97
|
-
property: prop,
|
|
98
|
-
oldValue: deprecatedConfig[prop],
|
|
99
|
-
newValue: globalConfig[prop],
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
if (config_1.DEFAULT_ACCOUNT in globalConfig &&
|
|
105
|
-
config_1.DEFAULT_PORTAL in deprecatedConfig &&
|
|
106
|
-
globalConfig.defaultAccount !== deprecatedConfig.defaultPortal) {
|
|
107
|
-
conflicts.push({
|
|
108
|
-
property: config_1.DEFAULT_ACCOUNT,
|
|
109
|
-
oldValue: deprecatedConfig.defaultPortal,
|
|
110
|
-
newValue: globalConfig.defaultAccount,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
else if (config_1.DEFAULT_PORTAL in deprecatedConfig) {
|
|
114
|
-
globalConfig.defaultAccount = deprecatedConfig.defaultPortal;
|
|
115
|
-
}
|
|
116
|
-
return { initialConfig: globalConfig, conflicts };
|
|
117
|
-
}
|
|
118
|
-
exports.mergeConfigProperties = mergeConfigProperties;
|
|
119
|
-
function mergeAccounts(globalConfig, deprecatedConfig) {
|
|
120
|
-
let existingAccountIds = [];
|
|
121
|
-
const skippedAccountIds = [];
|
|
122
|
-
if (globalConfig.accounts && deprecatedConfig.portals) {
|
|
123
|
-
existingAccountIds = globalConfig.accounts.map(account => account.accountId);
|
|
124
|
-
const newAccounts = deprecatedConfig.portals
|
|
125
|
-
.filter(portal => {
|
|
126
|
-
const isExisting = existingAccountIds.includes(portal.portalId);
|
|
127
|
-
if (isExisting) {
|
|
128
|
-
skippedAccountIds.push(portal.portalId);
|
|
129
|
-
}
|
|
130
|
-
return !isExisting;
|
|
131
|
-
})
|
|
132
|
-
.map(({ portalId, ...rest }) => ({
|
|
133
|
-
...rest,
|
|
134
|
-
accountId: portalId,
|
|
135
|
-
}));
|
|
136
|
-
if (newAccounts.length > 0) {
|
|
137
|
-
globalConfig.accounts.push(...newAccounts);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
finalConfig: globalConfig,
|
|
142
|
-
skippedAccountIds,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function mergeExistingConfigs(globalConfig, deprecatedConfig) {
|
|
146
|
-
const { finalConfig, skippedAccountIds } = mergeAccounts(globalConfig, deprecatedConfig);
|
|
147
|
-
writeGlobalConfigFile(finalConfig);
|
|
148
|
-
return { finalConfig, skippedAccountIds };
|
|
149
|
-
}
|
|
150
|
-
exports.mergeExistingConfigs = mergeExistingConfigs;
|