@hubspot/local-dev-lib 3.10.0-beta.0 → 3.10.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.
- package/errors/index.d.ts +1 -0
- package/errors/index.js +10 -1
- package/lang/en.json +1 -0
- package/lib/github.js +12 -0
- package/package.json +1 -1
package/errors/index.d.ts
CHANGED
|
@@ -14,5 +14,6 @@ export declare function isTimeoutError(err: unknown): err is HubSpotHttpError;
|
|
|
14
14
|
export declare function isAuthError(err: unknown): err is HubSpotHttpError;
|
|
15
15
|
export declare function isValidationError(err: unknown): boolean;
|
|
16
16
|
export declare function isHubSpotHttpError(error?: unknown): error is HubSpotHttpError;
|
|
17
|
+
export declare function isGithubRateLimitError(err: unknown): boolean;
|
|
17
18
|
export declare function isSystemError(err: unknown): err is BaseError;
|
|
18
19
|
export declare function isFileSystemError(err: unknown): err is FileSystemError;
|
package/errors/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFileSystemError = exports.isSystemError = exports.isHubSpotHttpError = exports.isValidationError = exports.isAuthError = exports.isTimeoutError = exports.isGatingError = exports.isMissingScopeError = exports.isSpecifiedError = void 0;
|
|
3
|
+
exports.isFileSystemError = exports.isSystemError = exports.isGithubRateLimitError = exports.isHubSpotHttpError = exports.isValidationError = exports.isAuthError = exports.isTimeoutError = exports.isGatingError = exports.isMissingScopeError = exports.isSpecifiedError = void 0;
|
|
4
4
|
const HubSpotHttpError_1 = require("../models/HubSpotHttpError");
|
|
5
5
|
const FileSystemError_1 = require("../models/FileSystemError");
|
|
6
6
|
function isSpecifiedError(err, { statusCode, category, subCategory, errorType, code, }) {
|
|
@@ -47,6 +47,15 @@ function isHubSpotHttpError(error) {
|
|
|
47
47
|
return !!error && error instanceof HubSpotHttpError_1.HubSpotHttpError;
|
|
48
48
|
}
|
|
49
49
|
exports.isHubSpotHttpError = isHubSpotHttpError;
|
|
50
|
+
function isGithubRateLimitError(err) {
|
|
51
|
+
if (!isHubSpotHttpError(err)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return (!!err.headers &&
|
|
55
|
+
err.headers['x-ratelimit-remaining'] === '0' &&
|
|
56
|
+
'x-github-request-id' in err.headers);
|
|
57
|
+
}
|
|
58
|
+
exports.isGithubRateLimitError = isGithubRateLimitError;
|
|
50
59
|
function isSystemError(err) {
|
|
51
60
|
return (err instanceof Error &&
|
|
52
61
|
'errno' in err &&
|
package/lang/en.json
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"github": {
|
|
34
|
+
"rateLimitError": "Github rate limit hit. Set the GITHUB_TOKEN env variable with your github PATH. This will increase the github api's rate limit.",
|
|
34
35
|
"fetchFileFromRepository": {
|
|
35
36
|
"fetching": "Fetching {{ path }}...",
|
|
36
37
|
"errors": {
|
package/lib/github.js
CHANGED
|
@@ -24,6 +24,7 @@ async function fetchFileFromRepository(repoPath, filePath, ref) {
|
|
|
24
24
|
return data;
|
|
25
25
|
}
|
|
26
26
|
catch (err) {
|
|
27
|
+
checkGithubRateLimit(err);
|
|
27
28
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.fetchFileFromRepository.errors.fetchFail`), {
|
|
28
29
|
cause: err,
|
|
29
30
|
});
|
|
@@ -43,6 +44,7 @@ async function fetchReleaseData(repoPath, tag) {
|
|
|
43
44
|
return data;
|
|
44
45
|
}
|
|
45
46
|
catch (err) {
|
|
47
|
+
checkGithubRateLimit(err);
|
|
46
48
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.fetchReleaseData.errors.fetchFail`, {
|
|
47
49
|
tag: tag || 'latest',
|
|
48
50
|
}), { cause: err });
|
|
@@ -72,6 +74,7 @@ async function downloadGithubRepoZip(repoPath, isRelease = false, options = {})
|
|
|
72
74
|
return data;
|
|
73
75
|
}
|
|
74
76
|
catch (err) {
|
|
77
|
+
checkGithubRateLimit(err);
|
|
75
78
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.downloadGithubRepoZip.errors.fetchFail`), {
|
|
76
79
|
cause: err,
|
|
77
80
|
});
|
|
@@ -147,6 +150,7 @@ async function downloadGithubRepoContents(repoPath, contentPath, dest, ref, filt
|
|
|
147
150
|
await Promise.all(contentPromises);
|
|
148
151
|
}
|
|
149
152
|
catch (e) {
|
|
153
|
+
checkGithubRateLimit(e);
|
|
150
154
|
if ((0, errors_1.isSystemError)(e) && e?.error?.message) {
|
|
151
155
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.downloadGithubRepoContents.errors.fetchFail`, {
|
|
152
156
|
errorMessage: e.error.message,
|
|
@@ -166,6 +170,7 @@ async function listGithubRepoContents(repoPath, contentPath, fileFilter) {
|
|
|
166
170
|
return filteredFiles;
|
|
167
171
|
}
|
|
168
172
|
catch (e) {
|
|
173
|
+
checkGithubRateLimit(e);
|
|
169
174
|
if ((0, errors_1.isHubSpotHttpError)(e) && e.data.message) {
|
|
170
175
|
throw new Error((0, lang_1.i18n)(`${i18nKey}.downloadGithubRepoContents.errors.fetchFail`, {
|
|
171
176
|
errorMessage: e.data.message,
|
|
@@ -175,3 +180,10 @@ async function listGithubRepoContents(repoPath, contentPath, fileFilter) {
|
|
|
175
180
|
}
|
|
176
181
|
}
|
|
177
182
|
exports.listGithubRepoContents = listGithubRepoContents;
|
|
183
|
+
function checkGithubRateLimit(err) {
|
|
184
|
+
if ((0, errors_1.isGithubRateLimitError)(err)) {
|
|
185
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.rateLimitError`), {
|
|
186
|
+
cause: err,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
package/package.json
CHANGED