@hubspot/local-dev-lib 0.0.3 → 0.0.5

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 (143) hide show
  1. package/config/CLIConfiguration.d.ts +6 -6
  2. package/config/CLIConfiguration.js +11 -11
  3. package/config/configFile.js +1 -2
  4. package/constants/extensions.d.ts +1 -0
  5. package/constants/extensions.js +2 -1
  6. package/errors/fileSystemErrors.d.ts +7 -1
  7. package/errors/fileSystemErrors.js +1 -2
  8. package/errors/standardErrors.d.ts +14 -4
  9. package/errors/standardErrors.js +38 -34
  10. package/{src/http → http}/requestOptions.js +1 -1
  11. package/lang/en.lyaml +109 -0
  12. package/lang/lang/en.lyaml +109 -0
  13. package/lib/archive.js +2 -4
  14. package/lib/path.d.ts +0 -3
  15. package/lib/path.js +2 -19
  16. package/package.json +10 -9
  17. package/types/Config.d.ts +1 -1
  18. package/types/Error.d.ts +6 -13
  19. package/utils/git.d.ts +2 -1
  20. package/utils/git.js +4 -68
  21. package/utils/lang.d.ts +5 -0
  22. package/utils/lang.js +30 -5
  23. package/errors/cmsFieldsJsErrors.d.ts +0 -9
  24. package/errors/cmsFieldsJsErrors.js +0 -31
  25. package/index.d.ts +0 -2
  26. package/index.js +0 -5
  27. package/src/config/CLIConfiguration.d.ts +0 -55
  28. package/src/config/CLIConfiguration.js +0 -392
  29. package/src/config/configFile.d.ts +0 -21
  30. package/src/config/configFile.js +0 -109
  31. package/src/config/configUtils.d.ts +0 -24
  32. package/src/config/configUtils.js +0 -85
  33. package/src/config/environment.d.ts +0 -3
  34. package/src/config/environment.js +0 -64
  35. package/src/constants/auth.d.ts +0 -24
  36. package/src/constants/auth.js +0 -31
  37. package/src/constants/config.d.ts +0 -8
  38. package/src/constants/config.js +0 -12
  39. package/src/constants/environments.d.ts +0 -13
  40. package/src/constants/environments.js +0 -16
  41. package/src/constants/extensions.d.ts +0 -2
  42. package/src/constants/extensions.js +0 -23
  43. package/src/constants/index.d.ts +0 -16
  44. package/src/constants/index.js +0 -12
  45. package/src/errors/HubSpotAuthError.d.ts +0 -3
  46. package/src/errors/HubSpotAuthError.js +0 -6
  47. package/src/errors/cmsFieldsJsErrors.d.ts +0 -9
  48. package/src/errors/cmsFieldsJsErrors.js +0 -31
  49. package/src/errors/fileSystemErrors.d.ts +0 -8
  50. package/src/errors/fileSystemErrors.js +0 -28
  51. package/src/errors/standardErrors.d.ts +0 -19
  52. package/src/errors/standardErrors.js +0 -67
  53. package/src/index.d.ts +0 -2
  54. package/src/index.js +0 -5
  55. package/src/lib/archive.d.ts +0 -7
  56. package/src/lib/archive.js +0 -111
  57. package/src/lib/modules.d.ts +0 -28
  58. package/src/lib/modules.js +0 -174
  59. package/src/lib/path.d.ts +0 -10
  60. package/src/lib/path.js +0 -84
  61. package/src/types/Accounts.d.ts +0 -50
  62. package/src/types/Accounts.js +0 -2
  63. package/src/types/CLIOptions.d.ts +0 -3
  64. package/src/types/CLIOptions.js +0 -2
  65. package/src/types/Config.d.ts +0 -10
  66. package/src/types/Config.js +0 -2
  67. package/src/types/Error.d.ts +0 -31
  68. package/src/types/Error.js +0 -2
  69. package/src/types/LogCallbacks.d.ts +0 -6
  70. package/src/types/LogCallbacks.js +0 -2
  71. package/src/types/Utils.d.ts +0 -1
  72. package/src/types/Utils.js +0 -2
  73. package/src/utils/encoding.d.ts +0 -1
  74. package/src/utils/encoding.js +0 -11
  75. package/src/utils/environment.d.ts +0 -1
  76. package/src/utils/environment.js +0 -16
  77. package/src/utils/escapeRegExp.d.ts +0 -1
  78. package/src/utils/escapeRegExp.js +0 -7
  79. package/src/utils/files.d.ts +0 -3
  80. package/src/utils/files.js +0 -35
  81. package/src/utils/fs/read.d.ts +0 -4
  82. package/src/utils/fs/read.js +0 -55
  83. package/src/utils/fs/walk.d.ts +0 -2
  84. package/src/utils/fs/walk.js +0 -44
  85. package/src/utils/git.d.ts +0 -4
  86. package/src/utils/git.js +0 -40
  87. package/src/utils/handleFieldsJS.d.ts +0 -35
  88. package/src/utils/handleFieldsJS.js +0 -158
  89. package/src/utils/interpolation.d.ts +0 -5
  90. package/src/utils/interpolation.js +0 -31
  91. package/src/utils/lang.d.ts +0 -8
  92. package/src/utils/lang.js +0 -83
  93. package/src/utils/logger.d.ts +0 -10
  94. package/src/utils/logger.js +0 -22
  95. package/src/utils/text.d.ts +0 -1
  96. package/src/utils/text.js +0 -16
  97. package/src/utils/urls.d.ts +0 -2
  98. package/src/utils/urls.js +0 -20
  99. package/utils/encoding.d.ts +0 -1
  100. package/utils/encoding.js +0 -11
  101. package/utils/environment.d.ts +0 -1
  102. package/utils/environment.js +0 -16
  103. package/utils/interpolation.d.ts +0 -5
  104. package/utils/interpolation.js +0 -31
  105. package/utils/text.d.ts +0 -1
  106. package/utils/text.js +0 -16
  107. /package/{src/constants → constants}/files.d.ts +0 -0
  108. /package/{src/constants → constants}/files.js +0 -0
  109. /package/{src/constants → constants}/github.d.ts +0 -0
  110. /package/{src/constants → constants}/github.js +0 -0
  111. /package/{src/http → http}/requestOptions.d.ts +0 -0
  112. /package/{src/lib → lib}/cms/handleFieldsJS.d.ts +0 -0
  113. /package/{src/lib → lib}/cms/handleFieldsJS.js +0 -0
  114. /package/{src/lib → lib}/cms/index.d.ts +0 -0
  115. /package/{src/lib → lib}/cms/index.js +0 -0
  116. /package/{src/lib → lib}/cms/modules.d.ts +0 -0
  117. /package/{src/lib → lib}/cms/modules.js +0 -0
  118. /package/{src/lib → lib}/cms/themes.d.ts +0 -0
  119. /package/{src/lib → lib}/cms/themes.js +0 -0
  120. /package/{src/lib → lib}/environment.d.ts +0 -0
  121. /package/{src/lib → lib}/environment.js +0 -0
  122. /package/{src/lib → lib}/fs.d.ts +0 -0
  123. /package/{src/lib → lib}/fs.js +0 -0
  124. /package/{src/lib → lib}/github.d.ts +0 -0
  125. /package/{src/lib → lib}/github.js +0 -0
  126. /package/{src/lib → lib}/gitignore.d.ts +0 -0
  127. /package/{src/lib → lib}/gitignore.js +0 -0
  128. /package/{src/lib → lib}/index.d.ts +0 -0
  129. /package/{src/lib → lib}/index.js +0 -0
  130. /package/{src/lib → lib}/text.d.ts +0 -0
  131. /package/{src/lib → lib}/text.js +0 -0
  132. /package/{src/lib → lib}/urls.d.ts +0 -0
  133. /package/{src/lib → lib}/urls.js +0 -0
  134. /package/{src/types → types}/Files.d.ts +0 -0
  135. /package/{src/types → types}/Files.js +0 -0
  136. /package/{src/types → types}/Github.d.ts +0 -0
  137. /package/{src/types → types}/Github.js +0 -0
  138. /package/{src/types → types}/Modules.d.ts +0 -0
  139. /package/{src/types → types}/Modules.js +0 -0
  140. /package/{src/utils → utils}/fieldsJS.d.ts +0 -0
  141. /package/{src/utils → utils}/fieldsJS.js +0 -0
  142. /package/{src/utils → utils}/modules.d.ts +0 -0
  143. /package/{src/utils → utils}/modules.js +0 -0
@@ -4,13 +4,11 @@ import { CLIOptions } from '../types/CLIOptions';
4
4
  import { LogCallbacksArg } from '../types/LogCallbacks';
5
5
  declare const validateLogCallbackKeys: readonly ["noConfig", "noConfigAccounts", "emptyAccountConfig", "noAccountId", "duplicateAccountIds", "duplicateAccountNames", "nameContainsSpaces"];
6
6
  declare class CLIConfiguration {
7
- active: boolean;
8
7
  options: CLIOptions;
9
8
  useEnvConfig: boolean;
10
9
  config: CLIConfig | null;
11
- constructor(options: CLIOptions);
12
- setActive(isActive: boolean): void;
13
- init(options: CLIOptions): void;
10
+ constructor();
11
+ init(options?: CLIOptions): void;
14
12
  load(): CLIConfig | null;
15
13
  configIsEmpty(): boolean;
16
14
  delete(): void;
@@ -22,7 +20,8 @@ declare class CLIConfiguration {
22
20
  getResolvedDefaultAccountForCWD(nameOrId: string | number): CLIAccount | null;
23
21
  getConfigAccountIndex(accountId: number): number;
24
22
  isAccountInConfig(nameOrId: string | number): boolean;
25
- getEnv(nameOrId: string | number): string;
23
+ getAndLoadConfigIfNeeded(options?: CLIOptions): CLIConfig;
24
+ getEnv(nameOrId?: string | number): string;
26
25
  /**
27
26
  * @throws {Error}
28
27
  */
@@ -52,4 +51,5 @@ declare class CLIConfiguration {
52
51
  */
53
52
  updateAllowUsageTracking(isEnabled: boolean): CLIConfig | null;
54
53
  }
55
- export default CLIConfiguration;
54
+ declare const _default: CLIConfiguration;
55
+ export default _default;
@@ -4,7 +4,7 @@ const logger_1 = require("../utils/logger");
4
4
  const standardErrors_1 = require("../errors/standardErrors");
5
5
  const environment_1 = require("./environment");
6
6
  const configFile_1 = require("./configFile");
7
- const text_1 = require("../utils/text");
7
+ const text_1 = require("../lib/text");
8
8
  const constants_1 = require("../constants");
9
9
  const auth_1 = require("../constants/auth");
10
10
  const config_1 = require("../constants/config");
@@ -19,23 +19,17 @@ const validateLogCallbackKeys = [
19
19
  'nameContainsSpaces',
20
20
  ];
21
21
  class CLIConfiguration {
22
- active;
23
22
  options;
24
23
  useEnvConfig;
25
24
  config;
26
- constructor(options) {
27
- this.active = false;
28
- this.options = options || {};
25
+ constructor() {
26
+ this.options = {};
29
27
  this.useEnvConfig = false;
30
28
  this.config = null;
31
29
  }
32
- setActive(isActive) {
33
- this.active = isActive;
34
- }
35
- init(options) {
30
+ init(options = {}) {
36
31
  this.options = options;
37
32
  this.load();
38
- this.active = true;
39
33
  }
40
34
  load() {
41
35
  if (this.options.useEnv) {
@@ -192,6 +186,12 @@ class CLIConfiguration {
192
186
  isAccountInConfig(nameOrId) {
193
187
  return (!!this.config && this.config.accounts && !!this.getAccountId(nameOrId));
194
188
  }
189
+ getAndLoadConfigIfNeeded(options) {
190
+ if (!this.config) {
191
+ this.init(options);
192
+ }
193
+ return this.config;
194
+ }
195
195
  getEnv(nameOrId) {
196
196
  const accountConfig = this.getAccount(nameOrId);
197
197
  if (accountConfig && accountConfig.accountId && accountConfig.env) {
@@ -389,4 +389,4 @@ class CLIConfiguration {
389
389
  return this.write();
390
390
  }
391
391
  }
392
- exports.default = CLIConfiguration;
392
+ exports.default = new CLIConfiguration();
@@ -60,8 +60,7 @@ function parseConfig(configSource) {
60
60
  parsed = js_yaml_1.default.load(configSource);
61
61
  }
62
62
  catch (err) {
63
- (0, logger_1.debug)(`${i18nKey}.errorParsing`);
64
- (0, standardErrors_1.throwError)(err);
63
+ (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.parsing`, {}, err);
65
64
  }
66
65
  return parsed;
67
66
  }
@@ -1 +1,2 @@
1
1
  export declare const ALLOWED_EXTENSIONS: Set<string>;
2
+ export declare const MODULE_EXTENSION = "module";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ALLOWED_EXTENSIONS = void 0;
3
+ exports.MODULE_EXTENSION = exports.ALLOWED_EXTENSIONS = void 0;
4
4
  exports.ALLOWED_EXTENSIONS = new Set([
5
5
  'css',
6
6
  'js',
@@ -20,3 +20,4 @@ exports.ALLOWED_EXTENSIONS = new Set([
20
20
  'woff2',
21
21
  'graphql',
22
22
  ]);
23
+ exports.MODULE_EXTENSION = 'module';
@@ -1,2 +1,8 @@
1
- import { BaseError, FileSystemErrorContext } from '../types/Error';
1
+ import { BaseError } from '../types/Error';
2
+ type FileSystemErrorContext = {
3
+ filepath: string;
4
+ write?: boolean;
5
+ read?: boolean;
6
+ };
2
7
  export declare function throwFileSystemError(error: BaseError, context: FileSystemErrorContext): void;
8
+ export {};
@@ -5,7 +5,6 @@ const lang_1 = require("../utils/lang");
5
5
  const standardErrors_1 = require("./standardErrors");
6
6
  const i18nKey = 'errors.errorTypes.fileSystem';
7
7
  function throwFileSystemError(error, context) {
8
- (0, standardErrors_1.debugErrorAndContext)(error, context);
9
8
  let fileAction = '';
10
9
  if (context.read) {
11
10
  fileAction = (0, lang_1.i18n)(`${i18nKey}.readAction`);
@@ -24,6 +23,6 @@ function throwFileSystemError(error, context) {
24
23
  if ((0, standardErrors_1.isSystemError)(error)) {
25
24
  message.push((0, lang_1.i18n)(`${i18nKey}.baseMessage`, { errorMessage: error.message }));
26
25
  }
27
- throw new Error(message.join(' '));
26
+ throw new Error(message.join(' '), { cause: error });
28
27
  }
29
28
  exports.throwFileSystemError = throwFileSystemError;
@@ -1,9 +1,19 @@
1
- import { ErrorContext } from '../types/Error';
2
1
  import { BaseError } from '../types/Error';
3
2
  export declare function isSystemError(err: BaseError): boolean;
4
3
  export declare function isFatalError(err: BaseError): boolean;
5
- export declare function debugErrorAndContext(error: BaseError, context?: ErrorContext): void;
4
+ /**
5
+ * @throws
6
+ */
6
7
  export declare function throwErrorWithMessage(identifier: string, interpolation?: {
7
8
  [key: string]: string | number;
8
- }): never;
9
- export declare function throwError(error: BaseError, context?: ErrorContext): never;
9
+ }, cause?: BaseError): never;
10
+ /**
11
+ * @throws
12
+ */
13
+ export declare function throwTypeErrorWithMessage(identifier: string, interpolation?: {
14
+ [key: string]: string | number;
15
+ }, cause?: BaseError): never;
16
+ /**
17
+ * @throws
18
+ */
19
+ export declare function throwError(error: BaseError): never;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.throwError = exports.throwErrorWithMessage = exports.debugErrorAndContext = exports.isFatalError = exports.isSystemError = void 0;
3
+ exports.throwError = exports.throwTypeErrorWithMessage = exports.throwErrorWithMessage = exports.isFatalError = exports.isSystemError = void 0;
4
4
  const HubSpotAuthError_1 = require("./HubSpotAuthError");
5
- const logger_1 = require("../utils/logger");
6
5
  const lang_1 = require("../utils/lang");
7
6
  function isSystemError(err) {
8
7
  return err.errno != null && err.code != null && err.syscall != null;
@@ -12,52 +11,57 @@ function isFatalError(err) {
12
11
  return err instanceof HubSpotAuthError_1.HubSpotAuthError;
13
12
  }
14
13
  exports.isFatalError = isFatalError;
15
- function debugErrorAndContext(error, context) {
16
- if (error.name === 'StatusCodeError') {
17
- const { statusCode, message, response } = error;
18
- (0, logger_1.debug)('standardErrors.error', {
19
- error: JSON.stringify({
20
- statusCode,
21
- message,
22
- url: response.request.href,
23
- method: response.request.method,
24
- response: response.body,
25
- headers: response.headers,
26
- }),
27
- });
28
- }
29
- else {
30
- (0, logger_1.debug)('standardErrors.error', { error: JSON.stringify(error) });
14
+ /**
15
+ * @throws
16
+ */
17
+ function throwErrorWithMessage(identifier, interpolation, cause) {
18
+ const message = (0, lang_1.i18n)(`errors.${identifier}`, interpolation);
19
+ if (cause) {
20
+ throw new Error(message, { cause });
31
21
  }
32
- (0, logger_1.debug)('standardErrors.context', { context: JSON.stringify(context) });
33
- }
34
- exports.debugErrorAndContext = debugErrorAndContext;
35
- function throwErrorWithMessage(identifier, interpolation) {
36
- throw new Error((0, lang_1.i18n)(`errors.${identifier}`, interpolation));
22
+ throw new Error(message);
37
23
  }
38
24
  exports.throwErrorWithMessage = throwErrorWithMessage;
39
- function throwSystemError(error, context) {
40
- debugErrorAndContext(error, context);
41
- throwErrorWithMessage('errorTypes.standard.system', {
42
- message: error.message,
25
+ /**
26
+ * @throws
27
+ */
28
+ function throwTypeErrorWithMessage(identifier, interpolation, cause) {
29
+ const message = (0, lang_1.i18n)(`errors.${identifier}`, interpolation);
30
+ if (cause) {
31
+ throw new TypeError(message, { cause });
32
+ }
33
+ throw new TypeError(message);
34
+ }
35
+ exports.throwTypeErrorWithMessage = throwTypeErrorWithMessage;
36
+ function throwStatusCodeError(error) {
37
+ const { statusCode, message, response } = error;
38
+ const errorData = JSON.stringify({
39
+ statusCode,
40
+ message,
41
+ url: response.request.href,
42
+ method: response.request.method,
43
+ response: response.body,
44
+ headers: response.headers,
43
45
  });
46
+ throw new Error(errorData, { cause: error });
44
47
  }
45
- // formally logErrorInstance
46
- function throwError(error, context) {
47
- debugErrorAndContext(error, context);
48
- if (isSystemError(error)) {
49
- throwSystemError(error, context);
48
+ /**
49
+ * @throws
50
+ */
51
+ function throwError(error) {
52
+ if (error.name === 'StatusCodeError') {
53
+ throwStatusCodeError(error);
50
54
  }
51
55
  else {
52
56
  // Error or Error subclass
53
57
  const name = error.name || 'Error';
54
- const message = [(0, lang_1.i18n)('errors.errorTypes.standard.generic', { name })];
58
+ const message = [(0, lang_1.i18n)('errors.errorTypes.generic', { name })];
55
59
  [error.message, error.reason].forEach(msg => {
56
60
  if (msg) {
57
61
  message.push(msg);
58
62
  }
59
63
  });
60
- throw new Error(message.join(' '));
64
+ throw new Error(message.join(' '), { cause: error });
61
65
  }
62
66
  }
63
67
  exports.throwError = throwError;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getRequestOptions = exports.DEFAULT_USER_AGENT_HEADERS = void 0;
7
- const package_json_1 = require("../../package.json");
7
+ const package_json_1 = require("../package.json");
8
8
  const CLIConfiguration_1 = __importDefault(require("../config/CLIConfiguration"));
9
9
  const urls_1 = require("../lib/urls");
10
10
  exports.DEFAULT_USER_AGENT_HEADERS = {
package/lang/en.lyaml ADDED
@@ -0,0 +1,109 @@
1
+ en:
2
+ debug:
3
+ archive:
4
+ extractZip:
5
+ init: "Extracting project source..."
6
+ success: "Completed project source extraction."
7
+ copySourceToDest:
8
+ init: "Copying project source..."
9
+ sourceEmpty: "Project source is empty"
10
+ success: "Completed copying project source."
11
+ error: An error occured copying project source to {{ dest }}.
12
+ cleanupTempDir:
13
+ error: "Failed to clean up temp dir: {{ tmpDir }}"
14
+ github:
15
+ fetchJsonFromRepository: "Fetching {{ uri }}..."
16
+ downloadGithubRepoZip:
17
+ fetching: "Fetching {{ releaseType }} with name {{ repoName }}..."
18
+ fetchingName: "Fetching {{ name }}..."
19
+ completed: "Completed project fetch."
20
+ cloneGithubRepo:
21
+ success: "Your new {{ type }} has been created in {{ dest }}"
22
+ downloadGithubRepoContents:
23
+ downloading: "Downloading content piece: {{ contentPiecePath }} from {{ downloadUrl }} to {{ downloadPath }}"
24
+ modules:
25
+ createModule:
26
+ creatingModule: "Creating module at {{ path }}"
27
+ creatingPath: "Creating {{ path }}"
28
+ config:
29
+ cliConfiguration:
30
+ load:
31
+ configFromEnv: "Loaded config from environment variables for {{ accountId }}"
32
+ configFromFile: "Loaded config from configuration file."
33
+ empty: "The config file was empty. Initializing an empty config."
34
+ validate:
35
+ noConfig: "Valiation failed: No config was found."
36
+ noConfigAccounts: "Valiation failed: config.accounts[] is not defined."
37
+ emptyAccountConfig: "Valiation failed: config.accounts[] has an empty entry."
38
+ noAccountId: "Valiation failed: config.accounts[] has an entry missing accountId."
39
+ duplicateAccountIds: "Valiation failed: config.accounts[] has multiple entries with {{ accountId }}."
40
+ duplicateAccountNames: "Valiation failed: config.accounts[] has multiple entries with {{ accountName }}."
41
+ nameContainsSpaces: "Valiation failed: config.name {{ accountName }} cannot contain spaces."
42
+ updateAccount:
43
+ noConfigToUpdate: "No config to update."
44
+ updating: "Updating account config for {{ accountId }}"
45
+ addingConfigEntry: "Adding account config entry for {{ accountId }}"
46
+ removeAccountFromConfig: "Deleting config for {{ accountId }}"
47
+ configFile:
48
+ errorReading: "Config file could not be read: {{ configPath }}"
49
+ writeSuccess: "Successfully wrote updated config data to {{ configPath }}"
50
+ errorLoading: "A configuration file could not be found at {{ configPath }}."
51
+ configUtils:
52
+ unknownType: "Unknown auth type {{ type }}"
53
+ environment:
54
+ loadConfig:
55
+ missingAccountId: "Unable to load config from environment variables: Missing accountId"
56
+ missingEnv: "Unable to load config from environment variables: Missing env"
57
+ unknownAuthType: "Unable to load config from environment variables: Unknown auth type"
58
+ utils:
59
+ handleFieldsJs:
60
+ convertFieldsJs:
61
+ creating: "Creating child process with pid {{ pid }}"
62
+ terminating: "Child process with pid {{ pid }} has been terminated"
63
+ errors:
64
+ archive:
65
+ extractZip:
66
+ write: "An error occured writing temp project source."
67
+ extract: "An error occured extracting project source."
68
+ errorTypes:
69
+ fileSystem:
70
+ readAction: "reading from"
71
+ writeAction: "writing to"
72
+ otherAction: "accessing"
73
+ unknownFilepath: "a file or folder"
74
+ baseMessage: "An error occurred while {{ fileAction }} {{ filepath }}."
75
+ systemErrorMessage: "This is the result of a system error: {{ errorMessage }}"
76
+ cmsFields:
77
+ syntax: 'There was an error converting JS file "{{ path }}"'
78
+ notFunction: 'There was an error loading JS file "{{ path }}". Expected type "Function" but received type "{{ returned }}". Make sure that your default export is a function.'
79
+ notReturnArray: 'There was an error loading JS file "{{ path }}". Expected type "Array" but received type "{{ returned }}" . Make sure that your function returns an array'
80
+ invalidPath: 'The path "{{ path }}" is not a path to a file or folder'
81
+ generic: "A {{ name }} has occurred"
82
+ github:
83
+ downloadGithubRepoContents: "Failed to fetch contents: {{ errorMessage }}"
84
+ fetchJsonFromRepository: "An error occured fetching JSON file."
85
+ fetchReleaseData: "Failed fetching release data for {{ tag }} project."
86
+ downloadGithubRepoZip: "An error occured fetching the project source."
87
+ modules:
88
+ throwInvalidPathInput: "Expected PathInput"
89
+ writeModuleMeta: "The {{ path }} path already exists"
90
+ utils:
91
+ git:
92
+ configIgnore: "Unable to determine if config file is properly ignored by git."
93
+ handleFieldsJs:
94
+ convertFieldsJs: "There was an error converting '{{ filePath }}'"
95
+ saveOutput: "There was an error saving the json output of {{ path }}"
96
+ createTmpDirSync: "An error occured writing temporary project source."
97
+ cleanupTmpDirSync: "There was an error deleting the temporary project source"
98
+ config:
99
+ cliConfiguration:
100
+ noConfigLoaded: "No Config loaded."
101
+ updateAccount: "An accountId is required to update the config"
102
+ updateDefaultAccount: "A 'defaultAccount' with value of number or string is required to update the config."
103
+ renameAccount: "Cannot find account with identifier {{ currentName }}"
104
+ removeAccountFromConfig: "Unable to find account for {{ nameOrId }}."
105
+ updateDefaultMode: "The mode {{ defaultMode }} is invalid. Valid values are {{ validModes }}."
106
+ updateHttpTimeout: The value {{ timeout }} is invalid. The value must be a number greater than {{ minTimeout }}.
107
+ updateAllowUsageTracking: Unable to update allowUsageTracking. The value {{ isEnabled }} is invalid. The value must be a boolean.
108
+ configFile:
109
+ parsing: "Config file could not be parsed"
@@ -0,0 +1,109 @@
1
+ en:
2
+ debug:
3
+ archive:
4
+ extractZip:
5
+ init: "Extracting project source..."
6
+ success: "Completed project source extraction."
7
+ copySourceToDest:
8
+ init: "Copying project source..."
9
+ sourceEmpty: "Project source is empty"
10
+ success: "Completed copying project source."
11
+ error: An error occured copying project source to {{ dest }}.
12
+ cleanupTempDir:
13
+ error: "Failed to clean up temp dir: {{ tmpDir }}"
14
+ github:
15
+ fetchJsonFromRepository: "Fetching {{ uri }}..."
16
+ downloadGithubRepoZip:
17
+ fetching: "Fetching {{ releaseType }} with name {{ repoName }}..."
18
+ fetchingName: "Fetching {{ name }}..."
19
+ completed: "Completed project fetch."
20
+ cloneGithubRepo:
21
+ success: "Your new {{ type }} has been created in {{ dest }}"
22
+ downloadGithubRepoContents:
23
+ downloading: "Downloading content piece: {{ contentPiecePath }} from {{ downloadUrl }} to {{ downloadPath }}"
24
+ modules:
25
+ createModule:
26
+ creatingModule: "Creating module at {{ path }}"
27
+ creatingPath: "Creating {{ path }}"
28
+ config:
29
+ cliConfiguration:
30
+ load:
31
+ configFromEnv: "Loaded config from environment variables for {{ accountId }}"
32
+ configFromFile: "Loaded config from configuration file."
33
+ empty: "The config file was empty. Initializing an empty config."
34
+ validate:
35
+ noConfig: "Valiation failed: No config was found."
36
+ noConfigAccounts: "Valiation failed: config.accounts[] is not defined."
37
+ emptyAccountConfig: "Valiation failed: config.accounts[] has an empty entry."
38
+ noAccountId: "Valiation failed: config.accounts[] has an entry missing accountId."
39
+ duplicateAccountIds: "Valiation failed: config.accounts[] has multiple entries with {{ accountId }}."
40
+ duplicateAccountNames: "Valiation failed: config.accounts[] has multiple entries with {{ accountName }}."
41
+ nameContainsSpaces: "Valiation failed: config.name {{ accountName }} cannot contain spaces."
42
+ updateAccount:
43
+ noConfigToUpdate: "No config to update."
44
+ updating: "Updating account config for {{ accountId }}"
45
+ addingConfigEntry: "Adding account config entry for {{ accountId }}"
46
+ removeAccountFromConfig: "Deleting config for {{ accountId }}"
47
+ configFile:
48
+ errorReading: "Config file could not be read: {{ configPath }}"
49
+ writeSuccess: "Successfully wrote updated config data to {{ configPath }}"
50
+ errorLoading: "A configuration file could not be found at {{ configPath }}."
51
+ configUtils:
52
+ unknownType: "Unknown auth type {{ type }}"
53
+ environment:
54
+ loadConfig:
55
+ missingAccountId: "Unable to load config from environment variables: Missing accountId"
56
+ missingEnv: "Unable to load config from environment variables: Missing env"
57
+ unknownAuthType: "Unable to load config from environment variables: Unknown auth type"
58
+ utils:
59
+ handleFieldsJs:
60
+ convertFieldsJs:
61
+ creating: "Creating child process with pid {{ pid }}"
62
+ terminating: "Child process with pid {{ pid }} has been terminated"
63
+ errors:
64
+ archive:
65
+ extractZip:
66
+ write: "An error occured writing temp project source."
67
+ extract: "An error occured extracting project source."
68
+ errorTypes:
69
+ fileSystem:
70
+ readAction: "reading from"
71
+ writeAction: "writing to"
72
+ otherAction: "accessing"
73
+ unknownFilepath: "a file or folder"
74
+ baseMessage: "An error occurred while {{ fileAction }} {{ filepath }}."
75
+ systemErrorMessage: "This is the result of a system error: {{ errorMessage }}"
76
+ cmsFields:
77
+ syntax: 'There was an error converting JS file "{{ path }}"'
78
+ notFunction: 'There was an error loading JS file "{{ path }}". Expected type "Function" but received type "{{ returned }}". Make sure that your default export is a function.'
79
+ notReturnArray: 'There was an error loading JS file "{{ path }}". Expected type "Array" but received type "{{ returned }}" . Make sure that your function returns an array'
80
+ invalidPath: 'The path "{{ path }}" is not a path to a file or folder'
81
+ generic: "A {{ name }} has occurred"
82
+ github:
83
+ downloadGithubRepoContents: "Failed to fetch contents: {{ errorMessage }}"
84
+ fetchJsonFromRepository: "An error occured fetching JSON file."
85
+ fetchReleaseData: "Failed fetching release data for {{ tag }} project."
86
+ downloadGithubRepoZip: "An error occured fetching the project source."
87
+ modules:
88
+ throwInvalidPathInput: "Expected PathInput"
89
+ writeModuleMeta: "The {{ path }} path already exists"
90
+ utils:
91
+ git:
92
+ configIgnore: "Unable to determine if config file is properly ignored by git."
93
+ handleFieldsJs:
94
+ convertFieldsJs: "There was an error converting '{{ filePath }}'"
95
+ saveOutput: "There was an error saving the json output of {{ path }}"
96
+ createTmpDirSync: "An error occured writing temporary project source."
97
+ cleanupTmpDirSync: "There was an error deleting the temporary project source"
98
+ config:
99
+ cliConfiguration:
100
+ noConfigLoaded: "No Config loaded."
101
+ updateAccount: "An accountId is required to update the config"
102
+ updateDefaultAccount: "A 'defaultAccount' with value of number or string is required to update the config."
103
+ renameAccount: "Cannot find account with identifier {{ currentName }}"
104
+ removeAccountFromConfig: "Unable to find account for {{ nameOrId }}."
105
+ updateDefaultMode: "The mode {{ defaultMode }} is invalid. Valid values are {{ validModes }}."
106
+ updateHttpTimeout: The value {{ timeout }} is invalid. The value must be a number greater than {{ minTimeout }}.
107
+ updateAllowUsageTracking: Unable to update allowUsageTracking. The value {{ isEnabled }} is invalid. The value must be a boolean.
108
+ configFile:
109
+ parsing: "Config file could not be parsed"
package/lib/archive.js CHANGED
@@ -28,7 +28,6 @@ async function extractZip(name, zip) {
28
28
  });
29
29
  }
30
30
  catch (err) {
31
- (0, logger_1.debug)('archive.extractZip.writeError');
32
31
  if (tmpZipPath || result.tmpDir) {
33
32
  (0, fileSystemErrors_1.throwFileSystemError)(err, {
34
33
  filepath: tmpZipPath || result.tmpDir,
@@ -36,7 +35,7 @@ async function extractZip(name, zip) {
36
35
  });
37
36
  }
38
37
  else {
39
- (0, standardErrors_1.throwError)(err);
38
+ (0, standardErrors_1.throwErrorWithMessage)('archive.extractZip.write', {}, err);
40
39
  }
41
40
  return result;
42
41
  }
@@ -47,8 +46,7 @@ async function extractZip(name, zip) {
47
46
  result.extractDir = tmpExtractPath;
48
47
  }
49
48
  catch (err) {
50
- (0, logger_1.debug)('archive.extractZip.extractError');
51
- (0, standardErrors_1.throwError)(err);
49
+ (0, standardErrors_1.throwErrorWithMessage)('archive.extractZip.extract', {}, err);
52
50
  }
53
51
  (0, logger_1.debug)('archive.extractZip.success');
54
52
  return result;
package/lib/path.d.ts CHANGED
@@ -1,13 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import path from 'path';
3
3
  export declare function convertToUnixPath(_path: string): string;
4
- export declare function convertToImportPath(_path: string): string;
5
4
  export declare function convertToLocalFileSystemPath(_path: string): string;
6
5
  export declare function splitLocalPath(filepath: string, pathImplementation?: path.PlatformPath): Array<string>;
7
6
  export declare function splitHubSpotPath(filepath: string): Array<string>;
8
7
  export declare function getCwd(): string;
9
8
  export declare function getExt(filepath: string): string;
10
- export declare const getAllowedExtensions: () => Set<string>;
11
9
  export declare function isAllowedExtension(filepath: string): boolean;
12
10
  export declare function getAbsoluteFilePath(_path: string): string;
13
- export declare function isRelativePath(_path: string): boolean;
package/lib/path.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.isRelativePath = exports.getAbsoluteFilePath = exports.isAllowedExtension = exports.getAllowedExtensions = exports.getExt = exports.getCwd = exports.splitHubSpotPath = exports.splitLocalPath = exports.convertToLocalFileSystemPath = exports.convertToImportPath = exports.convertToUnixPath = void 0;
6
+ exports.getAbsoluteFilePath = exports.isAllowedExtension = exports.getExt = exports.getCwd = exports.splitHubSpotPath = exports.splitLocalPath = exports.convertToLocalFileSystemPath = exports.convertToUnixPath = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const unixify_1 = __importDefault(require("unixify"));
9
9
  const extensions_1 = require("../constants/extensions");
@@ -15,14 +15,6 @@ function convertToWindowsPath(_path) {
15
15
  const rgx = new RegExp(`\\${path_1.default.posix.sep}`, 'g');
16
16
  return path_1.default.normalize(_path).replace(rgx, path_1.default.win32.sep);
17
17
  }
18
- // Converts a Win32 path to Posix, retaining the drive letter (ex. 'c:')
19
- function convertToImportPath(_path) {
20
- if (path_1.default.sep === path_1.default.win32.sep) {
21
- return _path.split(path_1.default.win32.sep).join(path_1.default.posix.sep);
22
- }
23
- return _path;
24
- }
25
- exports.convertToImportPath = convertToImportPath;
26
18
  function convertToLocalFileSystemPath(_path) {
27
19
  switch (path_1.default.sep) {
28
20
  case path_1.default.posix.sep:
@@ -81,21 +73,12 @@ function getExt(filepath) {
81
73
  return ext[0] === '.' ? ext.slice(1) : ext;
82
74
  }
83
75
  exports.getExt = getExt;
84
- const getAllowedExtensions = () => {
85
- return extensions_1.ALLOWED_EXTENSIONS;
86
- };
87
- exports.getAllowedExtensions = getAllowedExtensions;
88
76
  function isAllowedExtension(filepath) {
89
77
  const ext = getExt(filepath);
90
- const allowedExtensions = (0, exports.getAllowedExtensions)();
91
- return allowedExtensions.has(ext);
78
+ return extensions_1.ALLOWED_EXTENSIONS.has(ext);
92
79
  }
93
80
  exports.isAllowedExtension = isAllowedExtension;
94
81
  function getAbsoluteFilePath(_path) {
95
82
  return path_1.default.resolve(getCwd(), _path);
96
83
  }
97
84
  exports.getAbsoluteFilePath = getAbsoluteFilePath;
98
- function isRelativePath(_path) {
99
- return !path_1.default.isAbsolute(_path);
100
- }
101
- exports.isRelativePath = isRelativePath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -12,14 +12,15 @@
12
12
  "access": "public"
13
13
  },
14
14
  "scripts": {
15
- "build": "tsc --rootDir . --outdir dist",
15
+ "build": "tsc --rootDir . --outdir dist && yarn copy-files",
16
16
  "check-main": "branch=$(git rev-parse --abbrev-ref HEAD) && [ $branch = main ] || (echo 'Error: New release can only be published on main branch' && exit 1)",
17
- "lint": "eslint --max-warnings=0 . && prettier --check src/**/*.ts",
17
+ "copy-files": "cp -r lang dist/lang",
18
+ "lint": "eslint --max-warnings=0 . && prettier --check ./**/*.ts",
18
19
  "local-dev": "yarn build && cd dist && yarn link && cd .. && tsc --watch --rootDir . --outdir dist",
19
20
  "_postinstall": "husky install",
20
21
  "prepack": "pinst --disable",
21
22
  "postpack": "pinst --enable",
22
- "prettier:write": "prettier --write src/**/*.{js,json}",
23
+ "prettier:write": "prettier --write ./**/*.{js,json}",
23
24
  "pub": "cd dist && npm publish --tag latest && cd ..",
24
25
  "push": "git push --atomic origin main v$npm_package_version",
25
26
  "release:major": "yarn check-main && yarn version --major && yarn build && yarn pub && yarn push",
@@ -46,11 +47,11 @@
46
47
  "typescript": "^4.9.5"
47
48
  },
48
49
  "exports": {
49
- ".": "./dist/lib/index.js",
50
- "./cms": "./dist/lib/cms",
51
- "./constants": "./dist/constants.js",
52
- "./github": "./dist/lib/github.js",
53
- "./path": "./dist/lib/path.js"
50
+ ".": "./lib/index.js",
51
+ "./cms": "./lib/cms",
52
+ "./constants": "./constants",
53
+ "./github": "./lib/github.js",
54
+ "./path": "./lib/path.js"
54
55
  },
55
56
  "dependencies": {
56
57
  "axios": "^1.3.5",
package/types/Config.d.ts CHANGED
@@ -6,5 +6,5 @@ export interface CLIConfig {
6
6
  defaultMode?: string;
7
7
  httpTimeout?: number;
8
8
  env?: string;
9
- test: number;
9
+ httpUseLocalhost?: boolean;
10
10
  }