-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.sh
executable file
·79 lines (58 loc) · 2.45 KB
/
setup.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
#!/bin/bash
USAGE="\033[0;37m[INFO] - usage: USERNAME=my-github-username PLUGIN_NAME=my-awesome-plugin REPOSITORY_NAME=my-awesome-plugin.nvim make setup\n\033[0m"
echo -e $USAGE
if [[ -z "$USERNAME" ]]; then
echo -e "\t> No USERNAME provided, what's your GitHub/GitLab username?"
read USERNAME
fi
if [[ -z "$REPOSITORY_NAME" ]]; then
REPOSITORY_NAME=$(basename -s .git `git config --get remote.origin.url`)
read -rp $'\t> No REPOSITORY_NAME provided, is \033[1;32m'"$REPOSITORY_NAME"$'\033[0m good? [Y/n]\n' yn
case $yn in
[Yy]* );;
[Nn]* )
echo -e "\t> Enter your repository name"
read REPOSITORY_NAME
;;
* )
echo -e $USAGE
exit 1;;
esac
fi
if [[ -z "$PLUGIN_NAME" ]]; then
DEFAULT_REPOSITORY_NAME=$(echo "$REPOSITORY_NAME" | sed -e "s/\.nvim//")
read -rp $'\t> No PLUGIN_NAME provided, defaulting to \033[1;32m'"$DEFAULT_REPOSITORY_NAME"$'\033[0m, continue? [Y/n]\n' yn
case $yn in
[Yy]* )
PLUGIN_NAME=$DEFAULT_REPOSITORY_NAME
;;
[Nn]* )
echo -e "\t> Enter your plugin name"
read PLUGIN_NAME
;;
* )
echo -e $USAGE
exit 1;;
esac
fi
echo -e "Username: \033[1;32m$USERNAME\033[0m\nRepository: \033[1;32m$REPOSITORY_NAME\033[0m\nPlugin: \033[1;32m$PLUGIN_NAME\033[0m\n\n\tRenaming placeholder files..."
rm -rf doc
mv plugin/your-plugin-name.lua plugin/$PLUGIN_NAME.lua
mv lua/your-plugin-name lua/$PLUGIN_NAME
mv README_TEMPLATE.md README.md
echo -e "\tReplacing placeholder names..."
PASCAL_CASE_PLUGIN_NAME=$(echo "$PLUGIN_NAME" | perl -pe 's/(^|-)./uc($&)/ge;s/-//g')
grep -rl "YourPluginName" .github/ plugin/ tests/ lua/ | xargs sed -i "" -e "s/YourPluginName/$PASCAL_CASE_PLUGIN_NAME/g"
grep -rl "your-plugin-name" README.md .github/ plugin/ tests/ lua/ | xargs sed -i "" -e "s/your-plugin-name/$PLUGIN_NAME/g"
grep -rl "YOUR_GITHUB_USERNAME" README.md .github/ | xargs sed -i "" -e "s/YOUR_GITHUB_USERNAME/$USERNAME/g"
grep -rl "YOUR_REPOSITORY_NAME" README.md .github/ | xargs sed -i "" -e "s/YOUR_REPOSITORY_NAME/$REPOSITORY_NAME/g"
echo -e "\n\033[1;32mOK.\033[0m"
echo -e "\tFetching dependencies (tests and documentation generator)..."
make deps
echo -e "\n\033[1;32mOK.\033[0m"
echo -e "\tGenerating docs..."
make documentation
echo -e "\n\033[1;32mOK.\033[0m"
echo -e "\tRunning tests..."
make test
echo -e "\n\033[1;32mOK.\033[0m"