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

haxx

v0.7.0

Published

a very opinionated runtime for scripts, it simply works

Downloads

3,077

Readme

haxx

easily create and run scripts using javascript

Features

  • 🔀 Process DX - easily manage and run processes
  • 📦 Javascript ESM - makes writing scripts easier, through javascript
  • 🔌 Great IO - provides easy to use IO functions, for known formats
  • 🧑‍💻 Opinionated - it's a great tool for writing tools, with tools inside

Getting started

It's as simple as creating a script file with a .mjs extension

#!/usr/bin/env haxx

const lastTag = await $`git tag | tail -n 1`
const tagMessage = String(await $`git tag -l -n9 ${lastTag}`)
    .match(/\s{2,}(.+)/)[1]
console.log(`Last tag message: ${tagMessage}`)

And running it

haxx my-script.mjs

Installation

You can either install it globally

npm i -g haxx
haxx my-script.mjs

Or run it through npx or any other package manager execute

npx -y haxx my-script.mjs

API

$

Executes a given command and returns a promise of the output.

Everything passed through ${...} will be automatically escaped and quoted.

const dirToRemove = 'my nice dir'
await $`rm -rf ${dirToRemove}` // rm -rf 'my nice dir'

You can pass arrays as arguments

const dirs = ['dir1', 'dir2']
await $`ls ${dirs}` // ls dir1 dir2

You can catch process exit codes upon a failing

try {
    await $`exit 1`
} catch (process) {
    console.log(`Exit code: ${process.exitCode}`)
    console.log(`Error: ${process.stderr}`)
}

You can pipe directly from the promise to any other stream

$`watch -n1 ls`.pipe(process.stdout)

read

Lets you read files easily, and specify formats

const content = await read`my-file.txt`

const package = await read.json`package.json`
console.log(package.version)

const deployment = await read.yaml`deployment.yaml`
console.log(deployment.metadata.name)

write

Lets you write files easily, and specify formats

await write('my-file', 'Hello world') 
// Hello World

await write.json('object.json', { hello: 'world' })
// { "hello": "world" }

await write.yaml('object.yaml', { hello: 'world' })
// hello: world

io

Gives you a nice interface for reading and saving files

const { data: pkg, save } = await io.json`package.json`
pkg.version = '1.0.1'
await save()

const { data: deployment, save: saveDeployment } = await io.yaml`deployment.yaml`
deployment.spec.template.spec.containers[0].image = 'my-new-image'
await saveDeployment()

exists

Checks if a file or directory exists

if (!exists('key')) {
    await write('key', Math.random().toString().slice(2))
}

remove

Removes a file or directory

remove('my-file')

cd

Changes the directory

await $`ls`
cd('another-directory')
await $`ls`

template

Lets you replace variables in a template

const phrase = template({ name: 'world'}, 'Hello {{ name }}')

const filled = template.file({ GITHUB_TOKEN: '...' }, 'my-template')

Included batteries

  • kleur - a nice color library
  • kleur-template - easier coloring through templating
  • glob - utility for globbing files
  • yaml - a yaml parser
  • os - the os package
  • path - the path package
  • minimist - your arguments parsed, availabe through the global constant argv

Acknowledgements

This project is heavily inspired by zx and fsxx, down to the code.

Check them out!