···4545# Function to publish package if version doesn't exist
4646publish_if_needed() {
4747 local package_dir=$1
4848- local package_name=$2
4949-4848+5049 cd "$package_dir"
5151-5252- # Get current version from package.json
5353- local version=$(node -p "require('./package.json').version")
5454-5050+5151+ # Derive name and version from package.json so the script stays in sync
5252+ # with whatever npm publish will actually publish (avoids drift if the
5353+ # package is renamed without updating this script).
5454+ # Declare and assign separately so `set -e` catches node -p failures
5555+ # (shellcheck SC2155: `local foo=$(...)` masks the subshell's exit status).
5656+ local package_name
5757+ package_name=$(node -p "require('./package.json').name")
5858+ local version
5959+ version=$(node -p "require('./package.json').version")
6060+5561 echo "📦 Checking $package_name@$version..."
5656-6262+5763 if check_version_exists "$package_name" "$version"; then
5864 echo "⏭️ Skipping $package_name@$version (already published)"
5965 cd ..
6066 return
6167 fi
6262-6868+6369 echo "📦 Publishing $package_name@$version..."
6470 npm install
6571 npm run build
···6874}
69757076# Publish packages
7171-publish_if_needed "types" "@roostorg/types"
7272-publish_if_needed "migrator" "@roostorg/db-migrator"
7777+publish_if_needed "types"
7878+publish_if_needed "migrator"
73797480echo "✅ All packages published successfully!"
7581echo ""