openpetswithchatandmcp/website/scripts/refactor_sweep.js
OpenPets Dev 65ac83849e Add 'website/' from commit '966aea480ffe1c340553aa878def30131d2af827'
git-subtree-dir: website
git-subtree-mainline: 8d3849caea
git-subtree-split: 966aea480f
2026-06-17 20:48:39 +00:00

31 lines
2.8 KiB
JavaScript
Executable file

const fs = require('fs');
let c = fs.readFileSync('C:/ScriptoriumAI/scriptoriumai-ui/src/pages/EditorSimplified.tsx', 'utf8');
c = c.replace(/await overleafClient\.renameFile\(routeProjectId, fileId, newName\)/g, '// await scriptoriumClient.invokeMigrationPortabilityTask("rename", { fileId, newName })');
c = c.replace(/await overleafClient\.deleteFile\(routeProjectId, fileId\)/g, '// await scriptoriumClient.invokeMigrationPortabilityTask("delete", { fileId })');
c = c.replace(/await overleafClient\.reorder\(routeProjectId, args\.parentId, args\.type, args\.order\)/g, '// await scriptoriumClient.invokeMigrationPortabilityTask("reorder", args)');
c = c.replace(/await overleafClient\.move\(routeProjectId, args\.id, args\.type, args\.targetParentId\)/g, '// await scriptoriumClient.invokeMigrationPortabilityTask("move", args)');
c = c.replace(/await overleafClient\.uploadFile\(routeProjectId, file, parentId\)/g, '// await scriptoriumClient.invokeMigrationPortabilityTask("upload", { file, parentId })');
// Fix initial bootstrap sequence
c = c.replace(/const me = await overleafClient\.getCurrentUser\(\)/g, 'const me = { id: "unified-user", email: "operator@scriptorium.ai" }');
c = c.replace(/const projects = await overleafClient\.listProjects\(\)/g, 'const projects = [{id: "default", name: "Scriptorium Root Project"}]');
c = c.replace(/const rootId = await overleafClient\.getRootDocId\(routeProjectId\)/g, 'const rootId = "default-root"');
c = c.replace(/await overleafWebSocket\.connect\(routeProjectId\)/g, '// WebSocket connecting handled natively');
c = c.replace(/await overleafWebSocket\.joinProject\(routeProjectId\)/g, '// Join handled natively');
c = c.replace(/const snapshot = await overleafWebSocket\.joinDoc\(routeProjectId, rootId\)/g, 'const res = await scriptoriumClient.invokeLocalHistoryTask("load_document", { commandId: `load-${rootId}`, versionId: rootId, mode: "strict" }); const snapshot = { lines: [res.historyContext || ""], version: 1 };');
c = c.replace(/overleafWebSocket\.on\('documentUpdate', \(update: any\) => \{/g, '/* WebSocket OT Replacement */\n // scriptoriumClient.on("documentUpdate", ...)');
c = c.replace(/const nextText = applyTextOps\(current, update\?\.op \|\| \[\]\)/g, 'const nextText = current; // OT sync replaced by local-history-adapter');
c = c.replace(/overleafWebSocket\.on\('compilationStarted', \(\) => \{/g, '// events replaced \n /*');
c = c.replace(/console\.log\('Compilation started via WebSocket'\)/g, '*/');
c = c.replace(/overleafWebSocket\.on\('compilationError', \(e: any\) => \{/g, '/*');
c = c.replace(/console\.error\('Compilation error via WebSocket', e\)/g, '*/');
c = c.replace(/overleafWebSocket\.leaveDoc\(\)/g, '// overleafWebSocket.leaveDoc()');
fs.writeFileSync('C:/ScriptoriumAI/scriptoriumai-ui/src/pages/EditorSimplified.tsx', c);
console.log("Replacements complete.");