From 89040f78a4261b01d3571b820a3ddf21ba3e514f Mon Sep 17 00:00:00 2001 From: John Yeo Date: Sun, 17 May 2026 10:36:38 +0100 Subject: [PATCH] cleanup --- docker/dev-services.compose.yml | 17 ----------- localtunnel-start.sh | 22 --------------- scripts/dev.ts | 50 ++++++++++++++++----------------- scripts/devServices/index.ts | 39 ++----------------------- 4 files changed, 26 insertions(+), 102 deletions(-) delete mode 100755 localtunnel-start.sh diff --git a/docker/dev-services.compose.yml b/docker/dev-services.compose.yml index f59cce55e..f5cf64191 100644 --- a/docker/dev-services.compose.yml +++ b/docker/dev-services.compose.yml @@ -29,23 +29,6 @@ services: volumes: - autumn-dev-dragonfly:/data - ngrok: - image: ngrok/ngrok:latest - environment: - NGROK_AUTHTOKEN: ${NGROK_AUTHTOKEN:-} - NGROK_DOMAIN: ${NGROK_DOMAIN:-} - command: - - http - - host.docker.internal:8080 - - --url - - ${NGROK_DOMAIN} - - --pooling-enabled - - --log=stdout - ports: - - "4040:4040" - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: autumn-dev-postgres-18: autumn-dev-redis-stack: diff --git a/localtunnel-start.sh b/localtunnel-start.sh deleted file mode 100755 index a0b66f565..000000000 --- a/localtunnel-start.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# Check for LOCAL_TUNNEL_RESERVED_KEY environment variable first -if [ -z "$LOCALTUNNEL_RESERVED_KEY" ]; then - # Read LOCAL_TUNNEL_RESERVED_KEY from .env file if env var not set - if [ -f "/app/server/.env" ]; then - export $(cat /app/server/.env | grep LOCALTUNNEL_RESERVED_KEY | grep -v '^#') - fi -fi - -# Set default subdomain if env var not found -if [ -z "$LOCALTUNNEL_RESERVED_KEY" ]; then - LOCALTUNNEL_RESERVED_KEY="autumn-dev" -fi - -echo "Installing localtunnel..." -echo "Reserved key: ${LOCAL_TUNNEL_RESERVED_KEY}" -bun install -g localtunnel - - -echo "Server is ready! Starting localtunnel..." -lt --port 8080 --local-host server --subdomain ${LOCALTUNNEL_RESERVED_KEY} --print-requests \ No newline at end of file diff --git a/scripts/dev.ts b/scripts/dev.ts index 1c23342cb..4f0803f52 100644 --- a/scripts/dev.ts +++ b/scripts/dev.ts @@ -226,35 +226,33 @@ async function startDev() { : `"cd apps/checkout && VITE_PORT=${CHECKOUT_PORT} bun dev"`, ); - // Stripe CLI webhook tunnel — agent worktrees only, silently skip if CLI absent. + // Stripe CLI webhook tunnel — silently skip if CLI absent. // Forwards to the direct localhost port (not portless) so we avoid CA trust issues. - if (worktreeNum > 1) { - const stripeAvailable = - Bun.spawnSync(["which", "stripe"]).exitCode === 0; - if (stripeAvailable) { - const auth = Bun.spawnSync( - ["stripe", "customers", "list", "--limit", "1"], - { stdout: "pipe", stderr: "pipe" }, - ); - if (auth.exitCode !== 0) { - const stderr = new TextDecoder().decode(auth.stderr); - console.error( - "\nStripe CLI is installed but not authenticated (or key expired).", - ); - console.error(` ${stderr.trim().split("\n").slice(-3).join("\n ")}`); - console.error("\nRun `stripe login` and try again.\n"); - process.exit(1); - } - const forwardUrl = `http://localhost:${SERVER_PORT}/webhooks/connect/sandbox`; - names.push("stripe"); - colors.push("cyan"); - // --forward-connect-to forwards events from connected accounts; - // the /webhooks/connect/* endpoint expects Connect-mode events. - const stripeCmd = `stripe listen --forward-connect-to ${forwardUrl} --skip-verify`; - cmds.push( - isWindows ? `"${stripeCmd}"` : `"${stripeCmd}"`, + const stripeAvailable = + Bun.spawnSync(["which", "stripe"]).exitCode === 0; + if (stripeAvailable) { + const auth = Bun.spawnSync( + ["stripe", "customers", "list", "--limit", "1"], + { stdout: "pipe", stderr: "pipe" }, + ); + if (auth.exitCode !== 0) { + const stderr = new TextDecoder().decode(auth.stderr); + console.error( + "\nStripe CLI is installed but not authenticated (or key expired).", ); + console.error(` ${stderr.trim().split("\n").slice(-3).join("\n ")}`); + console.error("\nRun `stripe login` and try again.\n"); + process.exit(1); } + const forwardUrl = `http://localhost:${SERVER_PORT}/webhooks/connect/sandbox`; + names.push("stripe"); + colors.push("cyan"); + // --forward-connect-to forwards events from connected accounts; + // the /webhooks/connect/* endpoint expects Connect-mode events. + const stripeCmd = `stripe listen --forward-connect-to ${forwardUrl} --skip-verify`; + cmds.push( + isWindows ? `"${stripeCmd}"` : `"${stripeCmd}"`, + ); } shellArgs = [ diff --git a/scripts/devServices/index.ts b/scripts/devServices/index.ts index 8a6d77ff5..85492dd47 100644 --- a/scripts/devServices/index.ts +++ b/scripts/devServices/index.ts @@ -1,4 +1,3 @@ -import { existsSync, readFileSync } from "node:fs"; import { createConnection } from "node:net"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; @@ -6,13 +5,11 @@ import { fileURLToPath } from "node:url"; const rootDir = join(dirname(fileURLToPath(import.meta.url)), "../.."); const composeFile = join(rootDir, "docker", "dev-services.compose.yml"); const composeProject = "autumn-dev-services"; -const serverEnvPath = join(rootDir, "server", ".env"); const localConfig = { postgresPort: 5432, redisStackPort: 6379, dragonflyPort: 6380, - ngrokApiUrl: "http://localhost:4040/api/tunnels", databaseUrl: "postgresql://postgres:postgres@localhost:5432/autumn", cacheUrl: "redis://localhost:6379", dragonflyUrl: "redis://localhost:6380", @@ -23,32 +20,7 @@ const flags = new Set(process.argv.slice(3)); const log = (message: string) => console.log(`[dev:services] ${message}`); -const parseEnvFile = (path: string): Record => { - if (!existsSync(path)) return {}; - - const env: Record = {}; - for (const line of readFileSync(path, "utf-8").split("\n")) { - const trimmed = line.trim(); - if (!trimmed || trimmed.startsWith("#") || !trimmed.includes("=")) continue; - const [key, ...valueParts] = trimmed.split("="); - if (!key) continue; - env[key.trim()] = valueParts.join("=").trim(); - } - return env; -}; - -const serverEnv = parseEnvFile(serverEnvPath); -const rawNgrokDomain = process.env.NGROK_DOMAIN || serverEnv.NGROK_DOMAIN || ""; -const ngrokDomain = - rawNgrokDomain && !/^https?:\/\//.test(rawNgrokDomain) - ? `https://${rawNgrokDomain}` - : rawNgrokDomain; -const composeEnv = { - ...process.env, - NGROK_AUTHTOKEN: - process.env.NGROK_AUTHTOKEN || serverEnv.NGROK_AUTHTOKEN || "", - NGROK_DOMAIN: ngrokDomain, -}; +const composeEnv = { ...process.env }; const run = ({ cmd, @@ -191,13 +163,6 @@ const doctor = async () => { }), ]); - try { - const response = await fetch(localConfig.ngrokApiUrl); - if (response.ok) console.log("ok ngrok API :4040"); - } catch { - console.log("info ngrok API :4040 not running"); - } - if (results.some((result) => !result)) process.exit(1); }; @@ -244,7 +209,7 @@ const help = () => { console.log(`Usage: bun dev:services Commands: - up Start local Postgres, Redis Stack, Dragonfly, and ngrok + up Start local Postgres, Redis Stack, and Dragonfly down Stop local services and keep all data down --volumes Stop services and delete Redis/Dragonfly data down --postgres Stop services and delete Postgres data