@@ -95,11 +95,29 @@ runs:
9595 sdk_packages=($(find . -maxdepth 1 -type d -exec basename {} \; | grep -v "^\.$"))
9696 echo "Found SDK packages: ${sdk_packages[*]}"
9797
98- # Check the status of each package and find the highest version
99- HIGHEST_VERSION ="0.0.0"
98+ # Check the status of each package, prioritizing @dotcms/client as base version
99+ BASE_VERSION ="0.0.0"
100100 VERSION_SOURCE="none"
101101 PACKAGES_STATUS=""
102+ CLIENT_VERSION=""
102103
104+ # First, check if @dotcms/client exists and use it as the authoritative base
105+ echo ""
106+ echo "🔍 Checking @dotcms/client (base package)..."
107+ if npm view @dotcms/client >/dev/null 2>&1; then
108+ CLIENT_VERSION=$(npm view @dotcms/client dist-tags --json 2>/dev/null | jq -r '.latest // empty')
109+ if [ -n "$CLIENT_VERSION" ] && [ "$CLIENT_VERSION" != "null" ] && [ "$CLIENT_VERSION" != "empty" ]; then
110+ BASE_VERSION="$CLIENT_VERSION"
111+ VERSION_SOURCE="existing"
112+ echo " ✅ @dotcms/client exists - Latest: $CLIENT_VERSION (using as base version)"
113+ else
114+ echo " ⚠️ @dotcms/client exists but no latest version found"
115+ fi
116+ else
117+ echo " 📦 @dotcms/client doesn't exist yet"
118+ fi
119+
120+ # Now check all packages for status tracking
103121 for sdk in "${sdk_packages[@]}"; do
104122 echo ""
105123 echo "🔍 Checking @dotcms/${sdk}..."
@@ -111,12 +129,15 @@ runs:
111129
112130 echo " ✅ Package exists - Latest: ${STABLE_VERSION:-'none'}"
113131
114- # Update highest version if this package has a higher stable version
115- if [ -n "$STABLE_VERSION" ] && [ "$STABLE_VERSION" != "null" ] && [ "$STABLE_VERSION" != "empty" ]; then
116- if [ "$STABLE_VERSION" != "0.0.0" ]; then
117- if [ "$HIGHEST_VERSION" = "0.0.0" ] || [ "$(printf '%s\n' "$STABLE_VERSION" "$HIGHEST_VERSION" | sort -V | tail -n1)" = "$STABLE_VERSION" ]; then
118- HIGHEST_VERSION="$STABLE_VERSION"
119- VERSION_SOURCE="existing"
132+ # If we don't have a base version yet and this isn't client, use this as fallback
133+ if [ "$VERSION_SOURCE" = "none" ] && [ "$sdk" != "client" ]; then
134+ if [ -n "$STABLE_VERSION" ] && [ "$STABLE_VERSION" != "null" ] && [ "$STABLE_VERSION" != "empty" ]; then
135+ if [ "$STABLE_VERSION" != "0.0.0" ]; then
136+ if [ "$BASE_VERSION" = "0.0.0" ] || [ "$(printf '%s\n' "$STABLE_VERSION" "$BASE_VERSION" | sort -V | tail -n1)" = "$STABLE_VERSION" ]; then
137+ BASE_VERSION="$STABLE_VERSION"
138+ VERSION_SOURCE="existing"
139+ echo " 📊 Using as fallback base version: $STABLE_VERSION"
140+ fi
120141 fi
121142 fi
122143 fi
@@ -130,9 +151,13 @@ runs:
130151
131152 # Determine the base version to use
132153 if [ "$VERSION_SOURCE" = "existing" ]; then
133- CURRENT_VERSION="$HIGHEST_VERSION "
154+ CURRENT_VERSION="$BASE_VERSION "
134155 echo ""
135- echo "📊 Using highest existing version: $CURRENT_VERSION"
156+ if [ -n "$CLIENT_VERSION" ]; then
157+ echo "📊 Using @dotcms/client as base version: $CURRENT_VERSION"
158+ else
159+ echo "📊 Using highest existing version: $CURRENT_VERSION"
160+ fi
136161 else
137162 CURRENT_VERSION="0.0.0"
138163 VERSION_SOURCE="none"
@@ -326,9 +351,9 @@ runs:
326351 VERSION_TYPE_USED="custom"
327352
328353 # Check if custom version is valid relative to current version
329- if [ "$VERSION_SOURCE" = "stable " ] && [ -n "$CURRENT_STABLE " ]; then
330- if version_compare "$CURRENT_STABLE " "$CUSTOM_VERSION"; then
331- echo "::warning::Custom version $CUSTOM_VERSION is not greater than current stable version $CURRENT_STABLE "
354+ if [ "$VERSION_SOURCE" = "existing " ] && [ -n "$CURRENT_VERSION " ]; then
355+ if version_compare "$CURRENT_VERSION " "$CUSTOM_VERSION"; then
356+ echo "::warning::Custom version $CUSTOM_VERSION is not greater than current version $CURRENT_VERSION "
332357 echo "This will still be published, but consider if this is intentional."
333358 fi
334359 fi
@@ -347,9 +372,9 @@ runs:
347372 VERSION_TYPE_USED="prerelease-to-stable"
348373 echo "Transitioning from prerelease version ($CURRENT_VERSION) to stable 1.0.0"
349374
350- elif [ "$VERSION_SOURCE" = "stable " ] && [ -n "$CURRENT_STABLE " ]; then
351- # We have a stable version, apply versioning logic
352- IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_STABLE "
375+ elif [ "$VERSION_SOURCE" = "existing " ] && [ -n "$CURRENT_VERSION " ]; then
376+ # We have an existing version, apply versioning logic
377+ IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION "
353378 MAJOR=${VERSION_PARTS[0]:-1}
354379 MINOR=${VERSION_PARTS[1]:-0}
355380 PATCH=${VERSION_PARTS[2]:-0}
0 commit comments