-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathupgrade-packs.sh
More file actions
executable file
·127 lines (111 loc) · 3.47 KB
/
upgrade-packs.sh
File metadata and controls
executable file
·127 lines (111 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env bash
set -euo pipefail
## upgrade-packs.sh
## Upgrade CodeQL pack dependencies for packs in the codeql-sap-js repository.
##
## This script upgrades lock files for both source and test packs, installing
## the latest compatible version of each dependency (ignoring existing lock files).
##
## Usage:
## ./scripts/upgrade-packs.sh
## ./scripts/upgrade-packs.sh --framework cap
## ./scripts/upgrade-packs.sh --framework ui5
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
FRAMEWORK=""
usage() {
cat <<EOF
Usage: $0 [OPTIONS]
Upgrade CodeQL pack dependencies for all packs in the repository.
OPTIONS:
--framework <name> Upgrade packs only for the specified framework
Valid values: cap, heuristic-models, ui5, ui5-webcomponents, xsjs
-h, --help Show this help message
By default, the script upgrades packs for all frameworks.
EOF
}
while [[ $# -gt 0 ]]; do
case $1 in
--framework)
if [[ $# -lt 2 || "${2-}" == -* ]]; then
echo "Error: --framework requires a value" >&2
usage >&2
exit 1
fi
FRAMEWORK="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Error: Unknown option $1" >&2
usage >&2
exit 1
;;
esac
done
## Validate framework if provided
VALID_FRAMEWORKS=("cap" "heuristic-models" "ui5" "ui5-webcomponents" "xsjs")
if [[ -n "${FRAMEWORK}" ]]; then
FRAMEWORK_VALID=false
for valid_fw in "${VALID_FRAMEWORKS[@]}"; do
if [[ "${FRAMEWORK}" == "${valid_fw}" ]]; then
FRAMEWORK_VALID=true
break
fi
done
if [[ "${FRAMEWORK_VALID}" == false ]]; then
echo "Error: Invalid framework '${FRAMEWORK}'" >&2
echo "Valid frameworks: ${VALID_FRAMEWORKS[*]}" >&2
exit 1
fi
fi
cd "${REPO_ROOT}"
## Upgrade a single pack given its qlpack.yml directory
upgrade_pack() {
local pack_dir="$1"
if [[ -d "${pack_dir}" ]]; then
echo "INFO: Running 'codeql pack upgrade' for '${pack_dir}'..."
codeql pack upgrade -- "${pack_dir}"
else
echo "WARNING: Directory '${pack_dir}' not found, skipping" >&2
fi
}
## Upgrade packs for a framework (all subdirectories that contain qlpack.yml)
upgrade_framework() {
local framework_path="$1"
echo "Upgrading packs for: ${framework_path}"
# Find all qlpack.yml files under this framework and upgrade their packs
# Exclude .codeql directories which contain cached packs from previous installs
find "${REPO_ROOT}/${framework_path}" -name ".codeql" -prune -o -name "qlpack.yml" -type f -print | sort | while read -r qlpack_file; do
local pack_dir
pack_dir=$(dirname "${qlpack_file}")
# Use relative path for cleaner output
local rel_path="${pack_dir#${REPO_ROOT}/}"
upgrade_pack "${rel_path}"
done
}
if [[ -n "${FRAMEWORK}" ]]; then
case "${FRAMEWORK}" in
heuristic-models)
upgrade_framework "javascript/heuristic-models"
;;
ui5-webcomponents)
upgrade_framework "javascript/frameworks/ui5-webcomponents"
;;
*)
upgrade_framework "javascript/frameworks/${FRAMEWORK}"
;;
esac
else
echo "Upgrading packs for all frameworks..."
upgrade_framework "javascript/frameworks/cap"
upgrade_framework "javascript/frameworks/ui5"
upgrade_framework "javascript/frameworks/ui5-webcomponents"
upgrade_framework "javascript/frameworks/xsjs"
upgrade_framework "javascript/heuristic-models"
fi
echo ""
echo "✅ All CodeQL pack lock files upgraded successfully."