satay
A utility for uploading static sites to AWS S3.
Usage
Using the CLI
-
Install
satay
globally:$ npm install -g satay
-
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` } } ] };
-
Configure your AWS credentials
-
Run
satay
$ satay
Using the API
-
Install
satay
locally:$ npm install --save-dev satay
-
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 } );
-
Configure your AWS credentials
-
Run
upload.js
$ node upload.js
CLI
$ satay --config=satay.config.js
Flags:
--config
- Optional. The configuration file name. Defaults tosatay.config.js
in the current working directory.
Configuration
Properties:
bucket
- Optional. Astring
. The name of the bucket.groups
- Required. Anarray
of file groupings.source
- Optional. Astring
. The directory that will be searched. Defaults toprocess.cwd()
.include
- Optional. ARegExp
orfunction
. A regular expression or function to filter which files are included.exclude
- Optional. ARegExp
orfunction
. A regular expression or function to filter which files are excluded.prefix
- Optional. Astring
. The prefix that will be prepended to the object key. Defaults to""
.params
- Optional. Anobject
. The additional parameters to pass toS3.putObject()
. Defaults to{ContentType: mime.lookup(filename), ACL: 'public-read'}
.
policy
- Optional. Anobject
. The AWS policy. Defaults to public read access for all files.website
- Optional. Anobject
. The AWS website configuration. Usesindex.html
as the defaultIndexDocument
and404.html
as the defaultErrorDocument
.shouldCreateBucket
- Optional. Aboolean
. Whether the bucket should be created if it doesn't exist.shouldConfigureBucket
- Optional. Aboolean
. Whether the bucket should be configured as a public website if it doesn't exist.shouldUploadUnmodifiedObjects
- Optional. Aboolean
. Whether the unmodified files on disk should be uploaded even though they are the same as the files in the bucket.shouldDeleteDeletedObjects
- Optional. Aboolean
. 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. Astring
. The name of the bucket.groups
- Required. Anarray
of file groupings.source
- Optional. Astring
. The directory that will be searched. Defaults toprocess.cwd()
.include
- Optional. ARegExp
orfunction
. A regular expression or function to filter which files are included.exclude
- Optional. ARegExp
orfunction
. A regular expression or function to filter which files are excluded.prefix
- Optional. Astring
. The prefix that will be prepended to the object key. Defaults to""
.params
- Optional. Anobject
. The additional parameters to pass toS3.putObject()
. Defaults to{ContentType: mime.lookup(filename), ACL: 'public-read'}
.
options
- Optional. Anobject
. Additional options.policy
- Optional. Anobject
. The AWS policy. Defaults to public read access for all files.website
- Optional. Anobject
. The AWS website configuration. Usesindex.html
as the defaultIndexDocument
and404.html
as the defaultErrorDocument
.shouldCreateBucket
- Optional. Aboolean
. Whether the bucket should be created if it doesn't exist.shouldConfigureBucket
- Optional. Aboolean
. Whether the bucket should be configured as a public website if it doesn't exist.shouldUploadUnmodifiedObjects
- Optional. Aboolean
. Whether the unmodified files on disk should be uploaded even though they are the same as the files in the bucket.shouldDeleteDeletedObjects
- Optional. Aboolean
. Whether the objects in the bucket should be deleted when the files are deleted from disk.