s3-npm-cache
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "s3-npm-cache", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Lightweight runtime to cache NPM dependencies in S3", | ||
@@ -34,3 +34,2 @@ "license": "MIT", | ||
"aws-sdk": "^2.11.0", | ||
"fs-walk": "0.0.1", | ||
"md5-file": "^3.1.1", | ||
@@ -37,0 +36,0 @@ "q": "^1.4.1", |
@@ -29,2 +29,3 @@ # S3 NPM Cache | ||
- Bower support | ||
- Multi-region support (currently defaults to ap-southeast-2) | ||
- Multi-region support (currently defaults to ap-southeast-2) | ||
- NPM shrinkwrap support |
@@ -7,3 +7,5 @@ /* | ||
path = require('path'), | ||
helpers = require('./helpers.js'); | ||
s3 = require('./lib/s3'), | ||
archive = require('./lib/archive'), | ||
misc = require('./lib/misc'); | ||
@@ -16,7 +18,7 @@ var init = function (s3BucketName, packageJsonFileLocation) { | ||
var unzipNodeModules = function (buffer) { | ||
console.log('Found ZIP file. Unzipping.'); | ||
helpers.unzip(buffer, nodeModulesFolder); | ||
console.log('Downloaded ZIP file from S3. Unzipping...'); | ||
archive.unzip(buffer, nodeModulesFolder); | ||
console.log('Running NPM rebuild...'); | ||
helpers.npmAction(packageJsonFileLocation, 'rebuild'); | ||
console.log('NPM rebuilding...'); | ||
misc.npmAction(packageJsonFileLocation, 'rebuild'); | ||
@@ -27,39 +29,47 @@ console.log('Done!'); | ||
var uploadNewFile = function (err) { | ||
if (err.code === 'NoSuchKey') { | ||
console.log(s3PackageName, 'not found . Uploading new package...'); | ||
if (err.code !== 'NoSuchKey') { | ||
console.warn('Error occurred attempting connection to S3', err); | ||
helpers.npmAction(packageJsonFileLocation, 'install'); | ||
console.log('Node modules installed. Zipping, please wait...'); | ||
console.log('Npm installing...'); | ||
misc.npmAction(packageJsonFileLocation, 'install'); | ||
var zipBuffer = helpers.createZip(nodeModulesFolder); | ||
console.log('Zip created.'); | ||
return; | ||
} | ||
helpers.uploadFileToS3(s3PackageName, zipBuffer) | ||
.then(function () { | ||
console.log('Upload successful.') | ||
}) | ||
.catch(function (err) { | ||
throw new Error(err); | ||
}); | ||
} else { | ||
console.warn('Error occurred attempting connection to S3', err); | ||
console.log(s3PackageName, 'not found . Npm installing...'); | ||
misc.npmAction(packageJsonFileLocation, 'install'); | ||
console.log('Npm installing...'); | ||
helpers.npmAction(packageJsonFileLocation, 'install'); | ||
} | ||
console.log('Node modules installed. Zipping...'); | ||
var zipBuffer = archive.createZip(nodeModulesFolder); | ||
console.log('Zip created. Uploading...'); | ||
s3.uploadFileToS3(s3PackageName, zipBuffer) | ||
.then(function () { | ||
console.log('Done!') | ||
}) | ||
.catch(function (err) { | ||
throw new Error(err); | ||
}); | ||
}; | ||
// Lift off! | ||
if (helpers.checkCredentials()) { | ||
console.log('Attempting to retrieve ZIP file from S3 -', path.join(s3BucketName, s3PackageName)); | ||
if (misc.checkFolderExists(nodeModulesFolder)) { | ||
console.log('Node modules already installed. Continuing...'); | ||
helpers.setS3BucketName(s3BucketName); | ||
helpers.getFileFromS3(s3PackageName) | ||
.then(unzipNodeModules) | ||
.catch(uploadNewFile); | ||
} else { | ||
return; | ||
} | ||
if (!s3.checkCredentials()) { | ||
console.warn('AWS credentials not found. Npm installing...'); | ||
helpers.npmAction(packageJsonFileLocation, 'install'); | ||
helpers.npmAction(packageJsonFileLocation, 'install'); | ||
return; | ||
} | ||
console.log('Attempting to retrieve ZIP file from S3 -', path.join(s3BucketName, s3PackageName)); | ||
s3.setS3BucketName(s3BucketName); | ||
s3.getFileFromS3(s3PackageName) | ||
.then(unzipNodeModules) | ||
.catch(uploadNewFile); | ||
}; | ||
@@ -66,0 +76,0 @@ |
{ | ||
"name": "application-name", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "node-hello-world": "^1.0.9" |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
6800
5
10
146
30
1
- Removedfs-walk@0.0.1
- Removedasync@3.2.6(transitive)
- Removedfs-walk@0.0.1(transitive)