@staff0rd/assist 0.518.0 → 0.519.0
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/commands/sessions/web/bundle.js +503 -502
- package/dist/index.js +42 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.519.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -10322,7 +10322,10 @@ async function fileContent(req, res) {
|
|
|
10322
10322
|
respondJson(res, 413, { error: "File too large" });
|
|
10323
10323
|
return;
|
|
10324
10324
|
}
|
|
10325
|
-
respondJson(res, 200, {
|
|
10325
|
+
respondJson(res, 200, {
|
|
10326
|
+
content: await readFile(resolved.target, "utf8"),
|
|
10327
|
+
mtimeMs: info.mtimeMs
|
|
10328
|
+
});
|
|
10326
10329
|
} catch {
|
|
10327
10330
|
respondJson(res, 404, { error: "File not found" });
|
|
10328
10331
|
}
|
|
@@ -12078,7 +12081,7 @@ async function uploadPrImage(req, res) {
|
|
|
12078
12081
|
}
|
|
12079
12082
|
|
|
12080
12083
|
// src/commands/sessions/web/writeFileContent.ts
|
|
12081
|
-
import { readFile as readFile2, writeFile as writeFile3 } from "fs/promises";
|
|
12084
|
+
import { readFile as readFile2, stat as stat3, writeFile as writeFile3 } from "fs/promises";
|
|
12082
12085
|
|
|
12083
12086
|
// src/commands/sessions/web/formatWithOxfmt.ts
|
|
12084
12087
|
import { execFile as execFile8 } from "child_process";
|
|
@@ -12108,26 +12111,50 @@ async function formatWithOxfmt(target, root) {
|
|
|
12108
12111
|
});
|
|
12109
12112
|
}
|
|
12110
12113
|
|
|
12111
|
-
// src/commands/sessions/web/
|
|
12112
|
-
async function
|
|
12113
|
-
const resolved = getFileTarget(req, res);
|
|
12114
|
-
if (!resolved) return;
|
|
12114
|
+
// src/commands/sessions/web/getFileWriteBody.ts
|
|
12115
|
+
async function getFileWriteBody(req, res) {
|
|
12115
12116
|
let body;
|
|
12116
12117
|
try {
|
|
12117
12118
|
body = await readJsonBody(req);
|
|
12118
12119
|
} catch {
|
|
12119
12120
|
respondJson(res, 400, { error: "Invalid JSON body" });
|
|
12120
|
-
return;
|
|
12121
|
+
return null;
|
|
12121
12122
|
}
|
|
12122
12123
|
if (typeof body.content !== "string") {
|
|
12123
12124
|
respondJson(res, 400, { error: "Missing content" });
|
|
12125
|
+
return null;
|
|
12126
|
+
}
|
|
12127
|
+
if (typeof body.mtimeMs !== "number") {
|
|
12128
|
+
respondJson(res, 400, { error: "Missing mtimeMs" });
|
|
12129
|
+
return null;
|
|
12130
|
+
}
|
|
12131
|
+
return { content: body.content, mtimeMs: body.mtimeMs };
|
|
12132
|
+
}
|
|
12133
|
+
|
|
12134
|
+
// src/commands/sessions/web/writeFileContent.ts
|
|
12135
|
+
var STALE_MESSAGE = "The file changed on disk since it was opened";
|
|
12136
|
+
async function currentMtimeMs(target) {
|
|
12137
|
+
try {
|
|
12138
|
+
return (await stat3(target)).mtimeMs;
|
|
12139
|
+
} catch {
|
|
12140
|
+
return null;
|
|
12141
|
+
}
|
|
12142
|
+
}
|
|
12143
|
+
async function writeFileContent(req, res) {
|
|
12144
|
+
const resolved = getFileTarget(req, res);
|
|
12145
|
+
if (!resolved) return;
|
|
12146
|
+
const body = await getFileWriteBody(req, res);
|
|
12147
|
+
if (!body) return;
|
|
12148
|
+
if (await currentMtimeMs(resolved.target) !== body.mtimeMs) {
|
|
12149
|
+
respondJson(res, 409, { error: STALE_MESSAGE });
|
|
12124
12150
|
return;
|
|
12125
12151
|
}
|
|
12126
12152
|
try {
|
|
12127
12153
|
await writeFile3(resolved.target, body.content, "utf8");
|
|
12128
12154
|
await formatWithOxfmt(resolved.target, repoRoot(resolved.cwd));
|
|
12129
12155
|
respondJson(res, 200, {
|
|
12130
|
-
content: await readFile2(resolved.target, "utf8")
|
|
12156
|
+
content: await readFile2(resolved.target, "utf8"),
|
|
12157
|
+
mtimeMs: await currentMtimeMs(resolved.target)
|
|
12131
12158
|
});
|
|
12132
12159
|
} catch (error) {
|
|
12133
12160
|
respondJson(res, 500, {
|
|
@@ -18499,10 +18526,10 @@ function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
|
18499
18526
|
continue;
|
|
18500
18527
|
const full = path32.join(dir, entry);
|
|
18501
18528
|
try {
|
|
18502
|
-
const
|
|
18503
|
-
if (
|
|
18529
|
+
const stat4 = statSync6(full);
|
|
18530
|
+
if (stat4.isFile() && entry.endsWith(".sln")) {
|
|
18504
18531
|
results.push(full);
|
|
18505
|
-
} else if (
|
|
18532
|
+
} else if (stat4.isDirectory()) {
|
|
18506
18533
|
results.push(...findSlnFiles(full, maxDepth, depth + 1));
|
|
18507
18534
|
}
|
|
18508
18535
|
} catch {
|
|
@@ -34246,13 +34273,13 @@ import { readFileSync as readFileSync54, statSync as statSync14 } from "fs";
|
|
|
34246
34273
|
import { isAbsolute as isAbsolute4, join as join78, resolve as resolve21 } from "path";
|
|
34247
34274
|
function resolveGitDir(cwd) {
|
|
34248
34275
|
const dotGit = join78(cwd, ".git");
|
|
34249
|
-
let
|
|
34276
|
+
let stat4;
|
|
34250
34277
|
try {
|
|
34251
|
-
|
|
34278
|
+
stat4 = statSync14(dotGit);
|
|
34252
34279
|
} catch {
|
|
34253
34280
|
return null;
|
|
34254
34281
|
}
|
|
34255
|
-
if (
|
|
34282
|
+
if (stat4.isDirectory()) {
|
|
34256
34283
|
return dotGit;
|
|
34257
34284
|
}
|
|
34258
34285
|
let contents;
|