Files
metabuilder/tools/refactoring/ast-lambda-refactor/functions/replace-original.ts
copilot-swe-agent[bot] 4db87be546 Changes before error encountered
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2025-12-29 19:33:03 +00:00

29 lines
1.1 KiB
TypeScript

import * as path from 'path'
import { analyzeAstFile, astNameHelpers } from './ast/analyze-ast-file'
import { AstExtractedFunction, ExtractedImport } from './lambda/types'
import { buildAstFunctionContent } from './io/build-ast-function-content'
import { buildClassWrapper } from './io/build-class-wrapper'
import { buildIndexContent } from './io/build-index-content'
import { writeFileSafely } from './io/write-file'
import { runLintFix } from './workflow/run-lint'
async function replaceOriginal(filePath: string, basename: string, className: string, sampleFunction: string) {
const newMainContent = `/**
* This file has been refactored into modular lambda-per-file structure.
*
* Import individual functions or use the class wrapper:
* @example
* import { ${sampleFunction} } from './${basename}'
*
* @example
* import { ${className} } from './${basename}'
* ${className}.${sampleFunction}(...)
*/
export * from './${basename}'
`
await writeFileSafely(filePath, newMainContent, this.dryRun)
this.log(` ✓ Updated ${path.basename(filePath)}`)
}