npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bunosh

v0.1.5

Published

> *Named after **banosh**, a traditional Ukrainian dish from cornmeal cooked with various ingredients such as mushrooms, cheese, sour cream*

Downloads

43

Readme

🍲 bunosh

Named after banosh, a traditional Ukrainian dish from cornmeal cooked with various ingredients such as mushrooms, cheese, sour cream

What it is?

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:

  • shell scripts → use JavaScript to write them (you know it better, anyway!)
  • boilerplate scripts → create new files from templates
  • deploy scripts → combine JS and Shell commands to build and deploy
  • parallel tasks → with native Promise.all execute multiple tasks at once
  • ...every other task you have previously written a custom js or shell script

Bunosh 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

Command Rules:

  • each exported function is a command:
    • function addUserModelbunosh add:user-model
  • each function argument is a command argument:
    • addUser(name)bunosh add:user <name>
    • addUser(name='john')bunosh add:user [name=john]
  • last argument passed as an object defines options:
    • clean(opts = {tmp: false, logs: false})bunosh clean --tmp --logs
    • addUsers(opts = {num: 1})bunosh add:users --num 1
  • docblock or first-line comment of a function makes a command description
  • functions can call make fetch requests, exec shell commands or call other functions

Installation

Install Bun (faster NodeJS alternative)

Install Bunosh globally:

bun install -g bunosh 

Create a new tasks file in a project directory:

bunosh init

API

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

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: