Kashan A.
Sassywares

Meet Crust šŸž - The hottest NPM package template in town

#TypeScript #Vitest #Changesets #CI/CD #NPM #GitHub Actions

Introducing Crust: šŸž A simple boilerplate for creating and publishing packages to NPM. It includes a basic configuration for TypeScript, ESLint, Prettier, Vitest, and Changesets as well as a simple list of scripts for building, linting, testing and publishing your package. Crust is the dough, you can add whatever toppings you want. šŸ•

If you know me, you know how much I love messing around with new packages and libraries. Iā€™ve been doing this for a while now and Iā€™ve noticed that I tend to use the same set of tools and configurations for all my projects. So, I decided to create a template that I can use to quickly bootstrap my projects and why just my projects? Why not yours too? So, I decided to make it public and share it with the world, and also add a few polished touches to it so the world doesnā€™t see the real mess inside (just kidding, itā€™s not that bad).

Whatā€™s included?

Well, I usually install the same few deps in all my projects and then create the same few cool NPM scripts to build, lint, test, and publish my packages. So, I decided to include them in the template so you donā€™t have to do it yourself. Hereā€™s a list of all the things included in Crust:

You have built-in support for:

šŸ“˜ Note

The deps will keep getting outdated and our job is to keep them up to date. So, make sure you keep updating them regularly. Just a good olā€™ npm update should do the trick (most of the time).

šŸ”„ Hot NPM scripts

Lemme tell you something exciting, Crust comes jam-packed with cool scripts that literally version, build, lint, test, and publish your package with a single command. Hereā€™s a list of all the scripts included in Crust:

šŸ“¦ Pre-configured CI workflow

Builds

But, thatā€™s not all. Crust also comes with a pre-configured CI workflow (using GitHub Actions) that publishes a new version of the package to NPM every time you push a new tag to the remote repository. Thereā€™s a release.yml file in the .github/workflows directory that contains the workflow. You can modify it to suit your needs, Iā€™ve added some noteworthy instructions in the readme file, make sure you add that to your netflix playlist as well.

How to use Crust?

Using Crust is as easy as making a sandwich. All you have to do is click the green ā€œUse this templateā€ button on the repo page and follow the instructions. Once youā€™ve created the repo, clone it to your local machine and run npm install to install all the dependencies. You can then start writing your code in the src directory and run npm run dev to build it. You can also run npm run test.watch to run the tests in watch mode.

Once youā€™re done, you can run npm run release to publish a new version of the package to NPM. Thatā€™s it, youā€™re done. šŸŽ‰ Alternatively, you can just run the npm run release.version command and let the CI workflow do the rest, upto you. What happens underneath is that the release.version script bumps the package version and adds a git tag which is what triggers the CI workflow. The workflow then runs the release.prepare script to build and test the code and then runs the release.publish script to publish the package to NPM.

So, whatā€™s the catch?

Thereā€™s no catch, I promise. Crust is completely free and open-source. You can use it for your personal and commercial projects without any restrictions. You can also modify it to suit your needs and even contribute to it if you want to. The only reason why Crust exists in the first place is because the web dev world is a mess and itā€™s not easy to integrate a bunch of tools together. You can build whatever flavor of pizza you want, crust is just a dough. šŸ•

Whatā€™s next?

Iā€™m glad you asked. Iā€™m planning to make a react- version of Crust as well as a few other flavors. The thing about Crust is that we can all contribute to it and make it better. So, if you have any ideas or suggestions, feel free to open an issue or a pull request. Iā€™ll be more than happy to review it and merge it if itā€™s good. Iā€™m also planning to add a few more scripts to Crust to make it even more awesome. So, stay tuned for that.

How can I help?

Glad you asked. Hereā€™s a list of things you can do to help:

Thatā€™s it. I hope you like Crust. If you do, please spread the word. If you donā€™t, please let me know why. Cheers! šŸ»

Back to Blog

Creating web apps the proper way!

I used Astro to put this site together and added a bit of an interstellar vibe. Styling is done with Tailwind, and it's running on Cloudflare. Oh, and all the text is in Bricolage Grotesque font for that extra touch.

Get in touch Open to work