#!/bin/bash # Publish shared packages to private npm registry set -e REGISTRY="${NPM_REGISTRY:-http://localhost:4873}" SCOPE="@workspace" echo "📦 Publishing shared packages to registry: $REGISTRY" # Check if registry is accessible if ! curl -s "$REGISTRY" > /dev/null; then echo "❌ Registry not accessible at $REGISTRY" echo " Please ensure registry is running or set NPM_REGISTRY environment variable" exit 1 fi # Publish each package for package in packages/*/; do if [ -f "$package/package.json" ]; then package_name=$(basename "$package") echo "📤 Publishing $package_name..." cd "$package" # Build package pnpm build # Publish npm publish --registry="$REGISTRY" --access restricted || { echo "⚠️ Failed to publish $package_name (may already be published)" } cd - > /dev/null fi done echo "✅ Publishing complete!"