style: format code biome
Local Build and Deploy / deploy (push) Failing after 46s

This commit is contained in:
openhands committed 2026-07-13 21:57:41 +02:00
1 parent 8efd032cc6
commit df38dccbf1
735 files changed
+128321 -120870

No files matched your search

+45 -45
View File
@@ -10,23 +10,23 @@
// the caller can decide whether to fall back to a full re-serialization.
export interface PatchResult {
/** The new file content, with surgical edits applied. */
content: string;
/** Keys that we could not patch surgically (missing or unusual format). */
unpatchedKeys: string[];
/** The new file content, with surgical edits applied. */
content: string;
/** Keys that we could not patch surgically (missing or unusual format). */
unpatchedKeys: string[];
}
function escapeRegExp(s: string): string {
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function escapeForQuote(value: string, quote: '"' | "'"): string {
// Escape backslashes first, then the chosen quote. Newlines/tabs are
// preserved as escape sequences so we don't break the JSON5 parser.
let out = value.replace(/\\/g, "\\\\");
out = out.replace(new RegExp(quote, "g"), `\\${quote}`);
out = out.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
return out;
// Escape backslashes first, then the chosen quote. Newlines/tabs are
// preserved as escape sequences so we don't break the JSON5 parser.
let out = value.replace(/\\/g, "\\\\");
out = out.replace(new RegExp(quote, "g"), `\\${quote}`);
out = out.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
return out;
}
/**
@@ -35,44 +35,44 @@ function escapeForQuote(value: string, quote: '"' | "'"): string {
* different value in `updated`) are touched.
*/
export function patchJson5(
raw: string,
original: Record<string, string>,
updated: Record<string, string>,
raw: string,
original: Record<string, string>,
updated: Record<string, string>,
): PatchResult {
let result = raw;
const unpatchedKeys: string[] = [];
let result = raw;
const unpatchedKeys: string[] = [];
for (const [key, newVal] of Object.entries(updated)) {
if (!(key in original)) {
// Key did not exist on disk — append/merge logic is the caller's job.
unpatchedKeys.push(key);
continue;
}
if (original[key] === newVal) continue;
for (const [key, newVal] of Object.entries(updated)) {
if (!(key in original)) {
// Key did not exist on disk — append/merge logic is the caller's job.
unpatchedKeys.push(key);
continue;
}
if (original[key] === newVal) continue;
const keyPattern = `(['"]?)${escapeRegExp(key)}\\1\\s*:\\s*(["'])((?:\\\\.|(?!\\2).)*)\\2`;
const re = new RegExp(keyPattern);
const idx = result.search(re);
if (idx < 0) {
unpatchedKeys.push(key);
continue;
}
const match = re.exec(result);
if (!match) {
unpatchedKeys.push(key);
continue;
}
const keyPattern = `(['"]?)${escapeRegExp(key)}\\1\\s*:\\s*(["'])((?:\\\\.|(?!\\2).)*)\\2`;
const re = new RegExp(keyPattern);
const idx = result.search(re);
if (idx < 0) {
unpatchedKeys.push(key);
continue;
}
const match = re.exec(result);
if (!match) {
unpatchedKeys.push(key);
continue;
}
const valueQuote = match[2] as '"' | "'";
const oldValueLen = match[3].length;
const fullLen = match[0].length;
// prefix keeps everything up to and including the opening value quote
const prefix = match[0].slice(0, fullLen - oldValueLen - 1);
const escaped = escapeForQuote(newVal, valueQuote);
const replacement = prefix + escaped + valueQuote;
const valueQuote = match[2] as '"' | "'";
const oldValueLen = match[3].length;
const fullLen = match[0].length;
// prefix keeps everything up to and including the opening value quote
const prefix = match[0].slice(0, fullLen - oldValueLen - 1);
const escaped = escapeForQuote(newVal, valueQuote);
const replacement = prefix + escaped + valueQuote;
result = result.slice(0, idx) + replacement + result.slice(idx + fullLen);
}
result = result.slice(0, idx) + replacement + result.slice(idx + fullLen);
}
return { content: result, unpatchedKeys };
return { content: result, unpatchedKeys };
}