mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-04 09:07:20 +01:00
* chore: pnpm — the fleet has one package manager - packageManager pnpm@11.25.0; lockfile via pnpm import, package-lock.json removed - npm "overrides" moved to pnpm-workspace.yaml overrides (pnpm ignores the npm-only package.json field); nested gray-matter>js-yaml pin kept; $sharp reference spelled out (pnpm 11 deprecates $ syntax) - allowBuilds for native/postinstall deps; temporary minimumReleaseAgeExclude for our own @bitbaum/ai-kit@0.6.2 (published <24h ago — pnpm 11's supply-chain window would refuse it) - postinstall dropped: it was the npm optional-deps sharp workaround (npm/cli#4828); pnpm resolves optional deps correctly - CI/CD/e2e-auth workflows: pnpm/action-setup@v6, store-dir pinned outside the action's bin dir, cache: pnpm, frozen-lockfile installs, pnpm run; Next cache key now hashes pnpm-lock.yaml; npm audit → pnpm audit --prod - phantom deps declared: espree (eslint.config.mjs) and @mdx-js/mdx (scripts/check-mdx.mjs), previously resolved via npm hoisting only - package.json scripts, husky hooks, deploy-selfhost.sh converted to pnpm Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn * fix: another phantom dep only the CI clean room could see @radix-ui/react-visually-hidden (CommandPalette.tsx) resolved locally through the parent repo's hoisted npm node_modules. Declared; a full src/ bare-import sweep against package.json now reports no other undeclared specifier. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn * fix: declare wait-on — npx fetched it on the fly, pnpm exec requires it Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn * fix(ci): security job — no install means no pnpm store, so no cache to save The audit step itself passed (2 moderate, below the high gate); the job went red in setup-node's POST step, which fails when the cache path it was told to save (the pnpm store) was never created. This job only needs the lockfile. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn --------- Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
205 lines
4.6 KiB
Bash
Executable File
205 lines
4.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# OrangeCat Environment Setup Script
|
|
# ==================================
|
|
#
|
|
# This script sets up a robust environment management system that prevents
|
|
# accidental loss of credentials and provides secure authentication flows.
|
|
#
|
|
# Features:
|
|
# - direnv for automatic environment loading
|
|
# - Interactive OAuth login for GitHub
|
|
# - Automated backups and recovery
|
|
# - Environment validation
|
|
#
|
|
# Usage: ./scripts/setup-env.sh
|
|
|
|
set -e
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
log() {
|
|
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
|
|
}
|
|
|
|
success() {
|
|
echo -e "${GREEN}✅ $1${NC}"
|
|
}
|
|
|
|
warning() {
|
|
echo -e "${YELLOW}⚠️ $1${NC}"
|
|
}
|
|
|
|
error() {
|
|
echo -e "${RED}❌ $1${NC}"
|
|
}
|
|
|
|
# Check if we're in the right directory
|
|
if [ ! -f "package.json" ] || [ ! -d "src" ]; then
|
|
error "Please run this script from the OrangeCat project root directory"
|
|
exit 1
|
|
fi
|
|
|
|
log "🚀 Starting OrangeCat Environment Setup"
|
|
echo "======================================"
|
|
|
|
# Step 1: Check direnv installation
|
|
log "Step 1: Checking direnv installation..."
|
|
if ! command -v direnv &> /dev/null; then
|
|
warning "direnv not found. Installing..."
|
|
curl -sfL https://direnv.net/install.sh | bash
|
|
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
|
|
source ~/.bashrc
|
|
success "direnv installed and configured"
|
|
else
|
|
success "direnv is already installed"
|
|
fi
|
|
|
|
# Step 2: Set up .envrc file
|
|
log "Step 2: Setting up automatic environment loading..."
|
|
if [ ! -f ".envrc" ]; then
|
|
cat > .envrc << 'EOF'
|
|
# OrangeCat Environment Variables
|
|
# This file is managed by direnv - never edit directly!
|
|
# Use 'direnv edit .' to modify these variables safely
|
|
|
|
# Load .env.local if it exists
|
|
if [ -f .env.local ]; then
|
|
dotenv .env.local
|
|
fi
|
|
|
|
# Load .env.development if .env.local doesn't exist
|
|
if [ ! -f .env.local ] && [ -f .env.development ]; then
|
|
dotenv .env.development
|
|
fi
|
|
|
|
# Required environment variables with defaults
|
|
export NODE_ENV=${NODE_ENV:-development}
|
|
export NEXT_PUBLIC_SITE_URL=${NEXT_PUBLIC_SITE_URL:-http://localhost:3000}
|
|
export NEXT_PUBLIC_SITE_NAME=${NEXT_PUBLIC_SITE_NAME:-OrangeCat}
|
|
|
|
# Supabase defaults (will be overridden if set in .env files)
|
|
export NEXT_PUBLIC_SUPABASE_URL=${NEXT_PUBLIC_SUPABASE_URL}
|
|
export NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY}
|
|
|
|
# Bitcoin defaults
|
|
export NEXT_PUBLIC_BITCOIN_ADDRESS=${NEXT_PUBLIC_BITCOIN_ADDRESS:-bc1qtkxw47wqlld9t0w7sujycl4mrmc90phypjygf6}
|
|
export NEXT_PUBLIC_LIGHTNING_ADDRESS=${NEXT_PUBLIC_LIGHTNING_ADDRESS:-orangecat@getalby.com}
|
|
|
|
# Validate required variables
|
|
if [ -z "$NEXT_PUBLIC_SUPABASE_URL" ] || [ -z "$NEXT_PUBLIC_SUPABASE_ANON_KEY" ]; then
|
|
echo "⚠️ WARNING: Supabase credentials not set!"
|
|
echo " Run: direnv edit ."
|
|
echo " Or create .env.local with proper values"
|
|
fi
|
|
|
|
echo "✅ OrangeCat environment loaded"
|
|
EOF
|
|
success ".envrc file created"
|
|
else
|
|
success ".envrc file already exists"
|
|
fi
|
|
|
|
# Allow direnv to load the .envrc
|
|
direnv allow .
|
|
|
|
# Step 3: Set up environment manager
|
|
log "Step 3: Setting up environment manager..."
|
|
if [ ! -f ".env.local" ]; then
|
|
node scripts/utils/env-manager.js setup
|
|
else
|
|
success "Environment file already exists"
|
|
fi
|
|
|
|
# Step 4: Create initial backup
|
|
log "Step 4: Creating initial backup..."
|
|
node scripts/utils/env-manager.js backup
|
|
|
|
# Step 5: Validate environment
|
|
log "Step 5: Validating environment..."
|
|
if node scripts/utils/env-manager.js validate > /dev/null 2>&1; then
|
|
success "Environment validation passed"
|
|
else
|
|
warning "Environment validation found issues"
|
|
echo "Run: node scripts/utils/env-manager.js validate"
|
|
fi
|
|
|
|
echo ""
|
|
echo "🎉 ENVIRONMENT SETUP COMPLETE!"
|
|
echo "=============================="
|
|
echo ""
|
|
echo "Your environment is now protected with:"
|
|
echo " • 🔄 Automatic loading via direnv"
|
|
echo " • 💾 Automatic backups before changes"
|
|
echo " • 🔐 Secure OAuth login for GitHub"
|
|
echo " • ✅ Environment validation"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. Add GitHub token: node scripts/auth/github-login.js"
|
|
echo " 2. Validate setup: node scripts/utils/env-manager.js validate"
|
|
echo " 3. Start developing: pnpm run dev"
|
|
echo ""
|
|
echo "Management commands:"
|
|
echo " • Backup: node scripts/utils/env-manager.js backup"
|
|
echo " • Restore: node scripts/utils/env-manager.js restore"
|
|
echo " • List backups: node scripts/utils/env-manager.js list"
|
|
echo " • Help: node scripts/utils/env-manager.js help"
|
|
echo ""
|
|
echo "🛡️ Safety: Your credentials are never committed to git!"
|
|
echo " Backups are stored in .env-backups/ (also gitignored)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|