@hubspot/local-dev-lib 0.3.12 → 0.3.14

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 (47) hide show
  1. package/api/projects.d.ts +7 -0
  2. package/api/projects.js +14 -1
  3. package/config/CLIConfiguration.js +1 -1
  4. package/config/configFile.js +1 -1
  5. package/config/configUtils.js +1 -1
  6. package/config/config_DEPRECATED.js +1 -1
  7. package/config/environment.js +1 -1
  8. package/errors/apiErrors.d.ts +2 -1
  9. package/errors/apiErrors.js +4 -2
  10. package/http/index.js +1 -1
  11. package/lang/en.json +0 -15
  12. package/lang/lang/en.json +0 -15
  13. package/lib/archive.js +1 -1
  14. package/lib/cms/functions.js +1 -1
  15. package/lib/cms/handleFieldsJS.js +1 -1
  16. package/lib/cms/modules.js +1 -1
  17. package/lib/cms/templates.js +1 -1
  18. package/lib/cms/uploadFolder.js +1 -1
  19. package/lib/cms/watch.js +1 -1
  20. package/lib/developerTestAccounts.d.ts +2 -2
  21. package/lib/developerTestAccounts.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/types/developerTestAccounts.d.ts +1 -0
  35. package/utils/PortManagerServer.js +1 -1
  36. package/utils/git.d.ts +1 -7
  37. package/utils/git.js +2 -18
  38. package/lib/logging/git.d.ts +0 -2
  39. package/lib/logging/git.js +0 -54
  40. package/lib/logging/logs.d.ts +0 -22
  41. package/lib/logging/logs.js +0 -86
  42. package/lib/logging/table.d.ts +0 -3
  43. package/lib/logging/table.js +0 -47
  44. package/utils/objectUtils.d.ts +0 -8
  45. package/utils/objectUtils.js +0 -33
  46. /package/lib/{logging/logger.d.ts → logger.d.ts} +0 -0
  47. /package/lib/{logging/logger.js → logger.js} +0 -0
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,10 +1,11 @@
1
1
  import { AxiosError } from 'axios';
2
2
  import { GenericError, AxiosErrorContext, ValidationError } from '../types/Error';
3
3
  import { HubSpotAuthError } from '../models/HubSpotAuthError';
4
- export declare function isSpecifiedError(err: Error | AxiosError, { statusCode, category, subCategory, code, }: {
4
+ export declare function isSpecifiedError(err: Error | AxiosError, { statusCode, category, subCategory, errorType, code, }: {
5
5
  statusCode?: number;
6
6
  category?: string;
7
7
  subCategory?: string;
8
+ errorType?: string;
8
9
  code?: string;
9
10
  }): boolean;
10
11
  export declare function isMissingScopeError(err: Error | AxiosError): boolean;
@@ -5,17 +5,19 @@ const api_1 = require("../constants/api");
5
5
  const lang_1 = require("../utils/lang");
6
6
  const standardErrors_1 = require("./standardErrors");
7
7
  const i18nKey = 'errors.apiErrors';
8
- function isSpecifiedError(err, { statusCode, category, subCategory, code, }) {
8
+ function isSpecifiedError(err, { statusCode, category, subCategory, errorType, code, }) {
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  const error = (err && err.cause) || err;
11
11
  const statusCodeErr = !statusCode || error.response?.status === statusCode;
12
12
  const categoryErr = !category || error.response?.data?.category === category;
13
13
  const subCategoryErr = !subCategory || error.response?.data?.subCategory === subCategory;
14
+ const errorTypeErr = !errorType || error.response?.data?.errorType === errorType;
14
15
  const codeError = !code || error.code === code;
15
16
  return (error.isAxiosError &&
16
17
  statusCodeErr &&
17
18
  categoryErr &&
18
19
  subCategoryErr &&
20
+ errorTypeErr &&
19
21
  codeError);
20
22
  }
21
23
  exports.isSpecifiedError = isSpecifiedError;
@@ -34,7 +36,7 @@ exports.isTimeoutError = isTimeoutError;
34
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
37
  function isApiUploadValidationError(err) {
36
38
  return (err.isAxiosError &&
37
- err.status === 400 &&
39
+ (err.status === 400 || err.response?.status === 400) &&
38
40
  !!err.response &&
39
41
  !!(err.response?.data?.message || !!err.response?.data?.errors));
40
42
  }
package/http/index.js CHANGED
@@ -12,7 +12,7 @@ const getAxiosConfig_1 = require("./getAxiosConfig");
12
12
  const personalAccessKey_1 = require("../lib/personalAccessKey");
13
13
  const oauth_1 = require("../lib/oauth");
14
14
  const standardErrors_1 = require("../errors/standardErrors");
15
- const logger_1 = require("../lib/logging/logger");
15
+ const logger_1 = require("../lib/logger");
16
16
  const lang_1 = require("../utils/lang");
17
17
  const i18nKey = 'http.index';
18
18
  async function withOauth(accountId, accountConfig, axiosConfig) {
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": {
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": {
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({
@@ -1,4 +1,4 @@
1
- import { DeveloperTestAccount } from '../types/developerTestAccounts';
1
+ import { DeveloperTestAccount, FetchDeveloperTestAccountsResponse } from '../types/developerTestAccounts';
2
2
  export declare function createDeveloperTestAccount(accountId: number, accountName: string): Promise<DeveloperTestAccount>;
3
3
  export declare function deleteDeveloperTestAccount(accountId: number, testAccountId: number): Promise<void>;
4
- export declare function fetchDeveloperTestAccounts(accountId: number): Promise<DeveloperTestAccount[]>;
4
+ export declare function fetchDeveloperTestAccounts(accountId: number): Promise<FetchDeveloperTestAccountsResponse>;
@@ -26,7 +26,7 @@ exports.deleteDeveloperTestAccount = deleteDeveloperTestAccount;
26
26
  async function fetchDeveloperTestAccounts(accountId) {
27
27
  try {
28
28
  const resp = await (0, developerTestAccounts_1.fetchDeveloperTestAccounts)(accountId);
29
- return resp.results;
29
+ return resp;
30
30
  }
31
31
  catch (err) {
32
32
  (0, apiErrors_1.throwApiError)(err);
@@ -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.12",
3
+ "version": "0.3.14",
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,4 +8,5 @@ export type DeveloperTestAccount = {
8
8
  };
9
9
  export type FetchDeveloperTestAccountsResponse = {
10
10
  results: DeveloperTestAccount[];
11
+ maxTestPortals: number;
11
12
  };
@@ -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