@demon-utils/playwright 0.1.6 → 0.1.7
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/bin/demon-demo-init.js +56 -0
- package/dist/bin/demon-demo-init.js.map +10 -0
- package/dist/bin/demon-demo-review.js +187 -523
- package/dist/bin/demon-demo-review.js.map +7 -7
- package/dist/bin/demoon.js +1445 -0
- package/dist/bin/demoon.js.map +22 -0
- package/dist/bin/review-template.html +62 -0
- package/dist/github-issue.js +749 -0
- package/dist/github-issue.js.map +16 -0
- package/dist/index.js +1320 -867
- package/dist/index.js.map +16 -8
- package/dist/orchestrator.js +1421 -0
- package/dist/orchestrator.js.map +20 -0
- package/dist/review-generator.js +424 -0
- package/dist/review-generator.js.map +12 -0
- package/dist/review-template.html +62 -0
- package/package.json +11 -2
- package/src/bin/demon-demo-init.ts +59 -0
- package/src/bin/demon-demo-review.ts +19 -97
- package/src/bin/demoon.ts +140 -0
- package/src/feedback-server.ts +138 -0
- package/src/git-context.test.ts +68 -2
- package/src/git-context.ts +48 -9
- package/src/github-issue.test.ts +188 -0
- package/src/github-issue.ts +139 -0
- package/src/html-generator.e2e.test.ts +361 -80
- package/src/index.ts +9 -3
- package/src/orchestrator.test.ts +183 -0
- package/src/orchestrator.ts +341 -0
- package/src/review-generator.ts +221 -0
- package/src/review-types.ts +3 -0
- package/src/review.ts +13 -7
- package/src/html-generator.test.ts +0 -561
- package/src/html-generator.ts +0 -461
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
20
|
+
// ../../node_modules/universal-user-agent/index.js
|
|
21
|
+
function getUserAgent() {
|
|
22
|
+
if (typeof navigator === "object" && "userAgent" in navigator) {
|
|
23
|
+
return navigator.userAgent;
|
|
24
|
+
}
|
|
25
|
+
if (typeof process === "object" && process.version !== undefined) {
|
|
26
|
+
return `Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`;
|
|
27
|
+
}
|
|
28
|
+
return "<environment undetectable>";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ../../node_modules/@octokit/endpoint/dist-bundle/index.js
|
|
32
|
+
var VERSION = "0.0.0-development";
|
|
33
|
+
var userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;
|
|
34
|
+
var DEFAULTS = {
|
|
35
|
+
method: "GET",
|
|
36
|
+
baseUrl: "https://api.github.com",
|
|
37
|
+
headers: {
|
|
38
|
+
accept: "application/vnd.github.v3+json",
|
|
39
|
+
"user-agent": userAgent
|
|
40
|
+
},
|
|
41
|
+
mediaType: {
|
|
42
|
+
format: ""
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
function lowercaseKeys(object) {
|
|
46
|
+
if (!object) {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
return Object.keys(object).reduce((newObj, key) => {
|
|
50
|
+
newObj[key.toLowerCase()] = object[key];
|
|
51
|
+
return newObj;
|
|
52
|
+
}, {});
|
|
53
|
+
}
|
|
54
|
+
function isPlainObject(value) {
|
|
55
|
+
if (typeof value !== "object" || value === null)
|
|
56
|
+
return false;
|
|
57
|
+
if (Object.prototype.toString.call(value) !== "[object Object]")
|
|
58
|
+
return false;
|
|
59
|
+
const proto = Object.getPrototypeOf(value);
|
|
60
|
+
if (proto === null)
|
|
61
|
+
return true;
|
|
62
|
+
const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
63
|
+
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
|
64
|
+
}
|
|
65
|
+
function mergeDeep(defaults, options) {
|
|
66
|
+
const result = Object.assign({}, defaults);
|
|
67
|
+
Object.keys(options).forEach((key) => {
|
|
68
|
+
if (isPlainObject(options[key])) {
|
|
69
|
+
if (!(key in defaults))
|
|
70
|
+
Object.assign(result, { [key]: options[key] });
|
|
71
|
+
else
|
|
72
|
+
result[key] = mergeDeep(defaults[key], options[key]);
|
|
73
|
+
} else {
|
|
74
|
+
Object.assign(result, { [key]: options[key] });
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
function removeUndefinedProperties(obj) {
|
|
80
|
+
for (const key in obj) {
|
|
81
|
+
if (obj[key] === undefined) {
|
|
82
|
+
delete obj[key];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return obj;
|
|
86
|
+
}
|
|
87
|
+
function merge(defaults, route, options) {
|
|
88
|
+
if (typeof route === "string") {
|
|
89
|
+
let [method, url] = route.split(" ");
|
|
90
|
+
options = Object.assign(url ? { method, url } : { url: method }, options);
|
|
91
|
+
} else {
|
|
92
|
+
options = Object.assign({}, route);
|
|
93
|
+
}
|
|
94
|
+
options.headers = lowercaseKeys(options.headers);
|
|
95
|
+
removeUndefinedProperties(options);
|
|
96
|
+
removeUndefinedProperties(options.headers);
|
|
97
|
+
const mergedOptions = mergeDeep(defaults || {}, options);
|
|
98
|
+
if (options.url === "/graphql") {
|
|
99
|
+
if (defaults && defaults.mediaType.previews?.length) {
|
|
100
|
+
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter((preview) => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews);
|
|
101
|
+
}
|
|
102
|
+
mergedOptions.mediaType.previews = (mergedOptions.mediaType.previews || []).map((preview) => preview.replace(/-preview/, ""));
|
|
103
|
+
}
|
|
104
|
+
return mergedOptions;
|
|
105
|
+
}
|
|
106
|
+
function addQueryParameters(url, parameters) {
|
|
107
|
+
const separator = /\?/.test(url) ? "&" : "?";
|
|
108
|
+
const names = Object.keys(parameters);
|
|
109
|
+
if (names.length === 0) {
|
|
110
|
+
return url;
|
|
111
|
+
}
|
|
112
|
+
return url + separator + names.map((name) => {
|
|
113
|
+
if (name === "q") {
|
|
114
|
+
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+");
|
|
115
|
+
}
|
|
116
|
+
return `${name}=${encodeURIComponent(parameters[name])}`;
|
|
117
|
+
}).join("&");
|
|
118
|
+
}
|
|
119
|
+
var urlVariableRegex = /\{[^{}}]+\}/g;
|
|
120
|
+
function removeNonChars(variableName) {
|
|
121
|
+
return variableName.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g, "").split(/,/);
|
|
122
|
+
}
|
|
123
|
+
function extractUrlVariableNames(url) {
|
|
124
|
+
const matches = url.match(urlVariableRegex);
|
|
125
|
+
if (!matches) {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
|
|
129
|
+
}
|
|
130
|
+
function omit(object, keysToOmit) {
|
|
131
|
+
const result = { __proto__: null };
|
|
132
|
+
for (const key of Object.keys(object)) {
|
|
133
|
+
if (keysToOmit.indexOf(key) === -1) {
|
|
134
|
+
result[key] = object[key];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
function encodeReserved(str) {
|
|
140
|
+
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) {
|
|
141
|
+
if (!/%[0-9A-Fa-f]/.test(part)) {
|
|
142
|
+
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
|
|
143
|
+
}
|
|
144
|
+
return part;
|
|
145
|
+
}).join("");
|
|
146
|
+
}
|
|
147
|
+
function encodeUnreserved(str) {
|
|
148
|
+
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
|
|
149
|
+
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function encodeValue(operator, value, key) {
|
|
153
|
+
value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value);
|
|
154
|
+
if (key) {
|
|
155
|
+
return encodeUnreserved(key) + "=" + value;
|
|
156
|
+
} else {
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function isDefined(value) {
|
|
161
|
+
return value !== undefined && value !== null;
|
|
162
|
+
}
|
|
163
|
+
function isKeyOperator(operator) {
|
|
164
|
+
return operator === ";" || operator === "&" || operator === "?";
|
|
165
|
+
}
|
|
166
|
+
function getValues(context, operator, key, modifier) {
|
|
167
|
+
var value = context[key], result = [];
|
|
168
|
+
if (isDefined(value) && value !== "") {
|
|
169
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
170
|
+
value = value.toString();
|
|
171
|
+
if (modifier && modifier !== "*") {
|
|
172
|
+
value = value.substring(0, parseInt(modifier, 10));
|
|
173
|
+
}
|
|
174
|
+
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
|
|
175
|
+
} else {
|
|
176
|
+
if (modifier === "*") {
|
|
177
|
+
if (Array.isArray(value)) {
|
|
178
|
+
value.filter(isDefined).forEach(function(value2) {
|
|
179
|
+
result.push(encodeValue(operator, value2, isKeyOperator(operator) ? key : ""));
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
Object.keys(value).forEach(function(k) {
|
|
183
|
+
if (isDefined(value[k])) {
|
|
184
|
+
result.push(encodeValue(operator, value[k], k));
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
const tmp = [];
|
|
190
|
+
if (Array.isArray(value)) {
|
|
191
|
+
value.filter(isDefined).forEach(function(value2) {
|
|
192
|
+
tmp.push(encodeValue(operator, value2));
|
|
193
|
+
});
|
|
194
|
+
} else {
|
|
195
|
+
Object.keys(value).forEach(function(k) {
|
|
196
|
+
if (isDefined(value[k])) {
|
|
197
|
+
tmp.push(encodeUnreserved(k));
|
|
198
|
+
tmp.push(encodeValue(operator, value[k].toString()));
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
if (isKeyOperator(operator)) {
|
|
203
|
+
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
|
|
204
|
+
} else if (tmp.length !== 0) {
|
|
205
|
+
result.push(tmp.join(","));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
if (operator === ";") {
|
|
211
|
+
if (isDefined(value)) {
|
|
212
|
+
result.push(encodeUnreserved(key));
|
|
213
|
+
}
|
|
214
|
+
} else if (value === "" && (operator === "&" || operator === "?")) {
|
|
215
|
+
result.push(encodeUnreserved(key) + "=");
|
|
216
|
+
} else if (value === "") {
|
|
217
|
+
result.push("");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
function parseUrl(template) {
|
|
223
|
+
return {
|
|
224
|
+
expand: expand.bind(null, template)
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function expand(template, context) {
|
|
228
|
+
var operators = ["+", "#", ".", "/", ";", "?", "&"];
|
|
229
|
+
template = template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function(_, expression, literal) {
|
|
230
|
+
if (expression) {
|
|
231
|
+
let operator = "";
|
|
232
|
+
const values = [];
|
|
233
|
+
if (operators.indexOf(expression.charAt(0)) !== -1) {
|
|
234
|
+
operator = expression.charAt(0);
|
|
235
|
+
expression = expression.substr(1);
|
|
236
|
+
}
|
|
237
|
+
expression.split(/,/g).forEach(function(variable) {
|
|
238
|
+
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
|
|
239
|
+
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
|
|
240
|
+
});
|
|
241
|
+
if (operator && operator !== "+") {
|
|
242
|
+
var separator = ",";
|
|
243
|
+
if (operator === "?") {
|
|
244
|
+
separator = "&";
|
|
245
|
+
} else if (operator !== "#") {
|
|
246
|
+
separator = operator;
|
|
247
|
+
}
|
|
248
|
+
return (values.length !== 0 ? operator : "") + values.join(separator);
|
|
249
|
+
} else {
|
|
250
|
+
return values.join(",");
|
|
251
|
+
}
|
|
252
|
+
} else {
|
|
253
|
+
return encodeReserved(literal);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
if (template === "/") {
|
|
257
|
+
return template;
|
|
258
|
+
} else {
|
|
259
|
+
return template.replace(/\/$/, "");
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function parse(options) {
|
|
263
|
+
let method = options.method.toUpperCase();
|
|
264
|
+
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
|
265
|
+
let headers = Object.assign({}, options.headers);
|
|
266
|
+
let body;
|
|
267
|
+
let parameters = omit(options, [
|
|
268
|
+
"method",
|
|
269
|
+
"baseUrl",
|
|
270
|
+
"url",
|
|
271
|
+
"headers",
|
|
272
|
+
"request",
|
|
273
|
+
"mediaType"
|
|
274
|
+
]);
|
|
275
|
+
const urlVariableNames = extractUrlVariableNames(url);
|
|
276
|
+
url = parseUrl(url).expand(parameters);
|
|
277
|
+
if (!/^http/.test(url)) {
|
|
278
|
+
url = options.baseUrl + url;
|
|
279
|
+
}
|
|
280
|
+
const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl");
|
|
281
|
+
const remainingParameters = omit(parameters, omittedParameters);
|
|
282
|
+
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
|
|
283
|
+
if (!isBinaryRequest) {
|
|
284
|
+
if (options.mediaType.format) {
|
|
285
|
+
headers.accept = headers.accept.split(/,/).map((format) => format.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`)).join(",");
|
|
286
|
+
}
|
|
287
|
+
if (url.endsWith("/graphql")) {
|
|
288
|
+
if (options.mediaType.previews?.length) {
|
|
289
|
+
const previewsFromAcceptHeader = headers.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g) || [];
|
|
290
|
+
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => {
|
|
291
|
+
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json";
|
|
292
|
+
return `application/vnd.github.${preview}-preview${format}`;
|
|
293
|
+
}).join(",");
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (["GET", "HEAD"].includes(method)) {
|
|
298
|
+
url = addQueryParameters(url, remainingParameters);
|
|
299
|
+
} else {
|
|
300
|
+
if ("data" in remainingParameters) {
|
|
301
|
+
body = remainingParameters.data;
|
|
302
|
+
} else {
|
|
303
|
+
if (Object.keys(remainingParameters).length) {
|
|
304
|
+
body = remainingParameters;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (!headers["content-type"] && typeof body !== "undefined") {
|
|
309
|
+
headers["content-type"] = "application/json; charset=utf-8";
|
|
310
|
+
}
|
|
311
|
+
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
|
312
|
+
body = "";
|
|
313
|
+
}
|
|
314
|
+
return Object.assign({ method, url, headers }, typeof body !== "undefined" ? { body } : null, options.request ? { request: options.request } : null);
|
|
315
|
+
}
|
|
316
|
+
function endpointWithDefaults(defaults, route, options) {
|
|
317
|
+
return parse(merge(defaults, route, options));
|
|
318
|
+
}
|
|
319
|
+
function withDefaults(oldDefaults, newDefaults) {
|
|
320
|
+
const DEFAULTS2 = merge(oldDefaults, newDefaults);
|
|
321
|
+
const endpoint2 = endpointWithDefaults.bind(null, DEFAULTS2);
|
|
322
|
+
return Object.assign(endpoint2, {
|
|
323
|
+
DEFAULTS: DEFAULTS2,
|
|
324
|
+
defaults: withDefaults.bind(null, DEFAULTS2),
|
|
325
|
+
merge: merge.bind(null, DEFAULTS2),
|
|
326
|
+
parse
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
var endpoint = withDefaults(null, DEFAULTS);
|
|
330
|
+
|
|
331
|
+
// ../../node_modules/fast-content-type-parse/index.js
|
|
332
|
+
var NullObject = function NullObject2() {};
|
|
333
|
+
NullObject.prototype = Object.create(null);
|
|
334
|
+
var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
|
|
335
|
+
var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
|
|
336
|
+
var mediaTypeRE = /^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u;
|
|
337
|
+
var defaultContentType = { type: "", parameters: new NullObject };
|
|
338
|
+
Object.freeze(defaultContentType.parameters);
|
|
339
|
+
Object.freeze(defaultContentType);
|
|
340
|
+
function safeParse(header) {
|
|
341
|
+
if (typeof header !== "string") {
|
|
342
|
+
return defaultContentType;
|
|
343
|
+
}
|
|
344
|
+
let index = header.indexOf(";");
|
|
345
|
+
const type = index !== -1 ? header.slice(0, index).trim() : header.trim();
|
|
346
|
+
if (mediaTypeRE.test(type) === false) {
|
|
347
|
+
return defaultContentType;
|
|
348
|
+
}
|
|
349
|
+
const result = {
|
|
350
|
+
type: type.toLowerCase(),
|
|
351
|
+
parameters: new NullObject
|
|
352
|
+
};
|
|
353
|
+
if (index === -1) {
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
356
|
+
let key;
|
|
357
|
+
let match;
|
|
358
|
+
let value;
|
|
359
|
+
paramRE.lastIndex = index;
|
|
360
|
+
while (match = paramRE.exec(header)) {
|
|
361
|
+
if (match.index !== index) {
|
|
362
|
+
return defaultContentType;
|
|
363
|
+
}
|
|
364
|
+
index += match[0].length;
|
|
365
|
+
key = match[1].toLowerCase();
|
|
366
|
+
value = match[2];
|
|
367
|
+
if (value[0] === '"') {
|
|
368
|
+
value = value.slice(1, value.length - 1);
|
|
369
|
+
quotedPairRE.test(value) && (value = value.replace(quotedPairRE, "$1"));
|
|
370
|
+
}
|
|
371
|
+
result.parameters[key] = value;
|
|
372
|
+
}
|
|
373
|
+
if (index !== header.length) {
|
|
374
|
+
return defaultContentType;
|
|
375
|
+
}
|
|
376
|
+
return result;
|
|
377
|
+
}
|
|
378
|
+
var $safeParse = safeParse;
|
|
379
|
+
|
|
380
|
+
// ../../node_modules/@octokit/request-error/dist-src/index.js
|
|
381
|
+
class RequestError extends Error {
|
|
382
|
+
name;
|
|
383
|
+
status;
|
|
384
|
+
request;
|
|
385
|
+
response;
|
|
386
|
+
constructor(message, statusCode, options) {
|
|
387
|
+
super(message);
|
|
388
|
+
this.name = "HttpError";
|
|
389
|
+
this.status = Number.parseInt(statusCode);
|
|
390
|
+
if (Number.isNaN(this.status)) {
|
|
391
|
+
this.status = 0;
|
|
392
|
+
}
|
|
393
|
+
if ("response" in options) {
|
|
394
|
+
this.response = options.response;
|
|
395
|
+
}
|
|
396
|
+
const requestCopy = Object.assign({}, options.request);
|
|
397
|
+
if (options.request.headers.authorization) {
|
|
398
|
+
requestCopy.headers = Object.assign({}, options.request.headers, {
|
|
399
|
+
authorization: options.request.headers.authorization.replace(/(?<! ) .*$/, " [REDACTED]")
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
requestCopy.url = requestCopy.url.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]").replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
|
403
|
+
this.request = requestCopy;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// ../../node_modules/@octokit/request/dist-bundle/index.js
|
|
408
|
+
var VERSION2 = "9.2.4";
|
|
409
|
+
var defaults_default = {
|
|
410
|
+
headers: {
|
|
411
|
+
"user-agent": `octokit-request.js/${VERSION2} ${getUserAgent()}`
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
function isPlainObject2(value) {
|
|
415
|
+
if (typeof value !== "object" || value === null)
|
|
416
|
+
return false;
|
|
417
|
+
if (Object.prototype.toString.call(value) !== "[object Object]")
|
|
418
|
+
return false;
|
|
419
|
+
const proto = Object.getPrototypeOf(value);
|
|
420
|
+
if (proto === null)
|
|
421
|
+
return true;
|
|
422
|
+
const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
423
|
+
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
|
424
|
+
}
|
|
425
|
+
async function fetchWrapper(requestOptions) {
|
|
426
|
+
const fetch = requestOptions.request?.fetch || globalThis.fetch;
|
|
427
|
+
if (!fetch) {
|
|
428
|
+
throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");
|
|
429
|
+
}
|
|
430
|
+
const log = requestOptions.request?.log || console;
|
|
431
|
+
const parseSuccessResponseBody = requestOptions.request?.parseSuccessResponseBody !== false;
|
|
432
|
+
const body = isPlainObject2(requestOptions.body) || Array.isArray(requestOptions.body) ? JSON.stringify(requestOptions.body) : requestOptions.body;
|
|
433
|
+
const requestHeaders = Object.fromEntries(Object.entries(requestOptions.headers).map(([name, value]) => [
|
|
434
|
+
name,
|
|
435
|
+
String(value)
|
|
436
|
+
]));
|
|
437
|
+
let fetchResponse;
|
|
438
|
+
try {
|
|
439
|
+
fetchResponse = await fetch(requestOptions.url, {
|
|
440
|
+
method: requestOptions.method,
|
|
441
|
+
body,
|
|
442
|
+
redirect: requestOptions.request?.redirect,
|
|
443
|
+
headers: requestHeaders,
|
|
444
|
+
signal: requestOptions.request?.signal,
|
|
445
|
+
...requestOptions.body && { duplex: "half" }
|
|
446
|
+
});
|
|
447
|
+
} catch (error) {
|
|
448
|
+
let message = "Unknown Error";
|
|
449
|
+
if (error instanceof Error) {
|
|
450
|
+
if (error.name === "AbortError") {
|
|
451
|
+
error.status = 500;
|
|
452
|
+
throw error;
|
|
453
|
+
}
|
|
454
|
+
message = error.message;
|
|
455
|
+
if (error.name === "TypeError" && "cause" in error) {
|
|
456
|
+
if (error.cause instanceof Error) {
|
|
457
|
+
message = error.cause.message;
|
|
458
|
+
} else if (typeof error.cause === "string") {
|
|
459
|
+
message = error.cause;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const requestError = new RequestError(message, 500, {
|
|
464
|
+
request: requestOptions
|
|
465
|
+
});
|
|
466
|
+
requestError.cause = error;
|
|
467
|
+
throw requestError;
|
|
468
|
+
}
|
|
469
|
+
const status = fetchResponse.status;
|
|
470
|
+
const url = fetchResponse.url;
|
|
471
|
+
const responseHeaders = {};
|
|
472
|
+
for (const [key, value] of fetchResponse.headers) {
|
|
473
|
+
responseHeaders[key] = value;
|
|
474
|
+
}
|
|
475
|
+
const octokitResponse = {
|
|
476
|
+
url,
|
|
477
|
+
status,
|
|
478
|
+
headers: responseHeaders,
|
|
479
|
+
data: ""
|
|
480
|
+
};
|
|
481
|
+
if ("deprecation" in responseHeaders) {
|
|
482
|
+
const matches = responseHeaders.link && responseHeaders.link.match(/<([^<>]+)>; rel="deprecation"/);
|
|
483
|
+
const deprecationLink = matches && matches.pop();
|
|
484
|
+
log.warn(`[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${responseHeaders.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}`);
|
|
485
|
+
}
|
|
486
|
+
if (status === 204 || status === 205) {
|
|
487
|
+
return octokitResponse;
|
|
488
|
+
}
|
|
489
|
+
if (requestOptions.method === "HEAD") {
|
|
490
|
+
if (status < 400) {
|
|
491
|
+
return octokitResponse;
|
|
492
|
+
}
|
|
493
|
+
throw new RequestError(fetchResponse.statusText, status, {
|
|
494
|
+
response: octokitResponse,
|
|
495
|
+
request: requestOptions
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
if (status === 304) {
|
|
499
|
+
octokitResponse.data = await getResponseData(fetchResponse);
|
|
500
|
+
throw new RequestError("Not modified", status, {
|
|
501
|
+
response: octokitResponse,
|
|
502
|
+
request: requestOptions
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
if (status >= 400) {
|
|
506
|
+
octokitResponse.data = await getResponseData(fetchResponse);
|
|
507
|
+
throw new RequestError(toErrorMessage(octokitResponse.data), status, {
|
|
508
|
+
response: octokitResponse,
|
|
509
|
+
request: requestOptions
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
octokitResponse.data = parseSuccessResponseBody ? await getResponseData(fetchResponse) : fetchResponse.body;
|
|
513
|
+
return octokitResponse;
|
|
514
|
+
}
|
|
515
|
+
async function getResponseData(response) {
|
|
516
|
+
const contentType = response.headers.get("content-type");
|
|
517
|
+
if (!contentType) {
|
|
518
|
+
return response.text().catch(() => "");
|
|
519
|
+
}
|
|
520
|
+
const mimetype = $safeParse(contentType);
|
|
521
|
+
if (isJSONResponse(mimetype)) {
|
|
522
|
+
let text = "";
|
|
523
|
+
try {
|
|
524
|
+
text = await response.text();
|
|
525
|
+
return JSON.parse(text);
|
|
526
|
+
} catch (err) {
|
|
527
|
+
return text;
|
|
528
|
+
}
|
|
529
|
+
} else if (mimetype.type.startsWith("text/") || mimetype.parameters.charset?.toLowerCase() === "utf-8") {
|
|
530
|
+
return response.text().catch(() => "");
|
|
531
|
+
} else {
|
|
532
|
+
return response.arrayBuffer().catch(() => new ArrayBuffer(0));
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function isJSONResponse(mimetype) {
|
|
536
|
+
return mimetype.type === "application/json" || mimetype.type === "application/scim+json";
|
|
537
|
+
}
|
|
538
|
+
function toErrorMessage(data) {
|
|
539
|
+
if (typeof data === "string") {
|
|
540
|
+
return data;
|
|
541
|
+
}
|
|
542
|
+
if (data instanceof ArrayBuffer) {
|
|
543
|
+
return "Unknown error";
|
|
544
|
+
}
|
|
545
|
+
if ("message" in data) {
|
|
546
|
+
const suffix = "documentation_url" in data ? ` - ${data.documentation_url}` : "";
|
|
547
|
+
return Array.isArray(data.errors) ? `${data.message}: ${data.errors.map((v) => JSON.stringify(v)).join(", ")}${suffix}` : `${data.message}${suffix}`;
|
|
548
|
+
}
|
|
549
|
+
return `Unknown error: ${JSON.stringify(data)}`;
|
|
550
|
+
}
|
|
551
|
+
function withDefaults2(oldEndpoint, newDefaults) {
|
|
552
|
+
const endpoint2 = oldEndpoint.defaults(newDefaults);
|
|
553
|
+
const newApi = function(route, parameters) {
|
|
554
|
+
const endpointOptions = endpoint2.merge(route, parameters);
|
|
555
|
+
if (!endpointOptions.request || !endpointOptions.request.hook) {
|
|
556
|
+
return fetchWrapper(endpoint2.parse(endpointOptions));
|
|
557
|
+
}
|
|
558
|
+
const request2 = (route2, parameters2) => {
|
|
559
|
+
return fetchWrapper(endpoint2.parse(endpoint2.merge(route2, parameters2)));
|
|
560
|
+
};
|
|
561
|
+
Object.assign(request2, {
|
|
562
|
+
endpoint: endpoint2,
|
|
563
|
+
defaults: withDefaults2.bind(null, endpoint2)
|
|
564
|
+
});
|
|
565
|
+
return endpointOptions.request.hook(request2, endpointOptions);
|
|
566
|
+
};
|
|
567
|
+
return Object.assign(newApi, {
|
|
568
|
+
endpoint: endpoint2,
|
|
569
|
+
defaults: withDefaults2.bind(null, endpoint2)
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
var request = withDefaults2(endpoint, defaults_default);
|
|
573
|
+
|
|
574
|
+
// ../../node_modules/@octokit/graphql/dist-bundle/index.js
|
|
575
|
+
var VERSION3 = "0.0.0-development";
|
|
576
|
+
function _buildMessageForResponseErrors(data) {
|
|
577
|
+
return `Request failed due to following response errors:
|
|
578
|
+
` + data.errors.map((e) => ` - ${e.message}`).join(`
|
|
579
|
+
`);
|
|
580
|
+
}
|
|
581
|
+
var GraphqlResponseError = class extends Error {
|
|
582
|
+
constructor(request2, headers, response) {
|
|
583
|
+
super(_buildMessageForResponseErrors(response));
|
|
584
|
+
this.request = request2;
|
|
585
|
+
this.headers = headers;
|
|
586
|
+
this.response = response;
|
|
587
|
+
this.errors = response.errors;
|
|
588
|
+
this.data = response.data;
|
|
589
|
+
if (Error.captureStackTrace) {
|
|
590
|
+
Error.captureStackTrace(this, this.constructor);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
name = "GraphqlResponseError";
|
|
594
|
+
errors;
|
|
595
|
+
data;
|
|
596
|
+
};
|
|
597
|
+
var NON_VARIABLE_OPTIONS = [
|
|
598
|
+
"method",
|
|
599
|
+
"baseUrl",
|
|
600
|
+
"url",
|
|
601
|
+
"headers",
|
|
602
|
+
"request",
|
|
603
|
+
"query",
|
|
604
|
+
"mediaType",
|
|
605
|
+
"operationName"
|
|
606
|
+
];
|
|
607
|
+
var FORBIDDEN_VARIABLE_OPTIONS = ["query", "method", "url"];
|
|
608
|
+
var GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
|
|
609
|
+
function graphql(request2, query, options) {
|
|
610
|
+
if (options) {
|
|
611
|
+
if (typeof query === "string" && "query" in options) {
|
|
612
|
+
return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`));
|
|
613
|
+
}
|
|
614
|
+
for (const key in options) {
|
|
615
|
+
if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key))
|
|
616
|
+
continue;
|
|
617
|
+
return Promise.reject(new Error(`[@octokit/graphql] "${key}" cannot be used as variable name`));
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query;
|
|
621
|
+
const requestOptions = Object.keys(parsedOptions).reduce((result, key) => {
|
|
622
|
+
if (NON_VARIABLE_OPTIONS.includes(key)) {
|
|
623
|
+
result[key] = parsedOptions[key];
|
|
624
|
+
return result;
|
|
625
|
+
}
|
|
626
|
+
if (!result.variables) {
|
|
627
|
+
result.variables = {};
|
|
628
|
+
}
|
|
629
|
+
result.variables[key] = parsedOptions[key];
|
|
630
|
+
return result;
|
|
631
|
+
}, {});
|
|
632
|
+
const baseUrl = parsedOptions.baseUrl || request2.endpoint.DEFAULTS.baseUrl;
|
|
633
|
+
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
|
|
634
|
+
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
|
|
635
|
+
}
|
|
636
|
+
return request2(requestOptions).then((response) => {
|
|
637
|
+
if (response.data.errors) {
|
|
638
|
+
const headers = {};
|
|
639
|
+
for (const key of Object.keys(response.headers)) {
|
|
640
|
+
headers[key] = response.headers[key];
|
|
641
|
+
}
|
|
642
|
+
throw new GraphqlResponseError(requestOptions, headers, response.data);
|
|
643
|
+
}
|
|
644
|
+
return response.data.data;
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
function withDefaults3(request2, newDefaults) {
|
|
648
|
+
const newRequest = request2.defaults(newDefaults);
|
|
649
|
+
const newApi = (query, options) => {
|
|
650
|
+
return graphql(newRequest, query, options);
|
|
651
|
+
};
|
|
652
|
+
return Object.assign(newApi, {
|
|
653
|
+
defaults: withDefaults3.bind(null, newRequest),
|
|
654
|
+
endpoint: newRequest.endpoint
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
var graphql2 = withDefaults3(request, {
|
|
658
|
+
headers: {
|
|
659
|
+
"user-agent": `octokit-graphql.js/${VERSION3} ${getUserAgent()}`
|
|
660
|
+
},
|
|
661
|
+
method: "POST",
|
|
662
|
+
url: "/graphql"
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
// src/github-issue.ts
|
|
666
|
+
import { spawnSync } from "node:child_process";
|
|
667
|
+
var ISSUE_QUERY = `
|
|
668
|
+
query($owner: String!, $repo: String!, $number: Int!) {
|
|
669
|
+
repository(owner: $owner, name: $repo) {
|
|
670
|
+
issue(number: $number) {
|
|
671
|
+
number
|
|
672
|
+
title
|
|
673
|
+
body
|
|
674
|
+
state
|
|
675
|
+
labels(first: 20) {
|
|
676
|
+
nodes {
|
|
677
|
+
name
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
`;
|
|
684
|
+
function getRepoInfoFromGit() {
|
|
685
|
+
try {
|
|
686
|
+
const proc = spawnSync("git", ["remote", "get-url", "origin"], { encoding: "utf-8" });
|
|
687
|
+
if (proc.status !== 0 || !proc.stdout) {
|
|
688
|
+
return null;
|
|
689
|
+
}
|
|
690
|
+
const url = proc.stdout.trim();
|
|
691
|
+
const sshMatch = url.match(/git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/);
|
|
692
|
+
if (sshMatch) {
|
|
693
|
+
return { owner: sshMatch[1], repo: sshMatch[2] };
|
|
694
|
+
}
|
|
695
|
+
const httpsMatch = url.match(/https:\/\/github\.com\/([^/]+)\/(.+?)(?:\.git)?$/);
|
|
696
|
+
if (httpsMatch) {
|
|
697
|
+
return { owner: httpsMatch[1], repo: httpsMatch[2] };
|
|
698
|
+
}
|
|
699
|
+
return null;
|
|
700
|
+
} catch {
|
|
701
|
+
return null;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function getTokenFromEnvironment() {
|
|
705
|
+
return process.env["GITHUB_TOKEN"] ?? process.env["GH_TOKEN"] ?? null;
|
|
706
|
+
}
|
|
707
|
+
async function fetchGitHubIssue(issueId, options) {
|
|
708
|
+
const issueNumber = typeof issueId === "string" ? parseInt(issueId, 10) : issueId;
|
|
709
|
+
if (isNaN(issueNumber)) {
|
|
710
|
+
throw new Error(`Invalid issue ID: ${issueId}`);
|
|
711
|
+
}
|
|
712
|
+
let owner = options?.owner;
|
|
713
|
+
let repo = options?.repo;
|
|
714
|
+
if (!owner || !repo) {
|
|
715
|
+
const detected = getRepoInfoFromGit();
|
|
716
|
+
if (!detected) {
|
|
717
|
+
throw new Error("Could not detect repository owner/name from git remote. " + "Please provide owner and repo options, or run from a git repository with a GitHub origin.");
|
|
718
|
+
}
|
|
719
|
+
owner = owner ?? detected.owner;
|
|
720
|
+
repo = repo ?? detected.repo;
|
|
721
|
+
}
|
|
722
|
+
const token = options?.token ?? getTokenFromEnvironment();
|
|
723
|
+
if (!token) {
|
|
724
|
+
throw new Error("No GitHub token found. Please set GITHUB_TOKEN or GH_TOKEN environment variable, " + "or provide token in options.");
|
|
725
|
+
}
|
|
726
|
+
const graphqlFn = options?.graphql ?? graphql2.defaults({
|
|
727
|
+
headers: {
|
|
728
|
+
authorization: `token ${token}`
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
const response = await graphqlFn(ISSUE_QUERY, {
|
|
732
|
+
owner,
|
|
733
|
+
repo,
|
|
734
|
+
number: issueNumber
|
|
735
|
+
});
|
|
736
|
+
const issue = response.repository.issue;
|
|
737
|
+
return {
|
|
738
|
+
number: issue.number,
|
|
739
|
+
title: issue.title,
|
|
740
|
+
body: issue.body ?? "",
|
|
741
|
+
labels: issue.labels.nodes.map((l) => l.name),
|
|
742
|
+
state: issue.state.toLowerCase()
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
export {
|
|
746
|
+
fetchGitHubIssue
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
//# debugId=C7B1D170AF05809164756E2164756E21
|