forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-pack-contents.sh
More file actions
executable file
·44 lines (37 loc) · 1.09 KB
/
Copy pathcheck-pack-contents.sh
File metadata and controls
executable file
·44 lines (37 loc) · 1.09 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
#!/usr/bin/env bash
set -euo pipefail
PACK_OUTPUT=$(npm pack --dry-run 2>&1)
# Extract only actual file paths from npm pack output
# File lines look like: "npm notice 1.1kB LICENSE" or "npm notice 245B dist/config.d.cts"
FILES=$(echo "$PACK_OUTPUT" | grep -E '^npm notice [0-9]' | sed -E 's/^npm notice [0-9.]+[kMG]*B +//' | sort)
EXPECTED_PATTERNS=(
"^dist/"
"^README\.md$"
"^LICENSE$"
"^package\.json$"
)
UNEXPECTED=()
while IFS= read -r file; do
[ -z "$file" ] && continue
matched=false
for pattern in "${EXPECTED_PATTERNS[@]}"; do
if echo "$file" | grep -qE "$pattern"; then
matched=true
break
fi
done
if [ "$matched" = false ]; then
UNEXPECTED+=("$file")
fi
done <<< "$FILES"
if [ ${#UNEXPECTED[@]} -gt 0 ]; then
echo "ERROR: Unexpected files in npm pack output:"
printf ' %s\n' "${UNEXPECTED[@]}"
exit 1
fi
DIST_COUNT=$(echo "$FILES" | grep -c '^dist/' || true)
if [ "$DIST_COUNT" -lt 5 ]; then
echo "ERROR: Expected at least 5 dist files, found $DIST_COUNT"
exit 1
fi
echo "OK: npm pack contains only expected files ($DIST_COUNT dist entries)"