mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-16 18:13:06 +00:00
AAE-51793 Retry npm pack directly, drop redundant npm view pre check (#12234)
This commit is contained in:
@@ -35,20 +35,18 @@ error_out() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Retry to absorb npm registry propagation delay right after publish.
|
# Retry to absorb npm registry propagation delay right after publish.
|
||||||
NPM_VIEW_RETRIES=24
|
NPM_RETRIES=24
|
||||||
NPM_VIEW_RETRY_DELAY=20
|
NPM_RETRY_DELAY=20
|
||||||
|
|
||||||
npm_view_version() {
|
npm_pack_version() {
|
||||||
local spec=$1
|
local spec=$1
|
||||||
local attempt result
|
local attempt
|
||||||
for attempt in $(seq 1 "$NPM_VIEW_RETRIES"); do
|
for attempt in $(seq 1 "$NPM_RETRIES"); do
|
||||||
result=$(npm view "$spec" version 2>/dev/null)
|
if npm pack "$spec" 2>/dev/null; then
|
||||||
if [ -n "$result" ]; then
|
|
||||||
echo "$result"
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if [ "$attempt" -lt "$NPM_VIEW_RETRIES" ]; then
|
if [ "$attempt" -lt "$NPM_RETRIES" ]; then
|
||||||
sleep "$NPM_VIEW_RETRY_DELAY"
|
sleep "$NPM_RETRY_DELAY"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
@@ -62,12 +60,14 @@ for PACKAGE in ${projects[@]}
|
|||||||
do
|
do
|
||||||
mkdir $PACKAGE
|
mkdir $PACKAGE
|
||||||
cd $PACKAGE
|
cd $PACKAGE
|
||||||
|
PKG_VERSION=""
|
||||||
|
|
||||||
# Handle js-api differently - increase major version by 1
|
# Handle js-api differently - increase major version by 1
|
||||||
if [ $PACKAGE == 'js-api' ]; then
|
if [ $PACKAGE == 'js-api' ]; then
|
||||||
if [ $VERSION == 'alpha' ] || [ $VERSION == 'beta' ] || [ $VERSION == 'latest' ]; then
|
if [ $VERSION == 'alpha' ] || [ $VERSION == 'beta' ] || [ $VERSION == 'latest' ]; then
|
||||||
# For tag versions, we need to get the current version and increment
|
# For tag versions, we need to get the current version and increment
|
||||||
CURRENT_VERSION=$(npm view @alfresco/$PACKAGE@$VERSION version)
|
CURRENT_VERSION=$(npm view @alfresco/$PACKAGE@$VERSION version)
|
||||||
|
FALLBACK_VERSION=$CURRENT_VERSION
|
||||||
MAJOR_VERSION=$(echo $CURRENT_VERSION | cut -d'.' -f1)
|
MAJOR_VERSION=$(echo $CURRENT_VERSION | cut -d'.' -f1)
|
||||||
NEXT_MAJOR=$((MAJOR_VERSION + 1))
|
NEXT_MAJOR=$((MAJOR_VERSION + 1))
|
||||||
# Keep the rest of the version string
|
# Keep the rest of the version string
|
||||||
@@ -75,6 +75,7 @@ do
|
|||||||
PACKAGE_VERSION="${NEXT_MAJOR}.${REST_VERSION}"
|
PACKAGE_VERSION="${NEXT_MAJOR}.${REST_VERSION}"
|
||||||
else
|
else
|
||||||
# For specific versions, just increment the major number
|
# For specific versions, just increment the major number
|
||||||
|
FALLBACK_VERSION=$VERSION
|
||||||
MAJOR_VERSION=$(echo $VERSION | cut -d'.' -f1)
|
MAJOR_VERSION=$(echo $VERSION | cut -d'.' -f1)
|
||||||
NEXT_MAJOR=$((MAJOR_VERSION + 1))
|
NEXT_MAJOR=$((MAJOR_VERSION + 1))
|
||||||
REST_VERSION=$(echo $VERSION | cut -d'.' -f2-)
|
REST_VERSION=$(echo $VERSION | cut -d'.' -f2-)
|
||||||
@@ -85,13 +86,17 @@ do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Try the calculated package version first
|
# Try the calculated package version first
|
||||||
PKG_VERSION=$(npm_view_version @alfresco/$PACKAGE@$PACKAGE_VERSION)
|
if npm_pack_version '@alfresco/'$PACKAGE@$PACKAGE_VERSION; then
|
||||||
|
PKG_VERSION=$PACKAGE_VERSION
|
||||||
# If that fails for js-api, try the original version
|
elif [ $PACKAGE == 'js-api' ]; then
|
||||||
if [ -z "$PKG_VERSION" ] && [ $PACKAGE == 'js-api' ]; then
|
# If that fails, try the original (already resolved) version.
|
||||||
echo "Warning: js-api@$PACKAGE_VERSION not found, trying @$VERSION"
|
# FALLBACK_VERSION, not $VERSION directly, since npm pack writes the
|
||||||
PACKAGE_VERSION=$VERSION
|
# tarball under the resolved version, not the tag it was requested with.
|
||||||
PKG_VERSION=$(npm_view_version @alfresco/$PACKAGE@$PACKAGE_VERSION)
|
echo "Warning: js-api@$PACKAGE_VERSION not found, trying @$FALLBACK_VERSION"
|
||||||
|
PACKAGE_VERSION=$FALLBACK_VERSION
|
||||||
|
if [ -n "$PACKAGE_VERSION" ] && npm_pack_version '@alfresco/'$PACKAGE@$PACKAGE_VERSION; then
|
||||||
|
PKG_VERSION=$PACKAGE_VERSION
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If still no version found, exit with error
|
# If still no version found, exit with error
|
||||||
@@ -102,7 +107,6 @@ do
|
|||||||
|
|
||||||
echo "Inspecting: $PACKAGE@$PKG_VERSION"
|
echo "Inspecting: $PACKAGE@$PKG_VERSION"
|
||||||
|
|
||||||
npm pack '@alfresco/'$PACKAGE@$PACKAGE_VERSION
|
|
||||||
tar zxf 'alfresco-'$PACKAGE-$PKG_VERSION.tgz
|
tar zxf 'alfresco-'$PACKAGE-$PKG_VERSION.tgz
|
||||||
|
|
||||||
if [ $PACKAGE == 'js-api' ]; then
|
if [ $PACKAGE == 'js-api' ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user