revdeck 0.3.0 → 0.3.2
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/CHANGELOG.md +19 -0
- package/README.md +11 -3
- package/README.ru.md +11 -3
- package/dist/cli.js +183 -99
- package/dist/cli.js.map +3 -3
- package/dist/daemon.js +131 -72
- package/dist/daemon.js.map +3 -3
- package/dist/mcp.js +1 -1
- package/dist/mcp.js.map +1 -1
- package/dist/ui/assets/{index-CXNMvRvo.js → index-DinUxV1o.js} +2 -2
- package/dist/ui/index.html +1 -1
- package/docs/configuration.md +2 -0
- package/docs/integrations.md +3 -2
- package/docs/ru/configuration.md +2 -0
- package/docs/ru/integrations.md +2 -2
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -299,11 +299,11 @@ function diffStats(files) {
|
|
|
299
299
|
function changedPaths(files) {
|
|
300
300
|
return files.map((file) => file.path);
|
|
301
301
|
}
|
|
302
|
-
function findFile(files,
|
|
303
|
-
return files.find((file) => file.path ===
|
|
302
|
+
function findFile(files, path10) {
|
|
303
|
+
return files.find((file) => file.path === path10) ?? files.find((file) => file.oldPath === path10);
|
|
304
304
|
}
|
|
305
|
-
function findNewLine(files,
|
|
306
|
-
const file = findFile(files,
|
|
305
|
+
function findNewLine(files, path10, line) {
|
|
306
|
+
const file = findFile(files, path10);
|
|
307
307
|
if (!file) return void 0;
|
|
308
308
|
for (const hunk of file.hunks) {
|
|
309
309
|
for (const item of hunk.lines) {
|
|
@@ -312,8 +312,8 @@ function findNewLine(files, path9, line) {
|
|
|
312
312
|
}
|
|
313
313
|
return void 0;
|
|
314
314
|
}
|
|
315
|
-
function snippetAround(files,
|
|
316
|
-
const file = findFile(files,
|
|
315
|
+
function snippetAround(files, path10, line, radius = 6) {
|
|
316
|
+
const file = findFile(files, path10);
|
|
317
317
|
if (!file || line == null) return null;
|
|
318
318
|
const flat = file.hunks.flatMap((hunk) => hunk.lines);
|
|
319
319
|
const target = flat.findIndex((item) => item.newLine === line);
|
|
@@ -326,9 +326,9 @@ function snippetAround(files, path9, line, radius = 6) {
|
|
|
326
326
|
target: item.newLine === line
|
|
327
327
|
}));
|
|
328
328
|
}
|
|
329
|
-
function linePosition(files,
|
|
330
|
-
const file = findFile(files,
|
|
331
|
-
const found = findNewLine(files,
|
|
329
|
+
function linePosition(files, path10, line) {
|
|
330
|
+
const file = findFile(files, path10);
|
|
331
|
+
const found = findNewLine(files, path10, line);
|
|
332
332
|
if (!file || !found) return null;
|
|
333
333
|
return { newPath: file.path, newLine: line, oldPath: file.oldPath, oldLine: found.kind === " " ? found.oldLine : null };
|
|
334
334
|
}
|
|
@@ -344,6 +344,9 @@ var init_diff = __esm({
|
|
|
344
344
|
|
|
345
345
|
// src/core/exec.ts
|
|
346
346
|
import { execFile } from "node:child_process";
|
|
347
|
+
import { access, constants } from "node:fs/promises";
|
|
348
|
+
import os2 from "node:os";
|
|
349
|
+
import path5 from "node:path";
|
|
347
350
|
function scrubEnv(extra) {
|
|
348
351
|
const env = {};
|
|
349
352
|
for (const [key, value] of Object.entries(process.env)) {
|
|
@@ -359,7 +362,45 @@ function scrubEnv(extra) {
|
|
|
359
362
|
env.TERM = "dumb";
|
|
360
363
|
return { ...env, ...extra };
|
|
361
364
|
}
|
|
362
|
-
|
|
365
|
+
async function resolveExecutable(command) {
|
|
366
|
+
if (command.includes("/") || command.includes("\\")) {
|
|
367
|
+
try {
|
|
368
|
+
await access(command, constants.X_OK);
|
|
369
|
+
return command;
|
|
370
|
+
} catch {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
const override = process.env[`REVDECK_${command.toUpperCase()}`];
|
|
375
|
+
if (override) return override;
|
|
376
|
+
const cached = RESOLVED.get(command);
|
|
377
|
+
if (cached) return cached;
|
|
378
|
+
const dirs = [
|
|
379
|
+
...(process.env.PATH ?? "").split(path5.delimiter),
|
|
380
|
+
path5.join(os2.homedir(), ".local", "bin"),
|
|
381
|
+
path5.join(os2.homedir(), ".local", "share", "mise", "shims"),
|
|
382
|
+
path5.join(os2.homedir(), ".asdf", "shims"),
|
|
383
|
+
path5.join(os2.homedir(), ".npm-global", "bin"),
|
|
384
|
+
"/opt/homebrew/bin",
|
|
385
|
+
"/usr/local/bin",
|
|
386
|
+
"/usr/bin",
|
|
387
|
+
"/bin"
|
|
388
|
+
].filter(Boolean);
|
|
389
|
+
const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
390
|
+
for (const dir of [...new Set(dirs)]) {
|
|
391
|
+
for (const extension of extensions) {
|
|
392
|
+
const candidate = path5.join(dir, `${command}${extension}`);
|
|
393
|
+
try {
|
|
394
|
+
await access(candidate, constants.X_OK);
|
|
395
|
+
RESOLVED.set(command, candidate);
|
|
396
|
+
return candidate;
|
|
397
|
+
} catch {
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
var SECRET_ENV, RESOLVED, run;
|
|
363
404
|
var init_exec = __esm({
|
|
364
405
|
"src/core/exec.ts"() {
|
|
365
406
|
"use strict";
|
|
@@ -375,41 +416,45 @@ var init_exec = __esm({
|
|
|
375
416
|
"SSH_ASKPASS",
|
|
376
417
|
"REVDECK_TOKEN"
|
|
377
418
|
];
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
419
|
+
RESOLVED = /* @__PURE__ */ new Map();
|
|
420
|
+
run = async (command, args, options = {}) => {
|
|
421
|
+
const executable = await resolveExecutable(command) ?? command;
|
|
422
|
+
return new Promise((resolve, reject) => {
|
|
423
|
+
const child = execFile(
|
|
424
|
+
executable,
|
|
425
|
+
args,
|
|
426
|
+
{
|
|
427
|
+
cwd: options.cwd,
|
|
428
|
+
env: scrubEnv(options.env),
|
|
429
|
+
timeout: options.timeoutMs ?? 12e4,
|
|
430
|
+
maxBuffer: options.maxBuffer ?? 64 * 1024 * 1024,
|
|
431
|
+
encoding: "utf8",
|
|
432
|
+
windowsHide: true,
|
|
433
|
+
shell: false
|
|
434
|
+
},
|
|
435
|
+
(error, stdout, stderr) => {
|
|
436
|
+
const exitCode = error?.code;
|
|
437
|
+
const code = typeof exitCode === "number" ? exitCode : error ? 1 : 0;
|
|
438
|
+
if (error && !(options.allowExitCodes ?? []).includes(code)) {
|
|
439
|
+
const reason = (stderr || stdout || error.message).trim();
|
|
440
|
+
reject(Object.assign(new Error(reason.slice(0, 4e3)), { command, code, stderr, stdout }));
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
resolve({ stdout, stderr, code });
|
|
398
444
|
}
|
|
399
|
-
|
|
445
|
+
);
|
|
446
|
+
if (options.input !== void 0) {
|
|
447
|
+
child.stdin?.end(options.input);
|
|
400
448
|
}
|
|
401
|
-
);
|
|
402
|
-
|
|
403
|
-
child.stdin?.end(options.input);
|
|
404
|
-
}
|
|
405
|
-
});
|
|
449
|
+
});
|
|
450
|
+
};
|
|
406
451
|
}
|
|
407
452
|
});
|
|
408
453
|
|
|
409
454
|
// src/providers/util.ts
|
|
410
455
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
411
456
|
import { tmpdir } from "node:os";
|
|
412
|
-
import
|
|
457
|
+
import path6 from "node:path";
|
|
413
458
|
function parseJson(stdout, source) {
|
|
414
459
|
const text2 = stdout.trim();
|
|
415
460
|
if (!text2) throw new ProviderError(tr(`${source}: \u043F\u0443\u0441\u0442\u043E\u0439 \u043E\u0442\u0432\u0435\u0442`, `${source}: empty response`));
|
|
@@ -422,6 +467,16 @@ function parseJson(stdout, source) {
|
|
|
422
467
|
function cliError(error, platform, host) {
|
|
423
468
|
const message = redact(error?.message ?? error).trim();
|
|
424
469
|
const lower = message.toLowerCase();
|
|
470
|
+
if (/enoent|executable file not found|spawn .* enoent/.test(lower)) {
|
|
471
|
+
const binary = platform === "gitlab" ? "glab" : "gh";
|
|
472
|
+
throw new ProviderError(
|
|
473
|
+
`${platform}: ${message}`,
|
|
474
|
+
tr(
|
|
475
|
+
`${binary} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u0432 PATH \u0434\u0435\u043C\u043E\u043D\u0430: \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0435 \u0435\u0433\u043E, \u0434\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u0432 PATH \u0438\u043B\u0438 \u0437\u0430\u0434\u0430\u0439\u0442\u0435 REVDECK_${binary.toUpperCase()}; \u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 revdeck doctor. \u0415\u0441\u043B\u0438 \u0434\u0435\u043C\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0432 \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0435 \u2014 \u043F\u0435\u0440\u0435\u043D\u0435\u0441\u0438\u0442\u0435 \u0435\u0433\u043E \u043D\u0430 \u0445\u043E\u0441\u0442`,
|
|
476
|
+
`${binary} is not in the daemon PATH: install it, add its directory to PATH or set REVDECK_${binary.toUpperCase()}; check revdeck doctor. If the daemon runs in a container, move it to the host`
|
|
477
|
+
)
|
|
478
|
+
);
|
|
479
|
+
}
|
|
425
480
|
if (/(auth|unauthor|401|403|not logged|token|credential|forbidden)/.test(lower)) {
|
|
426
481
|
const hint = platform === "gitlab" ? tr(`\u0432\u043E\u0439\u0434\u0438\u0442\u0435 \u0432 glab \u043D\u0430 \u044D\u0442\u043E\u043C \u0445\u043E\u0441\u0442\u0435: glab auth login --hostname ${host}`, `log in to glab for this host: glab auth login --hostname ${host}`) : tr(`\u0432\u043E\u0439\u0434\u0438\u0442\u0435 \u0432 gh: GH_HOST=${host} gh auth login`, `log in to gh: GH_HOST=${host} gh auth login`);
|
|
427
482
|
throw new AuthError(`${platform}: ${message || tr("\u043D\u0435\u0442 \u0430\u0432\u0442\u043E\u0440\u0438\u0437\u0430\u0446\u0438\u0438", "not authenticated")}`, hint);
|
|
@@ -430,8 +485,8 @@ function cliError(error, platform, host) {
|
|
|
430
485
|
throw new ProviderError(`${platform}: ${message || tr("\u043A\u043E\u043C\u0430\u043D\u0434\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043B\u0430\u0441\u044C \u0441 \u043E\u0448\u0438\u0431\u043A\u043E\u0439", "the command failed")}`);
|
|
431
486
|
}
|
|
432
487
|
async function withTempJson(data, fn) {
|
|
433
|
-
const dir = await mkdtemp(
|
|
434
|
-
const file =
|
|
488
|
+
const dir = await mkdtemp(path6.join(tmpdir(), "revdeck-"));
|
|
489
|
+
const file = path6.join(dir, "payload.json");
|
|
435
490
|
try {
|
|
436
491
|
await writeFile(file, JSON.stringify(data), { mode: 384, flag: "wx" });
|
|
437
492
|
return await fn(file);
|
|
@@ -439,8 +494,8 @@ async function withTempJson(data, fn) {
|
|
|
439
494
|
await rm(dir, { recursive: true, force: true });
|
|
440
495
|
}
|
|
441
496
|
}
|
|
442
|
-
function query(
|
|
443
|
-
const url = new URL(
|
|
497
|
+
function query(path10, params) {
|
|
498
|
+
const url = new URL(path10.startsWith("/") ? path10 : `/${path10}`, "http://local");
|
|
444
499
|
for (const [key, value] of Object.entries(params)) {
|
|
445
500
|
if (value !== void 0 && value !== "") url.searchParams.set(key, String(value));
|
|
446
501
|
}
|
|
@@ -543,6 +598,7 @@ var init_gitlab = __esm({
|
|
|
543
598
|
sourceBranch: String(mr.source_branch ?? ""),
|
|
544
599
|
targetBranch: String(mr.target_branch ?? ""),
|
|
545
600
|
webUrl: String(mr.web_url ?? ""),
|
|
601
|
+
...typeof mr.project_id === "number" ? { projectId: mr.project_id } : {},
|
|
546
602
|
commit: { base, start, head },
|
|
547
603
|
updatedAt: String(mr.updated_at ?? ""),
|
|
548
604
|
stats: { files: Number.isFinite(files) ? files : 0, additions: 0, deletions: 0 }
|
|
@@ -691,7 +747,8 @@ rename to ${newPath}
|
|
|
691
747
|
const uploaded = await this.json(["--method", "POST", endpoint, "--form", `file=@${input.path}`]);
|
|
692
748
|
const raw = uploaded.full_path || uploaded.url || "";
|
|
693
749
|
if (!raw) throw new ProviderError(tr("GitLab \u043D\u0435 \u0432\u0435\u0440\u043D\u0443\u043B \u0441\u0441\u044B\u043B\u043A\u0443 \u043D\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043D\u044B\u0439 \u0444\u0430\u0439\u043B", "GitLab did not return a link to the uploaded file"));
|
|
694
|
-
const
|
|
750
|
+
const projectId = (await this.info().catch(() => null))?.projectId;
|
|
751
|
+
const absolute = raw.startsWith("http://") || raw.startsWith("https://") ? raw : raw.startsWith("/uploads/") && projectId ? `https://${this.ref.host}/-/project/${projectId}${raw}` : `https://${this.ref.host}${raw.startsWith("/") ? "" : "/"}${raw}`;
|
|
695
752
|
const label = input.name.replace(/[[\]\r\n]/g, " ").trim() || "attachment";
|
|
696
753
|
const markdown = input.contentType.startsWith("image/") || input.contentType.startsWith("video/") ? `` : `[${label}](${absolute})`;
|
|
697
754
|
return { name: input.name, url: absolute, markdown };
|
|
@@ -1057,7 +1114,7 @@ rename to ${newPath}
|
|
|
1057
1114
|
import { existsSync as existsSync4, readFileSync } from "node:fs";
|
|
1058
1115
|
import { appendFile, open as open2, readFile as readFile3, unlink as unlink4 } from "node:fs/promises";
|
|
1059
1116
|
import net2 from "node:net";
|
|
1060
|
-
import
|
|
1117
|
+
import path9 from "node:path";
|
|
1061
1118
|
import { fileURLToPath } from "node:url";
|
|
1062
1119
|
import { parseArgs } from "node:util";
|
|
1063
1120
|
|
|
@@ -1165,7 +1222,7 @@ async function writeFileAtomic(file, data, mode = 384) {
|
|
|
1165
1222
|
init_redact();
|
|
1166
1223
|
|
|
1167
1224
|
// src/version.ts
|
|
1168
|
-
var VERSION = "0.3.
|
|
1225
|
+
var VERSION = "0.3.2";
|
|
1169
1226
|
var PROTOCOL_VERSION = 1;
|
|
1170
1227
|
|
|
1171
1228
|
// src/daemon/main.ts
|
|
@@ -1720,7 +1777,7 @@ import { EventEmitter } from "node:events";
|
|
|
1720
1777
|
import { createHash as createHash2, randomBytes } from "node:crypto";
|
|
1721
1778
|
import { mkdtemp as mkdtemp2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
1722
1779
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
1723
|
-
import
|
|
1780
|
+
import path7 from "node:path";
|
|
1724
1781
|
|
|
1725
1782
|
// src/core/config.ts
|
|
1726
1783
|
import { z } from "zod";
|
|
@@ -1773,8 +1830,8 @@ function globToRegExp(glob) {
|
|
|
1773
1830
|
function escapeRegExp(value) {
|
|
1774
1831
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1775
1832
|
}
|
|
1776
|
-
function classifyFile(
|
|
1777
|
-
const lower =
|
|
1833
|
+
function classifyFile(path10) {
|
|
1834
|
+
const lower = path10.toLowerCase();
|
|
1778
1835
|
if (/(^|\/)(node_modules|dist|build|coverage|vendor)\//.test(lower)) return "generated";
|
|
1779
1836
|
if (/\.(md|mdx|rst|txt|adoc)$/.test(lower) || /(^|\/)(docs?|adr)\//.test(lower)) return "docs";
|
|
1780
1837
|
if (/(^|\/)(__tests__|tests?|spec|e2e)\//.test(lower) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(lower) || /_test\.go$/.test(lower)) return "test";
|
|
@@ -2134,12 +2191,11 @@ function imageIssue(text2, host) {
|
|
|
2134
2191
|
}
|
|
2135
2192
|
return null;
|
|
2136
2193
|
}
|
|
2137
|
-
function normalizeMediaLinks(body, platform, host) {
|
|
2138
|
-
if (platform !== "gitlab" || !host) return body;
|
|
2139
|
-
const
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
});
|
|
2194
|
+
function normalizeMediaLinks(body, platform, host, projectId) {
|
|
2195
|
+
if (platform !== "gitlab" || !host || !projectId) return body;
|
|
2196
|
+
const escaped = host.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2197
|
+
const correct = `https://${host}/-/project/${projectId}/uploads/`;
|
|
2198
|
+
return body.replace(new RegExp(`https?://${escaped}/uploads/`, "g"), correct).replace(new RegExp(`https?://${escaped}/-/project/\\d+/uploads/`, "g"), correct);
|
|
2143
2199
|
}
|
|
2144
2200
|
|
|
2145
2201
|
// src/core/attachments.ts
|
|
@@ -2838,8 +2894,8 @@ ${errors.join("\n")}`));
|
|
|
2838
2894
|
if (!matchesSignature(buffer, spec.contentType)) {
|
|
2839
2895
|
throw new Error(tr("\u0432\u043B\u043E\u0436\u0435\u043D\u0438\u0435: \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u0435 \u043D\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0430\u0435\u0442 \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043D\u0438\u0435\u043C", "attachment: content does not match the extension"));
|
|
2840
2896
|
}
|
|
2841
|
-
const dir = await mkdtemp2(
|
|
2842
|
-
const file =
|
|
2897
|
+
const dir = await mkdtemp2(path7.join(tmpdir4(), "revdeck-attachment-"));
|
|
2898
|
+
const file = path7.join(dir, spec.name);
|
|
2843
2899
|
try {
|
|
2844
2900
|
await writeFile2(file, buffer, { mode: 384, flag: "wx" });
|
|
2845
2901
|
const uploaded = await provider.upload({ path: file, name: spec.name, contentType: spec.contentType });
|
|
@@ -2922,8 +2978,8 @@ ${errors.join("\n")}`));
|
|
|
2922
2978
|
continue;
|
|
2923
2979
|
}
|
|
2924
2980
|
const rawBody = draft.body.trim();
|
|
2925
|
-
const body2 = normalizeMediaLinks(rawBody, review.info.ref.platform, review.info.ref.host);
|
|
2926
|
-
const posted = normalizeMediaLinks(draft.posted.trim(), review.info.ref.platform, review.info.ref.host);
|
|
2981
|
+
const body2 = normalizeMediaLinks(rawBody, review.info.ref.platform, review.info.ref.host, review.info.projectId);
|
|
2982
|
+
const posted = normalizeMediaLinks(draft.posted.trim(), review.info.ref.platform, review.info.ref.host, review.info.projectId);
|
|
2927
2983
|
const alreadyPosted = rawBody !== "" && posted === body2;
|
|
2928
2984
|
const resolveChanged = draft.resolve !== thread.resolved;
|
|
2929
2985
|
if (!body2 && !resolveChanged) {
|
|
@@ -2954,7 +3010,7 @@ ${errors.join("\n")}`));
|
|
|
2954
3010
|
warnings.push(tr(`\u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0435 ${finding.id} \u0443\u0436\u0435 \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D\u043E`, `finding ${finding.id} is already published`));
|
|
2955
3011
|
continue;
|
|
2956
3012
|
}
|
|
2957
|
-
const body2 = normalizeMediaLinks(finding.comment.trim(), review.info.ref.platform, review.info.ref.host);
|
|
3013
|
+
const body2 = normalizeMediaLinks(finding.comment.trim(), review.info.ref.platform, review.info.ref.host, review.info.projectId);
|
|
2958
3014
|
const check2 = sanitizeBody(body2, review.info.ref.platform, { host: review.info.ref.host });
|
|
2959
3015
|
if (!check2.ok) {
|
|
2960
3016
|
warnings.push(tr(`\u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0435 ${finding.id}: ${check2.reason}`, `finding ${finding.id}: ${check2.reason}`));
|
|
@@ -2980,7 +3036,7 @@ ${errors.join("\n")}`));
|
|
|
2980
3036
|
warnings.push(tr(`\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439 ${note.id} \u0443\u0436\u0435 \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D`, `comment ${note.id} is already published`));
|
|
2981
3037
|
continue;
|
|
2982
3038
|
}
|
|
2983
|
-
const body = normalizeMediaLinks(note.text, review.info.ref.platform, review.info.ref.host);
|
|
3039
|
+
const body = normalizeMediaLinks(note.text, review.info.ref.platform, review.info.ref.host, review.info.projectId);
|
|
2984
3040
|
const check = sanitizeBody(body, review.info.ref.platform, { host: review.info.ref.host });
|
|
2985
3041
|
if (!check.ok) {
|
|
2986
3042
|
warnings.push(tr(`\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439 ${note.id}: ${check.reason}`, `comment ${note.id}: ${check.reason}`));
|
|
@@ -3318,7 +3374,7 @@ init_errors();
|
|
|
3318
3374
|
import http from "node:http";
|
|
3319
3375
|
import { createReadStream } from "node:fs";
|
|
3320
3376
|
import { readFile as readFile2, stat } from "node:fs/promises";
|
|
3321
|
-
import
|
|
3377
|
+
import path8 from "node:path";
|
|
3322
3378
|
import { timingSafeEqual } from "node:crypto";
|
|
3323
3379
|
|
|
3324
3380
|
// src/daemon/rpc.ts
|
|
@@ -3326,11 +3382,14 @@ import net from "node:net";
|
|
|
3326
3382
|
import { chmod, unlink as unlink2 } from "node:fs/promises";
|
|
3327
3383
|
init_redact();
|
|
3328
3384
|
init_errors();
|
|
3385
|
+
init_exec();
|
|
3329
3386
|
var MAX_LINE = 40 * 1024 * 1024;
|
|
3330
3387
|
async function dispatch(service, method, params) {
|
|
3331
3388
|
switch (method) {
|
|
3332
|
-
case "ping":
|
|
3333
|
-
|
|
3389
|
+
case "ping": {
|
|
3390
|
+
const [glab, gh, git] = await Promise.all(["glab", "gh", "git"].map((name) => resolveExecutable(name)));
|
|
3391
|
+
return { ok: true, version: VERSION, protocol: PROTOCOL_VERSION, pid: process.pid, binaries: { glab, gh, git } };
|
|
3392
|
+
}
|
|
3334
3393
|
case "reviews.list":
|
|
3335
3394
|
return { reviews: service.listReviews() };
|
|
3336
3395
|
case "reviews.open": {
|
|
@@ -3607,15 +3666,15 @@ async function startHttpServer(options) {
|
|
|
3607
3666
|
res.end('<meta charset="utf-8"><h1>\u041D\u0443\u0436\u043D\u0430 \u0441\u0441\u044B\u043B\u043A\u0430 \u0437\u0430\u043F\u0443\u0441\u043A\u0430</h1><p>\u041E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 \u0430\u0434\u0440\u0435\u0441 \u0438\u0437 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0430: \u043E\u043D \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442 \u043E\u0434\u043D\u043E\u0440\u0430\u0437\u043E\u0432\u044B\u0439 \u0442\u043E\u043A\u0435\u043D.</p>');
|
|
3608
3667
|
return;
|
|
3609
3668
|
}
|
|
3610
|
-
const html = await readFile2(
|
|
3669
|
+
const html = await readFile2(path8.join(options.uiDir, "index.html"));
|
|
3611
3670
|
res.writeHead(200, { ...SECURITY_HEADERS, "content-type": MIME[".html"], "cache-control": "no-store" });
|
|
3612
3671
|
res.end(html);
|
|
3613
3672
|
return;
|
|
3614
3673
|
}
|
|
3615
3674
|
if (req.method === "GET" && (url.pathname.startsWith("/assets/") || url.pathname === "/favicon.svg")) {
|
|
3616
3675
|
const relative = url.pathname === "/favicon.svg" ? "favicon.svg" : url.pathname.slice("/assets/".length);
|
|
3617
|
-
const target =
|
|
3618
|
-
if (!target.startsWith(
|
|
3676
|
+
const target = path8.resolve(options.uiDir, url.pathname === "/favicon.svg" ? "" : "assets", relative);
|
|
3677
|
+
if (!target.startsWith(path8.resolve(options.uiDir) + path8.sep) || relative.includes("..")) {
|
|
3619
3678
|
reply(res, 404, { ok: false, error: "\u043D\u0435\u0442 \u0444\u0430\u0439\u043B\u0430" });
|
|
3620
3679
|
return;
|
|
3621
3680
|
}
|
|
@@ -3626,7 +3685,7 @@ async function startHttpServer(options) {
|
|
|
3626
3685
|
}
|
|
3627
3686
|
res.writeHead(200, {
|
|
3628
3687
|
...SECURITY_HEADERS,
|
|
3629
|
-
"content-type": MIME[
|
|
3688
|
+
"content-type": MIME[path8.extname(target)] ?? "application/octet-stream",
|
|
3630
3689
|
"cache-control": "public, max-age=31536000, immutable"
|
|
3631
3690
|
});
|
|
3632
3691
|
createReadStream(target).pipe(res);
|
|
@@ -3915,7 +3974,7 @@ async function main() {
|
|
|
3915
3974
|
});
|
|
3916
3975
|
const socket = socketPath();
|
|
3917
3976
|
const rpc = await startRpcServer(service, socket);
|
|
3918
|
-
const uiDir = values["ui-dir"] ?
|
|
3977
|
+
const uiDir = values["ui-dir"] ? path9.resolve(values["ui-dir"]) : path9.join(packageRoot(), "dist", "ui");
|
|
3919
3978
|
const http2 = await startHttpServer({
|
|
3920
3979
|
service,
|
|
3921
3980
|
token,
|
|
@@ -3966,7 +4025,7 @@ async function main() {
|
|
|
3966
4025
|
service.close();
|
|
3967
4026
|
await unlink4(daemonInfoPath()).catch(() => void 0);
|
|
3968
4027
|
await lock.close().catch(() => void 0);
|
|
3969
|
-
await unlink4(
|
|
4028
|
+
await unlink4(path9.join(stateDir(), "daemon.lock")).catch(() => void 0);
|
|
3970
4029
|
process.exit(0);
|
|
3971
4030
|
}
|
|
3972
4031
|
};
|
|
@@ -3978,9 +4037,9 @@ async function main() {
|
|
|
3978
4037
|
}
|
|
3979
4038
|
}
|
|
3980
4039
|
function packageRoot() {
|
|
3981
|
-
let dir =
|
|
4040
|
+
let dir = path9.dirname(fileURLToPath(import.meta.url));
|
|
3982
4041
|
for (; ; ) {
|
|
3983
|
-
const candidate =
|
|
4042
|
+
const candidate = path9.join(dir, "package.json");
|
|
3984
4043
|
if (existsSync4(candidate)) {
|
|
3985
4044
|
try {
|
|
3986
4045
|
const parsed = JSON.parse(readFileSync(candidate, "utf8"));
|
|
@@ -3988,7 +4047,7 @@ function packageRoot() {
|
|
|
3988
4047
|
} catch {
|
|
3989
4048
|
}
|
|
3990
4049
|
}
|
|
3991
|
-
const parent =
|
|
4050
|
+
const parent = path9.dirname(dir);
|
|
3992
4051
|
if (parent === dir) return process.cwd();
|
|
3993
4052
|
dir = parent;
|
|
3994
4053
|
}
|
|
@@ -4027,7 +4086,7 @@ async function runningDaemon() {
|
|
|
4027
4086
|
return reachable ? info : null;
|
|
4028
4087
|
}
|
|
4029
4088
|
async function acquireLock() {
|
|
4030
|
-
const file =
|
|
4089
|
+
const file = path9.join(stateDir(), "daemon.lock");
|
|
4031
4090
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
4032
4091
|
try {
|
|
4033
4092
|
const handle = await open2(file, "wx", 384);
|