Skip to content

Commit

Permalink
Removed default values for arguments. It interferes with environment …
Browse files Browse the repository at this point in the history
…variables
  • Loading branch information
willemliufdmg committed Feb 9, 2022
1 parent 4eb0f51 commit 189b26d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.env
.env*
analyzer
dist
images
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fdmg/imgix-upload",
"version": "0.0.5",
"version": "0.0.6",
"description": "Command-line tool to upload images to the FDMG IMGIX S3 Bucket",
"main": "dist/app.js",
"preferGlobal": true,
Expand All @@ -17,8 +17,10 @@
"build:dev": "webpack --mode=development",
"dry-run": "npm run start -- --dry-run -s -v",
"dogfood": "dotenv fiu -- -v -s -i ./images",
"dogfood2": "dotenv fiu -- -v -s -i ./public/images",
"help": "node -r dotenv/config dist/app.js --help",
"start": "node -r dotenv/config dist/app.js -o ./imageMap.json -i ./images -s",
"start2": "node -r dotenv/config dist/app.js -o ./imageMap.json -i ./public/images -s",
"release:fdmg": "node modifyPackageJson.js -s @fdmg",
"release:fdmediagroep": "node modifyPackageJson.js -s @fdmediagroep",
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
20 changes: 11 additions & 9 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ type Hashes = {
const argv: any = yargs(process.argv.slice(2)).options({
bucket: {
alias: "b",
default: "fd-dev-public-images",
description: "S3 bucket",
requiresArg: true,
required: false,
},
cacheControl: {
alias: "c",
default: "max-age=15768000",
description: "cache-control header",
requiresArg: true,
required: false,
Expand All @@ -42,29 +40,25 @@ const argv: any = yargs(process.argv.slice(2)).options({
},
environment: {
alias: "e",
default: "development",
description: "Environment: development | acceptance | production",
requiresArg: true,
required: false,
},
imagesFolder: {
alias: "i",
default: "./public",
description: "folder holding all the images",
description: "folder holding all the images e.g.: ./public",
requiresArg: true,
required: true,
},
outputImageMapLocation: {
alias: "o",
default: "./imageMap.json",
description: "output image map file name",
description: "output image map file name e.g.: ./imageMap.json",
requiresArg: true,
required: true,
},
region: {
alias: "r",
default: "eu-west-1",
description: "AWS Region",
description: "AWS Region e.g: eu-west-1",
requiresArg: true,
required: false,
},
Expand Down Expand Up @@ -160,6 +154,14 @@ async function uploadToS3(absolutePath: string, hashedFileName: string) {
mime.contentType(absolutePath.replace(/\//g, "")) || undefined;
if (!argv.dryRun) {
try {
console.log({
Bucket,
CacheControl,
Key: hashedFileName,
ContentType,
ContentEncoding: "gzip",
ACL: "public-read",
});
// Put object to S3.
await s3
.upload({
Expand Down

0 comments on commit 189b26d

Please sign in to comment.