forked from semgrep/semgrep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-cheatsheet
executable file
·36 lines (30 loc) · 963 Bytes
/
generate-cheatsheet
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
#! /usr/bin/env bash
#
# Wrapper for generating the cheatsheets from the semgrep repo.
#
set -euo pipefail
repo_root=$(git rev-parse --show-toplevel)
input=$repo_root/semgrep-core/tests/patterns
output=$(pwd)/cheatsheet.json
if [[ $# -gt 0 ]]; then
cat >&2 <<EOF
Usage: $0
Must run from the semgrep git repository.
Generate a json file $(basename "$output") containing semgrep examples to
be shown on the semgrep website, for each language supported by semgrep.
These files are read from $input, which is also where regression tests
for each language are located. For information on how to populate the
cheatsheet for a specific language, look into the python script
'generate_cheatsheet.py'.
EOF
fi
(
cd "$repo_root"/cli
pipenv run python3 ../scripts/generate_cheatsheet.py --json \
--directory "$input" \
--output-file "$output"
cat <<EOF
Created $output.
Copy that file to the semgrep-app repo: /frontend/src/assets/cheatsheet.json
EOF
)