@freshworks/shiftleft-tools 1.1.8
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 +351 -0
- package/bin/shiftleft.js +95 -0
- package/package.json +57 -0
- package/src/commands/doctor.js +208 -0
- package/src/commands/init-postman.js +298 -0
- package/src/commands/init-rules.js +78 -0
- package/src/commands/link.js +172 -0
- package/src/commands/protect.js +61 -0
- package/src/commands/run-tests.js +182 -0
- package/src/commands/setup-pipeline.js +209 -0
- package/src/commands/update.js +203 -0
- package/src/index.js +4 -0
- package/src/utils/copy-tree.js +98 -0
- package/src/utils/gitignore.js +26 -0
- package/src/utils/logger.js +9 -0
- package/src/utils/manifest.js +145 -0
- package/src/utils/stack.js +80 -0
- package/src/utils/template.js +135 -0
- package/templates/AGENTS.md +109 -0
- package/templates/CLAUDE.md +3 -0
- package/templates/jenkins/Jenkinsfile-java.groovy +432 -0
- package/templates/jenkins/Jenkinsfile-node.groovy +450 -0
- package/templates/postman/.husky/pre-commit +19 -0
- package/templates/postman/.prettierrc.json +5 -0
- package/templates/postman/README.md.ejs +147 -0
- package/templates/postman/collections/01-core.json.ejs +91 -0
- package/templates/postman/config/local.json.ejs +12 -0
- package/templates/postman/config/staging.json.ejs +26 -0
- package/templates/postman/environments/local.postman_environment.json.ejs +31 -0
- package/templates/postman/environments/staging.postman_environment.json.ejs +31 -0
- package/templates/postman/gitignore +16 -0
- package/templates/postman/npmrc +31 -0
- package/templates/postman/package.json.ejs +66 -0
- package/templates/postman/run-all-shim.sh +16 -0
- package/templates/postman/scripts/auth/generate-jwt.sh +113 -0
- package/templates/postman/scripts/auth/get-issuer-secret.sh +140 -0
- package/templates/postman/scripts/infra/start-mocks.sh +138 -0
- package/templates/postman/scripts/infra/stop-mocks.sh +43 -0
- package/templates/postman/scripts/lib/api_coverage.py +1122 -0
- package/templates/postman/scripts/lib/cleanup-reports.sh +101 -0
- package/templates/postman/scripts/lib/cleanup-stryker.sh +44 -0
- package/templates/postman/scripts/lib/report_combined.py +527 -0
- package/templates/postman/scripts/lib/report_consolidated.py +363 -0
- package/templates/postman/scripts/lib/report_generator.py +121 -0
- package/templates/postman/scripts/lib/report_migration.py +156 -0
- package/templates/postman/scripts/lib/report_mutation.py +110 -0
- package/templates/postman/scripts/lib/report_unit.py +353 -0
- package/templates/postman/scripts/lib/report_utils.py +973 -0
- package/templates/postman/scripts/report-generators/generate-consolidated-report.sh +445 -0
- package/templates/postman/scripts/report-generators/java-api-coverage-matrix.sh +257 -0
- package/templates/postman/scripts/report-generators/mutation-report.sh +672 -0
- package/templates/postman/scripts/report-generators/node-api-coverage-matrix.sh +167 -0
- package/templates/postman/scripts/report-generators/stage-report-artifacts.sh +27 -0
- package/templates/postman/scripts/run-all.sh +452 -0
- package/templates/postman/scripts/runners/run-mutation-tests.sh +113 -0
- package/templates/postman/scripts/runners/run-tests-local.sh +936 -0
- package/templates/postman/scripts/runners/run-tests-staging.sh +741 -0
- package/templates/postman-node/README.md.ejs +26 -0
- package/templates/postman-node/collections/crud/01-bootstrap.json.ejs +34 -0
- package/templates/postman-node/config/local.json.ejs +46 -0
- package/templates/postman-node/config/staging.json.ejs +31 -0
- package/templates/postman-node/local.test.env.ejs +3 -0
- package/templates/postman-node/mocks/external.js +14 -0
- package/templates/postman-node/package.json.ejs +39 -0
- package/templates/postman-node/requirements.txt +1 -0
- package/templates/postman-node/scripts/database/cleanup-mysql.sh +12 -0
- package/templates/postman-node/scripts/database/run-migrations.js +29 -0
- package/templates/postman-node/scripts/database/start-mysql.sh +34 -0
- package/templates/postman-node/scripts/database/wait-for-mysql.sh +36 -0
- package/templates/postman-node/scripts/lib/api_coverage_node.py +1137 -0
- package/templates/postman-node/scripts/lib/fetch-jwt.sh +86 -0
- package/templates/postman-node/scripts/lib/run-newman.sh +104 -0
- package/templates/postman-node/scripts/lib/setup-database.sh +55 -0
- package/templates/postman-node/scripts/lib/start-app.sh +48 -0
- package/templates/postman-node/scripts/lib/utils.sh +114 -0
- package/templates/postman-node/scripts/report-generators/stage-report-artifacts.sh +26 -0
- package/templates/postman-node/scripts/run-all.sh +303 -0
- package/templates/postman-node/scripts/runners/run-tests.sh +123 -0
- package/templates/postman-node/scripts/setup-mocks.js.ejs +29 -0
- package/templates/postman-node/stryker.config.js.ejs +51 -0
- package/templates/rules/local-test-setup.mdc +420 -0
- package/templates/rules/testing-node.mdc +66 -0
- package/templates/rules/testing.mdc +248 -0
- package/templates/skills/_shared/postman-standards.md +380 -0
- package/templates/skills/enhance-test-pipeline/SKILL-java.md +483 -0
- package/templates/skills/enhance-test-pipeline/SKILL-node.md +431 -0
- package/templates/skills/enhance-test-pipeline/SKILL.md +9 -0
- package/templates/skills/review-test-suite/SKILL-java.md +137 -0
- package/templates/skills/review-test-suite/SKILL-node.md +78 -0
- package/templates/skills/review-test-suite/SKILL.md +9 -0
- package/templates/skills/run-test-suite/SKILL-java.md +186 -0
- package/templates/skills/run-test-suite/SKILL-node.md +191 -0
- package/templates/skills/run-test-suite/SKILL.md +9 -0
- package/templates/skills/setup-api-tests/SKILL-java.md +1094 -0
- package/templates/skills/setup-api-tests/SKILL-node.md +141 -0
- package/templates/skills/setup-api-tests/SKILL.md +9 -0
- package/templates/skills/setup-mutation-tests/SKILL-java.md +303 -0
- package/templates/skills/setup-mutation-tests/SKILL-node.md +408 -0
- package/templates/skills/setup-mutation-tests/SKILL.md +9 -0
- package/templates/skills/setup-test-pipeline/SKILL-java.md +454 -0
- package/templates/skills/setup-test-pipeline/SKILL-node.md +318 -0
- package/templates/skills/setup-test-pipeline/SKILL.md +9 -0
- package/templates/skills/write-api-tests/SKILL-java.md +115 -0
- package/templates/skills/write-api-tests/SKILL-node.md +83 -0
- package/templates/skills/write-api-tests/SKILL.md +9 -0
- package/templates/stryker.config.js +50 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#==============================================================================
|
|
3
|
+
# cleanup-reports.sh - Shared report cleanup utilities
|
|
4
|
+
#==============================================================================
|
|
5
|
+
# This script provides common report cleanup functions used by:
|
|
6
|
+
# - run-tests-local.sh
|
|
7
|
+
# - run-tests-staging.sh
|
|
8
|
+
# - java-api-coverage-matrix.sh
|
|
9
|
+
#
|
|
10
|
+
# Usage: source this file from other scripts
|
|
11
|
+
#==============================================================================
|
|
12
|
+
|
|
13
|
+
# Clean a directory of timestamped reports (keep last N of each type)
|
|
14
|
+
# Args: $1=dir $2=ext $3=keep_count $4=total_deleted_var_name
|
|
15
|
+
cleanup_dir_keep_n() {
|
|
16
|
+
local dir="$1"
|
|
17
|
+
local ext="$2"
|
|
18
|
+
local keep="$3"
|
|
19
|
+
local total_var="${4:-}"
|
|
20
|
+
local deleted=0
|
|
21
|
+
|
|
22
|
+
# Get unique report prefixes (e.g., "local-freshdesk-crud-01-bootstrap")
|
|
23
|
+
local prefixes=$(find "$dir" -maxdepth 1 -name "*-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9].${ext}" 2>/dev/null | \
|
|
24
|
+
xargs -I {} basename {} 2>/dev/null | \
|
|
25
|
+
sed -E "s/-[0-9]{8}-[0-9]{6}\.${ext}\$//" | \
|
|
26
|
+
sort -u)
|
|
27
|
+
|
|
28
|
+
for prefix in $prefixes; do
|
|
29
|
+
[ -z "$prefix" ] && continue
|
|
30
|
+
# Get files sorted by time (newest first), skip the first N
|
|
31
|
+
local old_files=$(ls -1t "$dir/${prefix}"-*."${ext}" 2>/dev/null | tail -n +$((keep + 1)))
|
|
32
|
+
for file in $old_files; do
|
|
33
|
+
[ -f "$file" ] && rm -f "$file" && deleted=$((deleted + 1))
|
|
34
|
+
done
|
|
35
|
+
done
|
|
36
|
+
|
|
37
|
+
# Update caller's total if variable name provided
|
|
38
|
+
if [ -n "$total_var" ]; then
|
|
39
|
+
eval "$total_var=\$((\$$total_var + $deleted))"
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
echo $deleted
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# Clean up old reports for Newman test runs
|
|
46
|
+
# - Deletes all individual JSON reports (only needed for consolidation)
|
|
47
|
+
# - Keeps last N of each HTML report type
|
|
48
|
+
# - Keeps last N of consolidated JSON reports
|
|
49
|
+
# Args: $1=report_dir $2=keep_count (default: 2)
|
|
50
|
+
cleanup_newman_reports() {
|
|
51
|
+
local report_dir="$1"
|
|
52
|
+
local keep_count="${2:-2}"
|
|
53
|
+
local total_deleted=0
|
|
54
|
+
|
|
55
|
+
echo ""
|
|
56
|
+
echo " → Cleaning up reports..."
|
|
57
|
+
|
|
58
|
+
# Delete all individual JSON reports (json/ subdirectory)
|
|
59
|
+
# These are only needed temporarily for consolidated report generation
|
|
60
|
+
if [ -d "$report_dir/json" ]; then
|
|
61
|
+
local json_count=$(find "$report_dir/json" -name "*.json" -type f 2>/dev/null | wc -l | tr -d ' ')
|
|
62
|
+
if [ "$json_count" -gt 0 ]; then
|
|
63
|
+
rm -f "$report_dir/json"/*.json 2>/dev/null
|
|
64
|
+
total_deleted=$((total_deleted + json_count))
|
|
65
|
+
fi
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
# Keep last N of each HTML report type (individual test reports)
|
|
69
|
+
local html_deleted=$(cleanup_dir_keep_n "$report_dir" "html" "$keep_count")
|
|
70
|
+
total_deleted=$((total_deleted + html_deleted))
|
|
71
|
+
|
|
72
|
+
# Keep last N of consolidated JSON reports (in main reports dir)
|
|
73
|
+
local json_deleted=$(cleanup_dir_keep_n "$report_dir" "json" "$keep_count")
|
|
74
|
+
total_deleted=$((total_deleted + json_deleted))
|
|
75
|
+
|
|
76
|
+
if [ $total_deleted -gt 0 ]; then
|
|
77
|
+
echo "✓ Cleaned up $total_deleted old report(s)"
|
|
78
|
+
else
|
|
79
|
+
echo "✓ No old reports to clean up"
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
return 0
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# Clean up old reports for a specific report type (e.g., api-coverage-matrix)
|
|
86
|
+
# Args: $1=report_dir $2=pattern (glob) $3=keep_count (default: 1)
|
|
87
|
+
cleanup_reports_by_pattern() {
|
|
88
|
+
local reports_dir="$1"
|
|
89
|
+
local pattern="$2"
|
|
90
|
+
local keep_count="${3:-1}"
|
|
91
|
+
|
|
92
|
+
if [ -d "$reports_dir" ]; then
|
|
93
|
+
local count=$(find "$reports_dir" -name "$pattern" -type f 2>/dev/null | wc -l | tr -d ' ')
|
|
94
|
+
if [ "$count" -gt "$keep_count" ]; then
|
|
95
|
+
echo " → Cleaning up old reports (keeping last $keep_count)..."
|
|
96
|
+
find "$reports_dir" -name "$pattern" -type f 2>/dev/null | \
|
|
97
|
+
sort | head -n $((count - keep_count)) | xargs rm -f 2>/dev/null || true
|
|
98
|
+
echo "✓ Cleaned up $((count - keep_count)) old report(s)"
|
|
99
|
+
fi
|
|
100
|
+
fi
|
|
101
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#==============================================================================
|
|
3
|
+
# cleanup-stryker.sh - Stop Stryker workers and remove temp artifacts
|
|
4
|
+
#==============================================================================
|
|
5
|
+
# Stryker leaves child processes and a sandbox under coverage/mutation/.stryker-tmp.
|
|
6
|
+
# Unit/mutation tests can also leave the observability health server on port 8081.
|
|
7
|
+
#
|
|
8
|
+
# Usage: source this file, then:
|
|
9
|
+
# cleanup_stryker_processes
|
|
10
|
+
# cleanup_stryker_temp "$PROJECT_ROOT"
|
|
11
|
+
#==============================================================================
|
|
12
|
+
|
|
13
|
+
# Stop Stryker runners and the health server port used during Mocha runs.
|
|
14
|
+
cleanup_stryker_processes() {
|
|
15
|
+
pkill -9 -f "@stryker-mutator" 2>/dev/null || true
|
|
16
|
+
pkill -9 -f "stryker run" 2>/dev/null || true
|
|
17
|
+
pkill -9 -f "child-process-proxy-worker" 2>/dev/null || true
|
|
18
|
+
|
|
19
|
+
if command -v lsof >/dev/null 2>&1; then
|
|
20
|
+
local pid
|
|
21
|
+
for pid in $(lsof -ti:8081 2>/dev/null); do
|
|
22
|
+
kill -9 "$pid" 2>/dev/null || true
|
|
23
|
+
done
|
|
24
|
+
fi
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Remove Stryker sandbox and log files (keeps mutation-report.json / HTML reports).
|
|
28
|
+
cleanup_stryker_temp() {
|
|
29
|
+
local project_root="${1:-}"
|
|
30
|
+
[ -n "$project_root" ] || return 0
|
|
31
|
+
|
|
32
|
+
rm -rf "$project_root/coverage/mutation/.stryker-tmp"
|
|
33
|
+
rm -f "$project_root/stryker.log" "$project_root/.stryker-incremental.json" 2>/dev/null || true
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
cleanup_stryker() {
|
|
37
|
+
cleanup_stryker_processes
|
|
38
|
+
cleanup_stryker_temp "${1:-}"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
42
|
+
PROJECT_ROOT="$(cd "$(dirname "$0")/../../.." && pwd)"
|
|
43
|
+
cleanup_stryker "$PROJECT_ROOT"
|
|
44
|
+
fi
|