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 🙏

© 2026 – Pkg Stats / Ryan Hefner

digital-navy

v0.0.1

Published

Run lots of fully isolated commands on digital ocean

Readme

digital-navy

Run lots of fully isolated commands on digital ocean

Build Status Dependency Status NPM version

Installation

npm install digital-navy --save

Usage

var fs = require('fs');
var DigitalNavy = require('digital-navy');

var script = fs.readFileSync(__dirname + '/example-script.js');

var navy = new DigitalNavy({
  // Note that the base image is only re-built when the name changes,
  // so we include a shasum of the script and the node version
  name: 'node-' + process.version + '-' + shasum(script),
  // the prepare function is used to run ssh commands before creating
  // the snapshot.  Use it to install all your dependencies
  prepare(ssh) {
    console.log('installing node');
    // we install the same version of node as we're using locally
    return DigitalNavy.installNode(ssh, process.version).then(
      () => {
        console.log('installed node');
        // copy some JavaScript script to the server
        return ssh.exec('cat > ~/example-script.js', {stdin: script});
      }
    );
  },
  token: '<DIGITAL OCEAN KEY>',
  // keypair generated by either rsa-json or keypair
  keypair: keypair(),

  // You can use functions for minPoolSize and maxPoolSize if you want to have these change over time
  // changes in the return values of those functions will only be taken into
  // account when droplets start or stop executing
  minPoolSize: 3,
  maxPoolSize: 4,
});

// Call this function each time you want to run some commands in their own isolated sandbox
navy.run(
  ssh => {
    console.log('got droplet');
    return ssh.exec('node ~/example-script.js').then(
      result => {
        console.log('finished script');
        console.dir(result);
        assert(result === 'Hello World\n');
        return result;
      },
    );
  }
);

DigitalNavy constructor

options:

name | default | description ------------| --------------- |----------------- name | required | The name for the snapshot and instances. The snapshot is rebuilt whenever this name changes, so use it to encode all versioning info. prepare | required | A function to be called with an ssh connection to the droplet that will be used to generate a snapshot. Use it to install dependencies. token | required | A digital ocean token, used to create the droplets 😊 keypair | required | An object with {public, private} keys. Generated with keypair or rsa-json maxPoolSize | 2 | The maximum number of isolated virtual machines to allocate at a time. By default this is kept low to prevent you accidentally spending lots of money. minPoolSize | 0 | The minimum number of workers to keep running at a time. Keeping servers running even when there's no work to do helps a lot with latency. workerSize | '512mb' | The size of the droplet allocated for performing the work. Increase this if you need more memory or CPU for each worker. builderSize | = workerSize | The size of the droplet used to build the initial sandbox. Use a larger droplet if you need to build big assets up front, but the actual worker droplets can be much smaller.

digitalNavy.run(options, fn) (instance method)

Run a sequence of ssh commands in an isolated droplet. The function fn is given an instance of SshConnection.

options:

name | default | description ------------| --------------- |----------------- debug | false | Set this to true to emit the stdout & stderr or remote commands on the local terminal

DigitalNavy.installNode(ssh, version) (static method)

A helper method to install a chosen version of node.js via an SshConnection. You probably want to use this in your prepare function.

SshConnection#exec(commands, options) (instance method)

execute a command or sequence of commands and return a Promise for the string value of stdout.

name | default | description ------------| ----------------------- |----------------- debug | = parentOptions.debug | Set this to true to override the default value set in digitalNavy.run stdin | null | Set this to a Buffer or string to provide it as the stdin for the command being run

License

MIT