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.8 to 0.1.0

36

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

@@ -13,5 +13,6 @@ const spawn = require('child_process').spawn;

.version('0.0.1')
.option('--delete_exclude <type>', 'Directories to exclude in the sync')
.requiredOption('--directory <type>', 'Directory of the site to upload')
.requiredOption('--bucket_name <type>', 'The name of the bucket to upload to');
program.parse(process.argv);

@@ -23,9 +24,10 @@

const bucketName = opts['bucket_name'];
const deleteExclude = opts['delete_exclude'];
logMetadata(directory, bucketName);
logMetadata(directory, deleteExclude, bucketName);
await publishToS3Bucket(directory, bucketName);
await publishToS3Bucket(directory, deleteExclude, bucketName);
}
function logMetadata(directory, bucketName) {
function logMetadata(directory, deleteExclude, bucketName) {
console.log(`

@@ -36,2 +38,3 @@

📂 Directory: ${directory}
📂 Delete Exclude: ${deleteExclude}
🗑️ Bucket: ${bucketName}

@@ -42,7 +45,7 @@

async function publishToS3Bucket(dir, bucketName) {
async function publishToS3Bucket(dir, deleteExclude, bucketName) {
const s3Bucket = `s3://${bucketName}/`;
const shortTermCacheExt = ['html', 'xml', 'json', 'svg'];
const longTermCacheExt = ['css', 'js', 'png', 'jpg', 'jpeg', 'gif', 'webp', 'woff', 'woff2', 'mp3', 'pdf'];
const longTermCacheExt = ['css', 'js', 'png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'woff', 'woff2', 'mp3', 'pdf'];
const deleteExt = shortTermCacheExt.concat(longTermCacheExt);

@@ -57,3 +60,3 @@ const steps = [

// Delete any files we no longer need
makeSyncDelete(dir, s3Bucket, deleteExt),
makeSyncDelete(dir, deleteExclude, s3Bucket, deleteExt),
];

@@ -81,8 +84,8 @@

function makeSyncDelete(dir, s3Bucket, extensions) {
function makeSyncDelete(dir, deleteExclude, s3Bucket, extensions) {
const parts = [
`aws s3 sync ${dir} ${s3Bucket}`,
'--delete',
'--exclude', '*',
]
for (const e of extensions) {

@@ -92,2 +95,9 @@ parts.push(`--include`, `*.${e}`)

// Exclude at the end to ensure the generated files are excluded
if (deleteExclude) {
parts.push('--exclude', deleteExclude)
} else {
parts.push('--exclude', '*')
}
return parts.join(" ")

@@ -103,11 +113,11 @@ }

const cmdProcess = spawn(cmdPieces[0], cmdPieces.splice(1))
cmdProcess.stdout.on('data', function (data) {
console.log(`${data}`);
});
cmdProcess.stderr.on('data', function (data) {
console.error(`${data}`);
});
cmdProcess.on('close', function (code) {

@@ -114,0 +124,0 @@ if (code != 0) {

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

},
"version": "0.0.8",
"version": "0.1.0",
"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