1.1.6 • Published 5 years ago

satay v1.1.6

Weekly downloads
163
License
MIT
Repository
github
Last release
5 years ago

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',
    
      groups: [
        {
          source: './static',
          include: /\.html$/
        },
    
        //cache finger-printed assets for up to 1 year
        {
          source: './static',
          exclude: /\.html$/,
          params: {
            CacheControl: `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: `max-age=${60 * 60 * 24 * 365.25}, public`
        }
      }
    ]);
  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.

Configuration

Properties:

  • 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'}.
  • policy - Optional. An object. The AWS policy. Defaults to public read access for all files.
  • website - Optional. An object. The AWS website configuration. Uses index.html as the default IndexDocument and 404.html as the default ErrorDocument.

API

satay(bucket: String, groups: Array<Group>, options: Object): 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.
    • policy - Optional. An object. The AWS policy. Defaults to public read access for all files.
    • website - 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