forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-deps.sh
More file actions
executable file
路73 lines (60 loc) 路 1.89 KB
/
Copy pathcheck-deps.sh
File metadata and controls
executable file
路73 lines (60 loc) 路 1.89 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
#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "${REPO_ROOT}"
if ! command -v jq >/dev/null 2>&1; then
echo "jq is required."
exit 1
fi
CONFIG_PATH="infrastructure/ci/update-config.json"
EXCLUDES="$(jq -r '.exclude[]?' "${CONFIG_PATH}" 2>/dev/null || true)"
collect_outdated() {
local dir="$1"
if [[ -f "${dir}/package.json" ]]; then
(cd "${dir}" && npm outdated --json || true)
else
echo "{}"
fi
}
mkdir -p infrastructure/ci/reports
REPORT_FILE="infrastructure/ci/reports/dependency-outdated-report.json"
root_outdated="$(collect_outdated ".")"
frontend_outdated="$(collect_outdated "Frontend")"
backend_outdated="$(collect_outdated "Backend")"
analytics_outdated="$(collect_outdated "analytics")"
jq -n \
--argjson root "${root_outdated:-{}}" \
--argjson frontend "${frontend_outdated:-{}}" \
--argjson backend "${backend_outdated:-{}}" \
--argjson analytics "${analytics_outdated:-{}}" \
'{root:$root, frontend:$frontend, backend:$backend, analytics:$analytics}' > "${REPORT_FILE}"
if [[ -n "${EXCLUDES}" ]]; then
while IFS= read -r pkg; do
jq "walk(if type == \"object\" then del(.\"${pkg}\") else . end)" "${REPORT_FILE}" > "${REPORT_FILE}.tmp"
mv "${REPORT_FILE}.tmp" "${REPORT_FILE}"
done <<<"${EXCLUDES}"
fi
run_updates() {
local dir="$1"
if [[ -f "${dir}/package.json" ]]; then
(cd "${dir}" && npm update)
fi
}
run_updates "."
run_updates "Frontend"
run_updates "Backend"
run_updates "analytics"
run_tests_if_present() {
local dir="$1"
if [[ -f "${dir}/package.json" ]]; then
has_test="$(jq -r '.scripts.test // empty' "${dir}/package.json")"
if [[ -n "${has_test}" ]]; then
(cd "${dir}" && npm test)
fi
fi
}
run_tests_if_present "."
run_tests_if_present "Frontend"
run_tests_if_present "Backend"
run_tests_if_present "analytics"
echo "Dependency update and test run completed."