This repository is a template for building a library and a CLI using Bun. It’s meant to be used via the "Use this Repository as a Template" button on GitHub.
I have been using this as my personal stack for shipping npm packages for some time and decided to make a "cutout" to share. Why Bun? It's nice when things just work. Exercise caution as this project is very new and there are probably things wrong with it. Please submit an issue. I welcome contributors!
# optionally install bun
curl -fsSL https://bun.sh/install | bash
# install project dependencies
bun install
# build the project
bun run build
# run project tests
bun test
bun dev # runs the cli
bun test # runs tests of code in lib.ts and state.ts
bun deploy:dev # publish development version
bun release-it # interactive release creation
-
Library & CLI:
Thesrc/
folder contains both library functionality (src/lib.ts
) and a command line interface (src/cli.ts
). -
Build Process:
Use the provided npm scripts (e.g.,bun run build
,bun run test
) to build, test, and run your project. -
Package Setup:
Thepackage.json
is preconfigured with build, release, and publish scripts, allowing you to easily package and publish a new version.
- Use the repository template to create your own project.
- Modify the source code in
src/
(for example, updatesrc/lib.ts
orsrc/cli.ts
as needed). - Test your changes locally:
bun run test
- Build the project:
bun run build
- Update the version in
package.json
for your new release. - Commit your changes.
- Publish the new version to npm:
bun run deploy:dev
MIT License
© 2024 Geoff Seemueller
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.