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

s3-npm-cache

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

s3-npm-cache - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

lib/archive.js

3

package.json
{
"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"

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