@hubspot/local-dev-lib 0.7.4-experimental.4 → 0.7.5-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/api/projects.d.ts +4 -1
- package/api/projects.js +17 -0
- package/api/sandboxHubs.d.ts +3 -0
- package/api/sandboxHubs.js +4 -0
- package/api/sandboxSync.d.ts +6 -0
- package/api/sandboxSync.js +7 -0
- package/config/defaultAccountOverride.d.ts +0 -1
- package/config/defaultAccountOverride.js +0 -15
- package/config/index.d.ts +0 -1
- package/config/index.js +11 -31
- package/constants/config.d.ts +0 -3
- package/constants/config.js +0 -3
- package/constants/projects.d.ts +1 -0
- package/constants/projects.js +1 -0
- package/lib/gitignore.d.ts +0 -1
- package/lib/gitignore.js +1 -22
- package/package.json +1 -2
- package/types/Project.d.ts +21 -0
- package/types/Sandbox.d.ts +6 -0
- package/config/hsSettings.d.ts +0 -4
- package/config/hsSettings.js +0 -57
- package/types/HsSettings.d.ts +0 -4
- package/types/HsSettings.js +0 -1
package/api/projects.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HubSpotPromise, QueryParams } from '../types/Http.js';
|
|
2
|
-
import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse, WarnLogsResponse, UploadIRResponse } from '../types/Project.js';
|
|
2
|
+
import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse, WarnLogsResponse, UploadIRResponse, Release, FetchListReleasesResponse } from '../types/Project.js';
|
|
3
3
|
import { Build, FetchProjectBuildsResponse } from '../types/Build.js';
|
|
4
4
|
import { ComponentStructureResponse, ProjectComponentsMetadata } from '../types/ComponentStructure.js';
|
|
5
5
|
import { Deploy, ProjectDeployResponse, ProjectDeployResponseV1 } from '../types/Deploy.js';
|
|
@@ -31,6 +31,9 @@ export declare function deleteFileFromBuild(accountId: number, projectName: stri
|
|
|
31
31
|
export declare function cancelStagedBuild(accountId: number, projectName: string): HubSpotPromise<void>;
|
|
32
32
|
export declare function fetchBuildWarnLogs(accountId: number, projectName: string, buildId: number): HubSpotPromise<WarnLogsResponse>;
|
|
33
33
|
export declare function fetchDeployWarnLogs(accountId: number, projectName: string, deployId: number): HubSpotPromise<WarnLogsResponse>;
|
|
34
|
+
export declare function createRelease(accountId: number, projectName: string, buildId: number): HubSpotPromise<Release>;
|
|
35
|
+
export declare function listReleases(accountId: number, projectName: string, params?: QueryParams): HubSpotPromise<FetchListReleasesResponse>;
|
|
36
|
+
export declare function getReleaseInfo(accountId: number, projectName: string, releaseTag: string): HubSpotPromise<Release>;
|
|
34
37
|
/**
|
|
35
38
|
* @deprecated
|
|
36
39
|
*/
|
package/api/projects.js
CHANGED
|
@@ -202,6 +202,23 @@ export function fetchDeployWarnLogs(accountId, projectName, deployId) {
|
|
|
202
202
|
url: `${PROJECTS_LOGS_API_PATH}/logs/projects/${encodeURIComponent(projectName)}/deploys/${deployId}/combined/warn`,
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
|
+
export function createRelease(accountId, projectName, buildId) {
|
|
206
|
+
return http.post(accountId, {
|
|
207
|
+
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/releases`,
|
|
208
|
+
data: { buildId },
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
export function listReleases(accountId, projectName, params = {}) {
|
|
212
|
+
return http.get(accountId, {
|
|
213
|
+
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/releases`,
|
|
214
|
+
params,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
export function getReleaseInfo(accountId, projectName, releaseTag) {
|
|
218
|
+
return http.get(accountId, {
|
|
219
|
+
url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/releases/${encodeURIComponent(releaseTag)}`,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
205
222
|
/**
|
|
206
223
|
* @deprecated
|
|
207
224
|
*/
|
package/api/sandboxHubs.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { SandboxPersonalAccessKey, SandboxResponse, SandboxUsageLimitsResponse, V2Sandbox } from '../types/Sandbox.js';
|
|
2
2
|
import { HubSpotPromise } from '../types/Http.js';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use createV2Sandbox instead
|
|
5
|
+
*/
|
|
3
6
|
export declare function createSandbox(accountId: number, name: string, type: 1 | 2): HubSpotPromise<SandboxResponse>;
|
|
4
7
|
export declare function deleteSandbox(parentAccountId: number, sandboxAccountId: number): HubSpotPromise<void>;
|
|
5
8
|
export declare function getSandboxUsageLimits(parentAccountId: number): HubSpotPromise<SandboxUsageLimitsResponse>;
|
package/api/sandboxHubs.js
CHANGED
|
@@ -2,6 +2,10 @@ import { http } from '../http/index.js';
|
|
|
2
2
|
import { SANDBOX_TIMEOUT } from '../constants/api.js';
|
|
3
3
|
const SANDBOX_API_PATH = 'sandbox-hubs/v1';
|
|
4
4
|
const SANDBOX_API_PATH_V2 = 'sandbox-hubs/v2';
|
|
5
|
+
/* TODO: Delete createSandbox in the next major release (as of 2/20/2026) */
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use createV2Sandbox instead
|
|
8
|
+
*/
|
|
5
9
|
export function createSandbox(accountId, name, type) {
|
|
6
10
|
return http.post(accountId, {
|
|
7
11
|
data: { name, type, generatePersonalAccessKey: true }, // For CLI, generatePersonalAccessKey will always be true since we'll be saving the entry to the config
|
package/api/sandboxSync.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { InitiateSyncResponse, FetchTypesResponse, TaskRequestData } from '../types/Sandbox.js';
|
|
2
2
|
import { HubSpotPromise } from '../types/Http.js';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Sync functionality has been deprecated and will be removed in a future release.
|
|
5
|
+
*/
|
|
3
6
|
export declare function initiateSync(fromHubId: number, toHubId: number, tasks: Array<TaskRequestData>, sandboxHubId: number): HubSpotPromise<InitiateSyncResponse>;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
*/
|
|
4
10
|
export declare function fetchTypes(accountId: number, toHubId: number): HubSpotPromise<FetchTypesResponse>;
|
package/api/sandboxSync.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { http } from '../http/index.js';
|
|
2
2
|
import { SANDBOX_TIMEOUT } from '../constants/api.js';
|
|
3
3
|
const SANDBOXES_SYNC_API_PATH = 'sandboxes-sync/v1';
|
|
4
|
+
/* TODO: Delete this entire file in the next major release (as of 2/20/2026) */
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Sync functionality has been deprecated and will be removed in a future release.
|
|
7
|
+
*/
|
|
4
8
|
export async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
|
|
5
9
|
return http.post(fromHubId, {
|
|
6
10
|
data: {
|
|
@@ -14,6 +18,9 @@ export async function initiateSync(fromHubId, toHubId, tasks, sandboxHubId) {
|
|
|
14
18
|
url: `${SANDBOXES_SYNC_API_PATH}/tasks/initiate/async`,
|
|
15
19
|
});
|
|
16
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated
|
|
23
|
+
*/
|
|
17
24
|
export async function fetchTypes(accountId, toHubId) {
|
|
18
25
|
return http.get(accountId, {
|
|
19
26
|
url: `${SANDBOXES_SYNC_API_PATH}/types${toHubId ? `?toHubId=${toHubId}` : ''}`,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { HubSpotConfigAccount } from '../types/Accounts.js';
|
|
2
2
|
export declare function getDefaultAccountOverrideAccountId(accounts: Array<HubSpotConfigAccount>): number | null;
|
|
3
|
-
export declare function removeDefaultAccountOverrideFile(): void;
|
|
4
3
|
export declare function getDefaultAccountOverrideFilePath(): string | null;
|
|
@@ -40,21 +40,6 @@ export function getDefaultAccountOverrideAccountId(accounts) {
|
|
|
40
40
|
}
|
|
41
41
|
return account.accountId;
|
|
42
42
|
}
|
|
43
|
-
export function removeDefaultAccountOverrideFile() {
|
|
44
|
-
const filePath = getDefaultAccountOverrideFilePath();
|
|
45
|
-
if (!filePath) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
fs.unlinkSync(filePath);
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
throw new FileSystemError({ cause: e }, {
|
|
53
|
-
filepath: filePath,
|
|
54
|
-
operation: 'write',
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
43
|
export function getDefaultAccountOverrideFilePath() {
|
|
59
44
|
return findup([DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME], {
|
|
60
45
|
cwd: getCwd(),
|
package/config/index.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ export declare function getConfigAccountIfExists(identifier: number | string): H
|
|
|
18
18
|
export declare function getConfigDefaultAccount(): HubSpotConfigAccount;
|
|
19
19
|
export declare function getConfigDefaultAccountIfExists(): HubSpotConfigAccount | undefined;
|
|
20
20
|
export declare function getAllConfigAccounts(): HubSpotConfigAccount[];
|
|
21
|
-
export declare function getLinkedOrAllConfigAccounts(): HubSpotConfigAccount[];
|
|
22
21
|
export declare function getConfigAccountEnvironment(identifier: number | string): Environment;
|
|
23
22
|
export declare function addConfigAccount(accountToAdd: HubSpotConfigAccount): void;
|
|
24
23
|
export declare function updateConfigAccount(updatedAccount: HubSpotConfigAccount): void;
|
package/config/index.js
CHANGED
|
@@ -11,7 +11,6 @@ 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 { getHsSettingsFileIfExists } from './hsSettings.js';
|
|
15
14
|
const EMPTY_CONFIG = { accounts: [] };
|
|
16
15
|
export function getGlobalConfigFilePath() {
|
|
17
16
|
return GLOBAL_CONFIG_PATH;
|
|
@@ -153,17 +152,11 @@ export function getConfigAccountIfExists(identifier) {
|
|
|
153
152
|
export function getConfigDefaultAccount() {
|
|
154
153
|
const { accounts, defaultAccount } = getConfig();
|
|
155
154
|
let defaultAccountToUse = defaultAccount;
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const currentConfigPath = getConfigFilePath();
|
|
162
|
-
const globalConfigPath = getGlobalConfigFilePath();
|
|
163
|
-
if (currentConfigPath === globalConfigPath && globalConfigFileExists()) {
|
|
164
|
-
const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId(accounts);
|
|
165
|
-
defaultAccountToUse = defaultAccountOverrideAccountId || defaultAccount;
|
|
166
|
-
}
|
|
155
|
+
const currentConfigPath = getConfigFilePath();
|
|
156
|
+
const globalConfigPath = getGlobalConfigFilePath();
|
|
157
|
+
if (currentConfigPath === globalConfigPath && globalConfigFileExists()) {
|
|
158
|
+
const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId(accounts);
|
|
159
|
+
defaultAccountToUse = defaultAccountOverrideAccountId || defaultAccount;
|
|
167
160
|
}
|
|
168
161
|
if (!defaultAccountToUse) {
|
|
169
162
|
throw new HubSpotConfigError(i18n('config.getConfigDefaultAccount.fieldMissingError'), HUBSPOT_CONFIG_ERROR_TYPES.NO_DEFAULT_ACCOUNT, HUBSPOT_CONFIG_OPERATIONS.READ);
|
|
@@ -179,17 +172,12 @@ export function getConfigDefaultAccount() {
|
|
|
179
172
|
export function getConfigDefaultAccountIfExists() {
|
|
180
173
|
const { accounts, defaultAccount } = getConfig();
|
|
181
174
|
let defaultAccountToUse = defaultAccount;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const globalConfigPath = getGlobalConfigFilePath();
|
|
189
|
-
if (currentConfigPath === globalConfigPath && globalConfigFileExists()) {
|
|
190
|
-
const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId(accounts);
|
|
191
|
-
defaultAccountToUse = defaultAccountOverrideAccountId || defaultAccount;
|
|
192
|
-
}
|
|
175
|
+
// Only check for default account override if we're using the global config
|
|
176
|
+
const currentConfigPath = getConfigFilePath();
|
|
177
|
+
const globalConfigPath = getGlobalConfigFilePath();
|
|
178
|
+
if (currentConfigPath === globalConfigPath && globalConfigFileExists()) {
|
|
179
|
+
const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId(accounts);
|
|
180
|
+
defaultAccountToUse = defaultAccountOverrideAccountId || defaultAccount;
|
|
193
181
|
}
|
|
194
182
|
if (!defaultAccountToUse) {
|
|
195
183
|
return;
|
|
@@ -201,14 +189,6 @@ export function getAllConfigAccounts() {
|
|
|
201
189
|
const { accounts } = getConfig();
|
|
202
190
|
return accounts;
|
|
203
191
|
}
|
|
204
|
-
export function getLinkedOrAllConfigAccounts() {
|
|
205
|
-
const { accounts } = getConfig();
|
|
206
|
-
const hsSettingsFile = getHsSettingsFileIfExists();
|
|
207
|
-
if (!hsSettingsFile || hsSettingsFile.accounts.length === 0) {
|
|
208
|
-
return accounts;
|
|
209
|
-
}
|
|
210
|
-
return accounts.filter(a => hsSettingsFile.accounts.includes(a.accountId));
|
|
211
|
-
}
|
|
212
192
|
export function getConfigAccountEnvironment(identifier) {
|
|
213
193
|
const config = getConfig();
|
|
214
194
|
const account = getConfigAccountByInferredIdentifier(config.accounts, identifier);
|
package/constants/config.d.ts
CHANGED
|
@@ -102,6 +102,3 @@ export declare const HUBSPOT_CONFIG_OPERATIONS: {
|
|
|
102
102
|
readonly WRITE: "WRITE";
|
|
103
103
|
readonly DELETE: "DELETE";
|
|
104
104
|
};
|
|
105
|
-
export declare const HS_FOLDER = ".hs";
|
|
106
|
-
export declare const HS_SETTINGS_FILENAME = "settings.json";
|
|
107
|
-
export declare const HS_README_FILENAME = "README.txt";
|
package/constants/config.js
CHANGED
package/constants/projects.d.ts
CHANGED
package/constants/projects.js
CHANGED
package/lib/gitignore.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { GitInclusionResult } from '../types/Config.js';
|
|
2
2
|
export declare function checkAndAddConfigToGitignore(configPath: string): void;
|
|
3
|
-
export declare function checkAndAddHsFolderToGitignore(settingsPath: string): void;
|
|
4
3
|
export declare function checkGitInclusion(configPath: string): GitInclusionResult;
|
package/lib/gitignore.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { isConfigPathInGitRepo, getGitignoreFiles, configFilenameIsIgnoredByGitignore, } from '../utils/git.js';
|
|
4
|
-
import { DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME
|
|
4
|
+
import { DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME } from '../constants/config.js';
|
|
5
5
|
import { i18n } from '../utils/lang.js';
|
|
6
6
|
const i18nKey = 'lib.gitignore';
|
|
7
7
|
const GITIGNORE_FILE = '.gitignore';
|
|
@@ -23,27 +23,6 @@ export function checkAndAddConfigToGitignore(configPath) {
|
|
|
23
23
|
throw new Error(i18n(`${i18nKey}.errors.configIgnore`), { cause: e });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
export function checkAndAddHsFolderToGitignore(settingsPath) {
|
|
27
|
-
try {
|
|
28
|
-
const hsDirPath = path.resolve(path.dirname(settingsPath));
|
|
29
|
-
const { configIgnored, gitignoreFiles } = checkGitInclusion(hsDirPath);
|
|
30
|
-
if (configIgnored)
|
|
31
|
-
return;
|
|
32
|
-
let gitignoreFilePath = gitignoreFiles && gitignoreFiles.length ? gitignoreFiles[0] : null;
|
|
33
|
-
if (!gitignoreFilePath) {
|
|
34
|
-
gitignoreFilePath = path.join(path.dirname(hsDirPath), GITIGNORE_FILE);
|
|
35
|
-
fs.writeFileSync(gitignoreFilePath, '');
|
|
36
|
-
}
|
|
37
|
-
const gitignoreContents = fs.readFileSync(gitignoreFilePath).toString();
|
|
38
|
-
if (gitignoreContents.includes(HS_FOLDER))
|
|
39
|
-
return;
|
|
40
|
-
const updatedContents = `${gitignoreContents.trim()}\n\n# HubSpot link folder\n${HS_FOLDER}\n`;
|
|
41
|
-
fs.writeFileSync(gitignoreFilePath, updatedContents);
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
throw new Error(i18n(`${i18nKey}.errors.configIgnore`), { cause: e });
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
26
|
export function checkGitInclusion(configPath) {
|
|
48
27
|
const result = {
|
|
49
28
|
inGit: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/local-dev-lib",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5-experimental.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
|
|
6
6
|
"repository": {
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
"./config/defaultAccountOverride": "./config/defaultAccountOverride.js",
|
|
56
56
|
"./config/migrate": "./config/migrate.js",
|
|
57
57
|
"./config/state": "./config/state.js",
|
|
58
|
-
"./config/hsSettings": "./config/hsSettings.js",
|
|
59
58
|
"./config": "./config/index.js",
|
|
60
59
|
"./constants/*": "./constants/*.js",
|
|
61
60
|
"./enums/*": "./enums/*.js",
|
package/types/Project.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Build } from './Build.js';
|
|
2
2
|
import { GithubSourceData } from './Github.js';
|
|
3
3
|
import { ProjectLog } from './ProjectLog.js';
|
|
4
|
+
import { ValueOf } from './Utils.js';
|
|
5
|
+
import { SUBBUILD_TYPES } from '../enums/build.js';
|
|
4
6
|
export type Project = {
|
|
5
7
|
createdAt: number;
|
|
6
8
|
deletedAt: number;
|
|
@@ -48,3 +50,22 @@ export type FetchPlatformVersionResponse = {
|
|
|
48
50
|
export type WarnLogsResponse = {
|
|
49
51
|
logs: Array<ProjectLog>;
|
|
50
52
|
};
|
|
53
|
+
export type Release = {
|
|
54
|
+
releaseTag: string;
|
|
55
|
+
buildId: number;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
components?: Array<{
|
|
58
|
+
buildType: ValueOf<typeof SUBBUILD_TYPES>;
|
|
59
|
+
buildName?: string;
|
|
60
|
+
rootPath?: string;
|
|
61
|
+
id?: string;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
64
|
+
export type FetchListReleasesResponse = {
|
|
65
|
+
results: Array<Release>;
|
|
66
|
+
paging: {
|
|
67
|
+
next: {
|
|
68
|
+
after: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
package/types/Sandbox.d.ts
CHANGED
|
@@ -138,6 +138,9 @@ export type V2Sandbox = {
|
|
|
138
138
|
updatedAt?: string;
|
|
139
139
|
updatedByUser?: User | null;
|
|
140
140
|
};
|
|
141
|
+
/**
|
|
142
|
+
* @deprecated This type is deprecated and will be removed in the next major release.
|
|
143
|
+
*/
|
|
141
144
|
export type SandboxResponse = {
|
|
142
145
|
sandbox: Sandbox;
|
|
143
146
|
personalAccessKey: string;
|
|
@@ -176,6 +179,9 @@ export type SandboxType = {
|
|
|
176
179
|
groupType: string;
|
|
177
180
|
syncMandatory: boolean;
|
|
178
181
|
};
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated This type is deprecated and will be removed in the next major release.
|
|
184
|
+
*/
|
|
179
185
|
export type FetchTypesResponse = {
|
|
180
186
|
results: Array<SandboxType>;
|
|
181
187
|
};
|
package/config/hsSettings.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { HsSettingsFile } from '../types/HsSettings.js';
|
|
2
|
-
export declare function getHsSettingsFilePath(): string | null;
|
|
3
|
-
export declare function getHsSettingsFileIfExists(): HsSettingsFile | null;
|
|
4
|
-
export declare function writeHsSettingsFile(settingsFile: HsSettingsFile): void;
|
package/config/hsSettings.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import findupSync from 'findup-sync';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { HS_FOLDER, HS_README_FILENAME, HS_SETTINGS_FILENAME, } from '../constants/config.js';
|
|
5
|
-
import { getCwd } from '../lib/path.js';
|
|
6
|
-
import { FileSystemError } from '../models/FileSystemError.js';
|
|
7
|
-
const HS_README_CONTENTS = `Why do I have a folder named ".hs" in my project?
|
|
8
|
-
The ".hs" folder is created when you link a directory to a HubSpot project.
|
|
9
|
-
|
|
10
|
-
What does the "settings.json" file contain?
|
|
11
|
-
The "settings.json" file contains:
|
|
12
|
-
- The ID(s) of the HubSpot account(s) that you linked ("accounts")
|
|
13
|
-
- The ID of the HubSpot account that you set as the default for this directory ("linkedDefaultAccount")
|
|
14
|
-
|
|
15
|
-
Should I commit the ".hs" folder?
|
|
16
|
-
No, the ".hs" folder should not be committed to version control. It is automatically added to your .gitignore file when the directory is linked.
|
|
17
|
-
`;
|
|
18
|
-
export function getHsSettingsFilePath() {
|
|
19
|
-
return findupSync([`${HS_FOLDER}/${HS_SETTINGS_FILENAME}`], {
|
|
20
|
-
cwd: getCwd(),
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
export function getHsSettingsFileIfExists() {
|
|
24
|
-
const hsSettingsFilePath = getHsSettingsFilePath();
|
|
25
|
-
if (!hsSettingsFilePath) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
let hsSettingsFile;
|
|
29
|
-
try {
|
|
30
|
-
hsSettingsFile = JSON.parse(fs.readFileSync(hsSettingsFilePath, 'utf-8'));
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
throw new FileSystemError({ cause: e }, {
|
|
34
|
-
filepath: hsSettingsFilePath,
|
|
35
|
-
operation: 'read',
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return hsSettingsFile;
|
|
39
|
-
}
|
|
40
|
-
export function writeHsSettingsFile(settingsFile) {
|
|
41
|
-
const dir = getCwd();
|
|
42
|
-
const hsFolderPath = path.join(dir, HS_FOLDER);
|
|
43
|
-
const isFirstScaffold = !fs.existsSync(hsFolderPath);
|
|
44
|
-
try {
|
|
45
|
-
fs.mkdirSync(hsFolderPath, { recursive: true });
|
|
46
|
-
fs.writeFileSync(path.join(dir, HS_FOLDER, HS_SETTINGS_FILENAME), JSON.stringify(settingsFile, null, 2), 'utf8');
|
|
47
|
-
if (isFirstScaffold) {
|
|
48
|
-
fs.writeFileSync(path.join(hsFolderPath, HS_README_FILENAME), HS_README_CONTENTS, 'utf8');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
52
|
-
throw new FileSystemError({ cause: err }, {
|
|
53
|
-
filepath: dir,
|
|
54
|
-
operation: 'write',
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
package/types/HsSettings.d.ts
DELETED
package/types/HsSettings.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|