-
Notifications
You must be signed in to change notification settings - Fork 5
/
generate_power-by.sh
executable file
·39 lines (31 loc) · 1.18 KB
/
generate_power-by.sh
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
#!/bin/bash +x
fileName="powered-by.md"
report=$(license-report)
echo "# Dependencies Report" > $fileName
echo "" >> $fileName
echo "The following is a list of all the dependencies of this project:" >> $fileName
#base64 encoding/decoding used to handle any potential special characters or escape sequences in the JSON data.
for row in $(echo "${report}" | jq -r '.[] | @base64'); do
_jq() {
echo "${row}" | base64 --decode | jq -r ${1}
}
name=$(_jq '.name')
url=$(_jq '.link')
licenseType=$(_jq '.licenseType')
licensePeriod=$(_jq '.licensePeriod')
installedVersion=$(_jq '.installedVersion')
author=$(_jq '.author')
if [[ $author == *" <"* ]]; then
author="[${author%% <*}](${author##*<}"
author="${author%?}" # remove the extra ">" at the end
author="${author})" # adding ")" at the end
fi
echo "## [${name}](${url})" >> $fileName
echo "" >> $fileName
echo "**License:** ${licenseType} - ${licensePeriod}" >> $fileName
echo "" >> $fileName
echo "**Used version:** ${installedVersion}" >> $fileName
echo "" >> $fileName
echo "**Many thanks to:** ${author}" >> $fileName
echo "" >> $fileName
done