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

bitdrive-cli

v1.0.1

Published

A Bitspace service that for managing Bitdrives over FUSE.

Downloads

6

Readme

bitdrive-cli

A companion service for Bitspace that provides FUSE/CLI access to Bitdrives.

This service creates a "root drive" for you, which is a single, private Bitdrive that's mounted at ~/Bitdrive. You can think of this root drive as a replacement for your normal home directory (where you might have Documents, Videos, and Pictures folders, for example).

The CLI gives you commands for interacting with Bitdrives, both inside and outside of FUSE. Here are some of the included commands:

  • The mount and unmount commands allow you to attach/detach other other Bitdrives to/from your root drive.
  • The seed and unseed commands let you decide whether you'd like to advertise a drive on the Bitswarm DHT.
  • The import and export commands are for users who don't want to use FUSE, but still want to move data in and out of Bitdrives.

Installation

Before installing the Bitdrive service, you'll want to first install bitspace. Once Bitspace is installed, run:

npm i bitdrive-cli -g

After the NPM installation, you should have access to the bitdrive CLI tool.

Getting Started

In another terminal, spin up Bitspace by running bitspace (no other flags needed).

If you're planning on using FUSE, you have to perform a one-time setup step to do the FUSE installation. This will prompt you for sudo access:

$ bitdrive fuse-setup

Once FUSE has been configured, you're ready to start the Bitdrive service:

$ bitdrive start

API

bitdrive-cli exposes an API for programmatically interacting with your root drive. To create a client:

const BitdriveServiceClient = require('bitdrive-cli/client')
const client = new BitdriveServiceClient()

const client = new BitdriveServiceClient(opts = {})

Create a new client for interacting with the Bitdrive service.

If you don't provide any options, options will be loaded from a configuration file inside of the ~/.bitspace directory and a Bitspace client will be created automatically.

Options include:

{
  mnt: string, // The FUSE mountpoint
  key: Buffer, // Your root drive key.
  client: BitspaceClient // A bitspace client.
}

await client.mount(path, opts = {})

Mounts a Bitdrive inside of your root drive. path must be contained within your root drive's mountpoint (typically ~/Bitdrive).

Options include all options to Bitdrive's mount method, such as:

{
  key: Buffer, // The key of the drive you're mounting.
  version: number, // The drive version (if you're creating a static mount)
}

await client.unmount(path)

Unmount the drive mounted at path. path must be contained within your root drive's mountpoint (typically ~/Bitdrive).

await client.seed(path, opts = {})

Start announcing a mounted drive on the Bitswarm DHT.

Options include:

{
  remember: boolean, // true if this network configuration should be persisted across restarts.
}

await client.unseed(path, opts = {})

Stop announcing a mounted drive on the Bitswarm DHT.

Options include:

{
  remember: boolean, // true if this network configuration should be persisted across restarts.
}

await client.info(path)

Returns info about the drive mounted at path.

The info takes the form:

{
  key: Buffer, The drive's key
  discoveryKey: Buffer, // The drive's discovery key.
  writable: boolean, // true if the drive is writable.
  mountPath: string, // The path of the enclosing mountpoint.
  announce: boolean, // true if the drive is currently being announced on the DHT.
  lookup: boolean    // true if the drive is currently being looked up on the DHT.
}

await client.stats(path)

Return drive storage/networking statistics.

The stats take the form:

{
   storage, // Storage info about each mountpoint in the drive.
   network, // Networking info about each mountpoint in the drive.
}

where storage has the same structure as that returned by Bitdrive.stats and network has the form:

{
  '/': {
    metadata: {
      key,
      discoveryKey,
      length: number, // The Unichain's length,
      byteLength: number // The Unichain's byteLength
      peers: [Peer] // An Array of Unichain Peer objects.
    },
    content: {
      // Same as above
      ...
     }
  },
  '/mountpoint1': {
     // Same as above
     ...
  }
}

const { progress, drive } = client.import(key, dir, opts = {})

Imports a Bitdrive into Bitspace.

If you're using FUSE, you probably don't need to explictly import/export, because you can replicate this functionality using the filesystem alone.

progress is an instance of mirror-folder. drive is the Bitdrive that you're importing into.

Options include:

{
  watch: false // Watch for changes.
}

Note: This imported drive will not appear inside your root drive unless you explicitly mount it with bitdrive mount (mount path) (imported drive key)

const { progress, drive } = client.export(key, dir, opts = {})

Exports a Bitdrive into a local directory.

If you're using FUSE, you probably don't need to explictly import/export, because you can replicate this functionality using the filesystem alone.

Options include:

  watch: false // Watch for changes.

CLI Commands

The bitdrive CLI tool includes a handful of subcommands that wrap the API methods described above. Running bitdrive help will give more complete usage info:

$ ./bin/run/run help
A Bitspace service that for managing Bitdrives over FUSE.

VERSION
  bitdrive-cli/1.0.0 linux-x64 node-v12.9.1

USAGE
  $ bitdrive [COMMAND]

COMMANDS
  autocomplete   display autocomplete installation instructions
  create         Create a new drive mounted at the specified path
  export         Export a Bitdrive into a directory.
  force-unmount  Forcibly unmount the root filesystem (useful if it was not cleanly unmounted).
  fuse-setup     Perform a one-time configuration step for FUSE.
  help           display help for bitdrive
  import         Import a directory into a Bitdrive.
  info           Display information about the drive mounted at the given mountpoint.
  mount          Mount a drive at the specified mountpoint.
  seed           Seed a Bitdrive on the network.
  start          Start the Bitdrive service.
  stats          Get the networking stats for the drive mounted at a path.
  unmount        Unmount a drive. The root drive will be unmounted if a mountpoint is not specified.
  unseed         Stop seeding a Bitdrive on the network.

License

MIT