@architect/destroy
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -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 @@ |
{ | ||
"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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10290
246
8
4