@hubspot/local-dev-lib 4.0.4 → 5.0.0-beta.1

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 (205) hide show
  1. package/api/appsDev.d.ts +2 -2
  2. package/api/appsDev.js +13 -22
  3. package/api/crm.d.ts +2 -2
  4. package/api/crm.js +9 -16
  5. package/api/customObjects.d.ts +2 -2
  6. package/api/customObjects.js +13 -22
  7. package/api/designManager.d.ts +2 -2
  8. package/api/designManager.js +5 -10
  9. package/api/devSecrets.d.ts +2 -2
  10. package/api/devSecrets.js +9 -16
  11. package/api/developerTestAccounts.d.ts +2 -4
  12. package/api/developerTestAccounts.js +23 -52
  13. package/api/fileManager.d.ts +2 -2
  14. package/api/fileManager.js +14 -24
  15. package/api/fileMapper.d.ts +2 -3
  16. package/api/fileMapper.js +34 -49
  17. package/api/fileTransport.d.ts +1 -1
  18. package/api/fileTransport.js +12 -21
  19. package/api/fireAlarm.d.ts +2 -3
  20. package/api/fireAlarm.js +5 -9
  21. package/api/functions.d.ts +2 -2
  22. package/api/functions.js +11 -19
  23. package/api/github.d.ts +2 -4
  24. package/api/github.js +16 -27
  25. package/api/hubdb.d.ts +2 -2
  26. package/api/hubdb.js +19 -31
  27. package/api/lighthouseScore.d.ts +2 -2
  28. package/api/lighthouseScore.js +7 -13
  29. package/api/localDevAuth.d.ts +3 -6
  30. package/api/localDevAuth.js +10 -37
  31. package/api/marketplaceValidation.d.ts +2 -2
  32. package/api/marketplaceValidation.js +7 -13
  33. package/api/projects.d.ts +6 -8
  34. package/api/projects.js +65 -100
  35. package/api/sandboxHubs.d.ts +2 -5
  36. package/api/sandboxHubs.js +15 -42
  37. package/api/sandboxSync.d.ts +2 -2
  38. package/api/sandboxSync.js +7 -12
  39. package/api/secrets.d.ts +2 -2
  40. package/api/secrets.js +9 -16
  41. package/api/validateHubl.d.ts +2 -2
  42. package/api/validateHubl.js +3 -7
  43. package/config/defaultAccountOverride.d.ts +2 -1
  44. package/config/defaultAccountOverride.js +16 -26
  45. package/config/index.d.ts +4 -4
  46. package/config/index.js +141 -177
  47. package/config/migrate.d.ts +2 -2
  48. package/config/migrate.js +26 -37
  49. package/config/state.d.ts +1 -1
  50. package/config/state.js +17 -45
  51. package/config/utils.d.ts +4 -4
  52. package/config/utils.js +85 -108
  53. package/constants/api.js +3 -6
  54. package/constants/auth.js +9 -12
  55. package/constants/config.js +37 -43
  56. package/constants/endpoints.d.ts +6 -0
  57. package/constants/endpoints.js +6 -0
  58. package/constants/environments.js +1 -4
  59. package/constants/extensions.js +6 -9
  60. package/constants/files.js +5 -8
  61. package/constants/ports.js +3 -6
  62. package/constants/projects.js +2 -5
  63. package/enums/build.d.ts +1 -0
  64. package/enums/build.js +6 -8
  65. package/enums/deploy.js +2 -5
  66. package/enums/project.js +1 -4
  67. package/errors/index.d.ts +4 -5
  68. package/errors/index.js +17 -39
  69. package/errors/isSystemError.d.ts +2 -0
  70. package/errors/isSystemError.js +9 -0
  71. package/http/addQueryParams.d.ts +1 -1
  72. package/http/addQueryParams.js +1 -5
  73. package/http/client.js +14 -42
  74. package/http/getAxiosConfig.d.ts +1 -1
  75. package/http/getAxiosConfig.js +21 -31
  76. package/http/index.d.ts +2 -2
  77. package/http/index.js +39 -46
  78. package/http/unauthed.d.ts +1 -1
  79. package/http/unauthed.js +15 -18
  80. package/lang/en.json +1 -1
  81. package/lib/archive.d.ts +1 -3
  82. package/lib/archive.js +37 -67
  83. package/lib/cms/functions.d.ts +1 -1
  84. package/lib/cms/functions.js +45 -55
  85. package/lib/cms/handleFieldsJS.js +36 -44
  86. package/lib/cms/modules.d.ts +2 -2
  87. package/lib/cms/modules.js +49 -59
  88. package/lib/cms/processFieldsJs.js +17 -32
  89. package/lib/cms/templates.js +17 -26
  90. package/lib/cms/themes.js +10 -18
  91. package/lib/cms/uploadFolder.d.ts +4 -4
  92. package/lib/cms/uploadFolder.js +55 -64
  93. package/lib/cms/validate.d.ts +1 -1
  94. package/lib/cms/validate.js +11 -18
  95. package/lib/cms/watch.d.ts +2 -2
  96. package/lib/cms/watch.js +66 -73
  97. package/lib/crm.d.ts +1 -1
  98. package/lib/crm.js +15 -23
  99. package/lib/customObjects.d.ts +1 -1
  100. package/lib/customObjects.js +15 -25
  101. package/lib/environment.d.ts +1 -1
  102. package/lib/environment.js +5 -11
  103. package/lib/escapeRegExp.js +1 -5
  104. package/lib/fileManager.js +43 -51
  105. package/lib/fileMapper.d.ts +1 -1
  106. package/lib/fileMapper.js +68 -84
  107. package/lib/fs.d.ts +1 -1
  108. package/lib/fs.js +18 -27
  109. package/lib/github.d.ts +1 -3
  110. package/lib/github.js +39 -51
  111. package/lib/gitignore.d.ts +1 -1
  112. package/lib/gitignore.js +16 -24
  113. package/lib/hubdb.d.ts +1 -1
  114. package/lib/hubdb.js +29 -40
  115. package/lib/ignoreRules.js +25 -34
  116. package/lib/isDeepEqual.js +1 -5
  117. package/lib/logger.d.ts +8 -20
  118. package/lib/logger.js +47 -59
  119. package/lib/notify.js +9 -16
  120. package/lib/oauth.d.ts +2 -2
  121. package/lib/oauth.js +12 -17
  122. package/lib/path.d.ts +0 -1
  123. package/lib/path.js +30 -48
  124. package/lib/personalAccessKey.d.ts +2 -4
  125. package/lib/personalAccessKey.js +43 -60
  126. package/lib/portManager.d.ts +2 -2
  127. package/lib/portManager.js +26 -41
  128. package/lib/text.js +2 -7
  129. package/lib/trackUsage.d.ts +0 -2
  130. package/lib/trackUsage.js +23 -29
  131. package/lib/urls.js +4 -9
  132. package/models/FileSystemError.d.ts +1 -1
  133. package/models/FileSystemError.js +12 -16
  134. package/models/HubSpotConfigError.d.ts +1 -1
  135. package/models/HubSpotConfigError.js +8 -12
  136. package/models/HubSpotHttpError.d.ts +1 -1
  137. package/models/HubSpotHttpError.js +22 -26
  138. package/models/OAuth2Manager.d.ts +1 -1
  139. package/models/OAuth2Manager.js +17 -24
  140. package/package.json +20 -16
  141. package/types/Accounts.d.ts +6 -5
  142. package/types/Accounts.js +1 -2
  143. package/types/Activity.d.ts +3 -3
  144. package/types/Activity.js +1 -2
  145. package/types/Api.d.ts +1 -1
  146. package/types/Api.js +1 -2
  147. package/types/Apps.js +1 -2
  148. package/types/Archive.js +1 -2
  149. package/types/Build.d.ts +4 -5
  150. package/types/Build.js +1 -2
  151. package/types/CLIOptions.js +1 -2
  152. package/types/ComponentStructure.d.ts +2 -2
  153. package/types/ComponentStructure.js +1 -2
  154. package/types/Config.d.ts +4 -6
  155. package/types/Config.js +1 -2
  156. package/types/Crm.js +1 -2
  157. package/types/Deploy.d.ts +5 -11
  158. package/types/Deploy.js +1 -2
  159. package/types/DesignManager.js +1 -2
  160. package/types/DevSecrets.js +1 -2
  161. package/types/Error.js +1 -2
  162. package/types/FieldsJS.js +1 -2
  163. package/types/FileManager.js +1 -2
  164. package/types/Files.d.ts +4 -4
  165. package/types/Files.js +1 -2
  166. package/types/FireAlarm.js +1 -2
  167. package/types/Functions.js +1 -2
  168. package/types/Github.d.ts +1 -1
  169. package/types/Github.js +1 -2
  170. package/types/Http.d.ts +0 -4
  171. package/types/Http.js +1 -2
  172. package/types/Hubdb.js +1 -2
  173. package/types/HublValidation.js +1 -2
  174. package/types/Lang.d.ts +1 -1
  175. package/types/Lang.js +1 -2
  176. package/types/Lighthouse.js +1 -2
  177. package/types/MarketplaceValidation.js +1 -2
  178. package/types/Migration.d.ts +2 -2
  179. package/types/Migration.js +1 -4
  180. package/types/Modules.js +1 -2
  181. package/types/PortManager.js +1 -2
  182. package/types/Project.d.ts +3 -21
  183. package/types/Project.js +1 -2
  184. package/types/ProjectComponents.d.ts +24 -0
  185. package/types/ProjectComponents.js +1 -0
  186. package/types/ProjectLog.js +1 -2
  187. package/types/Sandbox.js +2 -5
  188. package/types/Schemas.js +1 -2
  189. package/types/Secrets.js +1 -2
  190. package/types/Utils.js +1 -2
  191. package/types/developerTestAccounts.js +1 -2
  192. package/utils/PortManagerServer.d.ts +1 -2
  193. package/utils/PortManagerServer.js +32 -38
  194. package/utils/cms/fieldsJS.d.ts +1 -1
  195. package/utils/cms/fieldsJS.js +1 -5
  196. package/utils/cms/modules.d.ts +1 -1
  197. package/utils/cms/modules.js +13 -22
  198. package/utils/detectPort.js +12 -19
  199. package/utils/git.js +17 -26
  200. package/utils/lang.d.ts +1 -1
  201. package/utils/lang.js +5 -14
  202. package/utils/personalAccessKey.d.ts +8 -0
  203. package/utils/personalAccessKey.js +51 -0
  204. package/errors/errors_DEPRECATED.d.ts +0 -3
  205. package/errors/errors_DEPRECATED.js +0 -60
package/lib/logger.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Chalk } from 'chalk';
1
+ import { type ChalkInstance } from 'chalk';
2
2
  export declare const LOG_LEVEL: {
3
3
  NONE: number;
4
4
  DEBUG: number;
@@ -10,26 +10,14 @@ export declare const LOG_LEVEL: {
10
10
  * Chalk styles for logger strings.
11
11
  */
12
12
  export declare const Styles: {
13
- debug: Chalk & {
14
- supportsColor: import("chalk").ColorSupport;
15
- };
16
- log: Chalk & {
17
- supportsColor: import("chalk").ColorSupport;
18
- };
19
- success: Chalk & {
20
- supportsColor: import("chalk").ColorSupport;
21
- };
22
- info: Chalk & {
23
- supportsColor: import("chalk").ColorSupport;
24
- };
25
- warn: Chalk & {
26
- supportsColor: import("chalk").ColorSupport;
27
- };
28
- error: Chalk & {
29
- supportsColor: import("chalk").ColorSupport;
30
- };
13
+ debug: ChalkInstance;
14
+ log: ChalkInstance;
15
+ success: ChalkInstance;
16
+ info: ChalkInstance;
17
+ warn: ChalkInstance;
18
+ error: ChalkInstance;
31
19
  };
32
- export declare function stylize(label: string, style: Chalk, args: any[]): any[];
20
+ export declare function stylize(label: string, style: ChalkInstance, args: any[]): any[];
33
21
  export declare class Logger {
34
22
  error(...args: any[]): void;
35
23
  warn(...args: any[]): void;
package/lib/logger.js CHANGED
@@ -1,12 +1,6 @@
1
- "use strict";
2
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.logger = exports.getLogLevel = exports.shouldLog = exports.setLogLevel = exports.setLogger = exports.Logger = exports.stylize = exports.Styles = exports.LOG_LEVEL = void 0;
8
- const chalk_1 = __importDefault(require("chalk"));
9
- exports.LOG_LEVEL = {
2
+ import chalk from 'chalk';
3
+ export const LOG_LEVEL = {
10
4
  NONE: 0,
11
5
  DEBUG: 1,
12
6
  LOG: 2,
@@ -16,15 +10,15 @@ exports.LOG_LEVEL = {
16
10
  /**
17
11
  * Chalk styles for logger strings.
18
12
  */
19
- exports.Styles = {
20
- debug: chalk_1.default.reset.blue,
21
- log: chalk_1.default.reset,
22
- success: chalk_1.default.reset.green,
23
- info: chalk_1.default.reset.white,
24
- warn: chalk_1.default.reset.yellow,
25
- error: chalk_1.default.reset.red,
13
+ export const Styles = {
14
+ debug: chalk.reset.blue,
15
+ log: chalk.reset.white,
16
+ success: chalk.reset.green,
17
+ info: chalk.reset.white,
18
+ warn: chalk.reset.yellow,
19
+ error: chalk.reset.red,
26
20
  };
27
- function stylize(label, style, args) {
21
+ export function stylize(label, style, args) {
28
22
  const styledLabel = style(label);
29
23
  const [firstArg, ...rest] = args;
30
24
  if (typeof firstArg === 'string') {
@@ -32,25 +26,24 @@ function stylize(label, style, args) {
32
26
  }
33
27
  return [styledLabel, ...args];
34
28
  }
35
- exports.stylize = stylize;
36
- class Logger {
29
+ export class Logger {
37
30
  error(...args) {
38
- console.error(...stylize('[ERROR]', exports.Styles.error, args));
31
+ console.error(...stylize('[ERROR]', Styles.error, args));
39
32
  }
40
33
  warn(...args) {
41
- console.warn(...stylize('[WARNING]', exports.Styles.warn, args));
34
+ console.warn(...stylize('[WARNING]', Styles.warn, args));
42
35
  }
43
36
  log(...args) {
44
37
  console.log(...args);
45
38
  }
46
39
  success(...args) {
47
- console.log(...stylize('[SUCCESS]', exports.Styles.success, args));
40
+ console.log(...stylize('[SUCCESS]', Styles.success, args));
48
41
  }
49
42
  info(...args) {
50
- console.info(...stylize('[INFO]', exports.Styles.info, args));
43
+ console.info(...stylize('[INFO]', Styles.info, args));
51
44
  }
52
45
  debug(...args) {
53
- console.debug(...stylize('[DEBUG]', exports.Styles.log, args));
46
+ console.debug(...stylize('[DEBUG]', Styles.log, args));
54
47
  }
55
48
  group(...args) {
56
49
  console.group(...args);
@@ -59,81 +52,76 @@ class Logger {
59
52
  console.groupEnd();
60
53
  }
61
54
  }
62
- exports.Logger = Logger;
63
55
  let currentLogger = new Logger();
64
- let currentLogLevel = exports.LOG_LEVEL.ERROR;
65
- function setLogger(logger) {
56
+ let currentLogLevel = LOG_LEVEL.ERROR;
57
+ export function setLogger(logger) {
66
58
  currentLogger = logger;
67
59
  }
68
- exports.setLogger = setLogger;
69
- function setLogLevel(level) {
60
+ export function setLogLevel(level) {
70
61
  switch (level) {
71
- case exports.LOG_LEVEL.DEBUG:
62
+ case LOG_LEVEL.DEBUG:
72
63
  currentLogLevel =
73
- exports.LOG_LEVEL.DEBUG | exports.LOG_LEVEL.LOG | exports.LOG_LEVEL.WARN | exports.LOG_LEVEL.ERROR;
64
+ LOG_LEVEL.DEBUG | LOG_LEVEL.LOG | LOG_LEVEL.WARN | LOG_LEVEL.ERROR;
74
65
  break;
75
- case exports.LOG_LEVEL.LOG:
76
- currentLogLevel = exports.LOG_LEVEL.LOG | exports.LOG_LEVEL.WARN | exports.LOG_LEVEL.ERROR;
66
+ case LOG_LEVEL.LOG:
67
+ currentLogLevel = LOG_LEVEL.LOG | LOG_LEVEL.WARN | LOG_LEVEL.ERROR;
77
68
  break;
78
- case exports.LOG_LEVEL.WARN:
79
- currentLogLevel = exports.LOG_LEVEL.WARN | exports.LOG_LEVEL.ERROR;
69
+ case LOG_LEVEL.WARN:
70
+ currentLogLevel = LOG_LEVEL.WARN | LOG_LEVEL.ERROR;
80
71
  break;
81
- case exports.LOG_LEVEL.ERROR:
82
- currentLogLevel = exports.LOG_LEVEL.ERROR;
72
+ case LOG_LEVEL.ERROR:
73
+ currentLogLevel = LOG_LEVEL.ERROR;
83
74
  break;
84
- case exports.LOG_LEVEL.NONE:
75
+ case LOG_LEVEL.NONE:
85
76
  default:
86
- currentLogLevel = exports.LOG_LEVEL.NONE;
77
+ currentLogLevel = LOG_LEVEL.NONE;
87
78
  }
88
79
  }
89
- exports.setLogLevel = setLogLevel;
90
- function shouldLog(level) {
80
+ export function shouldLog(level) {
91
81
  return !!(currentLogLevel & level);
92
82
  }
93
- exports.shouldLog = shouldLog;
94
- function getLogLevel() {
83
+ export function getLogLevel() {
95
84
  switch (currentLogLevel) {
96
- case exports.LOG_LEVEL.DEBUG | exports.LOG_LEVEL.LOG | exports.LOG_LEVEL.WARN | exports.LOG_LEVEL.ERROR:
97
- return exports.LOG_LEVEL.DEBUG;
98
- case exports.LOG_LEVEL.LOG | exports.LOG_LEVEL.WARN | exports.LOG_LEVEL.ERROR:
99
- return exports.LOG_LEVEL.LOG;
100
- case exports.LOG_LEVEL.WARN | exports.LOG_LEVEL.ERROR:
101
- return exports.LOG_LEVEL.WARN;
102
- case exports.LOG_LEVEL.ERROR:
103
- return exports.LOG_LEVEL.ERROR;
85
+ case LOG_LEVEL.DEBUG | LOG_LEVEL.LOG | LOG_LEVEL.WARN | LOG_LEVEL.ERROR:
86
+ return LOG_LEVEL.DEBUG;
87
+ case LOG_LEVEL.LOG | LOG_LEVEL.WARN | LOG_LEVEL.ERROR:
88
+ return LOG_LEVEL.LOG;
89
+ case LOG_LEVEL.WARN | LOG_LEVEL.ERROR:
90
+ return LOG_LEVEL.WARN;
91
+ case LOG_LEVEL.ERROR:
92
+ return LOG_LEVEL.ERROR;
104
93
  default:
105
- return exports.LOG_LEVEL.NONE;
94
+ return LOG_LEVEL.NONE;
106
95
  }
107
96
  }
108
- exports.getLogLevel = getLogLevel;
109
- exports.logger = {
97
+ export const logger = {
110
98
  error(...args) {
111
- if (shouldLog(exports.LOG_LEVEL.ERROR)) {
99
+ if (shouldLog(LOG_LEVEL.ERROR)) {
112
100
  currentLogger.error(...args);
113
101
  }
114
102
  },
115
103
  warn(...args) {
116
- if (shouldLog(exports.LOG_LEVEL.WARN)) {
104
+ if (shouldLog(LOG_LEVEL.WARN)) {
117
105
  currentLogger.warn(...args);
118
106
  }
119
107
  },
120
108
  log(...args) {
121
- if (shouldLog(exports.LOG_LEVEL.LOG)) {
109
+ if (shouldLog(LOG_LEVEL.LOG)) {
122
110
  currentLogger.log(...args);
123
111
  }
124
112
  },
125
113
  success(...args) {
126
- if (shouldLog(exports.LOG_LEVEL.LOG)) {
114
+ if (shouldLog(LOG_LEVEL.LOG)) {
127
115
  currentLogger.success(...args);
128
116
  }
129
117
  },
130
118
  info(...args) {
131
- if (shouldLog(exports.LOG_LEVEL.LOG)) {
119
+ if (shouldLog(LOG_LEVEL.LOG)) {
132
120
  currentLogger.info(...args);
133
121
  }
134
122
  },
135
123
  debug(...args) {
136
- if (shouldLog(exports.LOG_LEVEL.DEBUG)) {
124
+ if (shouldLog(LOG_LEVEL.DEBUG)) {
137
125
  currentLogger.debug(...args);
138
126
  }
139
127
  },
package/lib/notify.js CHANGED
@@ -1,27 +1,20 @@
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.triggerNotify = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const moment_1 = __importDefault(require("moment"));
9
- const debounce_1 = __importDefault(require("debounce"));
10
- const lang_1 = require("../utils/lang");
1
+ import fs from 'fs';
2
+ import moment from 'moment';
3
+ import debounce from 'debounce';
4
+ import { i18n } from '../utils/lang.js';
11
5
  const i18nKey = 'utils.notify';
12
6
  const notifyQueue = [];
13
7
  const notifyPromises = [];
14
- const debouncedWaitForActionsToCompleteAndWriteQueueToFile = (0, debounce_1.default)(waitForActionsToCompleteAndWriteQueueToFile, 500);
8
+ const debouncedWaitForActionsToCompleteAndWriteQueueToFile = debounce(waitForActionsToCompleteAndWriteQueueToFile, 500);
15
9
  // Collects actions that have been taken on files and the corresponding Promise
16
10
  // for the remote action that is in-process
17
- function triggerNotify(filePathToNotify, actionType, filePath, actionPromise) {
11
+ export function triggerNotify(filePathToNotify, actionType, filePath, actionPromise) {
18
12
  if (filePathToNotify) {
19
- notifyQueue.push(`${(0, moment_1.default)().toISOString()} ${actionType}: ${filePath}\n`);
13
+ notifyQueue.push(`${moment().toISOString()} ${actionType}: ${filePath}\n`);
20
14
  notifyPromises.push(actionPromise);
21
15
  debouncedWaitForActionsToCompleteAndWriteQueueToFile(filePathToNotify);
22
16
  }
23
17
  }
24
- exports.triggerNotify = triggerNotify;
25
18
  // Clears both the notifyQueue and notifyPromises array, generates the output
26
19
  // string that will be eventually logged, and waits for all promises currently
27
20
  // in the notifyPromises array to resolve before logging the output
@@ -34,10 +27,10 @@ function waitForActionsToCompleteAndWriteQueueToFile(filePathToNotify) {
34
27
  function notifyFilePath(filePathToNotify, outputToWrite) {
35
28
  if (filePathToNotify) {
36
29
  try {
37
- fs_1.default.appendFileSync(filePathToNotify, outputToWrite);
30
+ fs.appendFileSync(filePathToNotify, outputToWrite);
38
31
  }
39
32
  catch (e) {
40
- throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.filePath`, { filePath: filePathToNotify }), { cause: e });
33
+ throw new Error(i18n(`${i18nKey}.errors.filePath`, { filePath: filePathToNotify }), { cause: e });
41
34
  }
42
35
  }
43
36
  }
package/lib/oauth.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { OAuth2Manager } from '../models/OAuth2Manager';
2
- import { OAuthConfigAccount } from '../types/Accounts';
1
+ import { OAuth2Manager } from '../models/OAuth2Manager.js';
2
+ import { OAuthConfigAccount } from '../types/Accounts.js';
3
3
  export declare function getOauthManager(account: OAuthConfigAccount): OAuth2Manager | undefined;
4
4
  export declare function addOauthToAccountConfig(oauth: OAuth2Manager): void;
package/lib/oauth.js CHANGED
@@ -1,26 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addOauthToAccountConfig = exports.getOauthManager = void 0;
4
- const OAuth2Manager_1 = require("../models/OAuth2Manager");
5
- const logger_1 = require("./logger");
6
- const config_1 = require("../config");
7
- const lang_1 = require("../utils/lang");
1
+ import { OAuth2Manager } from '../models/OAuth2Manager.js';
2
+ import { logger } from './logger.js';
3
+ import { updateConfigAccount } from '../config/index.js';
4
+ import { i18n } from '../utils/lang.js';
8
5
  const i18nKey = 'lib.oauth';
9
6
  const oauthManagers = new Map();
10
7
  function writeOauthTokenInfo(account) {
11
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.writeTokenInfo`, { portalId: account.accountId }));
12
- (0, config_1.updateConfigAccount)(account);
8
+ logger.debug(i18n(`${i18nKey}.writeTokenInfo`, { portalId: account.accountId }));
9
+ updateConfigAccount(account);
13
10
  }
14
- function getOauthManager(account) {
11
+ export function getOauthManager(account) {
15
12
  if (!oauthManagers.has(account.accountId)) {
16
- oauthManagers.set(account.accountId, new OAuth2Manager_1.OAuth2Manager(account, () => writeOauthTokenInfo(account)));
13
+ oauthManagers.set(account.accountId, new OAuth2Manager(account, () => writeOauthTokenInfo(account)));
17
14
  }
18
15
  return oauthManagers.get(account.accountId);
19
16
  }
20
- exports.getOauthManager = getOauthManager;
21
- function addOauthToAccountConfig(oauth) {
22
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.addOauthToAccountConfig.init`));
23
- (0, config_1.updateConfigAccount)(oauth.account);
24
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.addOauthToAccountConfig.success`));
17
+ export function addOauthToAccountConfig(oauth) {
18
+ logger.log(i18n(`${i18nKey}.addOauthToAccountConfig.init`));
19
+ updateConfigAccount(oauth.account);
20
+ logger.success(i18n(`${i18nKey}.addOauthToAccountConfig.success`));
25
21
  }
26
- exports.addOauthToAccountConfig = addOauthToAccountConfig;
package/lib/path.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import path from 'path';
3
2
  export declare function convertToUnixPath(_path: string): string;
4
3
  export declare function convertToLocalFileSystemPath(_path: string): string;
package/lib/path.js CHANGED
@@ -1,32 +1,24 @@
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.untildify = exports.isValidPath = exports.sanitizeFileName = exports.getAbsoluteFilePath = exports.isAllowedExtension = exports.getAllowedExtensions = exports.getExt = exports.getCwd = exports.splitHubSpotPath = exports.splitLocalPath = exports.convertToLocalFileSystemPath = exports.convertToUnixPath = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const unixify_1 = __importDefault(require("unixify"));
9
- const extensions_1 = require("../constants/extensions");
10
- const os_1 = __importDefault(require("os"));
11
- function convertToUnixPath(_path) {
12
- return (0, unixify_1.default)(path_1.default.normalize(_path));
1
+ import path from 'path';
2
+ import unixify from 'unixify';
3
+ import { ALLOWED_EXTENSIONS } from '../constants/extensions.js';
4
+ import os from 'os';
5
+ export function convertToUnixPath(_path) {
6
+ return unixify(path.normalize(_path));
13
7
  }
14
- exports.convertToUnixPath = convertToUnixPath;
15
8
  function convertToWindowsPath(_path) {
16
- const rgx = new RegExp(`\\${path_1.default.posix.sep}`, 'g');
17
- return path_1.default.normalize(_path).replace(rgx, path_1.default.win32.sep);
9
+ const rgx = new RegExp(`\\${path.posix.sep}`, 'g');
10
+ return path.normalize(_path).replace(rgx, path.win32.sep);
18
11
  }
19
- function convertToLocalFileSystemPath(_path) {
20
- switch (path_1.default.sep) {
21
- case path_1.default.posix.sep:
12
+ export function convertToLocalFileSystemPath(_path) {
13
+ switch (path.sep) {
14
+ case path.posix.sep:
22
15
  return convertToUnixPath(_path);
23
- case path_1.default.win32.sep:
16
+ case path.win32.sep:
24
17
  return convertToWindowsPath(_path);
25
18
  default:
26
- return path_1.default.normalize(_path);
19
+ return path.normalize(_path);
27
20
  }
28
21
  }
29
- exports.convertToLocalFileSystemPath = convertToLocalFileSystemPath;
30
22
  function removeTrailingSlashFromSplits(parts) {
31
23
  if (parts.length > 1 && parts[parts.length - 1] === '') {
32
24
  return parts.slice(0, parts.length - 1);
@@ -34,24 +26,23 @@ function removeTrailingSlashFromSplits(parts) {
34
26
  return parts;
35
27
  }
36
28
  // Splits a filepath for local file system sources.
37
- function splitLocalPath(filepath, pathImplementation = path_1.default) {
29
+ export function splitLocalPath(filepath, pathImplementation = path) {
38
30
  if (!filepath)
39
31
  return [];
40
32
  const { sep } = pathImplementation;
41
33
  const rgx = new RegExp(`\\${sep}+`, 'g');
42
34
  const parts = pathImplementation.normalize(filepath).split(rgx);
43
35
  // Restore posix root if present
44
- if (sep === path_1.default.posix.sep && parts[0] === '') {
36
+ if (sep === path.posix.sep && parts[0] === '') {
45
37
  parts[0] = '/';
46
38
  }
47
39
  return removeTrailingSlashFromSplits(parts);
48
40
  }
49
- exports.splitLocalPath = splitLocalPath;
50
41
  // Splits a filepath for remote sources (HubSpot).
51
- function splitHubSpotPath(filepath) {
42
+ export function splitHubSpotPath(filepath) {
52
43
  if (!filepath)
53
44
  return [];
54
- const rgx = new RegExp(`\\${path_1.default.posix.sep}+`, 'g');
45
+ const rgx = new RegExp(`\\${path.posix.sep}+`, 'g');
55
46
  const parts = convertToUnixPath(filepath).split(rgx);
56
47
  // Restore root if present
57
48
  if (parts[0] === '') {
@@ -59,39 +50,33 @@ function splitHubSpotPath(filepath) {
59
50
  }
60
51
  return removeTrailingSlashFromSplits(parts);
61
52
  }
62
- exports.splitHubSpotPath = splitHubSpotPath;
63
- function getCwd() {
53
+ export function getCwd() {
64
54
  if (process.env.INIT_CWD) {
65
55
  return process.env.INIT_CWD;
66
56
  }
67
57
  return process.cwd();
68
58
  }
69
- exports.getCwd = getCwd;
70
- function getExt(filepath) {
59
+ export function getExt(filepath) {
71
60
  if (typeof filepath !== 'string')
72
61
  return '';
73
- const ext = path_1.default.extname(filepath).trim().toLowerCase();
62
+ const ext = path.extname(filepath).trim().toLowerCase();
74
63
  return ext[0] === '.' ? ext.slice(1) : ext;
75
64
  }
76
- exports.getExt = getExt;
77
- function getAllowedExtensions(allowList = []) {
78
- return new Set([...Array.from(extensions_1.ALLOWED_EXTENSIONS), ...allowList]);
65
+ export function getAllowedExtensions(allowList = []) {
66
+ return new Set([...Array.from(ALLOWED_EXTENSIONS), ...allowList]);
79
67
  }
80
- exports.getAllowedExtensions = getAllowedExtensions;
81
- function isAllowedExtension(filepath, allowList = []) {
68
+ export function isAllowedExtension(filepath, allowList = []) {
82
69
  const ext = getExt(filepath);
83
70
  const allowedExtensions = getAllowedExtensions(allowList);
84
71
  return allowedExtensions.has(ext);
85
72
  }
86
- exports.isAllowedExtension = isAllowedExtension;
87
- function getAbsoluteFilePath(_path) {
88
- return path_1.default.resolve(getCwd(), _path);
73
+ export function getAbsoluteFilePath(_path) {
74
+ return path.resolve(getCwd(), _path);
89
75
  }
90
- exports.getAbsoluteFilePath = getAbsoluteFilePath;
91
76
  // Reserved names (Windows specific)
92
77
  const reservedNames = /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;
93
78
  // Based on the node-sanitize-filename package: https://github.com/parshap/node-sanitize-filename/blob/master/index.js
94
- function sanitizeFileName(fileName) {
79
+ export function sanitizeFileName(fileName) {
95
80
  // Windows invalid/control characters
96
81
  // eslint-disable-next-line no-control-regex
97
82
  const invalidChars = /[<>:"/|?*\x00-\x1F]/g;
@@ -105,13 +90,12 @@ function sanitizeFileName(fileName) {
105
90
  }
106
91
  return sanitizedFileName;
107
92
  }
108
- exports.sanitizeFileName = sanitizeFileName;
109
93
  // Based on the node-sanitize-filename package: https://github.com/parshap/node-sanitize-filename/blob/master/index.js
110
- function isValidPath(_path) {
94
+ export function isValidPath(_path) {
111
95
  // Invalid characters excluding forward slash
112
96
  // eslint-disable-next-line no-control-regex
113
97
  const invalidChars = /[<>:"|?*\x00-\x1F]/;
114
- const baseName = path_1.default.basename(_path);
98
+ const baseName = path.basename(_path);
115
99
  if (invalidChars.test(baseName)) {
116
100
  return false;
117
101
  }
@@ -120,10 +104,9 @@ function isValidPath(_path) {
120
104
  }
121
105
  return true;
122
106
  }
123
- exports.isValidPath = isValidPath;
124
107
  // Based on the untildify package: https://github.com/sindresorhus/untildify/blob/main/index.js
125
- function untildify(pathWithTilde) {
126
- const homeDirectory = os_1.default.homedir();
108
+ export function untildify(pathWithTilde) {
109
+ const homeDirectory = os.homedir();
127
110
  if (typeof pathWithTilde !== 'string') {
128
111
  throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`);
129
112
  }
@@ -131,4 +114,3 @@ function untildify(pathWithTilde) {
131
114
  ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory)
132
115
  : pathWithTilde;
133
116
  }
134
- exports.untildify = untildify;
@@ -1,11 +1,9 @@
1
- import { PersonalAccessKeyConfigAccount, ScopeGroupAuthorization } from '../types/Accounts';
2
- import { Environment } from '../types/Config';
3
- import { AccessToken } from '../types/Accounts';
1
+ import { PersonalAccessKeyConfigAccount, Environment } from '../types/Accounts.js';
2
+ import { AccessToken } from '../types/Accounts.js';
4
3
  export declare function getAccessToken(personalAccessKey: string, env?: Environment, accountId?: number): Promise<AccessToken>;
5
4
  export declare function accessTokenForPersonalAccessKey(accountId: number, forceRefresh?: boolean): Promise<string | undefined>;
6
5
  export declare function enabledFeaturesForPersonalAccessKey(accountId: number): Promise<{
7
6
  [key: string]: number;
8
7
  } | undefined>;
9
8
  export declare function scopesOnAccessToken(accountId: number): Promise<Array<string>>;
10
- export declare function authorizedScopesForPortalAndUser(accountId: number): Promise<Array<ScopeGroupAuthorization>>;
11
9
  export declare function updateConfigWithAccessToken(token: AccessToken, personalAccessKey: string, env?: Environment, name?: string, makeDefault?: boolean): Promise<PersonalAccessKeyConfigAccount>;