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

betty

v0.0.1

Published

betty is a command line utility for uploading static websites to s3.

Downloads

3

Readme

Betty

Betty is a command line utility for uploading static websites to S3.

Installation

Betty requires Node.js v0.10.x. Use npm to install Betty:

$ npm install -g betty

Usage

Betty uploads files from a folder to an S3 bucket:

$ betty <folder> <bucket>

Let's use Betty to upload the folder "folder" with the file "index.html" to the bucket named "bucket":

$ betty folder/ bucket
[betty] Uploading 1 files from folder/ to bucket/.
[betty] PUT  index.html
[betty] Uploaded in 230ms

Betty is smart. Try the upload again:

$ betty folder/ bucket
[betty] Uploading 1 files from folder/ to bucket/.
[betty] SKIP index.html
[betty] Uploaded in 100ms

Betty doesn't upload unchanged files!

Betty uses AWS keys from environment variables AWS_ACCESS_KEY and AWS_SECRET_ACCESS_KEY:

$ betty folder/ bucket
[betty] The "AWS_ACCESS_KEY" environment variable must be set.

If you can't set them in your environment pass them directly:

$ AWS_ACCESS_KEY=key AWS_SECRET_ACCESS_KEY=secret betty folder/ bucket

Betty assumes the content you are uploading is for a public static website and sets approriate HTTP headers:

$ curl -s -D - bucket.s3.amazonaws.com/index.html
HTTP/1.1 200 OK
...
Cache-Control: public,max-age=600
Content-Type: text/html; charset=UTF-8

Optionally, you may pass Betty a "destination" to prefix upload paths:

$ betty <folder> [destination] <bucket>

To upload our file "index.html" to "blog/index.html":

$ betty folder/ blog bucket
[betty] Uploading 1 files from folder/ to bucket/blog.
[betty] PUT  blog/index.html
[betty] Uploaded in 221ms

To see what Betty would do without making changes set the "--dry-run" flag:

$ betty --dry-run folder/ bucket

To make Betty less chatty, pass the "--quiet" flag:

$ betty --quiet folder/ bucket

Features

  • Sane out of the box defaults for uploading public static websites to S3.
  • Parrallel operations for speedy uploads.
  • Minimizes network traffic by using S3's copy functionality where possible.

Upload details

  • Betty doesn't upload dotfiles.

  • Betty doesn't follow symlinks.

  • Betty adds headers to uploaded files:

      # Headers added for HTML files:
      x-amz-acl: public-read
      Content-Type: text/html; charset=UTF-8
      Cache-Control: public,max-age=<5 minutes>
    
      # Headers added for images, CSS and JavaScript:
      x-amz-acl: public-read
      Content-Type: <content type>; charset=UTF-8
      Cache-Control: public,max-age=<1 year>

Upload strategy

Betty minimizes network traffic to S3 by using copy where possible. Only content that doesn't already exist on S3 is uploaded. If the same content would be uploaded to multiple locations, Betty uploads it once and then copies it to the other locations.

Note that Betty restricts its search for matching content to the bucket's destination, so if matching content exists in the bucket outside of the destination there will be no benefits.