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

aws-sync-n-invalidate

v2.3.5

Published

Syncs a local directory to an AWS S3 bucket, optionally invalidating affected CloudFront paths.

Downloads

9

Readme

deploy-aws-s3-cloudfront

Syncs a local directory to an AWS S3 bucket, optionally invalidating affected CloudFront paths.

Installation

npm install --save deploy-aws-s3-cloudfront

Authentication

This packages uses the AWS SDK for Node.js and defers authentication to the SDK.

If you are relying on credentials stored in ~/.aws/credentials you can use AWS_PROFILE=<profile> deploy-aws-s3-cloudfront ... to use a custom-named profile.

Usage

deploy-aws-s3-cloudfront --bucket <bucket> [options]

Options

--acl <canned-acl>

A canned ACL string. See https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property for accepted values.

--bucket <name> (required)

AWS S3 bucket name to deploy to.

--delete

Delete files from AWS S3 that do not exist locally.

--destination <path>

Path to remote directory to sync to.

--distribution <ID>

AWS CloudFront distribution ID to invalidate.

No invalidation is performed if this option is omitted.

--exclude <pattern> [<pattern>...]

Pattern(s) to exclude from deployment.

Refer to the fast-glob documentation for supported patterns.

--invalidation-path <path>

Set the invalidation path (URL-encoded if necessary) instead of automatically detecting objects to invalidate.

This can be used to explicity set the invalidation path rather than have the paths generated from the changeset.

This option is typically used to reduce invalidation costs by using a wildcard pattern (e.g. --invalidation-path "/*").

--cache-control-no-cache <path> [<path>...]

Disable caching of specified S3 path(s). Paths ending with a * will be treated as wildcards.

--non-interactive

Do not prompt for confirmation.

--react

Use recommended settings for create-react-apps and disable caching of index.html.

Default value false

--source <path>

Path to local directory to sync from.

Default value .

Installation as a run-script alias (optional)

Add a deploy script alias to your package.json file:

{
  ...
  "scripts": {
    ...
    "deploy": "deploy-aws-s3-cloudfront --bucket my-bucket"
  }
}

Run yarn run deploy to deploy.

If you need to pass user or environment-level options that you don't want committed into package.json you can provide these at call-time, e.g. yarn run deploy --distribution abc123.

Configuration for create-react-app projects

Pass the --react option when deploying apps created using create-react-app. This is shortcut for deploy-aws-s3-cloudfront --source ./build/ --cache-control-no-cache index.html.

Alternatives (and why this package exists!)

  • AWS S3 Sync (bundled with AWS CLI)

    The aws s3 sync command uses the modification time to identify modified assets. This doesn't work well when building a project often involves regenerating files with fresh timestamps but identical content.

    This package will instead perform a checksum comparison to minimise the deployment payload. The MD5 checksum will be computed against local files then compared against the ETag of the corresponding remote objects.

  • react-deploy-s3

    For React apps, the react-deploy-s3 provides similar behaviour to this package. However, react-deploy-s3 expects your AWS credentials to be passed in as command arguments and requires additional configuration to get set up. In contrast, this package defers authentication to the AWS SDK and therefore supports multiple authentication strategies (e.g. IAM roles, environment variables and profiles).

    Additionally, react-deploy-s3 will purge everything from your S3 bucket before re-uploading the entire build directory. Here, however, deployments are incremental resulting in a smaller payload and minimal interruption. Likewise, this package will perform a more efficient CloudFront purge by executing an invalidation on the affected paths only, as opposed to a site-wide refresh as performed by react-deploy-s3.