Skip to content

Commit

Permalink
feat: make setup.sh more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Mar 25, 2023
1 parent b0a4d48 commit 6c2f360
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 31 deletions.
14 changes: 7 additions & 7 deletions README_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<h1 align="center">your-plugin-name</h2>
<h1 align="center">YOUR_REPOSITORY_NAME</h2>
</p>

<p align="center">
Expand Down Expand Up @@ -47,9 +47,9 @@ _[GIF version of the showcase video for mobile users](SHOWCASE_GIF_LINK)_

```lua
-- stable version
use {"your-plugin-name", tag = "*" }
use {"YOUR_REPOSITORY_NAME", tag = "*" }
-- dev version
use {"your-plugin-name"}
use {"YOUR_REPOSITORY_NAME"}
```

</td>
Expand All @@ -64,9 +64,9 @@ use {"your-plugin-name"}

```lua
-- stable version
Plug "your-plugin-name", { "tag": "*" }
Plug "YOUR_REPOSITORY_NAME", { "tag": "*" }
-- dev version
Plug "your-plugin-name"
Plug "YOUR_REPOSITORY_NAME"
```

</td>
Expand All @@ -81,9 +81,9 @@ Plug "your-plugin-name"

```lua
-- stable version
require("lazy").setup({{"your-plugin-name", version = "*"}})
require("lazy").setup({{"YOUR_REPOSITORY_NAME", version = "*"}})
-- dev version
require("lazy").setup({"your-plugin-name"})
require("lazy").setup({"YOUR_REPOSITORY_NAME"})
```

</td>
Expand Down
69 changes: 45 additions & 24 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,34 @@ 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
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
read -rp $'\t> No PLUGIN_NAME provided, defaulting to \033[1;32m'"$REPOSITORY_NAME"$'\033[0m, continue? [Y/n]\n' yn
case $yn in
[Yy]* )
PLUGIN_NAME=$REPOSITORY_NAME
;;
[Nn]* )
echo -e "\t> Enter your plugin name"
read PLUGIN_NAME
;;
* )
echo -e $USAGE
exit 1;;
esac
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..."
Expand All @@ -56,3 +57,23 @@ grep -rl "YourPluginName" .github/ plugin/ tests/ lua/ | xargs sed -i "" -e "s/Y
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"

0 comments on commit 6c2f360

Please sign in to comment.