50 lines
1.4 KiB
TypeScript
Executable file
50 lines
1.4 KiB
TypeScript
Executable file
import { Project } from 'ts-morph';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
console.log("Starting utility domain split for runboard-route-logic.tsx...");
|
|
const project = new Project({
|
|
tsConfigFilePath: 'C:/ScriptoriumAI/scriptoriumai-ui/tsconfig.json'
|
|
});
|
|
|
|
const sourceFile = project.getSourceFileOrThrow('C:/ScriptoriumAI/scriptoriumai-ui/src/utils/runboard-route-logic.tsx');
|
|
|
|
const utilityTypesFile = project.createSourceFile('C:/ScriptoriumAI/scriptoriumai-ui/src/utils/runboard/runboard-utility-types.ts', '', { overwrite: true });
|
|
|
|
const typeAliases = sourceFile.getTypeAliases();
|
|
const interfaces = sourceFile.getInterfaces();
|
|
|
|
const extractedNames = [];
|
|
|
|
for (const typeAlias of [...typeAliases]) {
|
|
if (typeAlias.isExported()) {
|
|
utilityTypesFile.addTypeAlias({
|
|
...typeAlias.getStructure(),
|
|
isExported: true
|
|
});
|
|
extractedNames.push(typeAlias.getName());
|
|
typeAlias.remove();
|
|
}
|
|
}
|
|
|
|
for (const iface of [...interfaces]) {
|
|
if (iface.isExported()) {
|
|
utilityTypesFile.addInterface({
|
|
...iface.getStructure(),
|
|
isExported: true
|
|
});
|
|
extractedNames.push(iface.getName());
|
|
iface.remove();
|
|
}
|
|
}
|
|
|
|
if (extractedNames.length > 0) {
|
|
sourceFile.addImportDeclaration({
|
|
moduleSpecifier: './runboard/runboard-utility-types',
|
|
namedImports: extractedNames.map(name => ({ name })),
|
|
isTypeOnly: true
|
|
});
|
|
}
|
|
|
|
console.log("Extracted types to runboard-utility-types.ts");
|
|
project.saveSync()
|