Modern CLI task runner powered by JS and Bun
Named after banosh, a traditional Ukrainian dish from cornmeal cooked with various ingredients such as mushrooms, cheese, sour cream
Bunosh is a task runner powered by Bun. Bunosh is aimed to help you to write common scripts in JavaScript with less effort. Combines awesome tools: Bun, Commander.js, Ink, Inquirer in a the most compact way.
What can you automate with Bunosh:
Promise.all
execute multiple tasks at oncejs
or shell
scriptBunosh will get your scripts cooked into a single JavaScript file.
Each function of this file:
/** Cleans up tmp & logs dir **/
export async function cleanTmp() {
await $`rm -rf tmp/*`;
await $`rm -rf logs/*`;
}
/** Builds Docker images for project **/
export async function build(opts = { push: false }) {
await Promise.all([
buildFrontend(),
buildBackend(),
])
if (opts.push) {
await $`docker push frontend`;
await $`docker push backend`;
}
}
/** Deploys application **/
export async function deploy(env = 'staging') {
await build();
// ...
}
/** Adds value to config **/
export async function addToConfig(key, value) {}
//....
Is turned into an executable command:
Commands:
add:to-config Adds value to config
bunosh add:to-config [key] [value]
build Builds Docker images for project
bunosh build --push
clean:tmp Cleans up tmp & logs dir
deploy Deploys application
bunosh deploy [env=staging]
Special Commands:
Edit bunosh file: bunosh edit
Export scripts to package.json: bunosh export:scripts
function addUserModel
bunosh add:user-model
addUser(name)
bunosh add:user <name>
addUser(name='john')
bunosh add:user [name=john]
clean(opts = {tmp: false, logs: false})
bunosh clean --tmp --logs
addUsers(opts = {num: 1})
bunosh add:users --num 1
Install Bun (faster NodeJS alternative)
Install Bunosh globally:
bun install -g bunosh
Create a new tasks file in a project directory:
bunosh init
Commands can be written using classical NodeJS API using fs
or child_process
modules and print output using console.log
. However, this doesn't unleash true Bunosh power.
Bunosh ships with a built-in functions to simplify writing scripts:
exec
or $
is a wrapper around Bun Shell. It is cross-platform bash-like shell with seamless JavaScript interop.
import { exec } from `bunosh`
export async function build()
{
await exec`docker ps`
await exec`docker build -t api .`
}
Bunosh wraps $
to make a fancy realtime output with Ink: