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

shipwright

v0.1.2

Published

DigitalOcean CLI control

Downloads

14

Readme

Shipwright

Shipwright

Shipwright is a command line interface for interacting with DigitalOcean.

It is a very lightweight wrapper around the API. Effectively it just wraps up some of the painful bits you'd need to do if you were using curl.

As such, the best docs on what you can do can be read here: https://developers.digitalocean.com/documentation/v2

Installation

Requirements

Shipwright requires node.js and npm.

Install via npm

You can install Shipwright using npm globally on your computer:

npm install -g shipwright

Usage

usage: shipwright [OPTIONS] OPERATION RESOURCE [ARGS]
options:
    --version       Print version and exit.
    -h, --help      Print this help and exit.
    -v, --verbose   Enable verbose output.
    --token=TOKEN   Specifies your DO API token. Environment: DO_TOKEN=TOKEN
    --fromfile=ARG  Allows you to read a given value from a file, eg:
                    --fromfile=userdata,~/user-data.
    --json          Output responses in raw JSON.
    --pretty        If set, will output more human-readable JSON.
    --stdin         If set, will read the request body from stdin.
    --wait          If set, will wait for the created action to complete. Eg:
                    when creating a droplet will wait for successful creation.

Operations

  • get
  • create (alias for 'post')
  • put
  • delete

Resources

Refer to the DigitalOcean API docs

Arguments

Arguments are parsed in a key=value fashion and are added to the request either as a request body or as a query string.

--fromfile is an interesting option that lets you read the given argument in from a file on disk. This is particularly useful for something like user_data. (See examples below.)

Authentication

Shipwright will first check for a DigitalOcean API token via the --token option.

Failing that, it will check the environment variable DO_TOKEN.

Failing that, Shipwright will look for a file in your home directory containing your API token:

.digitalocean.token

This last method is the recommended method: create a .digitalocean.token file by cutting/pasting your DigitalOcean API token.

Examples

Let's get a list of our SSH keys stored with DigitalOcean (we'll use them later):

> shipwright get account/keys
ssh_keys:
    -
    id:          <key id>
    fingerprint: <key fingerprint>
    public_key:  <key>
    name:        <key name>
    -
    id:          <key id>
    fingerprint: <key fingerprint>
    public_key:  <key>
    name:        <key name>
...

Let's see what pre-built applications DigitalOcean has for us to use as images:

> shipwright.js get images type=application
images:
    -
    id:            6423475
    name:          WordPress on 14.04
    distribution:  Ubuntu
    slug:          wordpress
    public:        true
    regions:
        - nyc1
        - ams1
        - sfo1
        - nyc2
        - ams2
        - sgp1
        - lon1
        - nyc3
        - ams3
        - fra1
    created_at:    2014-09-28T21:34:48Z
    min_disk_size: 20
    type:          snapshot
    -
    id:            10163059
    name:          FreeBSD AMP on 10.1
    distribution:  FreeBSD
    slug:          freebsd-amp
    public:        true
    regions:
        - nyc1
        - ams1
        - sfo1
        - nyc2
        - ams2
        - sgp1
        - lon1
        - nyc3
        - ams3
        - fra1
    created_at:    2015-01-21T15:45:44Z
    min_disk_size: 20
    type:          snapshot
...

Let's create a droplet in sfo1, 512mb of ram, some user data, private networking and from a docker image:

> shipwright create droplets --fromfile=user_data,~/docker/base-userdata name=01-sfo1-docker region=sfo1 size=512mb image=docker ssh_keys=[<key id>,<key id>] private_networking=true
droplet:
    features:
        - virtio
    id:                 <droplet id>
    vcpus:              1
    networks:

    name:               01-sfo1-docker
    disk:               20
    memory:             512
    locked:             true
    size:

    snapshot_ids:
        (empty array)
    backup_ids:
        (empty array)
    image:

    kernel:
    id:      4782
    name:    Ubuntu 14.04 x64 vmlinuz-3.13.0-52-generic-docker-memlimit
    version: 3.13.0-52-generic
    size_slug:          512mb
    status:             new
    next_backup_window: null
    created_at:         2015-06-19T20:32:02Z
    region:

    links:
        actions:
            -
            id:   <action id>
            rel:  create
            href: https://api.digitalocean.com/v2/actions/<action id>

Contributing

Pull requests are very welcome! Just make sure your code:

  1. Passes jshint given the included .jshintrc

  2. Is beautified using jsbeautifier and the included .jsbeautifyrc

Why?

I wanted a command line tool that gave me nearly direct access to the DigitalOcean API. Shipwright basically just passes things on to the API. It's really just a glorified curl.

CHANGELOG

v0.1.1

  • Improved error handling.

v0.1.0

  • Added the --wait option to wait for action completion.

v0.0.1

  • Initial release.