#!/bin/bash # Toggle npm/pnpm between corporate proxy and direct (home) network. # # Usage: # source scripts/switch-network.sh corp # AT&T / corporate proxy # source scripts/switch-network.sh home # Direct internet (home/VPN off) # source scripts/switch-network.sh status # Show current config # # This modifies ~/.npmrc. Must be sourced (not executed) to affect current shell. set -euo pipefail NPMRC="$HOME/.npmrc" CORP_PROXY="http://cso.proxy.att.com:8080/" CORP_REGISTRY="https://jfrog-pkg-proxy.it.att.com/artifactory/api/npm/att-npm-proxy-group/" HOME_REGISTRY="https://registry.npmjs.org/" show_status() { echo "=== Current npm config ===" echo " proxy: $(npm config get proxy 2>/dev/null || echo 'not set')" echo " https-proxy: $(npm config get https-proxy 2>/dev/null || echo 'not set')" echo " registry: $(npm config get registry 2>/dev/null || echo 'not set')" if command -v pnpm &>/dev/null; then echo " pnpm store: $(pnpm store path 2>/dev/null || echo 'unknown')" fi echo "" if [ -f "$NPMRC" ]; then echo "=== ~/.npmrc ===" cat "$NPMRC" else echo "No ~/.npmrc found" fi } set_corp() { cat > "$NPMRC" < "$NPMRC" <