-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·56 lines (46 loc) · 1.95 KB
/
entrypoint.sh
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
#!/bin/sh
set -e
inputPath=/github/workspace/$1
outputPath=/github/workspace/$2
analyzeSubDir=$3
DESTINATION_DIR="/tmp/packageFiles"
GRAPH_DIR="/tmp/graphs"
mkdir -p "$DESTINATION_DIR"
mkdir -p "$GRAPH_DIR"
# Function to copy package files if they exist
copy_package_files() {
local src_dir=$1
local dest_dir=$2
mkdir -p "$dest_dir"
for file in package.json package-lock.json yarn.lock; do
if [ -f "$src_dir/$file" ]; then
cp "$src_dir/$file" "$dest_dir"
echo "Copied $file from $src_dir to $dest_dir"
fi
done
}
# Function to copy package files from inputPath and optionally from subdirectories
copy_files() {
local base_dir=$1
local dest_dir=$2
# Copy package files from the base directory
copy_package_files "$base_dir" "$dest_dir/root"
# If analyzeSubDir is true, iterate over subdirectories and copy package files
if [ "$analyzeSubDir" = "true" ]; then
echo "Started analyzing subdirectories"
find "$base_dir" -mindepth 1 -type d | while read -r dir; do
# Create corresponding directory structure in DESTINATION_DIR
relative_path="${dir#$base_dir/}"
echo "Sub dir relative path $relative_path"
copy_package_files "$dir" "$dest_dir/$relative_path"
done
fi
}
# Copy files from the inputPath to the DESTINATION_DIR
copy_files "$inputPath" "$DESTINATION_DIR"
if [ "$analyzeSubDir" = "true" ]; then
sh /app/build/install/technical-lag-calculator/bin/technical-lag-calculator create-dependency-graph --multi-file-mode --projects-dir "$DESTINATION_DIR" --output-path "$GRAPH_DIR"
else
sh /app/build/install/technical-lag-calculator/bin/technical-lag-calculator create-dependency-graph --projects-dir "$DESTINATION_DIR/root" --output-path "$GRAPH_DIR"
fi
sh /app/build/install/technical-lag-calculator/bin/technical-lag-calculator calculate-technical-lag --dependency-graph-dirs "$GRAPH_DIR" --output-path "$outputPath"