Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gauntface/cli

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gauntface/cli - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

39

gauntface-aws-s3-deploy-static-site.js

@@ -42,11 +42,14 @@ const spawn = require('child_process').spawn;

const shortTermCacheExt = ['html', 'xml', 'json', 'svg'];
const longTermCacheExt = ['css', 'js', 'png', 'jpg', 'jpeg', 'gif', 'webp', 'woff', 'woff2', 'mp3'];
const deleteExt = shortTermCacheExt.concat(longTermCacheExt);
const steps = [
// Sync latest files with the s3 bucket
`aws s3 sync ${dir} ${s3Bucket} --delete --acl public-read`,
// Add cache headers for assets that do not have a hash
makeCopyCmd(s3Bucket, 86400, ['html', 'xml', 'json', 'svg']),
makeSyncCmd(dir, s3Bucket, 86400, shortTermCacheExt),
// Add cache headers for assets that do have a hash
makeCopyCmd(s3Bucket, 31104000, ['css', 'js', 'png', 'jpg', 'jpeg', 'gif', 'webp', 'woff', 'woff2', 'mp3']),
makeSyncCmd(dir, s3Bucket, 31104000, longTermCacheExt),
// Delete any files we no longer need
makeSyncDelete(dir, s3Bucket, deleteExt),
];

@@ -59,16 +62,13 @@

function makeCopyCmd(s3Bucket, maxAge, extensions) {
function makeSyncCmd(dir, s3Bucket, maxAge, extensions) {
const parts = [
`aws s3 cp ${s3Bucket} ${s3Bucket}`,
'--exclude="*"',
`aws s3 sync ${dir} ${s3Bucket}`,
'--acl', 'public-read',
'--exclude', '*',
]
for (const e of extensions) {
parts.push(`--include="*.${e}"`)
parts.push(`--include`, `*.${e}`)
}
// --cache-control Set cache control headers
parts.push(`--cache-control 'max-age=${maxAge}'`);
// --acl public-read Makes files accessible via web browser
parts.push(`--acl public-read`);
// --recursive Copy subdirectories and files
parts.push(`--recursive`);

@@ -78,2 +78,15 @@ return parts.join(" ")

function makeSyncDelete(dir, s3Bucket, extensions) {
const parts = [
`aws s3 sync ${dir} ${s3Bucket}`,
'--delete',
'--exclude', '*',
]
for (const e of extensions) {
parts.push(`--include`, `*.${e}`)
}
return parts.join(" ")
}
async function runCmd(cmd) {

@@ -80,0 +93,0 @@ console.log(`🤖 Running \`${cmd}\``);

@@ -6,3 +6,3 @@ {

},
"version": "0.0.6",
"version": "0.0.7",
"description": "A CLI tool to help with repetitive tasks.",

@@ -9,0 +9,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc