@hubspot/local-dev-lib 0.4.0-experimental.1 → 0.4.2-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/appsDev.d.ts CHANGED
@@ -4,3 +4,5 @@ export declare function fetchPublicAppsForPortal(accountId: number): HubSpotProm
4
4
  export declare function fetchPublicAppDeveloperTestAccountInstallData(appId: number, accountId: number): HubSpotPromise<PublicAppDeveloperTestAccountInstallData>;
5
5
  export declare function fetchPublicAppProductionInstallCounts(appId: number, accountId: number): HubSpotPromise<PublicAppInstallCounts>;
6
6
  export declare function fetchPublicAppMetadata(appId: number, accountId: number): HubSpotPromise<PublicApp>;
7
+ export declare function installStaticAuthAppOnTestAccount(appId: number, accountId: number, scopeGroupIds: number[]): HubSpotPromise<void>;
8
+ export declare function fetchAppMetadataByUid(appUid: string, accountId: number): HubSpotPromise<PublicApp>;
package/api/appsDev.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchPublicAppMetadata = exports.fetchPublicAppProductionInstallCounts = exports.fetchPublicAppDeveloperTestAccountInstallData = exports.fetchPublicAppsForPortal = void 0;
3
+ exports.fetchAppMetadataByUid = exports.installStaticAuthAppOnTestAccount = exports.fetchPublicAppMetadata = exports.fetchPublicAppProductionInstallCounts = exports.fetchPublicAppDeveloperTestAccountInstallData = exports.fetchPublicAppsForPortal = void 0;
4
4
  const http_1 = require("../http");
5
5
  const APPS_DEV_API_PATH = 'apps-dev/external/public/v3';
6
+ const APPS_HUBLETS_API_PATH = 'apps-hublets/external/static-token/v3';
6
7
  function fetchPublicAppsForPortal(accountId) {
7
8
  return http_1.http.get(accountId, {
8
9
  url: `${APPS_DEV_API_PATH}/full/portal`,
@@ -27,3 +28,23 @@ function fetchPublicAppMetadata(appId, accountId) {
27
28
  });
28
29
  }
29
30
  exports.fetchPublicAppMetadata = fetchPublicAppMetadata;
31
+ function installStaticAuthAppOnTestAccount(appId, accountId, scopeGroupIds) {
32
+ return http_1.http.post(accountId, {
33
+ url: APPS_HUBLETS_API_PATH,
34
+ data: {
35
+ appId,
36
+ targetInstallPortalId: accountId,
37
+ scopeGroupIds,
38
+ },
39
+ });
40
+ }
41
+ exports.installStaticAuthAppOnTestAccount = installStaticAuthAppOnTestAccount;
42
+ function fetchAppMetadataByUid(appUid, accountId) {
43
+ return http_1.http.get(accountId, {
44
+ url: `${APPS_DEV_API_PATH}/full/portal/sourceId`,
45
+ params: {
46
+ sourceId: appUid,
47
+ },
48
+ });
49
+ }
50
+ exports.fetchAppMetadataByUid = fetchAppMetadataByUid;
package/api/crm.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { HubSpotPromise } from '../types/Http';
2
+ import { ImportRequest, ImportResponse } from '../types/Crm';
3
+ export declare function createImport(accountId: number, importRequest: ImportRequest, dataFileNames: string[]): HubSpotPromise<ImportResponse>;
package/api/crm.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createImport = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const form_data_1 = __importDefault(require("form-data"));
10
+ const http_1 = require("../http");
11
+ const path_2 = require("../lib/path");
12
+ const HUBSPOT_CRM_IMPORT_PATH = '/crm/v3/imports';
13
+ function createImport(accountId, importRequest, dataFileNames) {
14
+ const jsonImportRequest = JSON.stringify(importRequest);
15
+ const formData = new form_data_1.default();
16
+ formData.append('importRequest', jsonImportRequest);
17
+ dataFileNames.forEach(file => {
18
+ const stream = fs_extra_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), file));
19
+ formData.append('files', stream, file);
20
+ });
21
+ return http_1.http.post(accountId, {
22
+ url: `${HUBSPOT_CRM_IMPORT_PATH}`,
23
+ data: formData,
24
+ headers: {
25
+ ...formData.getHeaders(),
26
+ },
27
+ });
28
+ }
29
+ exports.createImport = createImport;
@@ -1,13 +1,12 @@
1
- import { DeveloperTestAccount, CreateDeveloperTestAccountResponse, FetchDeveloperTestAccountsResponse } from '../types/developerTestAccounts';
1
+ import { DeveloperTestAccount, CreateDeveloperTestAccountResponse, FetchDeveloperTestAccountsResponse, DeveloperTestAccountConfig, CreateDeveloperTestAccountV3Response, InstallOauthAppIntoDeveloperTestAccountResponse, TestPortalStatusResponse, GenerateDeveloperTestAccountPersonalAccessKeyResponse } from '../types/developerTestAccounts';
2
2
  import { Environment } from '../types/Config';
3
3
  import { HubSpotPromise } from '../types/Http';
4
4
  export declare function fetchDeveloperTestAccounts(accountId: number): HubSpotPromise<FetchDeveloperTestAccountsResponse>;
5
- export declare function createDeveloperTestAccount(accountId: number, accountName: string, useV3?: boolean, accountLevels?: {
6
- marketingLevel?: string;
7
- opsLevel?: string;
8
- serviceLevel?: string;
9
- salesLevel?: string;
10
- contentLevel?: string;
11
- }): HubSpotPromise<CreateDeveloperTestAccountResponse>;
5
+ export declare function createDeveloperTestAccount(accountId: number, accountInfo: string): HubSpotPromise<CreateDeveloperTestAccountResponse>;
6
+ export declare function createDeveloperTestAccount(accountId: number, accountInfo: DeveloperTestAccountConfig): HubSpotPromise<CreateDeveloperTestAccountV3Response>;
12
7
  export declare function deleteDeveloperTestAccount(accountId: number, testAccountId: number, useV3?: boolean): HubSpotPromise<void>;
13
8
  export declare function fetchDeveloperTestAccountData(accessToken: string, accountId: number, env?: Environment): HubSpotPromise<DeveloperTestAccount>;
9
+ export declare function installOauthAppIntoDeveloperTestAccount(accountId: number, testAccountId: number, projectName: string, appUId: string): HubSpotPromise<InstallOauthAppIntoDeveloperTestAccountResponse>;
10
+ export declare function fetchDeveloperTestAccountOauthAppInstallStatus(accountId: number, projectName: string, appUId: string): HubSpotPromise<TestPortalStatusResponse>;
11
+ export declare function fetchDeveloperTestAccountGateSyncStatus(accountId: number, testAccountId: number): HubSpotPromise<TestPortalStatusResponse>;
12
+ export declare function generateDeveloperTestAccountPersonalAccessKey(accountId: number, testAccountId: number): HubSpotPromise<GenerateDeveloperTestAccountPersonalAccessKeyResponse>;
@@ -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.fetchDeveloperTestAccountData = exports.deleteDeveloperTestAccount = exports.createDeveloperTestAccount = exports.fetchDeveloperTestAccounts = void 0;
6
+ exports.generateDeveloperTestAccountPersonalAccessKey = exports.fetchDeveloperTestAccountGateSyncStatus = exports.fetchDeveloperTestAccountOauthAppInstallStatus = exports.installOauthAppIntoDeveloperTestAccount = exports.fetchDeveloperTestAccountData = exports.deleteDeveloperTestAccount = exports.createDeveloperTestAccount = exports.fetchDeveloperTestAccounts = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const http_1 = require("../http");
9
9
  const getAxiosConfig_1 = require("../http/getAxiosConfig");
@@ -17,17 +17,17 @@ function fetchDeveloperTestAccounts(accountId) {
17
17
  });
18
18
  }
19
19
  exports.fetchDeveloperTestAccounts = fetchDeveloperTestAccounts;
20
- function createDeveloperTestAccount(accountId, accountName, useV3 = false, accountLevels = {}) {
21
- if (useV3) {
20
+ function createDeveloperTestAccount(accountId, accountInfo) {
21
+ if (typeof accountInfo === 'object') {
22
22
  return http_1.http.post(accountId, {
23
23
  url: TEST_ACCOUNTS_API_PATH_V3,
24
- data: { accountName, generatePersonalAccessKey: true, ...accountLevels },
24
+ data: accountInfo,
25
25
  timeout: api_1.SANDBOX_TIMEOUT,
26
26
  });
27
27
  }
28
28
  return http_1.http.post(accountId, {
29
29
  url: TEST_ACCOUNTS_API_PATH,
30
- data: { accountName, generatePersonalAccessKey: true },
30
+ data: { accountName: accountInfo, generatePersonalAccessKey: true },
31
31
  timeout: api_1.SANDBOX_TIMEOUT,
32
32
  });
33
33
  }
@@ -59,3 +59,36 @@ function fetchDeveloperTestAccountData(accessToken, accountId, env = environment
59
59
  return (0, axios_1.default)(reqWithToken);
60
60
  }
61
61
  exports.fetchDeveloperTestAccountData = fetchDeveloperTestAccountData;
62
+ function installOauthAppIntoDeveloperTestAccount(accountId, testAccountId, projectName, appUId) {
63
+ return http_1.http.post(accountId, {
64
+ url: `${TEST_ACCOUNTS_API_PATH_V3}/install-apps`,
65
+ data: {
66
+ testPortalId: testAccountId,
67
+ developerQualifiedSymbol: { developerSymbol: appUId, projectName },
68
+ },
69
+ timeout: api_1.SANDBOX_TIMEOUT,
70
+ });
71
+ }
72
+ exports.installOauthAppIntoDeveloperTestAccount = installOauthAppIntoDeveloperTestAccount;
73
+ function fetchDeveloperTestAccountOauthAppInstallStatus(accountId, projectName, appUId) {
74
+ return http_1.http.post(accountId, {
75
+ url: `${TEST_ACCOUNTS_API_PATH_V3}/install-apps/readiness`,
76
+ data: {
77
+ developerQualifiedSymbol: { developerSymbol: appUId, projectName },
78
+ },
79
+ timeout: api_1.SANDBOX_TIMEOUT,
80
+ });
81
+ }
82
+ exports.fetchDeveloperTestAccountOauthAppInstallStatus = fetchDeveloperTestAccountOauthAppInstallStatus;
83
+ function fetchDeveloperTestAccountGateSyncStatus(accountId, testAccountId) {
84
+ return http_1.http.get(accountId, {
85
+ url: `${TEST_ACCOUNTS_API_PATH_V3}/gate-sync-status/${testAccountId}`,
86
+ });
87
+ }
88
+ exports.fetchDeveloperTestAccountGateSyncStatus = fetchDeveloperTestAccountGateSyncStatus;
89
+ function generateDeveloperTestAccountPersonalAccessKey(accountId, testAccountId) {
90
+ return http_1.http.get(accountId, {
91
+ url: `${TEST_ACCOUNTS_API_PATH_V3}/generate-pak/${testAccountId}`,
92
+ });
93
+ }
94
+ exports.generateDeveloperTestAccountPersonalAccessKey = generateDeveloperTestAccountPersonalAccessKey;
package/api/github.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchRepoContents = exports.fetchRepoFileByDownloadUrl = exports.fetchRepoFile = exports.fetchRepoAsZip = exports.fetchRepoReleaseData = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const getAxiosConfig_1 = require("../http/getAxiosConfig");
9
+ const errors_1 = require("../errors");
9
10
  const GITHUB_REPOS_API = 'https://api.github.com/repos';
10
11
  const GITHUB_RAW_CONTENT_API_PATH = 'https://raw.githubusercontent.com';
11
12
  function getAdditionalHeaders() {
@@ -18,16 +19,33 @@ function getAdditionalHeaders() {
18
19
  }
19
20
  return headers;
20
21
  }
22
+ function githubRequestWithFallback(url, responseType) {
23
+ const headersWithAuth = {
24
+ ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
25
+ ...getAdditionalHeaders(),
26
+ };
27
+ if (headersWithAuth.authorization) {
28
+ return axios_1.default
29
+ .get(url, { headers: headersWithAuth, responseType })
30
+ .catch(error => {
31
+ // 404 with an auth token might mean an SSO issue so retry without the authorization header
32
+ if ((0, errors_1.isSpecifiedError)(error, { statusCode: 404 })) {
33
+ return axios_1.default.get(url, {
34
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)() },
35
+ responseType,
36
+ });
37
+ }
38
+ throw error;
39
+ });
40
+ }
41
+ // No auth token, proceed normally
42
+ return axios_1.default.get(url, { headers: headersWithAuth, responseType });
43
+ }
21
44
  // Returns information about the repo's releases. Defaults to "latest" if no tag is provided
22
45
  // https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-a-release-by-tag-name
23
46
  function fetchRepoReleaseData(repoPath, tag = '') {
24
47
  const URL = `${GITHUB_REPOS_API}/${repoPath}/releases`;
25
- return axios_1.default.get(`${URL}/${tag ? `tags/${tag}` : 'latest'}`, {
26
- headers: {
27
- ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
28
- ...getAdditionalHeaders(),
29
- },
30
- });
48
+ return githubRequestWithFallback(`${URL}/${tag ? `tags/${tag}` : 'latest'}`);
31
49
  }
32
50
  exports.fetchRepoReleaseData = fetchRepoReleaseData;
33
51
  // Returns the entire repo content as a zip, using the zipball_url from fetchRepoReleaseData()
@@ -41,31 +59,19 @@ function fetchRepoAsZip(zipUrl) {
41
59
  exports.fetchRepoAsZip = fetchRepoAsZip;
42
60
  // Returns the raw file contents via the raw.githubusercontent endpoint
43
61
  function fetchRepoFile(repoPath, filePath, ref) {
44
- return axios_1.default.get(`${GITHUB_RAW_CONTENT_API_PATH}/${repoPath}/${ref}/${filePath}`, {
45
- headers: {
46
- ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
47
- ...getAdditionalHeaders(),
48
- },
49
- });
62
+ const url = `${GITHUB_RAW_CONTENT_API_PATH}/${repoPath}/${ref}/${filePath}`;
63
+ return githubRequestWithFallback(url);
50
64
  }
51
65
  exports.fetchRepoFile = fetchRepoFile;
52
66
  // Returns the raw file contents via the raw.githubusercontent endpoint
53
67
  function fetchRepoFileByDownloadUrl(downloadUrl) {
54
- return axios_1.default.get(downloadUrl, {
55
- headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...getAdditionalHeaders() },
56
- responseType: 'arraybuffer',
57
- });
68
+ return githubRequestWithFallback(downloadUrl, 'arraybuffer');
58
69
  }
59
70
  exports.fetchRepoFileByDownloadUrl = fetchRepoFileByDownloadUrl;
60
71
  // Returns the contents of a file or directory in a repository by path
61
72
  // https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-repository-content
62
73
  function fetchRepoContents(repoPath, path, ref) {
63
74
  const refQuery = ref ? `?ref=${ref}` : '';
64
- return axios_1.default.get(`${GITHUB_REPOS_API}/${repoPath}/contents/${path}${refQuery}`, {
65
- headers: {
66
- ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
67
- ...getAdditionalHeaders(),
68
- },
69
- });
75
+ return githubRequestWithFallback(`${GITHUB_REPOS_API}/${repoPath}/contents/${path}${refQuery}`);
70
76
  }
71
77
  exports.fetchRepoContents = fetchRepoContents;
@@ -7,4 +7,4 @@ export declare function fetchAccessToken(personalAccessKey: string, env?: Enviro
7
7
  export declare function fetchScopeData(accountId: number, scopeGroup: string): HubSpotPromise<ScopeData>;
8
8
  export declare function fetchScopeAuthorizationData(accountId: number): HubSpotPromise<ScopeAuthorizationResponse>;
9
9
  export declare function fetchAppInstallationData(portalId: number, projectId: number, appUid: string, requiredScopeGroups: Array<string>, optionalScopeGroups?: Array<string>): HubSpotPromise<PublicAppInstallationData>;
10
- export declare function fetchEnabledFeatures(accountId: number): Promise<import("axios").AxiosResponse<EnabledFeaturesResponse, any>>;
10
+ export declare function fetchEnabledFeatures(accountId: number): Promise<import("axios").AxiosResponse<EnabledFeaturesResponse, any, {}>>;
package/api/projects.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare function fetchPlatformVersions(accountId: number): HubSpotPromise
17
17
  export declare function fetchProjectBuilds(accountId: number, projectName: string, params?: QueryParams): HubSpotPromise<FetchProjectBuildsResponse>;
18
18
  export declare function getBuildStatus(accountId: number, projectName: string, buildId: number): HubSpotPromise<Build>;
19
19
  export declare function getBuildStructure(accountId: number, projectName: string, buildId: number): HubSpotPromise<ComponentStructureResponse>;
20
- export declare function deployProject(accountId: number, projectName: string, buildId: number, useNewDeployApi?: boolean): HubSpotPromise<ProjectDeployResponse>;
20
+ export declare function deployProject(accountId: number, projectName: string, buildId: number, useNewDeployApi?: boolean, force?: boolean): HubSpotPromise<ProjectDeployResponse>;
21
21
  export declare function getDeployStatus(accountId: number, projectName: string, deployId: number): HubSpotPromise<Deploy>;
22
22
  export declare function getDeployStructure(accountId: number, projectName: string, deployId: number): HubSpotPromise<ComponentStructureResponse>;
23
23
  export declare function fetchProjectSettings(accountId: number, projectName: string): HubSpotPromise<ProjectSettings>;
package/api/projects.js CHANGED
@@ -116,13 +116,14 @@ function getBuildStructure(accountId, projectName, buildId) {
116
116
  });
117
117
  }
118
118
  exports.getBuildStructure = getBuildStructure;
119
- function deployProject(accountId, projectName, buildId, useNewDeployApi = false) {
119
+ function deployProject(accountId, projectName, buildId, useNewDeployApi = false, force = false) {
120
120
  if (useNewDeployApi) {
121
121
  return http_1.http.post(accountId, {
122
122
  url: `${PROJECTS_DEPLOY_API_PATH_V3}/deploys/queue/async`,
123
123
  data: {
124
124
  projectName,
125
125
  targetBuildId: buildId,
126
+ ignoreWarnings: force,
126
127
  },
127
128
  });
128
129
  }
@@ -131,6 +132,7 @@ function deployProject(accountId, projectName, buildId, useNewDeployApi = false)
131
132
  data: {
132
133
  projectName,
133
134
  buildId,
135
+ skipRemovalWarning: force,
134
136
  },
135
137
  });
136
138
  }
@@ -1,8 +1,10 @@
1
1
  import { AxiosPromise } from 'axios';
2
2
  import { Environment } from '../types/Config';
3
- import { SandboxHubData, SandboxResponse, SandboxUsageLimitsResponse } from '../types/Sandbox';
3
+ import { SandboxPersonalAccessKey, SandboxHubData, SandboxResponse, SandboxUsageLimitsResponse, V2Sandbox } from '../types/Sandbox';
4
4
  import { HubSpotPromise } from '../types/Http';
5
5
  export declare function createSandbox(accountId: number, name: string, type: 1 | 2): HubSpotPromise<SandboxResponse>;
6
6
  export declare function deleteSandbox(parentAccountId: number, sandboxAccountId: number): HubSpotPromise<void>;
7
7
  export declare function getSandboxUsageLimits(parentAccountId: number): HubSpotPromise<SandboxUsageLimitsResponse>;
8
8
  export declare function fetchSandboxHubData(accessToken: string, accountId: number, env?: Environment): AxiosPromise<SandboxHubData>;
9
+ export declare function createV2Sandbox(accountId: number, name: string, type: 'STANDARD' | 'DEVELOPER', syncObjectRecords: boolean): HubSpotPromise<V2Sandbox>;
10
+ export declare function getSandboxPersonalAccessKey(accountId: number, sandboxId: number): HubSpotPromise<SandboxPersonalAccessKey>;
@@ -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.fetchSandboxHubData = exports.getSandboxUsageLimits = exports.deleteSandbox = exports.createSandbox = void 0;
6
+ exports.getSandboxPersonalAccessKey = exports.createV2Sandbox = exports.fetchSandboxHubData = exports.getSandboxUsageLimits = exports.deleteSandbox = exports.createSandbox = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const http_1 = require("../http");
9
9
  const getAxiosConfig_1 = require("../http/getAxiosConfig");
@@ -47,3 +47,20 @@ function fetchSandboxHubData(accessToken, accountId, env = environments_1.ENVIRO
47
47
  return (0, axios_1.default)(reqWithToken);
48
48
  }
49
49
  exports.fetchSandboxHubData = fetchSandboxHubData;
50
+ function createV2Sandbox(accountId, name, type, syncObjectRecords) {
51
+ return http_1.http.post(accountId, {
52
+ url: `${SANDBOX_API_PATH_V2}/sandboxes`,
53
+ data: { name, type, syncObjectRecords },
54
+ });
55
+ }
56
+ exports.createV2Sandbox = createV2Sandbox;
57
+ function getSandboxPersonalAccessKey(accountId, sandboxId) {
58
+ return http_1.http.post(accountId, {
59
+ url: `${SANDBOX_API_PATH_V2}/sandboxes/${sandboxId}/personal-access-key`,
60
+ headers: {
61
+ 'Content-Type': 'application/json',
62
+ },
63
+ timeout: api_1.SANDBOX_TIMEOUT,
64
+ });
65
+ }
66
+ exports.getSandboxPersonalAccessKey = getSandboxPersonalAccessKey;
@@ -61,8 +61,12 @@ declare class _CLIConfiguration {
61
61
  * @throws {Error}
62
62
  */
63
63
  updateAllowUsageTracking(isEnabled: boolean): CLIConfig_NEW | null;
64
+ updateAutoOpenBrowser(isEnabled: boolean): CLIConfig_NEW | null;
64
65
  isTrackingAllowed(): boolean;
65
66
  handleLegacyCmsPublishMode(config: CLIConfig_NEW | null): CLIConfig_NEW | null;
67
+ hasLocalStateFlag(flag: string): boolean;
68
+ addLocalStateFlag(flag: string): void;
69
+ removeLocalStateFlag(flag: string): void;
66
70
  }
67
71
  export declare const CLIConfiguration: _CLIConfiguration;
68
72
  export {};
@@ -497,6 +497,18 @@ class _CLIConfiguration {
497
497
  this.config.allowUsageTracking = isEnabled;
498
498
  return this.write();
499
499
  }
500
+ updateAutoOpenBrowser(isEnabled) {
501
+ if (!this.config) {
502
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
503
+ }
504
+ if (typeof isEnabled !== 'boolean') {
505
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.updateAutoOpenBrowser.errors.invalidInput`, {
506
+ isEnabled: `${isEnabled}`,
507
+ }));
508
+ }
509
+ this.config.autoOpenBrowser = isEnabled;
510
+ return this.write();
511
+ }
500
512
  isTrackingAllowed() {
501
513
  if (!this.config) {
502
514
  return true;
@@ -510,5 +522,27 @@ class _CLIConfiguration {
510
522
  }
511
523
  return config;
512
524
  }
525
+ hasLocalStateFlag(flag) {
526
+ if (!this.config) {
527
+ return false;
528
+ }
529
+ return this.config.flags?.includes(flag) || false;
530
+ }
531
+ addLocalStateFlag(flag) {
532
+ if (!this.config) {
533
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
534
+ }
535
+ if (!this.hasLocalStateFlag(flag)) {
536
+ this.config.flags = [...(this.config.flags || []), flag];
537
+ }
538
+ this.write();
539
+ }
540
+ removeLocalStateFlag(flag) {
541
+ if (!this.config) {
542
+ throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigLoaded`));
543
+ }
544
+ this.config.flags = this.config.flags?.filter(f => f !== flag) || [];
545
+ this.write();
546
+ }
513
547
  }
514
548
  exports.CLIConfiguration = new _CLIConfiguration();
@@ -18,6 +18,8 @@ export declare function getOrderedConfig(unorderedConfig: CLIConfig_DEPRECATED):
18
18
  defaultMode?: CmsPublishMode | undefined;
19
19
  env?: Environment | undefined;
20
20
  httpUseLocalhost?: boolean | undefined;
21
+ autoOpenBrowser?: boolean | undefined;
22
+ flags?: string[] | undefined;
21
23
  defaultCmsPublishMode: CmsPublishMode | undefined;
22
24
  httpTimeout: number | undefined;
23
25
  allowUsageTracking: boolean | undefined;
@@ -60,6 +62,7 @@ export declare function updateAllowAutoUpdates(enabled: boolean): void;
60
62
  * @throws {Error}
61
63
  */
62
64
  export declare function updateAllowUsageTracking(isEnabled: boolean): void;
65
+ export declare function updateAutoOpenBrowser(isEnabled: boolean): void;
63
66
  /**
64
67
  * @throws {Error}
65
68
  */
@@ -78,4 +81,7 @@ export declare function loadConfigFromEnvironment({ useEnv, }?: {
78
81
  }): {
79
82
  portals: Array<CLIAccount_DEPRECATED>;
80
83
  } | undefined;
81
- export declare function isConfigFlagEnabled(flag: keyof CLIConfig_DEPRECATED): boolean;
84
+ export declare function isConfigFlagEnabled(flag: keyof CLIConfig_DEPRECATED, defaultValue?: boolean): boolean;
85
+ export declare function hasLocalStateFlag(flag: string): boolean;
86
+ export declare function addLocalStateFlag(flag: string): void;
87
+ export declare function removeLocalStateFlag(flag: string): void;
@@ -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.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;
6
+ exports.removeLocalStateFlag = exports.addLocalStateFlag = exports.hasLocalStateFlag = exports.isConfigFlagEnabled = exports.loadConfigFromEnvironment = exports.deleteConfigFile = exports.deleteEmptyConfigFile = exports.createEmptyConfigFile = exports.deleteAccount = exports.renameAccount = exports.updateAutoOpenBrowser = 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"));
@@ -14,7 +14,6 @@ const auth_1 = require("../constants/auth");
14
14
  const files_1 = require("../constants/files");
15
15
  const environment_1 = require("../lib/environment");
16
16
  const logger_1 = require("../lib/logger");
17
- const git_1 = require("../utils/git");
18
17
  const errors_DEPRECATED_1 = require("../errors/errors_DEPRECATED");
19
18
  const ALL_CMS_PUBLISH_MODES = Object.values(files_1.CMS_PUBLISH_MODE);
20
19
  let _config;
@@ -191,12 +190,11 @@ function readConfigFile() {
191
190
  return { source, error };
192
191
  }
193
192
  try {
194
- (0, git_1.isConfigPathInGitRepo)(_configPath);
195
193
  source = fs_extra_1.default.readFileSync(_configPath);
196
194
  }
197
195
  catch (err) {
198
196
  error = err;
199
- logger_1.logger.error('Config file could not be read "%s"', _configPath);
197
+ logger_1.logger.error(`Config file could not be read: ${_configPath}`);
200
198
  (0, errors_DEPRECATED_1.logFileSystemErrorInstance)(error, {
201
199
  filepath: _configPath,
202
200
  operation: 'read',
@@ -215,7 +213,7 @@ function parseConfig(configSource) {
215
213
  }
216
214
  catch (err) {
217
215
  error = err;
218
- logger_1.logger.error('Config file could not be parsed "%s"', _configPath);
216
+ logger_1.logger.error(`Config file could not be parsed: ${_configPath}`);
219
217
  (0, errors_DEPRECATED_1.logErrorInstance)(err);
220
218
  }
221
219
  return { parsed, error };
@@ -517,6 +515,16 @@ function updateAllowUsageTracking(isEnabled) {
517
515
  writeConfig();
518
516
  }
519
517
  exports.updateAllowUsageTracking = updateAllowUsageTracking;
518
+ function updateAutoOpenBrowser(isEnabled) {
519
+ if (typeof isEnabled !== 'boolean') {
520
+ throw new Error(`Unable to update autoOpenBrowser. The value ${isEnabled} is invalid. The value must be a boolean.`);
521
+ }
522
+ const config = getAndLoadConfigIfNeeded();
523
+ config.autoOpenBrowser = isEnabled;
524
+ setDefaultConfigPathIfUnset();
525
+ writeConfig();
526
+ }
527
+ exports.updateAutoOpenBrowser = updateAutoOpenBrowser;
520
528
  /**
521
529
  * @throws {Error}
522
530
  */
@@ -688,12 +696,12 @@ function loadEnvironmentVariableConfig(options) {
688
696
  logger_1.logger.debug(`Loaded config from environment variables for account ${portalId}`);
689
697
  return setConfig(handleLegacyCmsPublishMode(envConfig));
690
698
  }
691
- function isConfigFlagEnabled(flag) {
699
+ function isConfigFlagEnabled(flag, defaultValue = false) {
692
700
  if (!configFileExists() || configFileIsBlank()) {
693
- return false;
701
+ return defaultValue;
694
702
  }
695
703
  const config = getAndLoadConfigIfNeeded();
696
- return Boolean(config[flag] || false);
704
+ return Boolean(config[flag] || defaultValue);
697
705
  }
698
706
  exports.isConfigFlagEnabled = isConfigFlagEnabled;
699
707
  function handleLegacyCmsPublishMode(config) {
@@ -703,3 +711,28 @@ function handleLegacyCmsPublishMode(config) {
703
711
  }
704
712
  return config;
705
713
  }
714
+ function hasLocalStateFlag(flag) {
715
+ if (!_config) {
716
+ return false;
717
+ }
718
+ return _config.flags?.includes(flag) || false;
719
+ }
720
+ exports.hasLocalStateFlag = hasLocalStateFlag;
721
+ function addLocalStateFlag(flag) {
722
+ if (!_config) {
723
+ throw new Error('No config loaded');
724
+ }
725
+ if (!hasLocalStateFlag(flag)) {
726
+ _config.flags = [...(_config.flags || []), flag];
727
+ }
728
+ writeConfig();
729
+ }
730
+ exports.addLocalStateFlag = addLocalStateFlag;
731
+ function removeLocalStateFlag(flag) {
732
+ if (!_config) {
733
+ throw new Error('No config loaded');
734
+ }
735
+ _config.flags = _config.flags?.filter(f => f !== flag) || [];
736
+ writeConfig();
737
+ }
738
+ exports.removeLocalStateFlag = removeLocalStateFlag;
package/config/index.d.ts CHANGED
@@ -26,8 +26,9 @@ export declare function deleteAccount(accountName: string): Promise<void | boole
26
26
  export declare function updateHttpTimeout(timeout: string): void;
27
27
  export declare function updateAllowAutoUpdates(enabled: boolean): void;
28
28
  export declare function updateAllowUsageTracking(isEnabled: boolean): void;
29
+ export declare function updateAutoOpenBrowser(isEnabled: boolean): void;
29
30
  export declare function deleteConfigFile(): void;
30
- export declare function isConfigFlagEnabled(flag: keyof CLIConfig): boolean;
31
+ export declare function isConfigFlagEnabled(flag: keyof CLIConfig, defaultValue?: boolean): boolean;
31
32
  export declare function isTrackingAllowed(): boolean;
32
33
  export declare function getEnv(nameOrId?: string | number): import("../types/Config").Environment;
33
34
  export declare function getAccountType(accountType?: AccountType, sandboxAccountType?: string | null): AccountType;
@@ -37,6 +38,9 @@ export declare function getConfigAccounts(): Array<CLIAccount_NEW> | Array<CLIAc
37
38
  export declare function updateDefaultCmsPublishMode(cmsPublishMode: CmsPublishMode): void | CLIConfig_NEW | null;
38
39
  export declare function getCWDAccountOverride(): string | number | null | undefined;
39
40
  export declare function getDefaultAccountOverrideFilePath(): string | null | undefined;
41
+ export declare function hasLocalStateFlag(flag: string): boolean;
42
+ export declare function addLocalStateFlag(flag: string): void;
43
+ export declare function removeLocalStateFlag(flag: string): void;
40
44
  export declare const getConfigAccountId: typeof config_DEPRECATED.getConfigAccountId;
41
45
  export declare const getOrderedAccount: typeof config_DEPRECATED.getOrderedAccount;
42
46
  export declare const getOrderedConfig: typeof config_DEPRECATED.getOrderedConfig;
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.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;
26
+ exports.findConfig = exports.setConfigPath = exports.setConfig = exports.getOrderedConfig = exports.getOrderedAccount = exports.getConfigAccountId = exports.removeLocalStateFlag = exports.addLocalStateFlag = exports.hasLocalStateFlag = exports.getDefaultAccountOverrideFilePath = exports.getCWDAccountOverride = exports.updateDefaultCmsPublishMode = exports.getConfigAccounts = exports.getDisplayDefaultAccount = exports.getConfigDefaultAccount = exports.getAccountType = exports.getEnv = exports.isTrackingAllowed = exports.isConfigFlagEnabled = exports.deleteConfigFile = exports.updateAutoOpenBrowser = 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");
@@ -202,6 +202,15 @@ function updateAllowUsageTracking(isEnabled) {
202
202
  }
203
203
  }
204
204
  exports.updateAllowUsageTracking = updateAllowUsageTracking;
205
+ function updateAutoOpenBrowser(isEnabled) {
206
+ if (CLIConfiguration_1.CLIConfiguration.isActive()) {
207
+ CLIConfiguration_1.CLIConfiguration.updateAutoOpenBrowser(isEnabled);
208
+ }
209
+ else {
210
+ config_DEPRECATED.updateAutoOpenBrowser(isEnabled);
211
+ }
212
+ }
213
+ exports.updateAutoOpenBrowser = updateAutoOpenBrowser;
205
214
  function deleteConfigFile() {
206
215
  if (CLIConfiguration_1.CLIConfiguration.isActive()) {
207
216
  (0, configFile_1.deleteConfigFile)();
@@ -211,11 +220,11 @@ function deleteConfigFile() {
211
220
  }
212
221
  }
213
222
  exports.deleteConfigFile = deleteConfigFile;
214
- function isConfigFlagEnabled(flag) {
223
+ function isConfigFlagEnabled(flag, defaultValue = false) {
215
224
  if (CLIConfiguration_1.CLIConfiguration.isActive()) {
216
- return CLIConfiguration_1.CLIConfiguration.isConfigFlagEnabled(flag);
225
+ return CLIConfiguration_1.CLIConfiguration.isConfigFlagEnabled(flag, defaultValue);
217
226
  }
218
- return config_DEPRECATED.isConfigFlagEnabled(flag);
227
+ return config_DEPRECATED.isConfigFlagEnabled(flag, defaultValue);
219
228
  }
220
229
  exports.isConfigFlagEnabled = isConfigFlagEnabled;
221
230
  function isTrackingAllowed() {
@@ -279,6 +288,31 @@ function getDefaultAccountOverrideFilePath() {
279
288
  }
280
289
  }
281
290
  exports.getDefaultAccountOverrideFilePath = getDefaultAccountOverrideFilePath;
291
+ function hasLocalStateFlag(flag) {
292
+ if (CLIConfiguration_1.CLIConfiguration.isActive()) {
293
+ return CLIConfiguration_1.CLIConfiguration.hasLocalStateFlag(flag);
294
+ }
295
+ return config_DEPRECATED.hasLocalStateFlag(flag);
296
+ }
297
+ exports.hasLocalStateFlag = hasLocalStateFlag;
298
+ function addLocalStateFlag(flag) {
299
+ if (CLIConfiguration_1.CLIConfiguration.isActive()) {
300
+ CLIConfiguration_1.CLIConfiguration.addLocalStateFlag(flag);
301
+ }
302
+ else {
303
+ config_DEPRECATED.addLocalStateFlag(flag);
304
+ }
305
+ }
306
+ exports.addLocalStateFlag = addLocalStateFlag;
307
+ function removeLocalStateFlag(flag) {
308
+ if (CLIConfiguration_1.CLIConfiguration.isActive()) {
309
+ CLIConfiguration_1.CLIConfiguration.removeLocalStateFlag(flag);
310
+ }
311
+ else {
312
+ config_DEPRECATED.removeLocalStateFlag(flag);
313
+ }
314
+ }
315
+ exports.removeLocalStateFlag = removeLocalStateFlag;
282
316
  // These functions are not supported with the new config setup
283
317
  exports.getConfigAccountId = config_DEPRECATED.getConfigAccountId;
284
318
  exports.getOrderedAccount = config_DEPRECATED.getOrderedAccount;
package/config/migrate.js CHANGED
@@ -124,6 +124,12 @@ function mergeConfigProperties(globalConfig, deprecatedConfig, force) {
124
124
  }
125
125
  }
126
126
  });
127
+ if (globalConfig.flags || deprecatedConfig.flags) {
128
+ globalConfig.flags = Array.from(new Set([
129
+ ...(globalConfig.flags || []),
130
+ ...(deprecatedConfig.flags || []),
131
+ ]));
132
+ }
127
133
  if (config_1.DEFAULT_ACCOUNT in globalConfig &&
128
134
  config_1.DEFAULT_PORTAL in deprecatedConfig &&
129
135
  globalConfig.defaultAccount !== deprecatedConfig.defaultPortal) {
package/errors/index.d.ts CHANGED
@@ -14,5 +14,6 @@ export declare function isTimeoutError(err: unknown): err is HubSpotHttpError;
14
14
  export declare function isAuthError(err: unknown): err is HubSpotHttpError;
15
15
  export declare function isValidationError(err: unknown): boolean;
16
16
  export declare function isHubSpotHttpError(error?: unknown): error is HubSpotHttpError;
17
+ export declare function isGithubRateLimitError(err: unknown): boolean;
17
18
  export declare function isSystemError(err: unknown): err is BaseError;
18
19
  export declare function isFileSystemError(err: unknown): err is FileSystemError;