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
moduleexports =bucket: 'jameslnewell.me'region: 'ap-southeast-2'groups:source: './static'include: /\.html$///cache finger-printed assets for up to 1 yearsource: './static'exclude: /\.html$/params:CacheControl: `Cache-Control: max-age=, 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
const satay = ;; -
Configure your AWS credentials
-
Run
upload.js
$ node upload.js
CLI
$ satay --config=satay.config.js --force-upload
Flags:
--config
- Optional. The configuration file name. Defaults tosatay.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. Astring
. The name of the bucket.region
- Optional. Astring
. The bucket region. Defaults to the region defined elsewhere by AWS configuration.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.websiteConfig
- Optional. Anobject
. The AWS website configuration. Usesindex.html
as the defaultIndexDocument
and404.html
as the defaultErrorDocument
.
API
sataybucket: String, groups: Array<Group>, options: Object: Promise
Parameters:
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'}
.
options
- Optional. Anobject
. Additional options.region
- Optional. Astring
. The bucket region. Defaults to the region defined elsewhere by AWS configuration.policy
- Optional. Anobject
. The AWS policy. Defaults to public read access for all files.websiteConfig
- Optional. Anobject
. The AWS website configuration. Usesindex.html
as the defaultIndexDocument
and404.html
as the defaultErrorDocument
.