commit
aaa
diff --git a/.env.example b/.env.example
index 07352a2..7269e01 100644
--- a/.env.example
+++ b/.env.example
@@ -53,7 +53,7 @@ PK_API_BASE=https://api.pluralkit.me/v2
# Contact URL embedded in the User-Agent. Point this at the REPOSITORY, not the
# deployment origin, so it survives the beta -> production domain move. The UA
# must be identical across every instance and must never vary by user or server.
-PK_USER_AGENT_CONTACT=https://github.com/OWNER/pkviewer
+PK_USER_AGENT_CONTACT=https://github.com/doughmination/pkviewer
# Self-imposed ceilings, deliberately below PluralKit's documented 10/s reads
# and 3/s writes, leaving headroom for burst and clock imprecision.
PK_RATE_LIMIT_READ_RPS=6
diff --git a/apps/api/test/config.test.ts b/apps/api/test/config.test.ts
index 9296e79..297ff02 100644
--- a/apps/api/test/config.test.ts
+++ b/apps/api/test/config.test.ts
@@ -1,3 +1,5 @@
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
import { describe, expect, test } from "bun:test";
import { buildUserAgent, ConfigError, loadConfig } from "../src/config/index.ts";
import { PKVIEWER_VERSION } from "../src/config/version.ts";
@@ -148,3 +150,36 @@ describe("beta readiness", () => {
}
});
});
+
+// .env.example is the first thing a fresh checkout copies into place, so a
+// placeholder left in it becomes a live value on somebody's machine. This one
+// matters more than most: PK_USER_AGENT_CONTACT is the contact URL PluralKit
+// is given for every request we make (P1), and shipping an unresolvable one
+// hands them a dead link instead of a way to reach us.
+describe("the example environment file", () => {
+ const exampleEnv = readFileSync(join(import.meta.dir, "..", "..", "..", ".env.example"), "utf8");
+
+ const exampleValue = (key: string): string => {
+ const match = exampleEnv.match(new RegExp(`^${key}=(.*)$`, "m"));
+ if (!match?.[1]) throw new Error(`${key} is missing or empty in .env.example`);
+ return match[1].trim();
+ };
+
+ test("ships a PluralKit contact URL that config accepts", () => {
+ expect(() =>
+ loadConfig({ ...base, PK_USER_AGENT_CONTACT: exampleValue("PK_USER_AGENT_CONTACT") }),
+ ).not.toThrow();
+ });
+
+ // A placeholder is spelled in capitals precisely so a human notices it, which
+ // makes it the one thing we can detect mechanically. Real path segments here
+ // are repository owners and names, which are not upper-case.
+ test("ships no placeholder in the PluralKit contact URL", () => {
+ const url = new URL(exampleValue("PK_USER_AGENT_CONTACT"));
+ const placeholders = url.pathname
+ .split("/")
+ .filter((segment) => segment.length > 0 && segment === segment.toUpperCase());
+ expect(placeholders).toEqual([]);
+ expect(url.pathname).not.toBe("/");
+ });
+});
diff --git a/apps/web/package.json b/apps/web/package.json
index 2b5be2b..cc508cd 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -3,9 +3,9 @@
"version": "0.1.0",
"private": true,
"scripts": {
- "dev": "next dev -p ${WEB_PORT:-3000}",
+ "dev": "next dev",
"build": "NEXT_DIST_DIR=.next-prod next build",
- "start": "NEXT_DIST_DIR=.next-prod next start -p ${WEB_PORT:-3000}",
+ "start": "NEXT_DIST_DIR=.next-prod next start",
"typecheck": "tsc -p tsconfig.json"
},
"dependencies": {
diff --git a/scripts/dev.ts b/scripts/dev.ts
index 312858c..366a072 100755
--- a/scripts/dev.ts
+++ b/scripts/dev.ts
@@ -14,9 +14,30 @@
import { spawn, type Subprocess } from "bun";
const RESET = "\x1b[0m";
+
+// The port the web tier listens on. Next reads PORT itself, so it is passed
+// through the environment rather than as a `-p` flag in the package script.
+// That is deliberate: bun's script shell does not implement ${VAR} expansion
+// on Windows, so `next dev -p ${WEB_PORT:-3000}` reached Next as that literal
+// string and the web tier refused to start. Keeping the default here leaves
+// the package scripts free of shell syntax entirely.
+const WEB_PORT = process.env["WEB_PORT"] ?? "3000";
+
const TIERS = [
- { name: "api", colour: "\x1b[35m", cwd: "apps/api", cmd: ["bun", "run", "--hot", "src/index.ts"] },
- { name: "web", colour: "\x1b[36m", cwd: "apps/web", cmd: ["bun", "run", "dev"] },
+ {
+ name: "api",
+ colour: "[35m",
+ cwd: "apps/api",
+ cmd: ["bun", "run", "--hot", "src/index.ts"],
+ env: {},
+ },
+ {
+ name: "web",
+ colour: "[36m",
+ cwd: "apps/web",
+ cmd: ["bun", "run", "dev"],
+ env: { PORT: WEB_PORT },
+ },
] as const;
const children: Subprocess[] = [];
@@ -63,7 +84,7 @@ for (const tier of TIERS) {
cwd: tier.cwd,
stdout: "pipe",
stderr: "pipe",
- env: { ...process.env, FORCE_COLOR: "1" },
+ env: { ...process.env, FORCE_COLOR: "1", ...tier.env },
onExit(_proc, exitCode) {
if (shuttingDown) return;
console.log(`${tier.colour}[${tier.name}]${RESET} exited (${exitCode ?? "signal"})`);