-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAKE.sh
96 lines (78 loc) · 2.59 KB
/
MAKE.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# /bin/bash
PROJECT_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -d "$PROJECT_HOME/dist" ]; then rm -Rf $PROJECT_HOME/dist; fi
cp -r $PROJECT_HOME/src $PROJECT_HOME/dist
cd $PROJECT_HOME/dist
echo "==============================="
echo "creating composing alias files..."
echo "==============================="
find ./** -type d | while read folder_path; do
echo "doing for folder $folder_path..."
cd $PROJECT_HOME/dist/$folder_path
filename="_$(basename $folder_path)_aliases"
find . -type f ! -name '_*' -name '*_aliases' | while read file; do
cat $file >> $filename
echo "" >> $filename
done
echo " - $filename created."
echo "---------------------------"
done
echo ""
echo ""
echo "==============================="
echo "creating unalias files..."
echo "==============================="
cd $PROJECT_HOME/dist
find ./** -type d | while read folder_path; do
echo "doing for folder $folder_path"
cd $PROJECT_HOME/dist/$folder_path
find . -type f -name '*_aliases' -name '*_aliases' -maxdepth 1 | while read file; do
unaliasFile=$(basename $file | sed 's/alias/unalias/g')
sed 's/alias/unalias/g' $file | sed "s/='.*'//g" >> $unaliasFile
echo '' >> $unaliasFile
echo " - $unaliasFile created."
done
echo "---------------------------"
done
cd $PROJECT_HOME/dist
echo "==============================="
echo "creating readme files..."
echo "==============================="
find ./** -type d | while read folder_path; do
echo "doing for folder $folder_path..."
cd $PROJECT_HOME/dist/$folder_path
filename="$(basename $folder_path)"
echo "# $filename" >> "README.md"
echo 'files:'
find . -type f -name "_$filename\_aliases" | while read file; do
cat $file |
sed "s/\(alias.*\)/\`\`\`bash\n\1\n\`\`\`/" |
sed "s/#/##/g" >> "README.md"
echo "" >> "README.md"
echo "" >> "README.md"
done
echo " - $filename.md created."
echo "---------------------------"
done
echo ""
cd $PROJECT_HOME/dist
echo "==============================="
echo "creating install.sh file..."
echo "==============================="
gh_base="https://raw.githubusercontent.com/doxsch/cli_aliases/master/dist/"
URLS=""
OPTIONS=""
FILES=($(find . -type f -name "*_aliases" ! -name "_*_*" 2>/dev/null))
for file in "${FILES[@]}"
do
option="$(echo $file | sed "s|\.\/bash\/||")"
OPTIONS+=" \"$option\""
url="$(echo $file | sed "s|\.\/|$gh_base|")"
URLS+=" $url"
done
echo "---------------------"
echo $URLS
echo $OPTIONS
echo "options=($OPTIONS)">./bash/install.sh
echo "urls=($URLS)">>./bash/install.sh
cat $PROJECT_HOME/install.sh >> ./bash/install.sh