From df7c0e34744b6b08da7d96fe6c25226e30b67d70 Mon Sep 17 00:00:00 2001 From: Jairo Suarez Date: Sat, 8 Aug 2026 21:00:27 +0200 Subject: [PATCH] Add --target flag to update-package-locks.sh --- scripts/update-package-locks.sh | 62 ++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/scripts/update-package-locks.sh b/scripts/update-package-locks.sh index 04278852..51eb376e 100755 --- a/scripts/update-package-locks.sh +++ b/scripts/update-package-locks.sh @@ -2,9 +2,49 @@ set -e -TARGETS=(code-editor-server code-editor-sagemaker-server code-editor-web-embedded code-editor-web-embedded-with-terminal) +ALL_TARGETS=(code-editor-server code-editor-sagemaker-server code-editor-web-embedded code-editor-web-embedded-with-terminal) -echo "Updating package-lock overrides for all targets..." +# Parse command line arguments +SELECTED_TARGETS=() +while [[ $# -gt 0 ]]; do + case "$1" in + --target) + [[ $# -ge 2 ]] || { echo "Error: --target requires a value" >&2; exit 1; } + if [[ ! -f "configuration/$2.json" ]]; then + echo "Error: Unknown target: $2" >&2 + echo "Available targets: ${ALL_TARGETS[*]}" >&2 + exit 1 + fi + SELECTED_TARGETS+=("$2") + shift 2 + ;; + *) + echo "Unknown option: $1" >&2 + echo "Usage: $0 [--target ]..." >&2 + exit 1 + ;; + esac +done + +if [[ ${#SELECTED_TARGETS[@]} -gt 0 ]]; then + TARGETS=("${SELECTED_TARGETS[@]}") +else + TARGETS=("${ALL_TARGETS[@]}") +fi + +# Unified OSS attribution needs all targets prepared +RUN_ATTRIBUTION=true +for target in "${ALL_TARGETS[@]}"; do + found=false + for selected in "${TARGETS[@]}"; do + [[ "$selected" == "$target" ]] && found=true + done + if [[ "$found" == false ]]; then + RUN_ATTRIBUTION=false + fi +done + +echo "Updating package-lock overrides for targets: ${TARGETS[*]}" # Clean up any existing prepared source directories for target in "${TARGETS[@]}"; do @@ -56,13 +96,19 @@ for target in "${TARGETS[@]}"; do echo "=== COMPLETED TARGET: $target ===" done -# Generate unified OSS attribution -echo "" -echo "Generating unified OSS attribution..." -./scripts/generate-oss-attribution.sh --command generate_unified_oss_attribution +# Generate unified OSS attribution (requires all targets prepared) +if [[ "$RUN_ATTRIBUTION" == true ]]; then + echo "" + echo "Generating unified OSS attribution..." + ./scripts/generate-oss-attribution.sh --command generate_unified_oss_attribution -# Copy LICENSE-THIRD-PARTY to root directory -cp overrides/LICENSE-THIRD-PARTY LICENSE-THIRD-PARTY + # Copy LICENSE-THIRD-PARTY to root directory + cp overrides/LICENSE-THIRD-PARTY LICENSE-THIRD-PARTY +else + echo "" + echo "Skipping unified OSS attribution: it requires all targets to be prepared." + echo "Run this script without --target, or run ./scripts/generate-oss-attribution.sh --command generate_unified_oss_attribution separately." +fi # Clean up prepared source directories echo "Cleaning up prepared source directories..."