@@ -79,12 +79,52 @@ jobs:
79
79
extract_deps_from_code "client" client_used_code.txt
80
80
extract_deps_from_code "api" api_used_code.txt
81
81
82
+ - name : Extract Workspace Dependencies
83
+ id : extract-workspace-deps
84
+ run : |
85
+ # Function to get dependencies from a workspace package that are used by another package
86
+ get_workspace_package_deps() {
87
+ local package_json=$1
88
+ local output_file=$2
89
+
90
+ # Get all workspace dependencies (starting with @librechat/)
91
+ if [[ -f "$package_json" ]]; then
92
+ local workspace_deps=$(jq -r '.dependencies // {} | to_entries[] | select(.key | startswith("@librechat/")) | .key' "$package_json" 2>/dev/null || echo "")
93
+
94
+ # For each workspace dependency, get its dependencies
95
+ for dep in $workspace_deps; do
96
+ # Convert @librechat/api to packages/api
97
+ local workspace_path=$(echo "$dep" | sed 's/@librechat\//packages\//')
98
+ local workspace_package_json="${workspace_path}/package.json"
99
+
100
+ if [[ -f "$workspace_package_json" ]]; then
101
+ # Extract all dependencies from the workspace package
102
+ jq -r '.dependencies // {} | keys[]' "$workspace_package_json" 2>/dev/null >> "$output_file"
103
+ # Also extract peerDependencies
104
+ jq -r '.peerDependencies // {} | keys[]' "$workspace_package_json" 2>/dev/null >> "$output_file"
105
+ fi
106
+ done
107
+ fi
108
+
109
+ if [[ -f "$output_file" ]]; then
110
+ sort -u "$output_file" -o "$output_file"
111
+ else
112
+ touch "$output_file"
113
+ fi
114
+ }
115
+
116
+ # Get workspace dependencies for each package
117
+ get_workspace_package_deps "package.json" root_workspace_deps.txt
118
+ get_workspace_package_deps "client/package.json" client_workspace_deps.txt
119
+ get_workspace_package_deps "api/package.json" api_workspace_deps.txt
120
+
82
121
- name : Run depcheck for root package.json
83
122
id : check-root
84
123
run : |
85
124
if [[ -f "package.json" ]]; then
86
125
UNUSED=$(depcheck --json | jq -r '.dependencies | join("\n")' || echo "")
87
- UNUSED=$(comm -23 <(echo "$UNUSED" | sort) <(cat root_used_deps.txt root_used_code.txt | sort) || echo "")
126
+ # Exclude dependencies used in scripts, code, and workspace packages
127
+ UNUSED=$(comm -23 <(echo "$UNUSED" | sort) <(cat root_used_deps.txt root_used_code.txt root_workspace_deps.txt | sort) || echo "")
88
128
echo "ROOT_UNUSED<<EOF" >> $GITHUB_ENV
89
129
echo "$UNUSED" >> $GITHUB_ENV
90
130
echo "EOF" >> $GITHUB_ENV
97
137
chmod -R 755 client
98
138
cd client
99
139
UNUSED=$(depcheck --json | jq -r '.dependencies | join("\n")' || echo "")
100
- UNUSED=$(comm -23 <(echo "$UNUSED" | sort) <(cat ../client_used_deps.txt ../client_used_code.txt | sort) || echo "")
140
+ # Exclude dependencies used in scripts, code, and workspace packages
141
+ UNUSED=$(comm -23 <(echo "$UNUSED" | sort) <(cat ../client_used_deps.txt ../client_used_code.txt ../client_workspace_deps.txt | sort) || echo "")
101
142
# Filter out false positives
102
143
UNUSED=$(echo "$UNUSED" | grep -v "^micromark-extension-llm-math$" || echo "")
103
144
echo "CLIENT_UNUSED<<EOF" >> $GITHUB_ENV
@@ -113,7 +154,8 @@ jobs:
113
154
chmod -R 755 api
114
155
cd api
115
156
UNUSED=$(depcheck --json | jq -r '.dependencies | join("\n")' || echo "")
116
- UNUSED=$(comm -23 <(echo "$UNUSED" | sort) <(cat ../api_used_deps.txt ../api_used_code.txt | sort) || echo "")
157
+ # Exclude dependencies used in scripts, code, and workspace packages
158
+ UNUSED=$(comm -23 <(echo "$UNUSED" | sort) <(cat ../api_used_deps.txt ../api_used_code.txt ../api_workspace_deps.txt | sort) || echo "")
117
159
echo "API_UNUSED<<EOF" >> $GITHUB_ENV
118
160
echo "$UNUSED" >> $GITHUB_ENV
119
161
echo "EOF" >> $GITHUB_ENV
0 commit comments