satay
1.0.0
A utility for uploading static sites to AWS S3.
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
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
$ satay --config=satay.config.js
Flags:
--config
- Optional. The configuration file name. Defaults to satay.config.js
in the current working directory.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.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