@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,113 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Run Stryker with pre/post cleanup (processes, sandbox, port 8081).
|
|
3
|
+
#
|
|
4
|
+
# Modes (set MUTATION_MODE or pass --full):
|
|
5
|
+
# since (default) — only scoped .js files changed vs origin/master (fast, for run-all / local)
|
|
6
|
+
# full — all scoped files, --force (Jenkins / yarn mutation-tests:full)
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
11
|
+
# shellcheck source=../lib/cleanup-stryker.sh
|
|
12
|
+
source "$SCRIPT_DIR/../lib/cleanup-stryker.sh"
|
|
13
|
+
|
|
14
|
+
MUTATION_MODE="${MUTATION_MODE:-since}"
|
|
15
|
+
MUTATION_BASE_REF="${MUTATION_BASE_REF:-origin/master}"
|
|
16
|
+
|
|
17
|
+
while [[ $# -gt 0 ]]; do
|
|
18
|
+
case "$1" in
|
|
19
|
+
--full) MUTATION_MODE=full; shift ;;
|
|
20
|
+
*) break ;;
|
|
21
|
+
esac
|
|
22
|
+
done
|
|
23
|
+
|
|
24
|
+
# Scoped paths aligned with stryker.config.js mutate / exclusions
|
|
25
|
+
is_mutatable_file() {
|
|
26
|
+
local f="${1//\\//}"
|
|
27
|
+
[[ "$f" == *.js ]] || return 1
|
|
28
|
+
case "$f" in
|
|
29
|
+
src/actions/*|src/serializers/*|src/middlewares/*) return 0 ;;
|
|
30
|
+
src/helpers/*)
|
|
31
|
+
case "$f" in
|
|
32
|
+
src/helpers/validator/schema/*) return 1 ;;
|
|
33
|
+
src/helpers/aws.js|src/helpers/chargebee.js|src/helpers/freshid.js|\
|
|
34
|
+
src/helpers/launchdarkly.js|src/helpers/emailNotifications.js|\
|
|
35
|
+
src/helpers/analytics.js|src/helpers/observability.js|\
|
|
36
|
+
src/helpers/mcp-gateway.js|src/helpers/mcp-gateway-util.js|\
|
|
37
|
+
src/helpers/mp-listings.js|src/helpers/mp-apps.js|\
|
|
38
|
+
src/helpers/constants.js|src/helpers/config.js) return 1 ;;
|
|
39
|
+
esac
|
|
40
|
+
return 0
|
|
41
|
+
;;
|
|
42
|
+
esac
|
|
43
|
+
return 1
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Populates CHANGED_MUTATE_LIST (comma-separated) or returns: 0 ok, 1 fallback to full, 2 skip
|
|
47
|
+
resolve_changed_mutate_list() {
|
|
48
|
+
local base_ref="$1"
|
|
49
|
+
local -a changed=()
|
|
50
|
+
local line
|
|
51
|
+
|
|
52
|
+
CHANGED_MUTATE_LIST=""
|
|
53
|
+
|
|
54
|
+
if ! git -C "$PROJECT_ROOT" rev-parse --verify "${base_ref}" >/dev/null 2>&1; then
|
|
55
|
+
echo -e "\033[1;33m[WARN]\033[0m ${base_ref} not found; falling back to full mutation scan." >&2
|
|
56
|
+
return 1
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
while IFS= read -r line; do
|
|
60
|
+
[ -z "$line" ] && continue
|
|
61
|
+
if is_mutatable_file "$line" && [ -f "$PROJECT_ROOT/$line" ]; then
|
|
62
|
+
changed+=("$line")
|
|
63
|
+
fi
|
|
64
|
+
done < <(git -C "$PROJECT_ROOT" diff --name-only --diff-filter=ACMR "${base_ref}...HEAD" 2>/dev/null || \
|
|
65
|
+
git -C "$PROJECT_ROOT" diff --name-only --diff-filter=ACMR "${base_ref}" HEAD)
|
|
66
|
+
|
|
67
|
+
if [ "${#changed[@]}" -eq 0 ]; then
|
|
68
|
+
echo -e "\033[1;33m[INFO]\033[0m No scoped source files changed vs ${base_ref}; skipping Stryker." >&2
|
|
69
|
+
return 2
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
CHANGED_MUTATE_LIST=$(IFS=,; echo "${changed[*]}")
|
|
73
|
+
return 0
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
cleanup_stryker "$PROJECT_ROOT"
|
|
77
|
+
cd "$PROJECT_ROOT"
|
|
78
|
+
|
|
79
|
+
if [[ -f "$PROJECT_ROOT/local.env" ]]; then
|
|
80
|
+
set -a
|
|
81
|
+
# shellcheck source=/dev/null
|
|
82
|
+
source "$PROJECT_ROOT/local.env"
|
|
83
|
+
set +a
|
|
84
|
+
fi
|
|
85
|
+
export NODE_ENV=test
|
|
86
|
+
|
|
87
|
+
STRYKER_ARGS=()
|
|
88
|
+
if [[ "$MUTATION_MODE" == "full" ]]; then
|
|
89
|
+
echo -e "\033[0;36mStryker: full scan (all scoped files)\033[0m"
|
|
90
|
+
STRYKER_ARGS+=(--force)
|
|
91
|
+
else
|
|
92
|
+
echo -e "\033[0;36mStryker: fast scan (changed vs ${MUTATION_BASE_REF})\033[0m"
|
|
93
|
+
set +e
|
|
94
|
+
resolve_changed_mutate_list "$MUTATION_BASE_REF"
|
|
95
|
+
COLLECT_STATUS=$?
|
|
96
|
+
set -e
|
|
97
|
+
if [ "$COLLECT_STATUS" -eq 2 ]; then
|
|
98
|
+
cleanup_stryker "$PROJECT_ROOT"
|
|
99
|
+
exit 0
|
|
100
|
+
fi
|
|
101
|
+
if [ "$COLLECT_STATUS" -ne 0 ]; then
|
|
102
|
+
STRYKER_ARGS+=(--force)
|
|
103
|
+
else
|
|
104
|
+
STRYKER_ARGS+=(--mutate "$CHANGED_MUTATE_LIST")
|
|
105
|
+
fi
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
set +e
|
|
109
|
+
yarn --ignore-engines stryker run "${STRYKER_ARGS[@]}" "$@"
|
|
110
|
+
RESULT=$?
|
|
111
|
+
set -e
|
|
112
|
+
cleanup_stryker "$PROJECT_ROOT"
|
|
113
|
+
exit $RESULT
|