Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

229
Visualizações
Building a CLI that needs to insert JSX elements at specific point in JSX tree

I'm looking for some direction on different tools I could use to update an existing JSX tree and insert new JSX elements / import statements via a CLI generator.

As an example, our CLI helps to build out dialog components and auto insert them into the tree so they are ready to use at the root of the project.

We have a tree that looks like this in the base of the app

<AppContainer>
  <Router routes={routeConfig} />
  <div id="dialog-holder">
    {/* LEAVE THIS IN PLACE FOR DIALOGS TO POPULATE INTO */}
  </div>
  <Snackbar />
</AppContainer>

Currently, I've used an AST walker to find this div element and insert a new line, something like this

<NewDialog />

And then add a new import statement at the top

import NewDialog from "dialogs/NewDialog"

We have a CLI working currently to do this, but we have more use cases where we would love to update files as we generate new components and other parts of our apps and working with the AST is not simple.

The CLI is built in node and currently, we are using Yeoman for the actual generator logic and functionality.

Are there any other Node tools that could be easier to work with that would allow us to do this fine file manipulation like this?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda