summaryrefslogtreecommitdiff
path: root/build.ts
diff options
context:
space:
mode:
authorseth <[email protected]>2024-07-29 04:53:25 -0400
committerGitHub <[email protected]>2024-07-29 04:53:25 -0400
commit984f4cfa24ee7e421bb1fbdf5907ae60375cf9ef (patch)
treef23c500548bdc82dfe4eb65233327312435ec6b6 /build.ts
parent9358cb6437bbe257717fe6cfd113aa9c34054c6c (diff)
use github contents api for image urls + summer cleaning (#253)
* nix: alejandra -> nixfmt-rfc-style * nix: pre-commit-hooks -> treefmt-nix * nix: use corepack * ci: cleanup workflows * ci: use better dependabot scopes * gitignore: extend with github templates * remove teawie-archive submodule * pnpm: 8.8.0 -> 9.6.0 * nix: add nrr to shell * nix: add node lsps to shell * use github contents api for image urls * ci: cleanup workflows * nix: add ci shell * `octokit` -> `fetch` & cache responses * nix: use nixpkgs wrangler * nix: update flake.lock Flake lock file updates: • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/d9c0b9d611277e42e6db055636ba0409c59db6d2' (2024-07-05) → 'github:NixOS/nixpkgs/038fb464fcfa79b4f08131b07f2d8c9a6bcc4160' (2024-07-28) * tsconfig: use strictest * adopt openapi * package.json: rename to teawie-api * nix: add treefmt to ci shell * ci: add release gate
Diffstat (limited to 'build.ts')
-rw-r--r--build.ts62
1 files changed, 2 insertions, 60 deletions
diff --git a/build.ts b/build.ts
index 95e29fd..238cf9c 100644
--- a/build.ts
+++ b/build.ts
@@ -1,67 +1,9 @@
import { BuildOptions, build } from "esbuild";
-import { existsSync } from "node:fs";
-import { constants, copyFile, mkdir, readdir, rm } from "node:fs/promises";
-import { basename, join } from "node:path";
-
-const distDir = "dist";
-const contentDir = "static";
-const teawieArchiveDir = "Teawie-Archive/teawie-media";
-const teawieContentDir = join(contentDir, "teawie");
-
-const checkAndCreate = async (dir: string) => {
- if (!existsSync(dir)) {
- await mkdir(dir, { recursive: true });
- } else {
- for (const f of await readdir(dir, { withFileTypes: true })) {
- await rm(f.path, { recursive: true, force: true });
- }
- }
-};
-
-const findWies = async () => {
- // grab directories from archive
- const wieDirs = (await readdir(teawieArchiveDir, { withFileTypes: true }))
- .filter((file) => file.isDirectory())
- .map((file) => join(file.path, file.name));
-
- // map over directories until we (probably) only have the images we want and their path
- const collected = wieDirs.map(async (dir) =>
- (await readdir(dir, { withFileTypes: true }))
- .filter(async (file) => {
- const fileExt = file.name.split(",").pop() ?? "";
- return file.isFile() && !["ini", "txt"].includes(fileExt);
- })
- .map((file) => join(file.path, file.name)),
- );
-
- const res = await Promise.all(collected);
-
- return res.flat();
-};
-
-const wies = await findWies();
-
-const define = {
- WIES: JSON.stringify(wies.map((wie) => basename(wie).replaceAll(" ", "%20"))),
- WIE_DIR: JSON.stringify(teawieContentDir),
-};
-
-await checkAndCreate(distDir);
-await checkAndCreate(join(distDir, contentDir));
-await checkAndCreate(join(distDir, teawieContentDir));
-
-for (const f of wies) {
- await copyFile(
- f,
- join(distDir, teawieContentDir, basename(f)),
- constants.COPYFILE_FICLONE,
- );
-}
+import { join } from "path";
const options = {
entryPoints: ["src/index.ts"],
- outfile: join(distDir, "_worker.js"),
- define,
+ outfile: join("dist", "_worker.js"),
format: "esm",
bundle: true,
minify: true,