generated from nhcarrigan/template
30 lines
902 B
TypeScript
30 lines
902 B
TypeScript
|
import { ListObjectsV2Command, S3Client } from "@aws-sdk/client-s3";
|
||
|
import { writeFile } from "fs/promises";
|
||
|
import { join } from "path";
|
||
|
|
||
|
(async () => {
|
||
|
const s3 = new S3Client({
|
||
|
endpoint: "https://sfo3.digitaloceanspaces.com",
|
||
|
region: "sfo3",
|
||
|
credentials: {
|
||
|
accessKeyId: process.env.DO_ACCESS_KEY as string,
|
||
|
secretAccessKey: process.env.DO_SECRET_KEY as string
|
||
|
}
|
||
|
})
|
||
|
|
||
|
const command = new ListObjectsV2Command({
|
||
|
Bucket: "nhcarrigan-cdn",
|
||
|
Prefix: "koikatsu"
|
||
|
})
|
||
|
|
||
|
const { Contents } = await s3.send(command);
|
||
|
|
||
|
const names = Contents?.map((content) => content.Key?.replace("koikatsu/", "")).filter((name) => name) || [];
|
||
|
|
||
|
await writeFile(join(process.cwd(), "src", "config", "Koikatsu.ts"), `/**
|
||
|
* @copyright nhcarrigan
|
||
|
* @license Naomi's Public License
|
||
|
* @author Naomi Carrigan
|
||
|
*/
|
||
|
export const Koikatsu = ${JSON.stringify(names, null, 2)};`, "utf-8");
|
||
|
})()
|