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

@artsy/bucket-assets

v1.0.3

Published

Uploads a folder of static assets to an s3 bucket with convenient assumptions.

Downloads

45

Readme

bucket-assets

Uploads a folder of static assets to an s3 bucket with convenient features. These include:

  • Fingerprints asset package based on file contents
  • Uploads a manifest file that stores a git hash to make rollback easy (first checks for the manifest stored in the ASSET_MANIFEST env variable, then checks the COMMIT_HASH env variable, then runs a git rev-parse HEAD)
  • Provides middleware to easily point to your uploaded assets
  • Adds appropriate s3 headers like setting files to 'public-read' and 'Content-Type'.

Bucket Assets is used in deploys of Artsy apps, but may be useful for you too.

Example

Run the CLI in your deployment process. You may omit these arguments if you use the defaults below.

bucket-assets \
  --files **/public/** \
  --secret s3-secret \
  --key s3-key \
  --bucket force-production \
  --fingerprint true

Add the middleware to your app

var bucketAssets = require('bucket-assets');
app.use(bucketAssets({

  // Glob that defaults to finding all files in "public" folders that
  // are children of process.cwd() e.g. /public + /components/modal/public.
  // Will always ignore public folders in node_modules.
  files: __dirname + '/**/public/**',

  // Defaults to "public". The name of the folder that is the root static
  // directory so relative paths work the same locally as they do on the CDN.
  root: 'public',

  // Defaults to process.env.S3_KEY
  key: 's3-key',

  // Defaults to process.env.S3_SECRET
  secret: 's3-secret',

  // Defaults to process.env.S3_BUCKET
  bucket: 'force-production',

  // Defaults to process.env.CDN_URL
  cdnUrl: '//xyz.cloudfront.net/',

  // Defaults to true. Use `false` to not use fingerprinting.
  fingerprint: true
}));

Use the view helper to point to the fingerprinted CDN assets in production or staging.

head
  link( type='text/css', rel='stylesheet', href=asset('main.css') )
body
  script( src=asset('main.js') )

With Heroku

Be sure to set env variables for production/staging if you're relying on the defaults

On your CI machine

S3_KEY=
S3_SECRET=

Run with deploy script

heroku config:set ASSET_MANIFEST=$(cat manifest.json)

Set once

heroku config:set CDN_URL=

Contributing

Please fork the project and submit a pull request with tests. Install node modules npm install and run tests with npm test.

License

MIT