Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion mnemion-js/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ CURRENT_KV_ID=$(awk '
/^\[/ { in_kv=0 }
in_kv && /^id *= *"/ { match($0, /"[^"]+"/); print substr($0, RSTART+1, RLENGTH-2); exit }
' wrangler.toml)
EXPECTED_KV_TITLE="${WORKER_NAME}-OAUTH_KV"
# wrangler titles the namespace after the binding name (OAUTH_KV), NOT
# "${WORKER_NAME}-OAUTH_KV" — match what `wrangler kv namespace create OAUTH_KV`
# actually produces, otherwise find-or-create never matches and the create fails
# on "already exists".
EXPECTED_KV_TITLE="OAUTH_KV"

# === KV namespace: find-or-create, patch wrangler.toml ===
echo "Checking KV namespace ${EXPECTED_KV_TITLE}..."
Expand Down Expand Up @@ -107,6 +111,14 @@ echo ""
echo "Setting master secret..."
printf '%s' "$SECRET" | npx wrangler secret put MNEMION_SECRET 2>&1 | grep -v "^$"

# === Build page bundles ===
# The worker imports compiled SSR/client bundles from dist/** (see [[rules]] in
# wrangler.toml). They must exist before `wrangler deploy`, or the deploy fails on
# unresolved imports. `npm run deploy` builds them; setup deploys directly, so do it here.
echo ""
echo "Building page bundles..."
npm run build:pages

# === Deploy ===
echo ""
echo "Deploying..."
Expand Down