Generate a new Bun module in seconds!
This repo provides a starter template with all the scaffolding you need to build and publish Bun modules.
You get:
mise.next) builds for all pr merges to main, andClick "Use this template" on GitHub or clone it:
git clone https://github.com/zenobi-us/bun-module.git my-module
cd my-module
./setup.sh
The generator will ask for:
my-awesome-module)cd my-module
bun install
mise run build
After running the generator, you'll have:
The generator cleans itself up - no template files or setup script left behind!
This repo encouranges using release-please for automated releases.
However, before you can rely on that, you need to set up a few things:
Manually publish the first version to npm:
mise run publish
Follow the instructions in ./template/RELEASE.md to set up this repository with npm trusted publishing.
# Generate a new module (interactive prompts)
./setup.sh generate
# Show help
./setup.sh help
# Show version
./setup.sh version
You can skip prompts by setting environment variables with the BUNMODULE_ prefix:
# Provide all values via environment variables
BUNMODULE_MODULENAME="my-awesome-module" \
BUNMODULE_DESCRIPTION="An awesome Bun module" \
BUNMODULE_AUTHORNAME="John Doe" \
BUNMODULE_AUTHOREMAIL="john@example.com" \
BUNMODULE_REPOSITORYURL="https://github.com/username/my-awesome-module" \
BUNMODULE_GITHUBORG="username" \
./setup.sh generate
Available Environment Variables:
BUNMODULE_MODULENAME - Module name (kebab-case)BUNMODULE_DESCRIPTION - Module descriptionBUNMODULE_AUTHORNAME - Author nameBUNMODULE_AUTHOREMAIL - Author emailBUNMODULE_REPOSITORYURL - Repository URLBUNMODULE_GITHUBORG - GitHub organization/usernameThis is useful for:
Generated modules have this structure:
my-module/
├── src/
│ ├── index.ts # Module entry point
│ └── something/else.ts # All the things!
├── .github/
│ └── workflows/ # CI/CD workflows
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript config
└── README.md # Your module's documentation
bun install # Install dependencies
mise run setup # Initial setup
mise run build # Build the module
mise run test # Run tests
mise run lint # Lint code
mise run lint:fix # Fix linting issues
mise run format # Format code with Prettier
mise run pkgjsonlint # Lint package.json
mise run prepare # Prepare for release
mise run publish # Publish the module
mise run version # Manage version
See RELEASE.md for publishing and release management details.
TL;DR: Push single commits to main with conventional commit format. Release-please will accumulate changes in a release PR. When this release PR is merged, a new minor version is released and published to npm. Until then, all other commits on main result in patch builds being published.
MIT
Need help?
Shell
88.2%
Pkl
6.0%
JavaScript
5.8%
Generate a new Bun module in seconds!
This repo provides a starter template with all the scaffolding you need to build and publish Bun modules.
You get:
mise.next) builds for all pr merges to main, andClick "Use this template" on GitHub or clone it:
git clone https://github.com/zenobi-us/bun-module.git my-module
cd my-module
./setup.sh
The generator will ask for:
my-awesome-module)cd my-module
bun install
mise run build
After running the generator, you'll have:
The generator cleans itself up - no template files or setup script left behind!
This repo encouranges using release-please for automated releases.
However, before you can rely on that, you need to set up a few things:
Manually publish the first version to npm:
mise run publish
Follow the instructions in ./template/RELEASE.md to set up this repository with npm trusted publishing.
# Generate a new module (interactive prompts)
./setup.sh generate
# Show help
./setup.sh help
# Show version
./setup.sh version
You can skip prompts by setting environment variables with the BUNMODULE_ prefix:
# Provide all values via environment variables
BUNMODULE_MODULENAME="my-awesome-module" \
BUNMODULE_DESCRIPTION="An awesome Bun module" \
BUNMODULE_AUTHORNAME="John Doe" \
BUNMODULE_AUTHOREMAIL="john@example.com" \
BUNMODULE_REPOSITORYURL="https://github.com/username/my-awesome-module" \
BUNMODULE_GITHUBORG="username" \
./setup.sh generate
Available Environment Variables:
BUNMODULE_MODULENAME - Module name (kebab-case)BUNMODULE_DESCRIPTION - Module descriptionBUNMODULE_AUTHORNAME - Author nameBUNMODULE_AUTHOREMAIL - Author emailBUNMODULE_REPOSITORYURL - Repository URLBUNMODULE_GITHUBORG - GitHub organization/usernameThis is useful for:
Generated modules have this structure:
my-module/
├── src/
│ ├── index.ts # Module entry point
│ └── something/else.ts # All the things!
├── .github/
│ └── workflows/ # CI/CD workflows
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript config
└── README.md # Your module's documentation
bun install # Install dependencies
mise run setup # Initial setup
mise run build # Build the module
mise run test # Run tests
mise run lint # Lint code
mise run lint:fix # Fix linting issues
mise run format # Format code with Prettier
mise run pkgjsonlint # Lint package.json
mise run prepare # Prepare for release
mise run publish # Publish the module
mise run version # Manage version
See RELEASE.md for publishing and release management details.
TL;DR: Push single commits to main with conventional commit format. Release-please will accumulate changes in a release PR. When this release PR is merged, a new minor version is released and published to npm. Until then, all other commits on main result in patch builds being published.
MIT
Need help?
Shell
88.2%
Pkl
6.0%
JavaScript
5.8%