Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!