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

@dotcom-tool-kit/upload-assets-to-s3

Package Overview
Dependencies
Maintainers
2
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotcom-tool-kit/upload-assets-to-s3 - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

jest.config.js

8

lib/commands/upload-assets-to-s3.d.ts

@@ -1,3 +0,3 @@

import { Command } from '@oclif/command';
export interface UploadAssetsToS3Options {
import { Command } from '@dotcom-tool-kit/command';
export declare type UploadAssetsToS3Options = {
accessKeyId: string;

@@ -10,8 +10,8 @@ secretAccessKey: string;

cacheControl: string;
}
};
export default class UploadAssetsToS3 extends Command {
static description: string;
options: UploadAssetsToS3Options;
run(): Promise<void[]>;
run(): Promise<void>;
}
//# sourceMappingURL=upload-assets-to-s3.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const command_1 = require("@oclif/command");
const command_1 = require("@dotcom-tool-kit/command");
const fs = tslib_1.__importStar(require("fs"));

@@ -24,3 +24,3 @@ const aws_sdk_1 = tslib_1.__importDefault(require("aws-sdk"));

async run() {
return uploadAssetsToS3(this.options);
await uploadAssetsToS3(this.options);
}

@@ -59,17 +59,16 @@ }

};
return new Promise((resolve, reject) => {
return s3.upload(params, (error, data) => {
if (error) {
console.error(`Upload of ${basename} to ${options.bucket} failed`);
reject(error);
}
else {
console.log(`Uploaded ${basename} to ${data.Location}`);
resolve();
}
});
});
try {
const data = await s3.upload(params).promise();
console.log(`Uploaded ${basename} to ${data.Location}`);
}
catch (error) {
console.error(`Upload of ${basename} to ${options.bucket} failed`);
throw error;
}
};
async function uploadAssetsToS3(options) {
const files = glob_1.glob.sync(`${options.directory}/**/*{${options.extensions}}`);
// Wrap extensions in braces if there are multiple
const extensions = options.extensions.includes(',') ? `{${options.extensions}}` : options.extensions;
const globFile = `${options.directory}/**/*${extensions}`;
const files = glob_1.glob.sync(globFile);
const s3 = new aws_sdk_1.default.S3({

@@ -76,0 +75,0 @@ accessKeyId: options.accessKeyId,

{
"name": "@dotcom-tool-kit/upload-assets-to-s3",
"version": "0.1.0",
"version": "0.2.0",
"description": "",
"main": "lib",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest --silent"
},

@@ -13,3 +13,3 @@ "keywords": [],

"dependencies": {
"@oclif/command": "^1.8.0",
"@dotcom-tool-kit/command": "^0.2.0",
"aws-sdk": "^2.901.0",

@@ -29,4 +29,7 @@ "glob": "^7.1.6",

"@types/glob": "^7.1.3",
"@types/mime": "^2.0.3"
"@types/jest": "^26.0.23",
"@types/mime": "^2.0.3",
"jest": "^26.6.3",
"ts-jest": "^26.5.6"
}
}

@@ -1,2 +0,2 @@

import { Command } from '@oclif/command'
import { Command } from '@dotcom-tool-kit/command'
import * as fs from 'fs'

@@ -8,3 +8,3 @@ import aws from 'aws-sdk'

export interface UploadAssetsToS3Options {
export type UploadAssetsToS3Options = {
accessKeyId: string

@@ -32,4 +32,4 @@ secretAccessKey: string

async run(): Promise<void[]> {
return uploadAssetsToS3(this.options)
async run(): Promise<void> {
await uploadAssetsToS3(this.options)
}

@@ -73,17 +73,16 @@ }

return new Promise<void>((resolve, reject) => {
return s3.upload(params, (error: Error, data: { Location: string }) => {
if (error) {
console.error(`Upload of ${basename} to ${options.bucket} failed`)
reject(error)
} else {
console.log(`Uploaded ${basename} to ${data.Location}`)
resolve()
}
})
})
try {
const data = await s3.upload(params).promise()
console.log(`Uploaded ${basename} to ${data.Location}`)
} catch (error) {
console.error(`Upload of ${basename} to ${options.bucket} failed`)
throw error
}
}
async function uploadAssetsToS3(options: UploadAssetsToS3Options) {
const files = glob.sync(`${options.directory}/**/*{${options.extensions}}`)
// Wrap extensions in braces if there are multiple
const extensions = options.extensions.includes(',') ? `{${options.extensions}}` : options.extensions
const globFile = `${options.directory}/**/*${extensions}`
const files = glob.sync(globFile)

@@ -90,0 +89,0 @@ const s3 = new aws.S3({

{
"extends": "../../tsconfig.settings.json",
"include": ["src/**/*"],
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
}
},
"references": [
{
"path": "../command"
}
]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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