chore: remove target args

This commit is contained in:
Charlie Lamb
2026-04-17 16:38:42 +01:00
parent 263fa81311
commit 545126451a

View File

@@ -10,26 +10,14 @@ import {
S3Client, S3Client,
} from "@aws-sdk/client-s3"; } from "@aws-sdk/client-s3";
import { import {
ADMIN_REQUEST_BLOCK_CONFIG_KEY as REQUEST_BLOCK_CONFIG_KEY,
getAdminS3Config, getAdminS3Config,
ADMIN_REQUEST_BLOCK_CONFIG_KEY as REQUEST_BLOCK_CONFIG_KEY,
} from "@server/external/aws/s3/adminS3Config.js"; } from "@server/external/aws/s3/adminS3Config.js";
const DEFAULT_REQUEST_BLOCK_CONFIG = { const DEFAULT_REQUEST_BLOCK_CONFIG = {
orgs: {}, orgs: {},
}; };
const getTargetFromArgs = () => {
const hasDevFlag = process.argv.includes("--dev");
const hasProdFlag = process.argv.includes("--prod");
if (hasDevFlag && hasProdFlag) {
throw new Error("Use either --dev or --prod, not both");
}
if (hasDevFlag) return "dev" as const;
if (hasProdFlag) return "prod" as const;
return undefined;
};
const createS3Client = ({ region }: { region: string }) => { const createS3Client = ({ region }: { region: string }) => {
return new S3Client({ region }); return new S3Client({ region });
}; };
@@ -178,12 +166,11 @@ const ensureRequestBlockConfigExists = async ({
}; };
const main = async () => { const main = async () => {
const target = getTargetFromArgs(); const { bucket, region } = getAdminS3Config();
const { bucket, region } = getAdminS3Config({ target });
const s3Client = createS3Client({ region }); const s3Client = createS3Client({ region });
console.log( console.log(
`Initializing S3 admin config for ${target || process.env.NODE_ENV || "default"} -> s3://${bucket}/${REQUEST_BLOCK_CONFIG_KEY}`, `Initializing S3 admin config for ${process.env.NODE_ENV || "default"} -> s3://${bucket}/${REQUEST_BLOCK_CONFIG_KEY}`,
); );
await ensureBucketExists({ await ensureBucketExists({