Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add getTsMorphProject method #4414

Merged
merged 4 commits into from Feb 24, 2024
Merged

Conversation

Julien-R44
Copy link
Member

@Julien-R44 Julien-R44 commented Feb 17, 2024

Two things :

  • add a getTsMorphProject() method on Codemods class. so that users can make their own codemods as explained in refactor: make project public in CodeTransformer assembler#74

    export async function configure(command: Configure) {
       const codemods = await command.createCodemods()
       const project = await codemods.getTsMorphProject()
     
      // can do whatever I want
       project.getSourceFileOrThrow('file.ts').addImportDeclaration({
         moduleSpecifier: 'ts-morph',
         namedImports: ['Project'],
       })
    }
  • Refactoring the Codemods class so as to create just one instance of ts-morph and CodeTransformer. Creating an instance of ts-morph is a costly operation

@Julien-R44 Julien-R44 marked this pull request as draft February 17, 2024 20:23
Base automatically changed from feat/codemods-plugins to develop February 24, 2024 15:16
Otherwise we have a nasty ` The inferred type of 'getTsMorphProject' cannot be named without a reference to ....`
@Julien-R44 Julien-R44 marked this pull request as ready for review February 24, 2024 15:24
@Julien-R44 Julien-R44 merged commit ee96efe into develop Feb 24, 2024
12 checks passed
@Julien-R44 Julien-R44 deleted the feat/get-code-transformer branch February 24, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant