I recently wanted to split of a series of scripts I made for a postgres project I was working on into its own cli tool. I started by outlining the tool, I wanted a
pgrun bundle, and a
pgrun test command. This is what I had after a little bit of development:
I had a whole bunch of functions spit into their own files, and it started to be a headache to maintain. I felt every time I made some new thing, I’d isolate it in it’s own file. I’ve vented about files and folders in the past, as well as invented whole new ways to organize typescript projects.
But nothing is as simple as this:
What’s the shift? Simply having all the functions in one mod.ts file, it’s still under 500 lines. It became a shift slightly but utilizing search and replace within the same file became much easier than digging around the files for the function, and having to deal with import / exports.
This is a gentle reminder to myself to not break things out early on, and keep it simple, keep it all contained in one file if you can, it makes it so much easier to manage.