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

simple-binary-install

v0.2.1

Published

Facilitates distributing gzipped binary tarballs from npm.

Downloads

1,466

Readme

🦀 simple-binary-install

A package to facilitate distributing gzipped binary tarballs (.tar.gz files). This package provides convenience functions for distributing theses binaries via npm and is likely best used as a devDependency in package.json.

Goals

  • To have a package with as few dependencies as possible that does the following:
    1. Downloads gzipped tarball
    2. Extracts tarball (stripping away the containing directory)
    3. Makes sure resulting file is executable
    4. Do it all securely

Why create this?

After using binary-install (on which this is based) I ran an npm audit and found it depended on an old, vulnerabile axios version. After modifying the code to use a newer version of axios I thought, "Why use axios at all!?". Removing the axios dependency and switching to fetch() necessitated a new method of extracting the tar package. The tar-stream package was chosen to fulfill that task.

Installation

npm i --save-dev simple-binary-install

or

pnpm i -D simple-binary-install

Usage

Usage is very similar to binary-install

Intro Concepts

The Binary class allows downloading a tarball containing a binary and extracting it to a given location.

An example of its use is given below using an install.js file that looks like:

#!/usr/bin/env node

import { Binary } from 'simple-binary-install'
let binary = new Binary('my-binary', 'https://example.com/binary/tar.gz')
binary.install()

If the install location of the binary needs to be modified, the third parameter can be a config object, used to change the installDirectory. e.g.

#!/usr/bin/env node

import { Binary } from 'simple-binary-install'
let binary = new Binary('my-binary', 'https://example.com/binary/tar.gz', {installDirectory: 'new/location'})
binary.install()

The shebang at the top of the file lets your shell know that this script should be run with the node runtime.

In your package.json, we would add the following:

{
  ...
  "scripts": {
    "postinstall": "node ./install.js"
  }
  ...
}

One more change to your project would be needed before your package is ready to distribute. Make a run.js file that looks similar to this:

#!/usr/bin/env node

import { Binary } from 'simple-binary-install'
let binary = new Binary('my-binary', 'https://example.com/binary/tar.gz')
binary.run()

And then in your package.json, add the following:

{
  ...
  "bin": {
    "my-binary": "run.js"
  }
  ...
}

Then, we could use it as shown below in a local directory!

pnpm i && npx my-binary --version
1.0.0

Maintenance

This project has been built for the needs of the translocate crate, but PRs to extend its functionality are welcome.

Lints

biome is used to lint and format the project's JS files. Before contributing changes please run the format command, e.g. npm run format.