Last active
April 26, 2023 13:47
-
-
Save aliemir/534078e2e828af100de462b4aa55f258 to your computer and use it in GitHub Desktop.
A small command line tool for easier development on [`refine`](https://refine.dev)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# A small command line tool for easier development on [`refine`](https://refine.dev) | |
version="1.7.0" | |
name="\e[35m[refine-development]\e[0m" | |
all_args=("$@") | |
first_arg="$1" | |
scopes_array=() | |
# help | |
function help_list() { | |
echo "${name} Help (version ${version})" | |
echo "" | |
echo "List of functions:" | |
echo "1. open or op: open selected directories in vscode" | |
echo -e "\e[2m - (ex: ./refine op packages/core packages/antd packages/mui)\e[0m" | |
echo "2. openadd or opa: open selected directories in current vscode window" | |
echo -e "\e[2m - (ex: ./refine opa packages/core packages/antd packages/mui)\e[0m" | |
echo "3. start or st: run start script for following packages" | |
echo -e "\e[2m - (ex: ./refine st @pankod/refine-core @pankod/refine-antd)\e[0m" | |
echo "4. bootstrap or bs: run bootstrap script for following packages" | |
echo -e "\e[2m - (ex: ./refine bs @pankod/refine-core @pankod/refine-antd)\e[0m" | |
echo "5. build or bl: run build script for following packages" | |
echo -e "\e[2m - (ex: ./refine bl @pankod/refine-core @pankod/refine-antd)\e[0m" | |
echo "6. test or te: run test script for following packages" | |
echo -e "\e[2m - (ex: ./refine te @pankod/refine-core @pankod/refine-antd)\e[0m" | |
echo "7. changeset or ch: run changeset script" | |
echo -e "\e[2m - (ex: ./refine ch)\e[0m" | |
echo "8. upgrade or up: update this tool" | |
echo -e "\e[2m - (ex: ./refine up)\e[0m" | |
echo "9. version or v: show version" | |
echo -e "\e[2m - (ex: ./refine v)\e[0m" | |
echo "10. HBKNM or hb: show easter egg" | |
echo "" | |
echo "" | |
} | |
function fallback() { | |
echo -e "${name} I am not sure what you mean with '\e[4m${first_arg}\e[0m'" | |
echo "\e[2m - Run \e[22m\e[34m./refine help\e[39m\e[2m for list of available commands.\e[0m" | |
} | |
function open() { | |
echo "${name} Opening" | |
code --new-window . ${all_args[@]:1} | |
} | |
function openadd() { | |
echo "${name} Opening in current window" | |
code --add ${all_args[@]:1} | |
} | |
function start() { | |
echo "${name} Starting" | |
npm run start -- ${scopes_array[@]} | |
} | |
function bootstrap() { | |
echo "${name} Bootstrapping" | |
npm run bootstrap -- ${scopes_array[@]} | |
} | |
function build() { | |
echo "${name} Building" | |
npm run build -- ${scopes_array[@]} | |
} | |
function test() { | |
echo "${name} Testing" | |
npm run test -- ${scopes_array[@]} | |
} | |
function changeset() { | |
echo "${name} Running Changesets..." | |
npm run changeset | |
} | |
function version() { | |
echo "${name} Version: ${version}" | |
} | |
function upgrade() { | |
echo "${name} Upgrading..." | |
curl -sL https://gist.github.com/aliemir/534078e2e828af100de462b4aa55f258/raw > refine_updated | |
chmod +x refine_updated | |
mv ./refine_updated ./refine | |
} | |
function hbknm() { | |
echo -e "\e[31m _ _ ____ _ __ _ _ __ __ _ \e[0m" | |
echo -e "\e[32m | | | | | _ \ | |/ / | \ | | | \/ | | | \e[0m" | |
echo -e "\e[34m | |__| | | |_) | | ' / | \| | | \ / | | | \e[0m" | |
echo -e "\e[35m | __ | | _ < | < | . \` | | |\/| | | |\e[0m" | |
echo -e "\e[36m | | | | | |_) | | . \ | |\ | | | | | |_| \e[0m" | |
echo -e "\e[37m |_| |_| |____/ |_|\_\ |_| \_| |_| |_| (_) \e[0m" | |
echo -e "\e[38m \e[0m" | |
} | |
function main() { | |
for i in "${all_args[@]:1}"; do | |
scopes_array+=(--scope) | |
scopes_array+=("$i") | |
done | |
case "${first_arg}" in | |
""|"help") help_list ;; | |
"open"|"op") open ;; | |
"openadd"|"opa") openadd ;; | |
"start"|"st") start ;; | |
"bootstrap"|"bs") bootstrap ;; | |
"build"|"bl") build ;; | |
"test"|"te") test ;; | |
"changeset"|"ch") changeset ;; | |
"upgrade"|"up") upgrade ;; | |
"version"|"v") version ;; | |
"HBKNM"|"hbknm"|"hb") hbknm ;; | |
*) fallback ;; | |
esac | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment