From b4831d990fde4542cfc39d994c9bf4e8fa634978 Mon Sep 17 00:00:00 2001 From: Gbadebo Bello Date: Wed, 18 Nov 2026 13:43:50 +0100 Subject: [PATCH] Log in to Postman CLI on every Codespace start Co-Authored-By: Claude --- .devcontainer/devcontainer.json | 3 ++- .devcontainer/post-create.sh | 9 --------- .devcontainer/postman-login.sh | 12 ++++++++++++ 3 files changed, 14 insertions(+), 10 deletions(-) create mode 100755 .devcontainer/postman-login.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6aa0b7c..d1bb327 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,5 +8,6 @@ "DISABLE_AUTOUPDATER": "1" }, "forwardPorts": [3000, 3100, 3200, 8080, 8090], - "postCreateCommand": "bash .devcontainer/post-create.sh" + "postCreateCommand": "bash .devcontainer/post-create.sh", + "postStartCommand": "bash .devcontainer/postman-login.sh" } diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh index 74111a4..361aa1b 100644 --- a/.devcontainer/post-create.sh +++ b/.devcontainer/post-create.sh @@ -25,12 +25,3 @@ if [ -n "${ANTHROPIC_API_KEY:-}" ]; then else echo "ANTHROPIC_API_KEY not set; add it as a Codespaces secret, or run: claude and log in" fi - -# Postman CLI: if POSTMAN_API_KEY is set, log in so `postman` commands work immediately. -if [ -n "${POSTMAN_API_KEY:-}" ]; then - postman login --with-api-key "$POSTMAN_API_KEY" >/dev/null \ - && echo "Postman CLI logged in" \ - || echo "Postman login failed; run: postman login" -else - echo "POSTMAN_API_KEY not set; add it as a Codespaces secret, or run: postman login" -fi diff --git a/.devcontainer/postman-login.sh b/.devcontainer/postman-login.sh new file mode 100755 index 0000000..72200da --- /dev/null +++ b/.devcontainer/postman-login.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# Runs on every Codespace start so the Postman CLI is always logged in. +# Needs the POSTMAN_API_KEY Codespaces secret (github.com/settings/codespaces). + +if [ -z "${POSTMAN_API_KEY:-}" ]; then + echo "POSTMAN_API_KEY not set; add it as a Codespaces secret (with access to this repo), or run: postman login --with-api-key " + exit 0 +fi + +postman login --with-api-key "$POSTMAN_API_KEY" \ + && echo "Postman CLI logged in" \ + || echo "Postman login failed; check that POSTMAN_API_KEY is a valid API key"