@vercel/python-analysis 0.4.0 → 0.4.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/dist/index.cjs +18 -4
- package/dist/index.js +18 -4
- package/dist/util/error.d.ts +7 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -138,7 +138,14 @@ var isErrnoException = (error, code = void 0) => {
|
|
|
138
138
|
return import_node_util.default.types.isNativeError(error) && "code" in error && (code === void 0 || error.code === code);
|
|
139
139
|
};
|
|
140
140
|
var PythonAnalysisError = class extends Error {
|
|
141
|
-
constructor({
|
|
141
|
+
constructor({
|
|
142
|
+
message,
|
|
143
|
+
code,
|
|
144
|
+
path: path4,
|
|
145
|
+
link,
|
|
146
|
+
action,
|
|
147
|
+
fileContent
|
|
148
|
+
}) {
|
|
142
149
|
super(message);
|
|
143
150
|
this.hideStackTrace = true;
|
|
144
151
|
this.name = "PythonAnalysisError";
|
|
@@ -146,6 +153,7 @@ var PythonAnalysisError = class extends Error {
|
|
|
146
153
|
this.path = path4;
|
|
147
154
|
this.link = link;
|
|
148
155
|
this.action = action;
|
|
156
|
+
this.fileContent = fileContent;
|
|
149
157
|
}
|
|
150
158
|
};
|
|
151
159
|
|
|
@@ -207,7 +215,8 @@ function parseRawConfig(content, filename, filetype = void 0) {
|
|
|
207
215
|
throw new PythonAnalysisError({
|
|
208
216
|
message: `Could not parse config file "${filename}": ${error.message}`,
|
|
209
217
|
code: "PYTHON_CONFIG_PARSE_ERROR",
|
|
210
|
-
path: filename
|
|
218
|
+
path: filename,
|
|
219
|
+
fileContent: content
|
|
211
220
|
});
|
|
212
221
|
}
|
|
213
222
|
throw error;
|
|
@@ -225,7 +234,8 @@ function parseConfig(content, filename, schema, filetype = void 0) {
|
|
|
225
234
|
message: `Invalid config in "${filename}":
|
|
226
235
|
${issues}`,
|
|
227
236
|
code: "PYTHON_CONFIG_VALIDATION_ERROR",
|
|
228
|
-
path: filename
|
|
237
|
+
path: filename,
|
|
238
|
+
fileContent: content
|
|
229
239
|
});
|
|
230
240
|
}
|
|
231
241
|
return result.data;
|
|
@@ -2042,12 +2052,16 @@ async function maybeLoadRequirementsTxt(root, subdir, fileName) {
|
|
|
2042
2052
|
} catch (error) {
|
|
2043
2053
|
if (error instanceof PythonAnalysisError) {
|
|
2044
2054
|
error.path = requirementsTxtRelPath;
|
|
2055
|
+
if (!error.fileContent) {
|
|
2056
|
+
error.fileContent = requirementsContent;
|
|
2057
|
+
}
|
|
2045
2058
|
throw error;
|
|
2046
2059
|
}
|
|
2047
2060
|
throw new PythonAnalysisError({
|
|
2048
2061
|
message: `could not parse ${fileName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
2049
2062
|
code: "PYTHON_REQUIREMENTS_PARSE_ERROR",
|
|
2050
|
-
path: requirementsTxtRelPath
|
|
2063
|
+
path: requirementsTxtRelPath,
|
|
2064
|
+
fileContent: requirementsContent
|
|
2051
2065
|
});
|
|
2052
2066
|
}
|
|
2053
2067
|
}
|
package/dist/index.js
CHANGED
|
@@ -66,7 +66,14 @@ var isErrnoException = (error, code = void 0) => {
|
|
|
66
66
|
return util.types.isNativeError(error) && "code" in error && (code === void 0 || error.code === code);
|
|
67
67
|
};
|
|
68
68
|
var PythonAnalysisError = class extends Error {
|
|
69
|
-
constructor({
|
|
69
|
+
constructor({
|
|
70
|
+
message,
|
|
71
|
+
code,
|
|
72
|
+
path: path4,
|
|
73
|
+
link,
|
|
74
|
+
action,
|
|
75
|
+
fileContent
|
|
76
|
+
}) {
|
|
70
77
|
super(message);
|
|
71
78
|
this.hideStackTrace = true;
|
|
72
79
|
this.name = "PythonAnalysisError";
|
|
@@ -74,6 +81,7 @@ var PythonAnalysisError = class extends Error {
|
|
|
74
81
|
this.path = path4;
|
|
75
82
|
this.link = link;
|
|
76
83
|
this.action = action;
|
|
84
|
+
this.fileContent = fileContent;
|
|
77
85
|
}
|
|
78
86
|
};
|
|
79
87
|
|
|
@@ -135,7 +143,8 @@ function parseRawConfig(content, filename, filetype = void 0) {
|
|
|
135
143
|
throw new PythonAnalysisError({
|
|
136
144
|
message: `Could not parse config file "${filename}": ${error.message}`,
|
|
137
145
|
code: "PYTHON_CONFIG_PARSE_ERROR",
|
|
138
|
-
path: filename
|
|
146
|
+
path: filename,
|
|
147
|
+
fileContent: content
|
|
139
148
|
});
|
|
140
149
|
}
|
|
141
150
|
throw error;
|
|
@@ -153,7 +162,8 @@ function parseConfig(content, filename, schema, filetype = void 0) {
|
|
|
153
162
|
message: `Invalid config in "${filename}":
|
|
154
163
|
${issues}`,
|
|
155
164
|
code: "PYTHON_CONFIG_VALIDATION_ERROR",
|
|
156
|
-
path: filename
|
|
165
|
+
path: filename,
|
|
166
|
+
fileContent: content
|
|
157
167
|
});
|
|
158
168
|
}
|
|
159
169
|
return result.data;
|
|
@@ -1973,12 +1983,16 @@ async function maybeLoadRequirementsTxt(root, subdir, fileName) {
|
|
|
1973
1983
|
} catch (error) {
|
|
1974
1984
|
if (error instanceof PythonAnalysisError) {
|
|
1975
1985
|
error.path = requirementsTxtRelPath;
|
|
1986
|
+
if (!error.fileContent) {
|
|
1987
|
+
error.fileContent = requirementsContent;
|
|
1988
|
+
}
|
|
1976
1989
|
throw error;
|
|
1977
1990
|
}
|
|
1978
1991
|
throw new PythonAnalysisError({
|
|
1979
1992
|
message: `could not parse ${fileName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
1980
1993
|
code: "PYTHON_REQUIREMENTS_PARSE_ERROR",
|
|
1981
|
-
path: requirementsTxtRelPath
|
|
1994
|
+
path: requirementsTxtRelPath,
|
|
1995
|
+
fileContent: requirementsContent
|
|
1982
1996
|
});
|
|
1983
1997
|
}
|
|
1984
1998
|
}
|
package/dist/util/error.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ interface PythonAnalysisErrorProps {
|
|
|
22
22
|
* Optional "action" to display before the `link`, such as "Learn More".
|
|
23
23
|
*/
|
|
24
24
|
action?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The raw content of the file that failed to parse, if available.
|
|
27
|
+
* Useful for diagnostic logging by callers.
|
|
28
|
+
*/
|
|
29
|
+
fileContent?: string;
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
27
32
|
* This error should be thrown from Python analysis functions
|
|
@@ -34,6 +39,7 @@ export declare class PythonAnalysisError extends Error {
|
|
|
34
39
|
path?: string;
|
|
35
40
|
link?: string;
|
|
36
41
|
action?: string;
|
|
37
|
-
|
|
42
|
+
fileContent?: string;
|
|
43
|
+
constructor({ message, code, path, link, action, fileContent, }: PythonAnalysisErrorProps);
|
|
38
44
|
}
|
|
39
45
|
export {};
|