revert npm logic

This commit is contained in:
pratik
2025-10-15 15:37:35 -05:00
parent 4feb9fe337
commit 2c7c5a1a97
5 changed files with 57 additions and 82 deletions

View File

@@ -26,9 +26,6 @@ fi
# Parse command line arguments
REBUILD=false
USE_ARTIFACTORY=false
NPM_REGISTRY="public"
BUILD_ARGS=""
while [[ $# -gt 0 ]]; do
case $1 in
@@ -36,22 +33,16 @@ while [[ $# -gt 0 ]]; do
REBUILD=true
shift
;;
-bsf)
USE_ARTIFACTORY=true
NPM_REGISTRY="artifactory"
BUILD_ARGS="--build-arg NPM_REGISTRY=artifactory"
shift
;;
--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --rebuild Force rebuild of all containers"
echo " -bsf Use Artifactory npm registry instead of public npm"
echo " --help Show this help message"
echo ""
echo "Environment Variables (when using -bsf):"
echo " ARTIFACTORY_AUTH_TOKEN Authentication token for Artifactory"
echo "NPM Registry:"
echo " Create frontend/.npmrc to configure custom npm registry"
echo " The Docker build will use this file if present"
echo ""
echo "Brings up the complete stack: database, backend API, and frontend"
echo ""
@@ -65,17 +56,24 @@ while [[ $# -gt 0 ]]; do
esac
done
# If using Artifactory, add auth token to build args if available
if [ "$USE_ARTIFACTORY" = true ]; then
echo "Using Artifactory npm registry"
if [ -n "$ARTIFACTORY_AUTH_TOKEN" ]; then
echo "✓ Artifactory auth token detected"
BUILD_ARGS="$BUILD_ARGS --build-arg ARTIFACTORY_AUTH_TOKEN=$ARTIFACTORY_AUTH_TOKEN"
# Copy user's .npmrc to frontend directory if it exists and frontend/.npmrc doesn't
USER_NPMRC="${HOME}/.npmrc"
FRONTEND_NPMRC="frontend/.npmrc"
if [ -f "$USER_NPMRC" ]; then
if [ ! -f "$FRONTEND_NPMRC" ]; then
echo " Copying npm registry config from $USER_NPMRC"
cp "$USER_NPMRC" "$FRONTEND_NPMRC"
echo "✓ Using custom npm registry configuration"
else
echo "⚠ Warning: ARTIFACTORY_AUTH_TOKEN not set (may be required for authentication)"
echo "✓ Using existing frontend/.npmrc"
fi
else
echo "Using public npm registry (registry.npmjs.org)"
if [ -f "$FRONTEND_NPMRC" ]; then
echo "✓ Using frontend/.npmrc"
else
echo " Using default npm registry (no .npmrc found)"
fi
fi
echo ""
@@ -98,20 +96,10 @@ if [ "$REBUILD" = true ]; then
echo "Removing existing images for rebuild..."
$COMPOSE_CMD down --rmi local 2>/dev/null || true
echo "Building and starting all services..."
if [ -n "$BUILD_ARGS" ]; then
$COMPOSE_CMD build $BUILD_ARGS
$COMPOSE_CMD up -d
else
$COMPOSE_CMD up -d --build
fi
$COMPOSE_CMD up -d --build
else
echo "Starting all services..."
if [ -n "$BUILD_ARGS" ]; then
$COMPOSE_CMD build $BUILD_ARGS
$COMPOSE_CMD up -d
else
$COMPOSE_CMD up -d
fi
$COMPOSE_CMD up -d
fi
echo ""