From 3f1b2fe5a933f0921d5f5763e5dde6da0802b3f4 Mon Sep 17 00:00:00 2001 From: Mateo Presa Castro Date: Thu, 7 Nov 2024 11:11:46 +0100 Subject: [PATCH] fix: Create mock bueckts not on test --- lib/aws/mod.ts | 11 +---------- lib/utils.ts | 4 ++-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/aws/mod.ts b/lib/aws/mod.ts index 04a61b7..e1cf085 100644 --- a/lib/aws/mod.ts +++ b/lib/aws/mod.ts @@ -11,20 +11,18 @@ import { GetObjectCommand, DeleteObjectCommand, CreateBucketCommand, - ListObjectsCommand, } from "@aws-sdk/client-s3"; import "server-only"; (async () => { if (!isDev) return; await createLocalStackBuckets(); - await listAllObjects(); })(); async function createLocalStackBuckets() { const buckets = await listBuckets(); if (buckets && buckets.length > 0) return; - [AWS_PUBLIC_BUCKET_NAME, AWS_PRIVATE_BUCKET_NAME, "test-bucket"].forEach( + [AWS_PUBLIC_BUCKET_NAME, AWS_PRIVATE_BUCKET_NAME].forEach( async (bucket) => await s3.send( new CreateBucketCommand({ @@ -39,13 +37,6 @@ async function createLocalStackBuckets() { console.log("Buckets created on localstack", await listBuckets()); } -async function listAllObjects() { - [AWS_PUBLIC_BUCKET_NAME, AWS_PRIVATE_BUCKET_NAME].forEach(async (bucket) => { - const objects = await s3.send(new ListObjectsCommand({ Bucket: bucket })); - console.log("Objects in bucket: ", bucket, objects); - }); -} - export async function listBuckets() { try { const data = await s3.send(new ListBucketsCommand({})); diff --git a/lib/utils.ts b/lib/utils.ts index 741d3ac..b83b1a5 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -5,8 +5,8 @@ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } -export const isDev = - process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test"; +export const isDev = process.env.NODE_ENV === "development"; +export const isTest = process.env.NODE_ENV === "test"; export function createSamplePackName(str: string) { return str