-
Notifications
You must be signed in to change notification settings - Fork 259
Expand file tree
/
Copy pathrunLicenseAudit.sh
More file actions
executable file
·68 lines (55 loc) · 2.06 KB
/
runLicenseAudit.sh
File metadata and controls
executable file
·68 lines (55 loc) · 2.06 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$REPO_ROOT"
echo "=== License Audit ==="
echo ""
# Step 1: Fetch licenses
echo "1. Fetching licenses from npm registry..."
node scripts/fetchLicenses.mjs
echo ""
# Step 2: Summarize licenses
echo "2. Summarizing licenses..."
node scripts/summarizeLicenses.mjs
echo ""
# Step 3: Run Claude audit
echo "3. Running Claude license audit..."
if ! command -v claude &> /dev/null; then
echo "Error: 'claude' CLI is not installed. Install it with: npm install -g @anthropic-ai/claude-code"
exit 1
fi
PROMPT_FILE="$SCRIPT_DIR/licenseAuditPrompt.txt"
if [ ! -f "$PROMPT_FILE" ]; then
echo "Error: Prompt file not found at $PROMPT_FILE"
exit 1
fi
claude --dangerously-skip-permissions -p "$(cat "$PROMPT_FILE")" \
--allowedTools "Bash,Read,Write,Glob,Grep,WebFetch"
echo ""
# Step 4: Validate result
echo "4. Validating audit result..."
if [ ! -f license-audit-result.json ]; then
echo "Error: license-audit-result.json was not created by the audit step"
exit 1
fi
STATUS=$(node -e "const r = require('./license-audit-result.json'); console.log(r.status)")
UNRESOLVED=$(node -e "const r = require('./license-audit-result.json'); console.log(r.summary.unresolvedCount)")
STRONG=$(node -e "const r = require('./license-audit-result.json'); console.log(r.summary.strongCopyleftCount)")
WEAK=$(node -e "const r = require('./license-audit-result.json'); console.log(r.summary.weakCopyleftCount)")
RESOLVED=$(node -e "const r = require('./license-audit-result.json'); console.log(r.summary.resolvedCount)")
echo ""
echo "== License Audit Result: $STATUS =="
echo ""
echo " Resolved: $RESOLVED"
echo " Unresolved: $UNRESOLVED"
echo " Strong copyleft: $STRONG"
echo " Weak copyleft: $WEAK"
if [ "$STATUS" = "FAIL" ]; then
echo ""
echo "FAIL reasons:"
node -e "const r = require('./license-audit-result.json'); r.failReasons.forEach(r => console.log(' - ' + r))"
exit 1
fi
echo ""
echo "License audit passed."