@hubspot/local-dev-lib 0.7.4-experimental.1 → 0.7.4-experimental.2
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/index.d.ts +2 -1
- package/config/index.js +29 -20
- package/package.json +1 -1
package/config/index.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ export declare function getConfigAccountByName(accountName: string): HubSpotConf
|
|
|
17
17
|
export declare function getConfigAccountIfExists(identifier: number | string): HubSpotConfigAccount | undefined;
|
|
18
18
|
export declare function getConfigDefaultAccount(): HubSpotConfigAccount;
|
|
19
19
|
export declare function getConfigDefaultAccountIfExists(): HubSpotConfigAccount | undefined;
|
|
20
|
-
export declare function getAllConfigAccounts(
|
|
20
|
+
export declare function getAllConfigAccounts(): HubSpotConfigAccount[];
|
|
21
|
+
export declare function getLinkedConfigAccounts(): HubSpotConfigAccount[];
|
|
21
22
|
export declare function getConfigAccountEnvironment(identifier: number | string): Environment;
|
|
22
23
|
export declare function addConfigAccount(accountToAdd: HubSpotConfigAccount): void;
|
|
23
24
|
export declare function updateConfigAccount(updatedAccount: HubSpotConfigAccount): void;
|
package/config/index.js
CHANGED
|
@@ -153,11 +153,17 @@ export function getConfigAccountIfExists(identifier) {
|
|
|
153
153
|
export function getConfigDefaultAccount() {
|
|
154
154
|
const { accounts, defaultAccount } = getConfig();
|
|
155
155
|
let defaultAccountToUse = defaultAccount;
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
const hsSettingsFile = getHsSettingsFile();
|
|
157
|
+
if (hsSettingsFile && hsSettingsFile.localDefaultAccount) {
|
|
158
|
+
defaultAccountToUse = hsSettingsFile.localDefaultAccount;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const currentConfigPath = getConfigFilePath();
|
|
162
|
+
const globalConfigPath = getGlobalConfigFilePath();
|
|
163
|
+
if (currentConfigPath === globalConfigPath && globalConfigFileExists()) {
|
|
164
|
+
const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId(accounts);
|
|
165
|
+
defaultAccountToUse = defaultAccountOverrideAccountId || defaultAccount;
|
|
166
|
+
}
|
|
161
167
|
}
|
|
162
168
|
if (!defaultAccountToUse) {
|
|
163
169
|
throw new HubSpotConfigError(i18n('config.getConfigDefaultAccount.fieldMissingError'), HUBSPOT_CONFIG_ERROR_TYPES.NO_DEFAULT_ACCOUNT, HUBSPOT_CONFIG_OPERATIONS.READ);
|
|
@@ -173,33 +179,36 @@ export function getConfigDefaultAccount() {
|
|
|
173
179
|
export function getConfigDefaultAccountIfExists() {
|
|
174
180
|
const { accounts, defaultAccount } = getConfig();
|
|
175
181
|
let defaultAccountToUse = defaultAccount;
|
|
176
|
-
// Only check for default account override if we're using the global config
|
|
177
|
-
const currentConfigPath = getConfigFilePath();
|
|
178
|
-
const globalConfigPath = getGlobalConfigFilePath();
|
|
179
|
-
if (currentConfigPath === globalConfigPath && globalConfigFileExists()) {
|
|
180
|
-
const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId(accounts);
|
|
181
|
-
defaultAccountToUse = defaultAccountOverrideAccountId || defaultAccount;
|
|
182
|
-
}
|
|
183
|
-
// Use the default account if .hs/settings.json is present
|
|
184
182
|
const hsSettingsFile = getHsSettingsFile();
|
|
185
183
|
if (hsSettingsFile && hsSettingsFile.localDefaultAccount) {
|
|
186
184
|
defaultAccountToUse = hsSettingsFile.localDefaultAccount;
|
|
187
185
|
}
|
|
186
|
+
else {
|
|
187
|
+
const currentConfigPath = getConfigFilePath();
|
|
188
|
+
const globalConfigPath = getGlobalConfigFilePath();
|
|
189
|
+
if (currentConfigPath === globalConfigPath && globalConfigFileExists()) {
|
|
190
|
+
const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId(accounts);
|
|
191
|
+
defaultAccountToUse = defaultAccountOverrideAccountId || defaultAccount;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
188
194
|
if (!defaultAccountToUse) {
|
|
189
195
|
return;
|
|
190
196
|
}
|
|
191
197
|
const account = getConfigAccountByInferredIdentifier(accounts, defaultAccountToUse);
|
|
192
198
|
return account;
|
|
193
199
|
}
|
|
194
|
-
export function getAllConfigAccounts(
|
|
195
|
-
|
|
196
|
-
// Show only accounts in the .hs/settings.json file
|
|
197
|
-
if (!showAll) {
|
|
198
|
-
const hsSettingsFile = getHsSettingsFile();
|
|
199
|
-
accounts = accounts.filter(a => hsSettingsFile ? hsSettingsFile.accounts.includes(a.accountId) : true);
|
|
200
|
-
}
|
|
200
|
+
export function getAllConfigAccounts() {
|
|
201
|
+
const { accounts } = getConfig();
|
|
201
202
|
return accounts;
|
|
202
203
|
}
|
|
204
|
+
export function getLinkedConfigAccounts() {
|
|
205
|
+
const { accounts } = getConfig();
|
|
206
|
+
const hsSettingsFile = getHsSettingsFile();
|
|
207
|
+
if (!hsSettingsFile) {
|
|
208
|
+
return accounts;
|
|
209
|
+
}
|
|
210
|
+
return accounts.filter(a => hsSettingsFile.accounts.includes(a.accountId));
|
|
211
|
+
}
|
|
203
212
|
export function getConfigAccountEnvironment(identifier) {
|
|
204
213
|
const config = getConfig();
|
|
205
214
|
const account = getConfigAccountByInferredIdentifier(config.accounts, identifier);
|
package/package.json
CHANGED