Files
wehub-resource-sync bb5c75ce05
Component Security Validation / Security Audit (push) Has been cancelled
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:38:58 +08:00

8 lines
2.4 KiB
JSON

{
"description": "Neon database context statusline showing project name, active branch, compute state, and autoscaling CU range. Uses only Neon REST API (no SQL connections needed). Helps avoid mistakes like running migrations on the wrong branch. Setup: Export NEON_API_KEY and NEON_PROJECT_ID as environment variables, or add them to your project's .env file. Get your API key from console.neon.tech and project ID from your Neon dashboard.",
"statusLine": {
"type": "command",
"command": "bash -c 'input=$(cat); DIR=$(echo \"$input\" | jq -r \".workspace.current_dir\" 2>/dev/null || echo \".\"); if [ -f \"$DIR/.env\" ]; then while IFS= read -r line; do case \"$line\" in NEON_API_KEY=*) export NEON_API_KEY=\"${line#*=}\";; NEON_PROJECT_ID=*) export NEON_PROJECT_ID=\"${line#*=}\";; esac; done < \"$DIR/.env\"; fi; if [ -z \"$NEON_API_KEY\" ] || [ -z \"$NEON_PROJECT_ID\" ]; then echo \"🐘 Neon 🔧 config-needed | set NEON_API_KEY & NEON_PROJECT_ID\"; exit 0; fi; PROJECT=$(curl -s -m 3 -H \"Authorization: Bearer $NEON_API_KEY\" \"https://console.neon.tech/api/v2/projects/$NEON_PROJECT_ID\" 2>/dev/null); PROJECT_NAME=$(echo \"$PROJECT\" | jq -r \".project.name // \\\"unknown\\\"\" 2>/dev/null || echo \"unknown\"); BRANCHES=$(curl -s -m 3 -H \"Authorization: Bearer $NEON_API_KEY\" \"https://console.neon.tech/api/v2/projects/$NEON_PROJECT_ID/branches\" 2>/dev/null); BRANCH_NAME=$(echo \"$BRANCHES\" | jq -r \"[.branches[] | select(.default == true)][0].name // \\\"unknown\\\"\" 2>/dev/null || echo \"unknown\"); BRANCH_ID=$(echo \"$BRANCHES\" | jq -r \"[.branches[] | select(.default == true)][0].id // \\\"\\\"\" 2>/dev/null); ENDPOINTS=$(curl -s -m 3 -H \"Authorization: Bearer $NEON_API_KEY\" \"https://console.neon.tech/api/v2/projects/$NEON_PROJECT_ID/endpoints\" 2>/dev/null); EP=$(echo \"$ENDPOINTS\" | jq -r --arg bid \"$BRANCH_ID\" \"[.endpoints[] | select(.branch_id == \\$bid)][0] // .endpoints[0]\"); STATE=$(echo \"$EP\" | jq -r \".current_state // \\\"unknown\\\"\" 2>/dev/null || echo \"unknown\"); MIN_CU=$(echo \"$EP\" | jq -r \".autoscaling_limit_min_cu // \\\"?\\\"\" 2>/dev/null || echo \"?\"); MAX_CU=$(echo \"$EP\" | jq -r \".autoscaling_limit_max_cu // \\\"?\\\"\" 2>/dev/null || echo \"?\"); case \"$STATE\" in active) STATE_ICON=\"🟢\";; idle) STATE_ICON=\"🟡\";; suspended) STATE_ICON=\"🔴\";; *) STATE_ICON=\"❓\";; esac; echo \"🐘 Neon | 📁 $PROJECT_NAME | 🌿 $BRANCH_NAME | $STATE_ICON $STATE | ⚡ $MIN_CU-$MAX_CU CU\"'"
}
}