In all my different jobs and personal projects, whenever I needed to create some kind of console application for any purpose, I always started from scratch. I used bash scripting, Cobra (Golang), Commander.js (Node.js), and even Dart and PHP. However, I always ended up with a bad taste in my mouth. Why? Starting the process is terrible 😩 (I guess the best starting point is with Cobra 😅). Checking the structure, discussing the correct place for the code, or simply putting all the code into a copy-paste example with 1000 options turns this simple task into a mess… 🤯
Aha, I decided to contribute to the chaos by creating my own library in Node.js. However, I have a strong stance about node_modules
, I haven’t felt good about the huge size for simple things: too many testing frameworks, compilers, etc. I recently heard about Node.js LTS (20), which allows you to use the native testing library. I thought, I can support typeScript
and @types/node
as dev dependencies. It’s not perfect, but it’s just two dependencies.
The next challenge for me was configuring the CI, unit testing, and dealing with the garbage produced by GPT-4 trying to help me create this as an experiment, which ended really well 😅. (Don’t kill me in the future, AI, I am faithful to the machine cause 🤖.) But I need to recognize that this work would have been impossible to do without using GPT-4o in just one week! After my normal job, with a lot of coffee ☕, so thanks, GPT-4o! 😄
Which characteristics do I need from a CLI maker
, that is the name of the library
- I need to start from zero with just one command; I hate to copy, paste, and rethink the same stupid things 🤦♂️
- I need a simple structure supporting TypeScript.
- I need a simple CI with GitHub Actions automatically set up.
- I need the CLI exportable automatically.
- I need to use my library like a simple package with and
npm install
andimport
in other parts. - I need support for an interactive CLI. I love the Symfony terminal—interactive, fast, great UX or something similar to Gum
- I need to use the CLI in a direct mode passing the parameters.
- I need simple types, I want to add emails, url, list and use them easily
- I don’t want to configure 1 million dev dependencies
- I want to see my commands and not want to vomit because of the mess 🤢
Yeah, I'm not picky, but I wanted something like this for myself 😅.
So, hands of work, I would like to present you cli-maker
my own version of the hell, just execute this command and check the magic,
Go to an empty directory and use Node 20 (I’ll add this validation, I promise you 😉)
Go to library if you want to skip this lecture npm @ideascol/cli-maker
npx @ideascol/cli-maker
And that’s it, you will see the usual installation process. Please be patient 😊.
Trust me, proceed… 😉
For now, I just have one command—the only one needed for now. Please proceed in an empty folder and fill in the data 😊.
Right! Now, create your own CLI 🚀.
npx @ideascol/cli-maker create
Fill data
If all was good, you’ll see this:
Let me explain to you in the next article how we can extract the best from this simple library… 📚✨
See you! 👋
Check the next cli-maker-more-than-we-see
Top comments (1)
Awesome , thanks for sharing 👏🏻.