Your Privacy

This site uses cookies to enhance your browsing experience and deliver personalized content. By continuing to use this site, you consent to our use of cookies.
COOKIE POLICY

Skip to main content

Consolidate Your Development Scripts by Writing Your Own CLI

Consolidate Your Development Scripts by Writing Your Own CLI
Back to insights

Do you have a list of shell or batch scripts sitting inside your codebase that perform development tasks? Have you ever had to implement the same script in a different language because most of your team uses Unix/Linux, but a fraction of your team uses Windows? Does your team store the scripts in various places or different languages?   

I recently reflected on this problem while working with a client on an application distributed across a few repositories. I produced a solution that helped overcome some of the script blight that was affecting our project. My solution was to build a Command Line Interface (CLI) for my team. Back in the day, building a CLI was tedious, but now it is easy! Let’s dig into the problems we were able to overcome by creating our own tooling!  

We had three different code repositories with scripts in each repository responsible for various development tasks on our project. One repository had a series of Docker configurations responsible for spinning up the stack for our application. Another repository had a series of scripts for generating code and generating types from our API. And finally, another project had a code for exporting information from an authentication service. If you need to run any of these scripts, the expectation is that you would change your directory to run the scripts in that other project. When I initially solved this problem, I wrote a shell script to alias a bunch of the scripts, so I had access to them across all the projects. It was a crude solution that barely worked. I am not great at writing shell scripts, so this solution certainly lacked polish. But the real problem was I moved over to working on a Windows laptop, and the shell scripts would not run in PowerShell, and more importantly, I didn’t want to change directories constantly. We needed something that felt native to our team, something in JavaScript.  

I went for the cross-platform JavaScript solution and decided to write my own NodeJS CLI. Usually, writing a CLI by hand in NodeJS is complicated. Fortunately, I already knew about Gluegun, which is a CLI builder that is open source. First, if you have never used Gluegun, one word to describe it is astonishing! I had used it previously to write generators. I have also used other popular tools like Plop.js and Yeoman. Gluegun gives you more freedom within the tool and is intuitive in a way that the other tools are not. It does not just do code generation either! It comes with a toolbox that gives you all things a good CLI needs. The toolbox contains methods for interacting with the file system, executing CLI commands, collecting input, and pretty-printing with colors, to name a few. Commands are all located in a single directory and can be extended by building plugins for your CLI. Honestly, I can go on for hours about how cool this tool is, and if you do not want to take my word for it, the AWS (Amazon Web Services) Amplify CLI team thinks it is cool too! Sorry, rant over!  

Using Gluegun, I was able to consolidate a few commands to help my development process a ton. I could execute scripts to launch my front end for local development, spin up my Docker containers, and launch a local windows application in one command. The best part is I did not have to change to three different directories to launch these services, and it will work for my team working with Unix/Linux or my team working on Windows. I can now run the tool for updating our types based on our API. In addition, I added some quality-of-life scripts for clearing out caches that I usually did by hand. The best part is that I can now share these scripts with my team by creating a new repository/package! I intend to add the generators that we previously wrote in Plop.js to be our one-stop-shop for developing our specific application.  

As our team adds new scripts, we will have a central location to put the scripts in for working with the application regardless of the repository the scripts directly influence. Now our team can write the scripts once and run them on Windows or Unix/Linux! And finally, we can start everything we need without changing directories 1000 times a day! 

 

Digging In

  • Digital Products

    What to Ask in a UX Discovery Session

    Better questions lead to better design. In my years as a UI/UX designer, I’ve learned that many design challenges may come from misalignment at the start. Discovery sessions are where product clarity is either made or missed. These are a few discovery questions I consistently return to in the discovery phase of my UX design […]

  • Digital Products

    Designing For Play and Friction in a Fast-Paced World

    At UDig, play is an integral part of our philosophy. “Having fun” is embedded in our culture, and we always find opportunities to use play to encourage collaboration, ignite creativity, and make room for bold experimentation to build stronger teams and solve problems ranging from the seemingly simple to the most complex. I always have […]

  • Digital Products

    Config 2025 Day Two Recap

    It felt as though Config 2025 ended as soon as it began, and I believe those of us that attended are all the better for it. By the end of the day, various inspirational and informative talks had been given by thought leaders and innovators in the product space. Between sessions, we had the opportunity […]

  • Digital Products

    Inside Config 2025: What’s New in Figma

    Config 2025 kicked off with a bang on Day 1. Figma’s annual conference brings together designers, developers, and all those involved in the making of a product. The 2-day event has a stacked lineup of accomplished speakers ready to share their insights on the world of product building. At today’s opening keynote, the Figma team, […]

  • Digital Products

    Choosing the Right Modernization Approach

    When organizations decide it’s time to modernize their technology infrastructure, choosing the right approach is crucial. Modernization isn’t merely a technical upgrade; it’s a strategic business move that significantly impacts growth, agility, and long-term success. Here’s how your company can effectively begin to select the best modernization strategy tailored to your goals and challenges. In […]

  • Digital Products

    TAG Panel: Differentiate Your Customer Experience

    Join the CX and Product Management Societies to hear from our panel of Human-Centered Design experts on the business value of Agentic AI.