@sun-asterisk/impact-analyzer 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +506 -0
- package/cli.js +38 -0
- package/config/default-config.js +56 -0
- package/index.js +128 -0
- package/modules/change-detector.js +258 -0
- package/modules/detectors/database-detector.js +182 -0
- package/modules/detectors/endpoint-detector.js +52 -0
- package/modules/impact-analyzer.js +124 -0
- package/modules/report-generator.js +373 -0
- package/modules/utils/ast-parser.js +241 -0
- package/modules/utils/dependency-graph.js +159 -0
- package/modules/utils/file-utils.js +116 -0
- package/modules/utils/git-utils.js +198 -0
- package/modules/utils/method-call-graph.js +952 -0
- package/package.json +26 -0
- package/run-impact-analysis.sh +124 -0
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sun-asterisk/impact-analyzer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Automated impact analysis for TypeScript/JavaScript projects",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"analyze": "node index.js",
|
|
9
|
+
"analyze:local": "node index.js --input=src --base=origin/main --head=HEAD",
|
|
10
|
+
"test": "node --test"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"impact-analysis",
|
|
14
|
+
"code-analysis",
|
|
15
|
+
"ci-cd"
|
|
16
|
+
],
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@babel/parser": "^7.23.0",
|
|
21
|
+
"@babel/traverse": "^7.23.0",
|
|
22
|
+
"glob": "^10.3.0",
|
|
23
|
+
"ts-morph": "^27.0.2"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {}
|
|
26
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Impact Analysis Runner Script
|
|
4
|
+
# Usage: ./run-impact-analysis.sh [options]
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
# Colors
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
YELLOW='\033[1;33m'
|
|
12
|
+
NC='\033[0m' # No Color
|
|
13
|
+
|
|
14
|
+
# Default values
|
|
15
|
+
INPUT_DIR="src"
|
|
16
|
+
BASE_REF="origin/main"
|
|
17
|
+
HEAD_REF="HEAD"
|
|
18
|
+
EXCLUDE="node_modules,dist,build,.next,coverage"
|
|
19
|
+
OUTPUT="impact-report.md"
|
|
20
|
+
JSON_OUTPUT=""
|
|
21
|
+
NO_FAIL=false
|
|
22
|
+
VERBOSE=false
|
|
23
|
+
|
|
24
|
+
# Help message
|
|
25
|
+
show_help() {
|
|
26
|
+
cat << EOF
|
|
27
|
+
Impact Analysis Runner
|
|
28
|
+
|
|
29
|
+
Usage: ./run-impact-analysis.sh [OPTIONS]
|
|
30
|
+
|
|
31
|
+
Options:
|
|
32
|
+
--input=DIR Source directory to analyze (default: src)
|
|
33
|
+
--base=REF Base git reference (default: origin/main)
|
|
34
|
+
--head=REF Head git reference (default: HEAD)
|
|
35
|
+
--exclude=PATHS Comma-separated paths to exclude (default: node_modules,dist,build)
|
|
36
|
+
--output=FILE Output markdown file (default: impact-report.md)
|
|
37
|
+
--json=FILE Optional JSON output file
|
|
38
|
+
--no-fail Don't exit with error on critical impact
|
|
39
|
+
--verbose Verbose output
|
|
40
|
+
-h, --help Show this help message
|
|
41
|
+
|
|
42
|
+
Examples:
|
|
43
|
+
./run-impact-analysis.sh --input=src --base=origin/main
|
|
44
|
+
./run-impact-analysis.sh --input=src --json=impact.json --verbose
|
|
45
|
+
EOF
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# Parse arguments
|
|
49
|
+
while [[ $# -gt 0 ]]; do
|
|
50
|
+
case $1 in
|
|
51
|
+
--input=*)
|
|
52
|
+
INPUT_DIR="${1#*=}"
|
|
53
|
+
shift
|
|
54
|
+
;;
|
|
55
|
+
--base=*)
|
|
56
|
+
BASE_REF="${1#*=}"
|
|
57
|
+
shift
|
|
58
|
+
;;
|
|
59
|
+
--head=*)
|
|
60
|
+
HEAD_REF="${1#*=}"
|
|
61
|
+
shift
|
|
62
|
+
;;
|
|
63
|
+
--exclude=*)
|
|
64
|
+
EXCLUDE="${1#*=}"
|
|
65
|
+
shift
|
|
66
|
+
;;
|
|
67
|
+
--output=*)
|
|
68
|
+
OUTPUT="${1#*=}"
|
|
69
|
+
shift
|
|
70
|
+
;;
|
|
71
|
+
--json=*)
|
|
72
|
+
JSON_OUTPUT="${1#*=}"
|
|
73
|
+
shift
|
|
74
|
+
;;
|
|
75
|
+
--no-fail)
|
|
76
|
+
NO_FAIL=true
|
|
77
|
+
shift
|
|
78
|
+
;;
|
|
79
|
+
--verbose)
|
|
80
|
+
VERBOSE=true
|
|
81
|
+
shift
|
|
82
|
+
;;
|
|
83
|
+
-h|--help)
|
|
84
|
+
show_help
|
|
85
|
+
exit 0
|
|
86
|
+
;;
|
|
87
|
+
*)
|
|
88
|
+
echo -e "${RED}Unknown option: $1${NC}"
|
|
89
|
+
show_help
|
|
90
|
+
exit 1
|
|
91
|
+
;;
|
|
92
|
+
esac
|
|
93
|
+
done
|
|
94
|
+
|
|
95
|
+
# Print configuration
|
|
96
|
+
echo -e "${GREEN}🚀 Running Impact Analysis...${NC}"
|
|
97
|
+
echo ""
|
|
98
|
+
echo "Configuration:"
|
|
99
|
+
echo " Input: $INPUT_DIR"
|
|
100
|
+
echo " Base: $BASE_REF"
|
|
101
|
+
echo " Head: $HEAD_REF"
|
|
102
|
+
echo " Output: $OUTPUT"
|
|
103
|
+
echo ""
|
|
104
|
+
|
|
105
|
+
# Build command
|
|
106
|
+
CMD="node index.js --input=$INPUT_DIR --base=$BASE_REF --head=$HEAD_REF --exclude=$EXCLUDE --output=$OUTPUT"
|
|
107
|
+
|
|
108
|
+
if [ ! -z "$JSON_OUTPUT" ]; then
|
|
109
|
+
CMD="$CMD --json=$JSON_OUTPUT"
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
if [ "$NO_FAIL" = true ]; then
|
|
113
|
+
CMD="$CMD --no-fail"
|
|
114
|
+
fi
|
|
115
|
+
|
|
116
|
+
if [ "$VERBOSE" = true ]; then
|
|
117
|
+
CMD="$CMD --verbose"
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
# Run the analyzer
|
|
121
|
+
eval $CMD
|
|
122
|
+
EXIT_CODE=$?
|
|
123
|
+
|
|
124
|
+
# Check
|