
Build Customizable, Reusable Project Templates With Node.js
Get every episode summarized
Each time Programming Tech Brief By HackerNoon publishes, we email you a written briefing from the transcript — the topics, who appeared, and any specific claims, with the ad reads skipped.
Email me new episodesFree for 3 shows. No card needed.
About this episode
“This audio is presented by Hacker Noon, where anyone can learn anything about any technology. Build customizable, reusable project templates with Node. At some point in your life you end up with a repo that is the starting point.”From the transcript
This story was originally published on HackerNoon at: https://hackernoon.com/build-customizable-reusable-project-templates-with-nodejs.
Build an interactive repository scaffolder with Inquirer and replace-in-file, with practical limits around file paths, replacements, and setup.
Check more stories related to programming at: https://hackernoon.com/c/programming.
You can also check exclusive content about #nodejs, #nodejs-scaffolding, #repository-templates, #yeoman, #cookiecutter, #interactive-cli, #developer-tooling, #inquirer-prompts, and more.
This story was written by: @lucastonelli. Learn more about this writer by checking @lucastonelli's about page,
and for more stories, please visit hackernoon.com.
The script uses a template with placeholders to create a new project, asking for each value and rewriting every occurrence across the repo with two libraries. This approach solves the problem of missing hardcoded values in a cloned project template.
The script is customizable and can be used as a drop-in solution, but it has limitations, such as not being able to rename directories and not being transactional, requiring a review step
Get every episode summarized
Each time Programming Tech Brief By HackerNoon publishes, we email you a written briefing from the transcript — the topics, who appeared, and any specific claims, with the ad reads skipped.
Email me new episodesFree for 3 shows. No card needed.
Hosts & guests
Transcript ready
51 searchable segments. Every word is indexed and playable.
Full transcript
Programming Tech Brief By HackerNoon — Build Customizable, Reusable Project Templates With Node.js. Machine-transcribed; use the interactive transcript above to jump the player to any line.
This audio is presented by Hacker Noon, where anyone can learn anything about any technology. Build customizable, reusable project templates with Node. JS. By Lucas Tonelli. At some point in your life you end up with a repo that is the starting point. It has the C pipeline you like, your preferred linting and formatting can fix and THE terraform layout that works like a charm. Then a new project shows up, you clone the base template and spend the next 20 minutes doing find and replace on the project name, ids, the domain name and whatever else is hard coded in there. It works, until you miss a thing and find out your project is failing but is it because of the template or because you missed something. However, AS Mall script and 2NPM packages solve this problem pretty well. Prompt and replace. Instead of hard coding values, you create a template with placeholders, using whatever delimiter is unlikely to show up naturally in your code. Something like sitting in your, terraform files, or any other file. Then a single script asks for each value and rewrites every occurrence across the repo with two
libraries doing the heavy lifting. At inquire, prompts for the questions and replace and file for the replacements. The script the interesting part is that the list of regaxes in is the only place you declare anything. The loop turns each pattern into a question by stripping the delimiters out of the regax source, so becomes, specify the domain underscore name. Adding a new parameter to your template means adding one line to that array, and the prompt comes for free. The array is a placeholder that gets fully overwritten by the answers, and since he thianth answer maps to the nth pattern, order matters. Two other details airworth pointing out, has to include the scaffolder itself. Otherwise the script rewrite's its own regaxes mid run and you get a fun debugging session. Is what makes actually reach the dot files, which is where half of your config lives anyway, and friends, of course, the script and everything else is customizable, so if you have a different idea, set it up in any way you prefer. What about Yomin and CookieCater? This problem is old and there are two well established tools that solve it. SoisFair to ask why you'd write 30 lines instead of using them.
Yomin Yomin is the node ecosystems answer and it's a proper framework. You write a generator as a separate package, it renders templates through EJS, handles conflict resolution when files already exist, composes generators together and can run install steps afterwards. That's genuinely more powerful, but it alsemines your template stops being a repository you can clone and run, and becomes a package you have to publish, version and install globally before anyone can use it. CookieCutter CookieCutter is the Python one and it's closer in spirit. A declares the variables and ginger renders the tree. It renames directories, which is exactly the thing the script above can't do, and it works on any project regardless of language. The tradeoff is that your node template repo now needs Python in every environment that touches it. Limitations. The package is what its name says, it replaces content in files. Pads are out of scope, as I mentioned, so a directory called stays exactly as it is after the script runs, quietly, with no error to tell you about it. However,
there are a few ways to work around it, an increasing order of effort. Keep folder names generic, if possible, law. Rename folders by hand afterwards. Fine for one or two paths, terrible as a convention because it's the exact manual step you were trying to delete. Add a rename pass to the script, walk the tree with, apply the same answers to path names and the matches. Just remember to go depth first, otherwise you rename a parent directory and invalidate every path you were about to visit. You may also have noticed that the replacements themselves are not transactional. If the process dies halfway through, part of your repo IS substituted and part isn't, so run it on a fresh clone with a clean and let be your review step. The script printing which files change helps a lot here, because a parameter that shows up in zero files is almost always a typo in your template rather than an unused variable. Wrap up. This isn't a replacement for Yo-Men or cookie-cater and it doesn't try to be. It's a single file you drop in a repo to turn it into a template, with NO framework to learn, no package to publish and no second language to install.
If you ever outgrow it, the placeholders you already wrote may help with migrating to another tool. Thank you for listening to this Hackernoon story, read by artificial intelligence. Visit Hackernoon.com to read, write, learn and publish.
More episodes
More from Programming Tech Brief By HackerNoon

How I Built a Kafka Consumer Framework So Teams Never Write Plumbing Twice
Programming Tech Brief By HackerNoon

The Best ETL Tools for Real-Time Data Integration in 2026
Programming Tech Brief By HackerNoon

MapReduce: The Abstraction Layer That Still Shapes How AI Workloads Scale
Programming Tech Brief By HackerNoon

GPT-6 Astra: How to Write Better Prompts and Skills
Programming Tech Brief By HackerNoon