GithubHelp home page GithubHelp logo

jameslnewell / satay Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 3.0 1.75 MB

A utility for uploading static sites to AWS S3.

JavaScript 4.92% HTML 33.27% TypeScript 61.80%
aws s3 bucket website static-site deploy upload

satay's Introduction

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

    import satay from '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`
          }
        }
      ],
      {
        shouldUploadUnmodifiedObjects: true
      }
    );
  3. Configure your AWS credentials

  4. Run upload.js

    $ node upload.js

CLI

$ satay --config=satay.config.js

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.
  • shouldCreateBucket - Optional. A boolean. Whether the bucket should be created if it doesn't exist.
  • shouldConfigureBucket - Optional. A boolean. Whether the bucket should be configured as a public website if it doesn't exist.
  • shouldUploadUnmodifiedObjects - Optional. A boolean. Whether the unmodified files on disk should be uploaded even though they are the same as the files in the bucket.
  • shouldDeleteDeletedObjects - Optional. A boolean. Whether the objects in the bucket should be deleted when the files are deleted from disk.

API

satay(bucket: String, groups: Array<Group>, options: Object): Promise

Parameters:

  • bucket - Required. 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.
    • shouldCreateBucket - Optional. A boolean. Whether the bucket should be created if it doesn't exist.
    • shouldConfigureBucket - Optional. A boolean. Whether the bucket should be configured as a public website if it doesn't exist.
    • shouldUploadUnmodifiedObjects - Optional. A boolean. Whether the unmodified files on disk should be uploaded even though they are the same as the files in the bucket.
    • shouldDeleteDeletedObjects - Optional. A boolean. Whether the objects in the bucket should be deleted when the files are deleted from disk.

Change log

Change log

satay's People

Contributors

dependabot[bot] avatar jameslnewell avatar mcous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

satay's Issues

Objects are not created with public access

Hey! Cool little tool you've got here!

I just tried it to deploy a simple little site, and while the "folders" created had the correct permissions set (public read), the objects themselves did not. I had to add params: {ACL: 'public-read'} to all my groups. Since this is a static website upload tool, this seems like a sensible default for params.

Happy to PR if this is something you'd like to do

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.