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

@architect/destroy

Package Overview
Dependencies
Maintainers
5
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@architect/destroy - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

8

changelog.md

@@ -5,2 +5,10 @@ # Architect Sandbox changelog

## [1.0.5] 2021-02-26
### Changed
- Emptying out S3 bucket contents now supports buckets that contain more than 1,000 objects.
---
## [1.0.4] 2020-12-04

@@ -7,0 +15,0 @@

9

package.json
{
"name": "@architect/destroy",
"version": "1.0.4",
"version": "1.0.5",
"description": "Destroy projects created with Architect",

@@ -11,4 +11,5 @@ "main": "src/index.js",

"lint": "eslint . --fix",
"test": "npm run lint && npm run test:unit",
"test:unit": "cross-env echo TODO add some unit tests, please!",
"test": "npm run lint && npm run coverage",
"test:unit": "cross-env tape 'test/unit/**/*-test.js' | tap-spec",
"coverage": "cross-env FUSE=0 nyc --reporter=lcov --reporter=text npm run test:unit",
"test:integration": "cross-env tape test/integration/**/*-test.js | tap-spec",

@@ -34,4 +35,6 @@ "rc": "npm version prerelease --preid RC"

"@architect/eslint-config": "1.0.0",
"aws-sdk-mock": "~5.1.0",
"cross-env": "~7.0.3",
"eslint": "~7.14.0",
"nyc": "~15.1.0",
"tap-spec": "^5.0.0",

@@ -38,0 +41,0 @@ "tape": "^5.0.1"

@@ -9,29 +9,48 @@ let aws = require('aws-sdk')

waterfall([
function (callback) {
s3.listObjectsV2({ Bucket: bucket }, function done (err, result) {
if (err) {
callback(err)
let objects = []
function collectObjects (ContinuationToken, callback) {
s3.listObjectsV2({
Bucket: bucket,
ContinuationToken
}, function done (err, result) {
if (err) {
callback(err)
}
else {
objects = objects.concat(result.Contents)
if (result.IsTruncated) {
collectObjects(result.NextContinuationToken, callback)
}
else if (result.IsTruncated) {
throw Error('bucket has too many objects to delete')
}
else {
callback(null, result.Contents.map(item => ({ Key: item.Key })))
callback(null, objects.map(item => ({ Key: item.Key })))
}
})
}
})
}
function deleteObjects (objs, callback) {
let batch = objs.splice(0, 1000) // S3.deleteObjects supports up to 1k keys
s3.deleteObjects({
Bucket: bucket,
Delete: {
Objects: batch
}
},
function done (err) {
if (err) callback(err)
else if (objs.length) {
deleteObjects(objs, callback)
}
else callback()
})
}
waterfall([
function (callback) {
collectObjects(null, callback)
},
function (stuffToDelete, callback) {
if (Array.isArray(stuffToDelete) && stuffToDelete.length > 0) {
s3.deleteObjects({
Bucket: bucket,
Delete: {
Objects: stuffToDelete
}
},
function done (err) {
if (err) callback(err)
else callback()
})
deleteObjects(stuffToDelete, callback)
}

@@ -38,0 +57,0 @@ else {

@@ -42,3 +42,3 @@ let aws = require('aws-sdk')

callback()
}, 5000)
}, process.env.FUSE ? parseInt(process.env.FUSE) : 5000) // provide an override (mostly for testing)
},

@@ -45,0 +45,0 @@

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