43 lines
1.4 KiB
JavaScript
Executable file
43 lines
1.4 KiB
JavaScript
Executable file
const fs = require('fs');
|
|
const runboardPath = 'C:/ScriptoriumAI/scriptoriumai-ui/src/pages/Runboard.tsx';
|
|
const lines = fs.readFileSync(runboardPath, 'utf8').split('\n');
|
|
|
|
const splitLineIdx = lines.findIndex(line => line.startsWith('export function Runboard() {'));
|
|
if (splitLineIdx === -1) throw new Error('Not found: export function Runboard');
|
|
|
|
const helperLines = lines.slice(0, splitLineIdx);
|
|
const updatedHelperLines = helperLines.map(line => {
|
|
return line.replace(/from '\.\//g, 'from \'../pages/');
|
|
});
|
|
|
|
fs.writeFileSync('C:/ScriptoriumAI/scriptoriumai-ui/src/utils/runboard-route-logic.tsx', updatedHelperLines.join('\n'));
|
|
|
|
const exportsList = [];
|
|
for (let i=0; i<helperLines.length; i++) {
|
|
const match = helperLines[i].match(/^export (?:function|type) ([a-zA-Z0-9_]+)/);
|
|
if (match) exportsList.push(match[1]);
|
|
}
|
|
|
|
const runboardLines = lines.slice(splitLineIdx);
|
|
|
|
const topImports = [];
|
|
let inImport = false;
|
|
for (let i=0; i<helperLines.length; i++) {
|
|
const line = helperLines[i];
|
|
if (line.startsWith('import ')) inImport = true;
|
|
if (inImport) {
|
|
topImports.push(line);
|
|
if (line.includes('from ')) inImport = false;
|
|
}
|
|
}
|
|
|
|
const newRunboardContent = [
|
|
...topImports,
|
|
'import { ' + exportsList.join(', ') + ' } from \'../utils/runboard-route-logic\';',
|
|
'',
|
|
...runboardLines
|
|
].join('\n');
|
|
|
|
fs.writeFileSync('C:/ScriptoriumAI/scriptoriumai-ui/src/pages/Runboard.tsx', newRunboardContent);
|
|
console.log('Done!');
|
|
|