@hubspot/local-dev-lib 0.7.4-experimental.1 → 0.7.4-experimental.3
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/hsSettings.d.ts +1 -1
- package/config/hsSettings.js +1 -1
- package/config/index.d.ts +2 -1
- package/config/index.js +31 -22
- package/lib/gitignore.d.ts +1 -1
- package/lib/gitignore.js +1 -1
- package/package.json +1 -1
package/config/hsSettings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { HsSettingsFile } from '../types/HsSettings.js';
|
|
2
2
|
export declare function getHsSettingsFilePath(): string | null;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function getHsSettingsFileIfExists(): HsSettingsFile | null;
|
|
4
4
|
export declare function writeHsSettingsFile(settingsFile: HsSettingsFile): void;
|
package/config/hsSettings.js
CHANGED
|
@@ -20,7 +20,7 @@ export function getHsSettingsFilePath() {
|
|
|
20
20
|
cwd: getCwd(),
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
export function
|
|
23
|
+
export function getHsSettingsFileIfExists() {
|
|
24
24
|
const hsSettingsFilePath = getHsSettingsFilePath();
|
|
25
25
|
if (!hsSettingsFilePath) {
|
|
26
26
|
return null;
|
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 getLinkedOrAllConfigAccounts(): 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
|
@@ -11,7 +11,7 @@ import { HubSpotConfigError } from '../models/HubSpotConfigError.js';
|
|
|
11
11
|
import { HUBSPOT_CONFIG_ERROR_TYPES } from '../constants/config.js';
|
|
12
12
|
import { isDeepEqual } from '../lib/isDeepEqual.js';
|
|
13
13
|
import { getCwd } from '../lib/path.js';
|
|
14
|
-
import {
|
|
14
|
+
import { getHsSettingsFileIfExists } from './hsSettings.js';
|
|
15
15
|
const EMPTY_CONFIG = { accounts: [] };
|
|
16
16
|
export function getGlobalConfigFilePath() {
|
|
17
17
|
return GLOBAL_CONFIG_PATH;
|
|
@@ -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 = getHsSettingsFileIfExists();
|
|
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
|
-
|
|
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
|
-
const hsSettingsFile = getHsSettingsFile();
|
|
182
|
+
const hsSettingsFile = getHsSettingsFileIfExists();
|
|
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 getLinkedOrAllConfigAccounts() {
|
|
205
|
+
const { accounts } = getConfig();
|
|
206
|
+
const hsSettingsFile = getHsSettingsFileIfExists();
|
|
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/lib/gitignore.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GitInclusionResult } from '../types/Config.js';
|
|
2
2
|
export declare function checkAndAddConfigToGitignore(configPath: string): void;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function checkAndAddHsFolderToGitignore(settingsPath: string): void;
|
|
4
4
|
export declare function checkGitInclusion(configPath: string): GitInclusionResult;
|
package/lib/gitignore.js
CHANGED
|
@@ -23,7 +23,7 @@ export function checkAndAddConfigToGitignore(configPath) {
|
|
|
23
23
|
throw new Error(i18n(`${i18nKey}.errors.configIgnore`), { cause: e });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
export function
|
|
26
|
+
export function checkAndAddHsFolderToGitignore(settingsPath) {
|
|
27
27
|
try {
|
|
28
28
|
const hsDirPath = path.resolve(path.dirname(settingsPath));
|
|
29
29
|
const { configIgnored, gitignoreFiles } = checkGitInclusion(hsDirPath);
|
package/package.json
CHANGED