@hubspot/local-dev-lib 0.3.13 → 0.3.15

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.
Files changed (46) hide show
  1. package/api/github.js +5 -5
  2. package/api/projects.d.ts +7 -0
  3. package/api/projects.js +14 -1
  4. package/config/CLIConfiguration.js +1 -1
  5. package/config/configFile.js +1 -1
  6. package/config/configUtils.js +1 -1
  7. package/config/config_DEPRECATED.js +1 -1
  8. package/config/environment.js +1 -1
  9. package/http/getAxiosConfig.d.ts +4 -1
  10. package/http/getAxiosConfig.js +14 -4
  11. package/http/index.d.ts +1 -0
  12. package/http/index.js +6 -1
  13. package/lang/en.json +1 -16
  14. package/lang/lang/en.json +1 -16
  15. package/lib/archive.js +1 -1
  16. package/lib/cms/functions.js +1 -1
  17. package/lib/cms/handleFieldsJS.js +1 -1
  18. package/lib/cms/modules.js +1 -1
  19. package/lib/cms/templates.js +1 -1
  20. package/lib/cms/uploadFolder.js +1 -1
  21. package/lib/cms/watch.js +1 -1
  22. package/lib/fileManager.js +1 -1
  23. package/lib/fileMapper.js +1 -1
  24. package/lib/github.js +1 -1
  25. package/lib/gitignore.d.ts +7 -0
  26. package/lib/gitignore.js +19 -2
  27. package/lib/oauth.js +1 -1
  28. package/lib/personalAccessKey.js +1 -1
  29. package/lib/trackUsage.js +1 -1
  30. package/models/OAuth2Manager.js +1 -1
  31. package/package.json +1 -3
  32. package/types/ProjectLog.d.ts +9 -0
  33. package/types/ProjectLog.js +2 -0
  34. package/utils/PortManagerServer.js +1 -1
  35. package/utils/git.d.ts +1 -7
  36. package/utils/git.js +2 -18
  37. package/lib/logging/git.d.ts +0 -2
  38. package/lib/logging/git.js +0 -54
  39. package/lib/logging/logs.d.ts +0 -22
  40. package/lib/logging/logs.js +0 -86
  41. package/lib/logging/table.d.ts +0 -3
  42. package/lib/logging/table.js +0 -47
  43. package/utils/objectUtils.d.ts +0 -8
  44. package/utils/objectUtils.js +0 -33
  45. /package/lib/{logging/logger.d.ts → logger.d.ts} +0 -0
  46. /package/lib/{logging/logger.js → logger.js} +0 -0
package/api/github.js CHANGED
@@ -16,7 +16,7 @@ const GITHUB_AUTH_HEADERS = {
16
16
  async function fetchRepoReleaseData(repoPath, tag = '') {
17
17
  const URL = `${GITHUB_REPOS_API}/${repoPath}/releases`;
18
18
  return axios_1.default.get(`${URL}/${tag ? `tags/${tag}` : 'latest'}`, {
19
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
19
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS },
20
20
  });
21
21
  }
22
22
  exports.fetchRepoReleaseData = fetchRepoReleaseData;
@@ -25,21 +25,21 @@ exports.fetchRepoReleaseData = fetchRepoReleaseData;
25
25
  async function fetchRepoAsZip(zipUrl) {
26
26
  return axios_1.default.get(zipUrl, {
27
27
  responseType: 'arraybuffer',
28
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
28
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS },
29
29
  });
30
30
  }
31
31
  exports.fetchRepoAsZip = fetchRepoAsZip;
32
32
  // Returns the raw file contents via the raw.githubusercontent endpoint
33
33
  async function fetchRepoFile(repoPath, filePath, ref) {
34
34
  return axios_1.default.get(`${GITHUB_RAW_CONTENT_API_PATH}/${repoPath}/${ref}/${filePath}`, {
35
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
35
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS },
36
36
  });
37
37
  }
38
38
  exports.fetchRepoFile = fetchRepoFile;
39
39
  // Returns the raw file contents via the raw.githubusercontent endpoint
40
40
  async function fetchRepoFileByDownloadUrl(downloadUrl) {
41
41
  return axios_1.default.get(downloadUrl, {
42
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
42
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS },
43
43
  });
44
44
  }
45
45
  exports.fetchRepoFileByDownloadUrl = fetchRepoFileByDownloadUrl;
@@ -48,7 +48,7 @@ exports.fetchRepoFileByDownloadUrl = fetchRepoFileByDownloadUrl;
48
48
  async function fetchRepoContents(repoPath, path, ref) {
49
49
  const refQuery = ref ? `?ref=${ref}` : '';
50
50
  return axios_1.default.get(`${GITHUB_REPOS_API}/${repoPath}/contents/${path}${refQuery}`, {
51
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
51
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS },
52
52
  });
53
53
  }
54
54
  exports.fetchRepoContents = fetchRepoContents;
package/api/projects.d.ts CHANGED
@@ -4,6 +4,7 @@ import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings }
4
4
  import { Build, FetchProjectBuildsResponse } from '../types/Build';
5
5
  import { ComponentMetadataResponse, ComponentStructureResponse } from '../types/ComponentStructure';
6
6
  import { Deploy, ProjectDeployResponse } from '../types/Deploy';
7
+ import { ProjectLog } from '../types/ProjectLog';
7
8
  export declare function fetchProjects(accountId: number): Promise<FetchProjectResponse>;
8
9
  export declare function createProject(accountId: number, name: string): Promise<Project>;
9
10
  export declare function uploadProject(accountId: number, projectName: string, projectFile: string, uploadMessage: string, platformVersion?: string): Promise<UploadProjectResponse>;
@@ -28,4 +29,10 @@ export declare function queueBuild(accountId: number, projectName: string, platf
28
29
  export declare function uploadFileToBuild(accountId: number, projectName: string, filePath: string, path: string): Promise<void>;
29
30
  export declare function deleteFileFromBuild(accountId: number, projectName: string, path: string): Promise<void>;
30
31
  export declare function cancelStagedBuild(accountId: number, projectName: string): Promise<void>;
32
+ export declare function fetchBuildWarnLogs(accountId: number, projectName: string, buildId: number): Promise<{
33
+ logs: Array<ProjectLog>;
34
+ }>;
35
+ export declare function fetchDeployWarnLogs(accountId: number, projectName: string, deployId: number): Promise<{
36
+ logs: Array<ProjectLog>;
37
+ }>;
31
38
  export {};
package/api/projects.js CHANGED
@@ -3,11 +3,12 @@ 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.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.fetchDeployComponentsMetadata = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0;
6
+ exports.fetchDeployWarnLogs = exports.fetchBuildWarnLogs = exports.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.fetchDeployComponentsMetadata = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0;
7
7
  const http_1 = __importDefault(require("../http"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const PROJECTS_API_PATH = 'dfs/v1/projects';
10
10
  const PROJECTS_DEPLOY_API_PATH = 'dfs/deploy/v1';
11
+ const PROJECTS_LOGS_API_PATH = 'dfs/logging/v1';
11
12
  const DEVELOPER_PROJECTS_API_PATH = 'developer/projects/v1';
12
13
  async function fetchProjects(accountId) {
13
14
  return http_1.default.get(accountId, {
@@ -159,3 +160,15 @@ async function cancelStagedBuild(accountId, projectName) {
159
160
  });
160
161
  }
161
162
  exports.cancelStagedBuild = cancelStagedBuild;
163
+ async function fetchBuildWarnLogs(accountId, projectName, buildId) {
164
+ return http_1.default.get(accountId, {
165
+ url: `${PROJECTS_LOGS_API_PATH}/logs/projects/${projectName}/builds/${buildId}/combined/warn`,
166
+ });
167
+ }
168
+ exports.fetchBuildWarnLogs = fetchBuildWarnLogs;
169
+ async function fetchDeployWarnLogs(accountId, projectName, deployId) {
170
+ return http_1.default.get(accountId, {
171
+ url: `${PROJECTS_LOGS_API_PATH}/logs/projects/${projectName}/deploys/${deployId}/combined/warn`,
172
+ });
173
+ }
174
+ exports.fetchDeployWarnLogs = fetchDeployWarnLogs;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const logger_1 = require("../lib/logging/logger");
3
+ const logger_1 = require("../lib/logger");
4
4
  const standardErrors_1 = require("../errors/standardErrors");
5
5
  const environment_1 = require("./environment");
6
6
  const environment_2 = require("../lib/environment");
@@ -8,7 +8,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const os_1 = __importDefault(require("os"));
10
10
  const js_yaml_1 = __importDefault(require("js-yaml"));
11
- const logger_1 = require("../lib/logging/logger");
11
+ const logger_1 = require("../lib/logger");
12
12
  const fileSystemErrors_1 = require("../errors/fileSystemErrors");
13
13
  const standardErrors_1 = require("../errors/standardErrors");
14
14
  const config_1 = require("../constants/config");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateConfig = exports.getOrderedConfig = exports.getOrderedAccount = void 0;
4
- const logger_1 = require("../lib/logging/logger");
4
+ const logger_1 = require("../lib/logger");
5
5
  const auth_1 = require("../constants/auth");
6
6
  const lang_1 = require("../utils/lang");
7
7
  const i18nKey = 'config.configUtils';
@@ -13,7 +13,7 @@ const environments_1 = require("../constants/environments");
13
13
  const auth_1 = require("../constants/auth");
14
14
  const files_1 = require("../constants/files");
15
15
  const environment_1 = require("../lib/environment");
16
- const logger_1 = require("../lib/logging/logger");
16
+ const logger_1 = require("../lib/logger");
17
17
  const git_1 = require("../utils/git");
18
18
  const errors_DEPRECATED_1 = require("../errors/errors_DEPRECATED");
19
19
  const ALL_MODES = Object.values(files_1.MODE);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadConfigFromEnvironment = void 0;
4
- const logger_1 = require("../lib/logging/logger");
4
+ const logger_1 = require("../lib/logger");
5
5
  const environments_1 = require("../constants/environments");
6
6
  const auth_1 = require("../constants/auth");
7
7
  const configUtils_1 = require("./configUtils");
@@ -1,6 +1,9 @@
1
1
  import { AxiosConfigOptions } from '../types/Http';
2
2
  import { AxiosRequestConfig } from 'axios';
3
- export declare const DEFAULT_USER_AGENT_HEADERS: {
3
+ export declare const USER_AGENTS: {
4
+ [key: string]: string;
5
+ };
6
+ export declare function getDefaultUserAgentHeader(): {
4
7
  'User-Agent': string;
5
8
  };
6
9
  export declare function getAxiosConfig(options: AxiosConfigOptions): AxiosRequestConfig;
@@ -1,12 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAxiosConfig = exports.DEFAULT_USER_AGENT_HEADERS = void 0;
3
+ exports.getAxiosConfig = exports.getDefaultUserAgentHeader = exports.USER_AGENTS = void 0;
4
4
  const package_json_1 = require("../package.json");
5
5
  const config_1 = require("../config");
6
6
  const urls_1 = require("../lib/urls");
7
- exports.DEFAULT_USER_AGENT_HEADERS = {
8
- 'User-Agent': `HubSpot Local Dev Lib/${package_json_1.version}`,
7
+ exports.USER_AGENTS = {
8
+ 'HubSpot Local Dev Lib': package_json_1.version,
9
9
  };
10
+ function getDefaultUserAgentHeader() {
11
+ let userAgentString = '';
12
+ Object.keys(exports.USER_AGENTS).forEach((userAgentKey, i) => {
13
+ userAgentString += `${i > 0 ? ', ' : ''}${userAgentKey}/${exports.USER_AGENTS[userAgentKey]}`;
14
+ });
15
+ return {
16
+ 'User-Agent': userAgentString,
17
+ };
18
+ }
19
+ exports.getDefaultUserAgentHeader = getDefaultUserAgentHeader;
10
20
  const DEFAULT_TRANSITIONAL = {
11
21
  clarifyTimeoutError: true,
12
22
  };
@@ -16,7 +26,7 @@ function getAxiosConfig(options) {
16
26
  return {
17
27
  baseURL: (0, urls_1.getHubSpotApiOrigin)(env, localHostOverride ? false : httpUseLocalhost),
18
28
  headers: {
19
- ...exports.DEFAULT_USER_AGENT_HEADERS,
29
+ ...getDefaultUserAgentHeader(),
20
30
  ...(headers || {}),
21
31
  },
22
32
  timeout: httpTimeout || 15000,
package/http/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { HttpOptions } from '../types/Http';
3
+ export declare function addUserAgentHeader(key: string, value: string): void;
3
4
  declare function getRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
4
5
  declare function postRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
5
6
  declare function putRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
package/http/index.js CHANGED
@@ -3,6 +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.addUserAgentHeader = void 0;
6
7
  const path_1 = __importDefault(require("path"));
7
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
9
  const content_disposition_1 = __importDefault(require("content-disposition"));
@@ -12,9 +13,13 @@ const getAxiosConfig_1 = require("./getAxiosConfig");
12
13
  const personalAccessKey_1 = require("../lib/personalAccessKey");
13
14
  const oauth_1 = require("../lib/oauth");
14
15
  const standardErrors_1 = require("../errors/standardErrors");
15
- const logger_1 = require("../lib/logging/logger");
16
+ const logger_1 = require("../lib/logger");
16
17
  const lang_1 = require("../utils/lang");
17
18
  const i18nKey = 'http.index';
19
+ function addUserAgentHeader(key, value) {
20
+ getAxiosConfig_1.USER_AGENTS[key] = value;
21
+ }
22
+ exports.addUserAgentHeader = addUserAgentHeader;
18
23
  async function withOauth(accountId, accountConfig, axiosConfig) {
19
24
  const { headers } = axiosConfig;
20
25
  const oauth = (0, oauth_1.getOauthManager)(accountId, accountConfig);
package/lang/en.json CHANGED
@@ -183,21 +183,6 @@
183
183
  "ready": "Watcher is ready and watching {{ src }}. Any changes detected will be automatically uploaded and overwrite the current version in the developer file system."
184
184
  }
185
185
  },
186
- "logging": {
187
- "git": {
188
- "securityIssue": "Security Issue Detected",
189
- "configFileTracked": "The HubSpot config file can be tracked by git.",
190
- "fileName": "File: \"{{ configPath }}\"",
191
- "remediate": "To remediate:",
192
- "moveConfig": "- Move the config file to your home directory: '{{ homeDir }}'",
193
- "addGitignore": "- Add gitignore pattern '{{ configPath }}' to a .gitignore file in root of your repository.",
194
- "noRemote": "- Ensure that the config file has not already been pushed to a remote repository.",
195
- "checkFailed": "Unable to determine if config file is properly ignored by git."
196
- },
197
- "logs": {
198
- "unableToProcessLog": "Unable to process log {{ log }}"
199
- }
200
- },
201
186
  "oauth": {
202
187
  "writeTokenInfo": "Updating Oauth2 token info for portalId: {{ portalId }}",
203
188
  "addOauthToAccountConfig": {
@@ -395,7 +380,7 @@
395
380
  "429": "The {{ messageDetail }} surpassed the rate limit. Retry in one minute.",
396
381
  "503": "The {{ messageDetail }} could not be handled at this time. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
397
382
  "403ProjectMissingScope": "Couldn't run the project command because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{ accountId }}, and generate a new one. Then run `hs auth` to update the CLI with the new key.",
398
- "403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/whats-new/betas?productUpdateId=13860216.",
383
+ "403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/product-updates/in-beta?update=13899236.",
399
384
  "500Generic": "The {{ messageDetail }} failed due to a server error. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
400
385
  "400Generic": "The {{ messageDetail }} failed due to a client error.",
401
386
  "generic": "The {{ messageDetail }} failed."
package/lang/lang/en.json CHANGED
@@ -183,21 +183,6 @@
183
183
  "ready": "Watcher is ready and watching {{ src }}. Any changes detected will be automatically uploaded and overwrite the current version in the developer file system."
184
184
  }
185
185
  },
186
- "logging": {
187
- "git": {
188
- "securityIssue": "Security Issue Detected",
189
- "configFileTracked": "The HubSpot config file can be tracked by git.",
190
- "fileName": "File: \"{{ configPath }}\"",
191
- "remediate": "To remediate:",
192
- "moveConfig": "- Move the config file to your home directory: '{{ homeDir }}'",
193
- "addGitignore": "- Add gitignore pattern '{{ configPath }}' to a .gitignore file in root of your repository.",
194
- "noRemote": "- Ensure that the config file has not already been pushed to a remote repository.",
195
- "checkFailed": "Unable to determine if config file is properly ignored by git."
196
- },
197
- "logs": {
198
- "unableToProcessLog": "Unable to process log {{ log }}"
199
- }
200
- },
201
186
  "oauth": {
202
187
  "writeTokenInfo": "Updating Oauth2 token info for portalId: {{ portalId }}",
203
188
  "addOauthToAccountConfig": {
@@ -395,7 +380,7 @@
395
380
  "429": "The {{ messageDetail }} surpassed the rate limit. Retry in one minute.",
396
381
  "503": "The {{ messageDetail }} could not be handled at this time. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
397
382
  "403ProjectMissingScope": "Couldn't run the project command because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{ accountId }}, and generate a new one. Then run `hs auth` to update the CLI with the new key.",
398
- "403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/whats-new/betas?productUpdateId=13860216.",
383
+ "403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/product-updates/in-beta?update=13899236.",
399
384
  "500Generic": "The {{ messageDetail }} failed due to a server error. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
400
385
  "400Generic": "The {{ messageDetail }} failed due to a client error.",
401
386
  "generic": "The {{ messageDetail }} failed."
package/lib/archive.js CHANGED
@@ -10,7 +10,7 @@ const os_1 = require("os");
10
10
  const extract_zip_1 = __importDefault(require("extract-zip"));
11
11
  const fileSystemErrors_1 = require("../errors/fileSystemErrors");
12
12
  const standardErrors_1 = require("../errors/standardErrors");
13
- const logger_1 = require("./logging/logger");
13
+ const logger_1 = require("./logger");
14
14
  const lang_1 = require("../utils/lang");
15
15
  const i18nKey = 'lib.archive';
16
16
  async function extractZip(name, zip) {
@@ -9,7 +9,7 @@ const path_1 = __importDefault(require("path"));
9
9
  const findup_sync_1 = __importDefault(require("findup-sync"));
10
10
  const path_2 = require("../path");
11
11
  const github_1 = require("../github");
12
- const logger_1 = require("../logging/logger");
12
+ const logger_1 = require("../logger");
13
13
  const standardErrors_1 = require("../../errors/standardErrors");
14
14
  const fileSystemErrors_1 = require("../../errors/fileSystemErrors");
15
15
  const lang_1 = require("../../utils/lang");
@@ -10,7 +10,7 @@ const path_1 = __importDefault(require("path"));
10
10
  const child_process_1 = require("child_process");
11
11
  const escapeRegExp_1 = require("../escapeRegExp");
12
12
  const modules_1 = require("../../utils/cms/modules");
13
- const logger_1 = require("../logging/logger");
13
+ const logger_1 = require("../logger");
14
14
  const standardErrors_1 = require("../../errors/standardErrors");
15
15
  const lang_1 = require("../../utils/lang");
16
16
  const i18nKey = 'lib.cms.handleFieldsJs';
@@ -10,7 +10,7 @@ const path_2 = require("../path");
10
10
  const fs_1 = require("../fs");
11
11
  const github_1 = require("../github");
12
12
  const standardErrors_1 = require("../../errors/standardErrors");
13
- const logger_1 = require("../logging/logger");
13
+ const logger_1 = require("../logger");
14
14
  const modules_1 = require("../../utils/cms/modules");
15
15
  const lang_1 = require("../../utils/lang");
16
16
  const i18nKey = 'lib.cms.modules';
@@ -8,7 +8,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const github_1 = require("../github");
10
10
  const standardErrors_1 = require("../../errors/standardErrors");
11
- const logger_1 = require("../logging/logger");
11
+ const logger_1 = require("../logger");
12
12
  const lang_1 = require("../../utils/lang");
13
13
  const i18nKey = 'lib.cms.templates';
14
14
  // Matches the .html file extension, excluding module.html
@@ -14,7 +14,7 @@ const escapeRegExp_1 = require("../escapeRegExp");
14
14
  const path_2 = require("../path");
15
15
  const standardErrors_1 = require("../../errors/standardErrors");
16
16
  const apiErrors_1 = require("../../errors/apiErrors");
17
- const logger_1 = require("../logging/logger");
17
+ const logger_1 = require("../logger");
18
18
  const files_1 = require("../../constants/files");
19
19
  const lang_1 = require("../../utils/lang");
20
20
  const i18nKey = 'lib.cms.uploadFolder';
package/lib/cms/watch.js CHANGED
@@ -18,7 +18,7 @@ const escapeRegExp_1 = require("../escapeRegExp");
18
18
  const path_2 = require("../path");
19
19
  const notify_1 = require("../notify");
20
20
  const themes_1 = require("./themes");
21
- const logger_1 = require("../logging/logger");
21
+ const logger_1 = require("../logger");
22
22
  const lang_1 = require("../../utils/lang");
23
23
  const i18nKey = 'lib.cms.watch';
24
24
  const queue = new p_queue_1.default({
@@ -9,7 +9,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const fileManager_1 = require("../api/fileManager");
11
11
  const fs_1 = require("./fs");
12
- const logger_1 = require("./logging/logger");
12
+ const logger_1 = require("./logger");
13
13
  const ignoreRules_1 = require("./ignoreRules");
14
14
  const http_1 = __importDefault(require("../http"));
15
15
  const escapeRegExp_1 = require("./escapeRegExp");
package/lib/fileMapper.js CHANGED
@@ -9,7 +9,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const p_queue_1 = __importDefault(require("p-queue"));
11
11
  const path_2 = require("./path");
12
- const logger_1 = require("./logging/logger");
12
+ const logger_1 = require("./logger");
13
13
  const fileMapper_1 = require("../api/fileMapper");
14
14
  const standardErrors_1 = require("../errors/standardErrors");
15
15
  const extensions_1 = require("../constants/extensions");
package/lib/github.js CHANGED
@@ -8,7 +8,7 @@ const path_1 = __importDefault(require("path"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const standardErrors_1 = require("../errors/standardErrors");
10
10
  const archive_1 = require("./archive");
11
- const logger_1 = require("./logging/logger");
11
+ const logger_1 = require("./logger");
12
12
  const github_1 = require("../api/github");
13
13
  const lang_1 = require("../utils/lang");
14
14
  const i18nKey = 'lib.github';
@@ -1 +1,8 @@
1
1
  export declare function checkAndAddConfigToGitignore(configPath: string): void;
2
+ type GitInclusionResult = {
3
+ inGit: boolean;
4
+ configIgnored: boolean;
5
+ gitignoreFiles: Array<string>;
6
+ };
7
+ export declare function checkGitInclusion(configPath: string): GitInclusionResult;
8
+ export {};
package/lib/gitignore.js CHANGED
@@ -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.checkAndAddConfigToGitignore = void 0;
6
+ exports.checkGitInclusion = exports.checkAndAddConfigToGitignore = void 0;
7
7
  const fs_extra_1 = require("fs-extra");
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const git_1 = require("../utils/git");
@@ -13,7 +13,7 @@ const i18nKey = 'lib.gitignore';
13
13
  const GITIGNORE_FILE = '.gitignore';
14
14
  function checkAndAddConfigToGitignore(configPath) {
15
15
  try {
16
- const { configIgnored, gitignoreFiles } = (0, git_1.checkGitInclusion)(configPath);
16
+ const { configIgnored, gitignoreFiles } = checkGitInclusion(configPath);
17
17
  if (configIgnored)
18
18
  return;
19
19
  let gitignoreFilePath = gitignoreFiles && gitignoreFiles.length ? gitignoreFiles[0] : null;
@@ -30,3 +30,20 @@ function checkAndAddConfigToGitignore(configPath) {
30
30
  }
31
31
  }
32
32
  exports.checkAndAddConfigToGitignore = checkAndAddConfigToGitignore;
33
+ function checkGitInclusion(configPath) {
34
+ const result = {
35
+ inGit: false,
36
+ configIgnored: false,
37
+ gitignoreFiles: [],
38
+ };
39
+ if ((0, git_1.isConfigPathInGitRepo)(configPath)) {
40
+ result.inGit = true;
41
+ result.gitignoreFiles = (0, git_1.getGitignoreFiles)(configPath);
42
+ if ((0, git_1.configFilenameIsIgnoredByGitignore)(result.gitignoreFiles, configPath)) {
43
+ // Found ignore statement in .gitignore that matches config filename
44
+ result.configIgnored = true;
45
+ }
46
+ }
47
+ return result;
48
+ }
49
+ exports.checkGitInclusion = checkGitInclusion;
package/lib/oauth.js CHANGED
@@ -7,7 +7,7 @@ exports.addOauthToAccountConfig = exports.getOauthManager = void 0;
7
7
  const OAuth2Manager_1 = __importDefault(require("../models/OAuth2Manager"));
8
8
  const auth_1 = require("../constants/auth");
9
9
  const standardErrors_1 = require("../errors/standardErrors");
10
- const logger_1 = require("./logging/logger");
10
+ const logger_1 = require("./logger");
11
11
  const getAccountIdentifier_1 = require("../utils/getAccountIdentifier");
12
12
  const config_1 = require("../config");
13
13
  const lang_1 = require("../utils/lang");
@@ -13,7 +13,7 @@ const sandboxHubs_1 = require("../api/sandboxHubs");
13
13
  const config_1 = require("../config");
14
14
  const config_2 = require("../constants/config");
15
15
  const developerTestAccounts_1 = require("../api/developerTestAccounts");
16
- const logger_1 = require("./logging/logger");
16
+ const logger_1 = require("./logger");
17
17
  const apiErrors_1 = require("../errors/apiErrors");
18
18
  const i18nKey = 'lib.personalAccessKey';
19
19
  const refreshRequests = new Map();
package/lib/trackUsage.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.trackUsage = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const getAxiosConfig_1 = require("../http/getAxiosConfig");
9
- const logger_1 = require("./logging/logger");
9
+ const logger_1 = require("./logger");
10
10
  const http_1 = __importDefault(require("../http"));
11
11
  const config_1 = require("../config");
12
12
  const fileMapper_1 = require("../api/fileMapper");
@@ -7,7 +7,7 @@ const axios_1 = __importDefault(require("axios"));
7
7
  const moment_1 = __importDefault(require("moment"));
8
8
  const urls_1 = require("../lib/urls");
9
9
  const environment_1 = require("../lib/environment");
10
- const logger_1 = require("../lib/logging/logger");
10
+ const logger_1 = require("../lib/logger");
11
11
  const getAccountIdentifier_1 = require("../utils/getAccountIdentifier");
12
12
  const auth_1 = require("../constants/auth");
13
13
  const standardErrors_1 = require("../errors/standardErrors");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -54,7 +54,6 @@
54
54
  "./http": "./http/index.js",
55
55
  "./config": "./config/index.js",
56
56
  "./constants/*": "./constants/*.js",
57
- "./logger": "./lib/logging/logger.js",
58
57
  "./models/*": "./models/*.js"
59
58
  },
60
59
  "dependencies": {
@@ -75,7 +74,6 @@
75
74
  "p-queue": "^6.0.2",
76
75
  "prettier": "^3.0.3",
77
76
  "semver": "^6.3.0",
78
- "table": "^6.8.1",
79
77
  "unixify": "^1.0.0"
80
78
  },
81
79
  "engines": {
@@ -0,0 +1,9 @@
1
+ export type ProjectLog = {
2
+ lineNumber: number;
3
+ logLevel: string;
4
+ message: string;
5
+ pipelineStepId: number;
6
+ pipelineSubstepId?: string;
7
+ pipelineSubstepName?: string;
8
+ timestamp: number;
9
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -8,7 +8,7 @@ const cors_1 = __importDefault(require("cors"));
8
8
  const detectPort_1 = require("./detectPort");
9
9
  const ports_1 = require("../constants/ports");
10
10
  const standardErrors_1 = require("../errors/standardErrors");
11
- const logger_1 = require("../lib/logging/logger");
11
+ const logger_1 = require("../lib/logger");
12
12
  const lang_1 = require("./lang");
13
13
  const i18nKey = 'utils.PortManagerServer';
14
14
  class PortManagerServer {
package/utils/git.d.ts CHANGED
@@ -1,9 +1,3 @@
1
+ export declare function getGitignoreFiles(configPath: string): Array<string>;
1
2
  export declare function isConfigPathInGitRepo(configPath: string): boolean;
2
3
  export declare function configFilenameIsIgnoredByGitignore(ignoreFiles: Array<string>, configPath: string): boolean;
3
- type GitInclusionResult = {
4
- inGit: boolean;
5
- configIgnored: boolean;
6
- gitignoreFiles: Array<string>;
7
- };
8
- export declare function checkGitInclusion(configPath: string): GitInclusionResult;
9
- export {};
package/utils/git.js CHANGED
@@ -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.checkGitInclusion = exports.configFilenameIsIgnoredByGitignore = exports.isConfigPathInGitRepo = void 0;
6
+ exports.configFilenameIsIgnoredByGitignore = exports.isConfigPathInGitRepo = exports.getGitignoreFiles = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const ignore_1 = __importDefault(require("ignore"));
@@ -47,6 +47,7 @@ function getGitignoreFiles(configPath) {
47
47
  }
48
48
  return files;
49
49
  }
50
+ exports.getGitignoreFiles = getGitignoreFiles;
50
51
  function isConfigPathInGitRepo(configPath) {
51
52
  const gitDir = getGitComparisonDir();
52
53
  if (!gitDir)
@@ -68,20 +69,3 @@ function configFilenameIsIgnoredByGitignore(ignoreFiles, configPath) {
68
69
  });
69
70
  }
70
71
  exports.configFilenameIsIgnoredByGitignore = configFilenameIsIgnoredByGitignore;
71
- function checkGitInclusion(configPath) {
72
- const result = {
73
- inGit: false,
74
- configIgnored: false,
75
- gitignoreFiles: [],
76
- };
77
- if (isConfigPathInGitRepo(configPath)) {
78
- result.inGit = true;
79
- result.gitignoreFiles = getGitignoreFiles(configPath);
80
- if (configFilenameIsIgnoredByGitignore(result.gitignoreFiles, configPath)) {
81
- // Found ignore statement in .gitignore that matches config filename
82
- result.configIgnored = true;
83
- }
84
- }
85
- return result;
86
- }
87
- exports.checkGitInclusion = checkGitInclusion;
@@ -1,2 +0,0 @@
1
- export declare function checkAndWarnGitInclusion(configPath: string): void;
2
- export declare function checkAndUpdateGitignore(configPath: string): void;
@@ -1,54 +0,0 @@
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.checkAndUpdateGitignore = exports.checkAndWarnGitInclusion = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- const os_1 = __importDefault(require("os"));
10
- const git_1 = require("../../utils/git");
11
- const logger_1 = require("./logger");
12
- const lang_1 = require("../../utils/lang");
13
- const config_1 = require("../../constants/config");
14
- const GITIGNORE_FILE = '.gitignore';
15
- const i18nKey = 'lib.logging.git';
16
- function checkAndWarnGitInclusion(configPath) {
17
- try {
18
- const { inGit, configIgnored } = (0, git_1.checkGitInclusion)(configPath);
19
- if (!inGit || configIgnored)
20
- return;
21
- logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.securityIssue`));
22
- logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.configFileTracked`));
23
- logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.fileName`, { configPath }));
24
- logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.remediate`));
25
- logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.moveConfig`, { homeDir: os_1.default.homedir() }));
26
- logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.addGitignore`, { configPath }));
27
- logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.noRemote`));
28
- }
29
- catch (e) {
30
- // fail silently
31
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.checkFailed`));
32
- }
33
- }
34
- exports.checkAndWarnGitInclusion = checkAndWarnGitInclusion;
35
- function checkAndUpdateGitignore(configPath) {
36
- try {
37
- const { configIgnored, gitignoreFiles } = (0, git_1.checkGitInclusion)(configPath);
38
- if (configIgnored)
39
- return;
40
- let gitignoreFilePath = gitignoreFiles && gitignoreFiles.length ? gitignoreFiles[0] : null;
41
- if (!gitignoreFilePath) {
42
- gitignoreFilePath = path_1.default.resolve(configPath, GITIGNORE_FILE);
43
- fs_extra_1.default.writeFileSync(gitignoreFilePath, '');
44
- }
45
- const gitignoreContents = fs_extra_1.default.readFileSync(gitignoreFilePath).toString();
46
- const updatedContents = `${gitignoreContents.trim()}\n\n# HubSpot config file\n${config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME}\n`;
47
- fs_extra_1.default.writeFileSync(gitignoreFilePath, updatedContents);
48
- }
49
- catch (e) {
50
- // fail silently
51
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.checkFailed`));
52
- }
53
- }
54
- exports.checkAndUpdateGitignore = checkAndUpdateGitignore;
@@ -1,22 +0,0 @@
1
- type Log = {
2
- log: string;
3
- status: 'SUCCESS' | 'ERROR' | 'UNHANDLED_ERROR' | 'HANDLED_ERROR';
4
- createdAt: string;
5
- executionTime: string;
6
- error: {
7
- type: string;
8
- message: string;
9
- stackTrace: Array<Array<string>>;
10
- };
11
- };
12
- type Options = {
13
- compact: boolean;
14
- insertions: {
15
- header: string;
16
- };
17
- };
18
- type LogsResponse = {
19
- results: Array<Log>;
20
- };
21
- export declare function outputLogs(logsResp: LogsResponse, options: Options): void;
22
- export {};
@@ -1,86 +0,0 @@
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.outputLogs = void 0;
7
- const moment_1 = __importDefault(require("moment"));
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const logger_1 = require("./logger");
10
- const lang_1 = require("../../utils/lang");
11
- const i18nKey = 'lib.logging.logs';
12
- const SEPARATOR = ' - ';
13
- const LOG_STATUS_COLORS = {
14
- SUCCESS: logger_1.Styles.success,
15
- ERROR: logger_1.Styles.error,
16
- UNHANDLED_ERROR: logger_1.Styles.error,
17
- HANDLED_ERROR: logger_1.Styles.error,
18
- };
19
- function errorHandler(log, options) {
20
- return `${formatLogHeader(log, options)}${formatError(log, options)}`;
21
- }
22
- const logHandler = {
23
- ERROR: errorHandler,
24
- UNHANDLED_ERROR: errorHandler,
25
- HANDLED_ERROR: errorHandler,
26
- SUCCESS: (log, options) => {
27
- return `${formatLogHeader(log, options)}${formatSuccess(log, options)}`;
28
- },
29
- };
30
- function formatSuccess(log, options) {
31
- if (!log.log || options.compact) {
32
- return '';
33
- }
34
- return `\n${log.log}`;
35
- }
36
- function formatError(log, options) {
37
- if (!log.error || options.compact) {
38
- return '';
39
- }
40
- return `${log.error.type}: ${log.error.message}\n${formatStackTrace(log)}`;
41
- }
42
- function formatLogHeader(log, options) {
43
- const color = LOG_STATUS_COLORS[log.status];
44
- const headerInsertion = options && options.insertions && options.insertions.header;
45
- return `${formatTimestamp(log)}${SEPARATOR}${color(log.status)}${headerInsertion ? `${SEPARATOR}${headerInsertion}` : ''}${SEPARATOR}${formatExecutionTime(log)}`;
46
- }
47
- function formatStackTrace(log) {
48
- const stackTrace = (log.error.stackTrace && log.error.stackTrace[0]) || [];
49
- return stackTrace
50
- .map(trace => {
51
- return ` at ${trace}\n`;
52
- })
53
- .join('');
54
- }
55
- function formatTimestamp(log) {
56
- return `${chalk_1.default.whiteBright((0, moment_1.default)(log.createdAt).toISOString())}`;
57
- }
58
- function formatExecutionTime(log) {
59
- return `${chalk_1.default.whiteBright('Execution Time:')} ${log.executionTime}ms`;
60
- }
61
- function processLog(log, options) {
62
- try {
63
- return logHandler[log.status](log, options);
64
- }
65
- catch (e) {
66
- logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.unableToProcessLog`, {
67
- log: JSON.stringify(log),
68
- }));
69
- }
70
- }
71
- function processLogs(logsResp, options) {
72
- if (!logsResp || (logsResp.results && !logsResp.results.length)) {
73
- return 'No logs found.';
74
- }
75
- else if (logsResp.results && logsResp.results.length) {
76
- return logsResp.results
77
- .map(log => {
78
- return processLog(log, options);
79
- })
80
- .join('\n');
81
- }
82
- }
83
- function outputLogs(logsResp, options) {
84
- logger_1.logger.log(processLogs(logsResp, options));
85
- }
86
- exports.outputLogs = outputLogs;
@@ -1,3 +0,0 @@
1
- import { TableUserConfig } from 'table';
2
- export declare function getTableContents(tableData?: Array<Array<any>>, tableConfig?: TableUserConfig): string;
3
- export declare function getTableHeader(headerItems: Array<string>): Array<string>;
@@ -1,47 +0,0 @@
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.getTableHeader = exports.getTableContents = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const table_1 = require("table");
9
- const objectUtils_1 = require("../../utils/objectUtils");
10
- const tableConfigDefaults = {
11
- singleLine: true,
12
- border: {
13
- topBody: '',
14
- topJoin: '',
15
- topLeft: '',
16
- topRight: '',
17
- bottomBody: '',
18
- bottomJoin: '',
19
- bottomLeft: '',
20
- bottomRight: '',
21
- bodyLeft: '',
22
- bodyRight: '',
23
- bodyJoin: '',
24
- joinBody: '',
25
- joinLeft: '',
26
- joinRight: '',
27
- joinJoin: '',
28
- },
29
- columnDefault: {
30
- paddingLeft: 0,
31
- paddingRight: 1,
32
- },
33
- drawHorizontalLine: () => {
34
- return false;
35
- },
36
- };
37
- function getTableContents(
38
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
- tableData = [], tableConfig = {}) {
40
- const mergedConfig = (0, objectUtils_1.mergeDeep)({}, tableConfigDefaults, tableConfig);
41
- return (0, table_1.table)(tableData, mergedConfig);
42
- }
43
- exports.getTableContents = getTableContents;
44
- function getTableHeader(headerItems) {
45
- return headerItems.map(headerItem => chalk_1.default.bold(headerItem));
46
- }
47
- exports.getTableHeader = getTableHeader;
@@ -1,8 +0,0 @@
1
- export declare function isObject(item: any): any;
2
- export declare function mergeDeep(target: {
3
- [key: string]: any;
4
- }, ...sources: Array<{
5
- [key: string]: any;
6
- }>): {
7
- [key: string]: any;
8
- };
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeDeep = exports.isObject = void 0;
4
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
- function isObject(item) {
6
- return item && typeof item === 'object' && !Array.isArray(item);
7
- }
8
- exports.isObject = isObject;
9
- function mergeDeep(
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
- target,
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- ...sources
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- ) {
16
- if (!sources.length)
17
- return target;
18
- const source = sources.shift();
19
- if (isObject(target) && source && isObject(source)) {
20
- for (const key in source) {
21
- if (isObject(source[key])) {
22
- if (!target[key])
23
- Object.assign(target, { [key]: {} });
24
- mergeDeep(target[key], source[key]);
25
- }
26
- else {
27
- Object.assign(target, { [key]: source[key] });
28
- }
29
- }
30
- }
31
- return mergeDeep(target, ...sources);
32
- }
33
- exports.mergeDeep = mergeDeep;
File without changes
File without changes