···1414 * Outputs the created DID which you can use to log in during local development.
1515 */
16161717-import { readFileSync } from "node:fs";
1817import { join } from "node:path";
19182019const PDS_URL = process.env.PDS_URL ?? "http://localhost:3000";
2120const ENV_FILE = join(import.meta.dir, "..", "pds", "pds.env");
22212323-function readEnvVar(name: string): string {
2424- const env = readFileSync(ENV_FILE, "utf-8");
2222+async function readEnvVar(name: string): Promise<string> {
2323+ const env = await Bun.file(ENV_FILE).text();
2524 const match = env.match(new RegExp(`^${name}=(.+)$`, "m"));
2625 if (!match) throw new Error(`${name} not found in pds/pds.env`);
2726 return match[1].trim();
···3635 process.exit(1);
3736}
38373939-const pdsHostname = readEnvVar("PDS_HOSTNAME");
3838+const pdsHostname = await readEnvVar("PDS_HOSTNAME");
4039const handle = `${name}.${pdsHostname}`;
41404242-const adminPassword = readEnvVar("PDS_ADMIN_PASSWORD");
4141+const adminPassword = await readEnvVar("PDS_ADMIN_PASSWORD");
43424443// Use the PDS admin API to create an invite code first
4544const inviteRes = await fetch(`${PDS_URL}/xrpc/com.atproto.server.createInviteCode`, {
+3-3
scripts/pds-init.ts
···77 * Usage: bun run scripts/pds-init.ts
88 */
991010-import { existsSync, mkdirSync, writeFileSync } from "node:fs";
1010+import { mkdirSync } from "node:fs";
1111import { join } from "node:path";
1212import { randomBytes } from "node:crypto";
1313···1515const PDS_DIR = join(ROOT, "pds");
1616const ENV_FILE = join(PDS_DIR, "pds.env");
17171818-if (existsSync(ENV_FILE)) {
1818+if (await Bun.file(ENV_FILE).exists()) {
1919 console.log("pds/pds.env already exists. Delete it to regenerate.");
2020 process.exit(0);
2121}
···5454PDS_CRAWLERS=
5555`;
56565757-writeFileSync(ENV_FILE, env);
5757+await Bun.write(ENV_FILE, env);
5858console.log("Created pds/pds.env");
5959console.log(` Admin password: ${adminPassword}`);
6060console.log("");