satay

1.1.6 • Public • Published

satay

satay Travis

A utility for uploading static sites to AWS S3.

Usage

Using the CLI

  1. Install satay globally:

    $ npm install -g satay
  2. Create a configuration file:

    satay.config.js

    module.exports = {
     
      bucket: 'jameslnewell.me',
      region: 'ap-southeast-2',
     
      groups: [
     
        {
          source: './static',
          include: /\.html$/
        },
     
        //cache finger-printed assets for up to 1 year
        {
          source: './static',
          exclude: /\.html$/,
          params: {
            CacheControl: `Cache-Control: max-age=${60*60*24*365.25}, public`
          }
        }
     
      ]
     
    };
  3. Configure your AWS credentials

  4. Run satay

    $ satay

Using the API

  1. Install satay locally:

    $ npm install --save-dev satay
  2. Create a script file:

    upload.js

    const satay = require('satay');
     
    satay('jameslnewell.me', [
     
        {
          source: './static',
          include: /\.html$/
        },
     
        //cache finger-printed assets for up to 1 year
        {
          source: './static',
          exclude: /\.html$/,
          params: {
            CacheControl: `Cache-Control: max-age=${60*60*24*365.25}, public`
          }
        }
     
    ], {region: 'ap-southeast-2'});
     
  3. Configure your AWS credentials

  4. Run upload.js

    $ node upload.js

CLI

$ satay --config=satay.config.js --force-upload

Flags:

  • --config - Optional. The configuration file name. Defaults to satay.config.js in the current working directory.
  • --force-upload - Optional. Forces all files to be uploaded regardless of whether the files have been modified. Useful for applying new metadata.

Configuration

Properties:

  • bucket - Optional. A string. The name of the bucket.
  • region - Optional. A string. The bucket region. Defaults to the region defined elsewhere by AWS configuration.
  • groups - Required. An array of file groupings.
    • source - Optional. A string. The directory that will be searched. Defaults to process.cwd().
    • include - Optional. A RegExp or function. A regular expression or function to filter which files are included.
    • exclude - Optional. A RegExp or function. A regular expression or function to filter which files are excluded.
    • prefix - Optional. A string. The prefix that will be prepended to the object key. Defaults to "".
    • params - Optional. An object. The additional parameters to pass to S3.putObject(). Defaults to {ContentType: mime.lookup(filename), ACL: 'public-read'}.
  • policy - Optional. An object. The AWS policy. Defaults to public read access for all files.
  • websiteConfig - Optional. An object. The AWS website configuration. Uses index.html as the default IndexDocument and 404.html as the default ErrorDocument.

API

satay(bucketString, groupsArray<Group>, optionsObject)Promise

Parameters:

  • bucket - Optional. A string. The name of the bucket.
  • groups - Required. An array of file groupings.
    • source - Optional. A string. The directory that will be searched. Defaults to process.cwd().
    • include - Optional. A RegExp or function. A regular expression or function to filter which files are included.
    • exclude - Optional. A RegExp or function. A regular expression or function to filter which files are excluded.
    • prefix - Optional. A string. The prefix that will be prepended to the object key. Defaults to "".
    • params - Optional. An object. The additional parameters to pass to S3.putObject(). Defaults to {ContentType: mime.lookup(filename), ACL: 'public-read'}.
  • options - Optional. An object. Additional options.
    • region - Optional. A string. The bucket region. Defaults to the region defined elsewhere by AWS configuration.
    • policy - Optional. An object. The AWS policy. Defaults to public read access for all files.
    • websiteConfig - Optional. An object. The AWS website configuration. Uses index.html as the default IndexDocument and 404.html as the default ErrorDocument.

Change log

Change log

Package Sidebar

Install

npm i satay

Weekly Downloads

2

Version

1.1.6

License

MIT

Last publish

Collaborators

  • jameslnewell
  • nicktho