feat(scripts): make GITEA_NPM_HOST conditional on NETWORK
- NETWORK=corp → GITEA_NPM_HOST=localhost (local Gitea Docker)
- NETWORK=home → GITEA_NPM_HOST from ~/.gitea_vm_host (Azure VM)
- Fallback: localhost if ~/.gitea_vm_host doesn't exist
This enables all repo .npmrc files to use ${GITEA_NPM_HOST}:3300
instead of hardcoded localhost:3300, matching the existing
.npmrc.docker pattern used during Docker builds.
This commit is contained in:
parent
6fbe8687ee
commit
f1793656f8
@ -91,12 +91,35 @@ fi
|
||||
|
||||
unset _CORP_PROXY _CORP_NPM_REGISTRY
|
||||
|
||||
# ── Gitea NPM token (always, regardless of NETWORK) ──────────────
|
||||
# Local Gitea registry at localhost:3300 — token for publish access.
|
||||
# Reads: public without auth. Writes: need GITEA_NPM_TOKEN.
|
||||
# Store token in ~/.gitea_npm_token (one line, no newline).
|
||||
# Create: curl -s -u admin:PASSWORD http://localhost:3300/api/v1/users/admin/tokens \
|
||||
# -H 'Content-Type: application/json' -d '{"name":"npm"}' | jq -r '.sha1 // .token'
|
||||
# ── Gitea NPM registry (NETWORK-aware) ────────────────────────────
|
||||
# Repos use .npmrc with: @bytelyst:registry=http://${GITEA_NPM_HOST}:3300/...
|
||||
#
|
||||
# NETWORK=corp → Gitea runs locally on this machine (localhost)
|
||||
# NETWORK=home → Gitea runs on the Azure VM (read host from ~/.gitea_vm_host)
|
||||
#
|
||||
# To configure the VM host (one-time):
|
||||
# echo "bytelyst-vm.eastus.cloudapp.azure.com" > ~/.gitea_vm_host
|
||||
#
|
||||
# Token for publish access (reads are public, writes need auth):
|
||||
# Store in ~/.gitea_npm_token (one line, no newline)
|
||||
# Create: curl -s -u admin:PASSWORD http://<host>:3300/api/v1/users/admin/tokens \
|
||||
# -H 'Content-Type: application/json' -d '{"name":"npm"}' | jq -r '.sha1 // .token'
|
||||
|
||||
_GITEA_VM_HOST_FILE="$HOME/.gitea_vm_host"
|
||||
if [ "${NETWORK:-home}" = "corp" ]; then
|
||||
export GITEA_NPM_HOST="localhost"
|
||||
else
|
||||
if [ -f "$_GITEA_VM_HOST_FILE" ]; then
|
||||
export GITEA_NPM_HOST
|
||||
GITEA_NPM_HOST="$(cat "$_GITEA_VM_HOST_FILE")"
|
||||
else
|
||||
# Fallback: assume Gitea on localhost (e.g., local Docker or SSH tunnel)
|
||||
export GITEA_NPM_HOST="localhost"
|
||||
fi
|
||||
fi
|
||||
unset _GITEA_VM_HOST_FILE
|
||||
|
||||
# Token: load from file if not already set
|
||||
_GITEA_TOKEN_FILE="$HOME/.gitea_npm_token"
|
||||
if [ -z "${GITEA_NPM_TOKEN:-}" ] && [ -f "$_GITEA_TOKEN_FILE" ]; then
|
||||
export GITEA_NPM_TOKEN
|
||||
|
||||
Loading…
Reference in New Issue
Block a user