From b31e7662e8b1d389cd006b1dea91b364f5a0e37c Mon Sep 17 00:00:00 2001 From: Paul Phan Date: Thu, 17 Jan 2019 23:02:34 -0500 Subject: [PATCH 1/8] - Updating Cog to take custom commands --- .env.example | 17 +++++++ bin/cog | 4 +- bin/cog-clone | 4 -- bin/cog-dev | 1 + bin/cog-help | 73 ++++++++++++++++++++---------- bin/cog-make:script | 1 + bin/cog-update | 3 -- depricated/cog-clone | 4 ++ {bin => depricated}/cog-compile | 0 {bin => depricated}/cog-convert | 0 {bin => depricated}/cog-ec2-deploy | 0 {bin => depricated}/cog-git-backup | 0 {bin => depricated}/cog-go | 0 {bin => depricated}/cog-s3-deploy | 0 {bin => depricated}/cog-serve | 0 {bin => depricated}/cog-watch | 0 16 files changed, 74 insertions(+), 33 deletions(-) create mode 100644 .env.example delete mode 100755 bin/cog-clone create mode 100755 depricated/cog-clone rename {bin => depricated}/cog-compile (100%) rename {bin => depricated}/cog-convert (100%) rename {bin => depricated}/cog-ec2-deploy (100%) rename {bin => depricated}/cog-git-backup (100%) rename {bin => depricated}/cog-go (100%) rename {bin => depricated}/cog-s3-deploy (100%) rename {bin => depricated}/cog-serve (100%) rename {bin => depricated}/cog-watch (100%) diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..6ae0a91 --- /dev/null +++ b/.env.example @@ -0,0 +1,17 @@ +APP_ENV= +APP_URL= +DB_CONNECTION= +DB_HOST= +DB_PORT= +DB_DATABASE= +DB_USERNAME= +DB_PASSWORD= +DB_BACKUP_NAME= +WEBSERVER_HOST= +WEBSERVER_PORT= +ARG_DIR= +S3_KEY= +S3_SECRET= +S3_REGION= +S3_BUCKET= +S3_BACKUP_BUCKET= diff --git a/bin/cog b/bin/cog index b58a06b..7c9619c 100755 --- a/bin/cog +++ b/bin/cog @@ -1,4 +1,6 @@ #!/bin/bash + +# cog requires an argument. If there is no argument, cog will call cog-help CMD=${1:-help} # Yarn global adds the cog binary to your $PATH through a bunch of @@ -6,7 +8,7 @@ CMD=${1:-help} # Python to grab the fully resolved path of `cog` and then two # `dirname`s to back out to the true installed repo directory. DIR=$(dirname $(dirname $(python -c "import os; print(os.path.realpath('${BASH_SOURCE[0]}'))"))) - +echo $DIR; # Include all scripts inside the tools folder for file in $DIR/tools/*; do source $file diff --git a/bin/cog-clone b/bin/cog-clone deleted file mode 100755 index 98f47b0..0000000 --- a/bin/cog-clone +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -git clone git@github.com:happycog/$1.git -cd $1 \ No newline at end of file diff --git a/bin/cog-dev b/bin/cog-dev index 1069b36..6d0fa9b 100755 --- a/bin/cog-dev +++ b/bin/cog-dev @@ -3,6 +3,7 @@ if [ -e .env ]; then source ./.env fi + # Check if gulpfile.js exist if [ -f 'gulpfile.js' ]; then COMPILE_TASK="gulp" diff --git a/bin/cog-help b/bin/cog-help index cf1c67c..0bdef24 100755 --- a/bin/cog-help +++ b/bin/cog-help @@ -10,6 +10,36 @@ BLUE='\033[0;34m' BOLD='\033[0;22m' NC='\033[0m' # No Color +display_commands() { + +echo -e "${YELLOW}Available commands:${NC}" + +# scripts=$PWD/bin/*; +echo $COG_DIRECTORY; +scripts=s$COG_DIRECTORY/bin/*; +for file in $scripts; do + base_file=$(basename "$file"); + if [[ "$base_file" == "cog" ]] || [[ "$base_file" == "cog-help" ]]; then + continue + fi + COG_COMMAND=$(sed -e 's#.*-\(\)#\1#' <<< "$base_file"); + COG_DESCRIPTION=$(sed -n 's/# Description: //p' $file); + echo -e "\t${GREEN}$COG_COMMAND${NC} $COG_DESCRIPTION"; + echo ""; +done +echo -e "\t${GREEN}make${NC} Run the make command" +echo -e "\t ${BLUE}:script${NC} Pass in the name argument to create a new script" +echo -e "\t ${BLUE}:env${NC} Creates a .env file for your project" +echo "" +echo -e "\t${GREEN}tag${NC} Create git tags [${BLUE} major | minor | patch | push${NC}]" +echo "" +echo -e "\t${GREEN}update${NC} Create git tags [${BLUE} major | minor | patch | push${NC}]" +echo "" +echo -e "\t${GREEN}ssl-check${NC} Outputs info and runs some validity checks on a domain's SSL certificate" +echo "" +} + + # Default help screen echo ' MMMMMMMMMMMMMMM MMMMMMMMMMMMMMM @@ -24,33 +54,26 @@ echo ' echo -e "${YELLOW}Usage:${NC}" echo -e "\tcommand [options] [arguments]" echo "" -echo -e "${YELLOW}Available commands:${NC}" -echo -e "\t${GREEN}go${NC} Run the project at localhost:${WEBSERVER_PORT:-8000}." -echo -e "\t ${BLUE}-h, --host${NC} " -echo -e "\t ${BLUE}-p, --port${NC} " -echo -e "\t ${BLUE}-d, --dir${NC} " -echo "" -echo -e "\t${GREEN}make${NC} Run the make command" -echo -e "\t ${BLUE}:script${NC} Pass in the name argument to create a new script" -echo -e "\t ${BLUE}:env${NC} Creates a .env file for your project" -echo "" -echo -e "\t${GREEN}serve${NC} Create localhost tunnel with ngrok" -echo "" -echo -e "\t${GREEN}git-backup${NC} Git clone a remote repository to a local folder and then checkout all remote branches so you have a complete backup" -echo "" -echo -e "\t${GREEN}compile${NC} Run the default preprocessor task (gulp compile, grunt compile, etc.)." +display_commands +# Load Project Scripts +echo -e "${YELLOW}Project commands:${NC}" echo "" -echo -e "\t${GREEN}convert${NC} Converts any .mov and .mp4 files into .gif" -echo "" -echo -e "\t${GREEN}watch${NC} Run the default preprocessor watch task (gulp watch, grunt watch, etc.)." -echo "" -echo -e "\t${GREEN}tag${NC} Create git tags [${BLUE} major | minor | patch | push${NC}]" -echo "" -echo -e "\t${GREEN}update${NC} Create git tags [${BLUE} major | minor | patch | push${NC}]" + +# scripts=$PWD/bin/*; +scripts=/Users/mrpaulphan/Development/kintone-pantheon/bin/*; +for file in $scripts; do + base_file=$(basename "$file"); + if [[ "$base_file" == "cog" ]] || [[ "$base_file" == "cog-help" ]]; then + continue + fi + COG_COMMAND=$(sed -e 's#.*-\(\)#\1#' <<< "$base_file"); + COG_DESCRIPTION=$(sed -n 's/# Description: //p' $file); + echo -e "\t${GREEN}$COG_COMMAND${NC} $COG_DESCRIPTION"; + echo ""; +done echo "" -echo -e "\t${GREEN}ssl-check${NC} Outputs info and runs some validity checks on a domain's SSL certificate" echo "" echo "Visit https://github.com/happycog/cog/ to learn more about cog." -#TODO -#Add abilty to search local bin for new commands +# #TODO +# #Add abilty to search local bin for new commands diff --git a/bin/cog-make:script b/bin/cog-make:script index 9121ae1..9c90184 100755 --- a/bin/cog-make:script +++ b/bin/cog-make:script @@ -27,6 +27,7 @@ if [ ! -f "cog-$ARG_FILENAME" ]; then chmod u+x cog-$ARG_FILENAME echo "#!/bin/bash" > cog-$ARG_FILENAME + echo "# Description: Add your descripton here" > cog-$ARG_FILENAME else echo "⚠️ File already exist. Please try again" exit 0 diff --git a/bin/cog-update b/bin/cog-update index de0dbaf..519c3ca 100755 --- a/bin/cog-update +++ b/bin/cog-update @@ -2,9 +2,6 @@ # cog update # This command will update all the this package to the latest version. -for file in ./tools/*; do - source $file -done echo -e "💻 Updating $(name)@$(version)..." diff --git a/depricated/cog-clone b/depricated/cog-clone new file mode 100755 index 0000000..e79870c --- /dev/null +++ b/depricated/cog-clone @@ -0,0 +1,4 @@ +#!/bin/bash + +COG_DESCRIPTION='This is a test'; +# Description: hey diff --git a/bin/cog-compile b/depricated/cog-compile similarity index 100% rename from bin/cog-compile rename to depricated/cog-compile diff --git a/bin/cog-convert b/depricated/cog-convert similarity index 100% rename from bin/cog-convert rename to depricated/cog-convert diff --git a/bin/cog-ec2-deploy b/depricated/cog-ec2-deploy similarity index 100% rename from bin/cog-ec2-deploy rename to depricated/cog-ec2-deploy diff --git a/bin/cog-git-backup b/depricated/cog-git-backup similarity index 100% rename from bin/cog-git-backup rename to depricated/cog-git-backup diff --git a/bin/cog-go b/depricated/cog-go similarity index 100% rename from bin/cog-go rename to depricated/cog-go diff --git a/bin/cog-s3-deploy b/depricated/cog-s3-deploy similarity index 100% rename from bin/cog-s3-deploy rename to depricated/cog-s3-deploy diff --git a/bin/cog-serve b/depricated/cog-serve similarity index 100% rename from bin/cog-serve rename to depricated/cog-serve diff --git a/bin/cog-watch b/depricated/cog-watch similarity index 100% rename from bin/cog-watch rename to depricated/cog-watch From 3983e1db16091349bdce1c3c6685f53f35531a75 Mon Sep 17 00:00:00 2001 From: Paul Phan Date: Mon, 21 Jan 2019 05:08:10 -0500 Subject: [PATCH 2/8] Format --- bin/cog | 30 +++++++------ bin/cog-help | 90 +++++++++++++++++-------------------- bin/cog-make | 3 -- bin/cog-make:env | 2 +- bin/cog-make:script | 37 ++------------- bin/cog-update | 4 +- {bin => depricated}/cog-dev | 0 {bin => depricated}/cog-tag | 1 + tools/create.sh | 38 ++++++++++++++++ 9 files changed, 100 insertions(+), 105 deletions(-) delete mode 100755 bin/cog-make rename {bin => depricated}/cog-dev (100%) rename {bin => depricated}/cog-tag (98%) create mode 100644 tools/create.sh diff --git a/bin/cog b/bin/cog index 7c9619c..a3c8731 100755 --- a/bin/cog +++ b/bin/cog @@ -1,27 +1,29 @@ #!/bin/bash -# cog requires an argument. If there is no argument, cog will call cog-help -CMD=${1:-help} - # Yarn global adds the cog binary to your $PATH through a bunch of # symlinks. `readlink -f` isn't available on Mac, so this uses # Python to grab the fully resolved path of `cog` and then two # `dirname`s to back out to the true installed repo directory. -DIR=$(dirname $(dirname $(python -c "import os; print(os.path.realpath('${BASH_SOURCE[0]}'))"))) -echo $DIR; +COG_DIRECTORY=$(dirname $(dirname $(python -c "import os; print(os.path.realpath('${BASH_SOURCE[0]}'))"))) +export COG_DIRECTORY; + + # Include all scripts inside the tools folder -for file in $DIR/tools/*; do +for file in $COG_DIRECTORY/tools/*; do source $file done -# Drop next argument -shift + +# cog requires an argument. If there is no argument, cog will call cog-help +CMD=${1:-help}; shift # Check if /bin exist in current directory and automaticlly include the .env file -if [ -f "./bin/cog-$CMD" ]; then - # Overwrite script exist. Run this - ( set -a; source .env 2> /dev/null; "./bin/cog-$CMD" "${@}") +if [ -d "$PWD/bin" ]; then + if [ -f "$PWD/bin/cog-$CMD" ]; then + ( set -a; source .env 2> /dev/null; "$PWD/bin/cog-$CMD" "${@}") else - # Execute default scripts - ( set -a; source .env 2> /dev/null; "$DIR/bin/cog-$CMD" "${@}" ) -fi + ( set -a; source .env 2> /dev/null; "$COG_DIRECTORY/bin/cog-$CMD" "${@}" ) + fi +else + ( set -a; source .env 2> /dev/null; "$COG_DIRECTORY/bin/cog-$CMD" "${@}" ) +fi \ No newline at end of file diff --git a/bin/cog-help b/bin/cog-help index 0bdef24..fe4396a 100755 --- a/bin/cog-help +++ b/bin/cog-help @@ -1,5 +1,4 @@ #!/bin/bash - # Set tabs space tabs 4 @@ -9,34 +8,47 @@ YELLOW='\033[0;33m' BLUE='\033[0;34m' BOLD='\033[0;22m' NC='\033[0m' # No Color +descriptionSpacing=10; -display_commands() { +displayGlobalCommands() { + echo -e "${YELLOW}Global commands:${NC}" + echo "" + for file in $COG_DIRECTORY/bin/*; do + base_file=$(basename "$file"); + # Ignore specific scripts + if [[ "$base_file" == "cog" ]] || [[ "$base_file" == "cog-help" ]] || [[ "$base_file" == "cog-ssl-check" ]]; then + continue + fi -echo -e "${YELLOW}Available commands:${NC}" + COG_COMMAND=$(sed -e 's#.*-\(\)#\1#' <<< "$base_file"); + COG_DESCRIPTION=$(sed -n 's/# Description: //p' $file); + # nameLength ${#COG_COMMAND}; + echo -e "\t${GREEN}$COG_COMMAND${NC} $COG_DESCRIPTION"; + echo ""; + done +} -# scripts=$PWD/bin/*; -echo $COG_DIRECTORY; -scripts=s$COG_DIRECTORY/bin/*; -for file in $scripts; do - base_file=$(basename "$file"); - if [[ "$base_file" == "cog" ]] || [[ "$base_file" == "cog-help" ]]; then - continue +displayProjectCommands() { + if [ -d "$PWD/bin" ]; then + echo -e "${YELLOW}Project commands:${NC}" + echo "" + for file in $PWD/bin/*; do + base_file=$(basename "$file"); + COG_COMMAND=$(sed -e 's#.*-\(\)#\1#' <<< "$base_file"); + COG_DESCRIPTION=$(sed -n 's/# Description: //p' $file); + echo -e "\t${GREEN}$COG_COMMAND${NC} $COG_DESCRIPTION"; + echo ""; + done + fi +} + +# Create even spacing for description +nameLength() { + length=$1; + + if (( $length > $descriptionSpacing )); then + descriptionSpacing=$length; fi - COG_COMMAND=$(sed -e 's#.*-\(\)#\1#' <<< "$base_file"); - COG_DESCRIPTION=$(sed -n 's/# Description: //p' $file); - echo -e "\t${GREEN}$COG_COMMAND${NC} $COG_DESCRIPTION"; - echo ""; -done -echo -e "\t${GREEN}make${NC} Run the make command" -echo -e "\t ${BLUE}:script${NC} Pass in the name argument to create a new script" -echo -e "\t ${BLUE}:env${NC} Creates a .env file for your project" -echo "" -echo -e "\t${GREEN}tag${NC} Create git tags [${BLUE} major | minor | patch | push${NC}]" -echo "" -echo -e "\t${GREEN}update${NC} Create git tags [${BLUE} major | minor | patch | push${NC}]" -echo "" -echo -e "\t${GREEN}ssl-check${NC} Outputs info and runs some validity checks on a domain's SSL certificate" -echo "" } @@ -50,30 +62,8 @@ echo ' MMMMMMMMMMN MMMMMMMMMMN MMMMMMMMMMMMMMM MMMMMMMMMMMMMMM ' - -echo -e "${YELLOW}Usage:${NC}" -echo -e "\tcommand [options] [arguments]" -echo "" -display_commands -# Load Project Scripts -echo -e "${YELLOW}Project commands:${NC}" +displayGlobalCommands; +displayProjectCommands; echo "" - -# scripts=$PWD/bin/*; -scripts=/Users/mrpaulphan/Development/kintone-pantheon/bin/*; -for file in $scripts; do - base_file=$(basename "$file"); - if [[ "$base_file" == "cog" ]] || [[ "$base_file" == "cog-help" ]]; then - continue - fi - COG_COMMAND=$(sed -e 's#.*-\(\)#\1#' <<< "$base_file"); - COG_DESCRIPTION=$(sed -n 's/# Description: //p' $file); - echo -e "\t${GREEN}$COG_COMMAND${NC} $COG_DESCRIPTION"; - echo ""; -done echo "" -echo "" -echo "Visit https://github.com/happycog/cog/ to learn more about cog." - -# #TODO -# #Add abilty to search local bin for new commands +echo "Visit https://github.com/happycog/cog/ to learn more about cog." \ No newline at end of file diff --git a/bin/cog-make b/bin/cog-make deleted file mode 100755 index ab95370..0000000 --- a/bin/cog-make +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -#add make commands diff --git a/bin/cog-make:env b/bin/cog-make:env index 8ff01f9..42c2f2e 100755 --- a/bin/cog-make:env +++ b/bin/cog-make:env @@ -1,6 +1,6 @@ #!/bin/bash +# Description: Create .env file -# Variables ARG_FILENAME=$1 if [ -f ".env" ]; then diff --git a/bin/cog-make:script b/bin/cog-make:script index 9c90184..7f3c5bc 100755 --- a/bin/cog-make:script +++ b/bin/cog-make:script @@ -1,36 +1,5 @@ #!/bin/bash +# Description: Pass a script name to create an executable script for cog -# Variables -ARG_FILENAME=$1 - -# Check to see if name argument was passed -if [ -z "$ARG_FILENAME" ]; then - echo '⚠️ Not enough arguments (missing: "name").' - echo '⚠️ Example: cog make:script ' - exit 0 -fi - -# Check if bin folder exist -if [ ! -d './bin' ]; then - echo '🗄 Creating bin folder...' - mkdir bin -fi - -cd ./bin - -# Check if file exist -if [ ! -f "cog-$ARG_FILENAME" ]; then - echo "[1/3] 📄 Creating cog-$ARG_FILENAME script..." - touch cog-$ARG_FILENAME - - echo "[2/3] ⌨️ Making cog-$ARG_FILENAME Executable..." - chmod u+x cog-$ARG_FILENAME - - echo "#!/bin/bash" > cog-$ARG_FILENAME - echo "# Description: Add your descripton here" > cog-$ARG_FILENAME -else - echo "⚠️ File already exist. Please try again" - exit 0 -fi - -echo "[3/3] ✨ Finished. cog-$ARG_FILENAME script was created in ./bin/" +source $COG_DIRECTORY/tools/create.sh; +createScript $1; \ No newline at end of file diff --git a/bin/cog-update b/bin/cog-update index 519c3ca..f6f33a2 100755 --- a/bin/cog-update +++ b/bin/cog-update @@ -1,7 +1,5 @@ #!/bin/bash - -# cog update -# This command will update all the this package to the latest version. +# Description: Update hc-cog to its latest version. echo -e "💻 Updating $(name)@$(version)..." diff --git a/bin/cog-dev b/depricated/cog-dev similarity index 100% rename from bin/cog-dev rename to depricated/cog-dev diff --git a/bin/cog-tag b/depricated/cog-tag similarity index 98% rename from bin/cog-tag rename to depricated/cog-tag index db84721..80a5055 100755 --- a/bin/cog-tag +++ b/depricated/cog-tag @@ -1,4 +1,5 @@ #!/bin/bash +# Description: Easicly Update tag # Color Format GREEN='\033[0;32m' diff --git a/tools/create.sh b/tools/create.sh new file mode 100644 index 0000000..8576363 --- /dev/null +++ b/tools/create.sh @@ -0,0 +1,38 @@ +createScript() { + +# Variables +ARG_FILENAME=$1 + +# Check to see if name argument was passed +if [ -z "$ARG_FILENAME" ]; then + echo '⚠️ Not enough arguments (missing: "name").' + echo '⚠️ Example: cog make:script ' + exit 0 +fi + +# Check if bin folder exist +if [ ! -d './bin' ]; then + echo '🗄 Creating bin folder...' + mkdir bin +fi + +cd ./bin + +# Check if file exist +if [ ! -f "cog-$ARG_FILENAME" ]; then + echo "[1/3] 📄 Creating cog-$ARG_FILENAME script..." + touch cog-$ARG_FILENAME + + echo "[2/3] ⌨️ Making cog-$ARG_FILENAME Executable..." + chmod u+x cog-$ARG_FILENAME + + echo "#!/bin/bash" > cog-$ARG_FILENAME + echo "# Description: Add your descripton here" > cog-$ARG_FILENAME +else + echo "⚠️ File already exist. Please try again" + exit 0 +fi + +echo "[3/3] ✨ Finished. cog-$ARG_FILENAME script was created in ./bin/" + +} From 5a0b7719c824dd8b8345afdc9d9833db1ddf4bd5 Mon Sep 17 00:00:00 2001 From: Paul Phan Date: Mon, 21 Jan 2019 05:09:24 -0500 Subject: [PATCH 3/8] Format --- .env.example | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index 6ae0a91..0000000 --- a/.env.example +++ /dev/null @@ -1,17 +0,0 @@ -APP_ENV= -APP_URL= -DB_CONNECTION= -DB_HOST= -DB_PORT= -DB_DATABASE= -DB_USERNAME= -DB_PASSWORD= -DB_BACKUP_NAME= -WEBSERVER_HOST= -WEBSERVER_PORT= -ARG_DIR= -S3_KEY= -S3_SECRET= -S3_REGION= -S3_BUCKET= -S3_BACKUP_BUCKET= From 562bd8e33e095242be9cfd2671301a22031a7ee4 Mon Sep 17 00:00:00 2001 From: Paul Phan Date: Mon, 21 Jan 2019 05:10:25 -0500 Subject: [PATCH 4/8] Removed spacing --- bin/cog-help | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/cog-help b/bin/cog-help index fe4396a..c6e5a72 100755 --- a/bin/cog-help +++ b/bin/cog-help @@ -8,7 +8,6 @@ YELLOW='\033[0;33m' BLUE='\033[0;34m' BOLD='\033[0;22m' NC='\033[0m' # No Color -descriptionSpacing=10; displayGlobalCommands() { echo -e "${YELLOW}Global commands:${NC}" From bd77939aaf20441c2c5545ae3d47cf7d088c9ef2 Mon Sep 17 00:00:00 2001 From: Paul Phan Date: Mon, 21 Jan 2019 16:12:18 -0500 Subject: [PATCH 5/8] Fixed spelling --- bin/cog | 10 +++++++--- bin/cog-make:env | 4 ++-- {depricated => deprecated}/cog-clone | 0 {depricated => deprecated}/cog-compile | 0 {depricated => deprecated}/cog-convert | 0 {depricated => deprecated}/cog-dev | 0 {depricated => deprecated}/cog-ec2-deploy | 0 {depricated => deprecated}/cog-git-backup | 0 {depricated => deprecated}/cog-go | 0 {depricated => deprecated}/cog-s3-deploy | 0 {depricated => deprecated}/cog-serve | 0 {depricated => deprecated}/cog-tag | 0 {depricated => deprecated}/cog-watch | 0 13 files changed, 9 insertions(+), 5 deletions(-) rename {depricated => deprecated}/cog-clone (100%) rename {depricated => deprecated}/cog-compile (100%) rename {depricated => deprecated}/cog-convert (100%) rename {depricated => deprecated}/cog-dev (100%) rename {depricated => deprecated}/cog-ec2-deploy (100%) rename {depricated => deprecated}/cog-git-backup (100%) rename {depricated => deprecated}/cog-go (100%) rename {depricated => deprecated}/cog-s3-deploy (100%) rename {depricated => deprecated}/cog-serve (100%) rename {depricated => deprecated}/cog-tag (100%) rename {depricated => deprecated}/cog-watch (100%) diff --git a/bin/cog b/bin/cog index a3c8731..efa733f 100755 --- a/bin/cog +++ b/bin/cog @@ -13,14 +13,18 @@ for file in $COG_DIRECTORY/tools/*; do source $file done +if [ -e .env ]; then + source ./.env +fi + # cog requires an argument. If there is no argument, cog will call cog-help CMD=${1:-help}; shift # Check if /bin exist in current directory and automaticlly include the .env file -if [ -d "$PWD/bin" ]; then - if [ -f "$PWD/bin/cog-$CMD" ]; then - ( set -a; source .env 2> /dev/null; "$PWD/bin/cog-$CMD" "${@}") +if [ -d "./bin" ]; then + if [ -f "./bin/cog-$CMD" ]; then + ( set -a; source .env 2> /dev/null; "./bin/cog-$CMD" "${@}") else ( set -a; source .env 2> /dev/null; "$COG_DIRECTORY/bin/cog-$CMD" "${@}" ) fi diff --git a/bin/cog-make:env b/bin/cog-make:env index 42c2f2e..90391d3 100755 --- a/bin/cog-make:env +++ b/bin/cog-make:env @@ -7,6 +7,6 @@ if [ -f ".env" ]; then echo "⚠️ File already exist. Please try again" exit 0 fi -touch .env.example -echo -e "APP_ENV=\nAPP_URL=\nDB_CONNECTION=\nDB_HOST=\nDB_PORT=\nDB_DATABASE=\nDB_USERNAME=\nDB_PASSWORD=\nDB_BACKUP_NAME=\nWEBSERVER_HOST=\nWEBSERVER_PORT=\nARG_DIR=\nS3_KEY=\nS3_SECRET=\nS3_REGION=\nS3_BUCKET=\nS3_BACKUP_BUCKET="> .env.example +touch .env +echo -e "APP_ENV=\nAPP_URL=\nDB_CONNECTION=\nDB_HOST=\nDB_PORT=\nDB_DATABASE=\nDB_USERNAME=\nDB_PASSWORD=\nDB_BACKUP_NAME=\nWEBSERVER_HOST=\nWEBSERVER_PORT=\nARG_DIR=\nS3_KEY=\nS3_SECRET=\nS3_REGION=\nS3_BUCKET=\nS3_BACKUP_BUCKET=" > .env echo '✨ .env.example was created. Rename the file to .env to use.' diff --git a/depricated/cog-clone b/deprecated/cog-clone similarity index 100% rename from depricated/cog-clone rename to deprecated/cog-clone diff --git a/depricated/cog-compile b/deprecated/cog-compile similarity index 100% rename from depricated/cog-compile rename to deprecated/cog-compile diff --git a/depricated/cog-convert b/deprecated/cog-convert similarity index 100% rename from depricated/cog-convert rename to deprecated/cog-convert diff --git a/depricated/cog-dev b/deprecated/cog-dev similarity index 100% rename from depricated/cog-dev rename to deprecated/cog-dev diff --git a/depricated/cog-ec2-deploy b/deprecated/cog-ec2-deploy similarity index 100% rename from depricated/cog-ec2-deploy rename to deprecated/cog-ec2-deploy diff --git a/depricated/cog-git-backup b/deprecated/cog-git-backup similarity index 100% rename from depricated/cog-git-backup rename to deprecated/cog-git-backup diff --git a/depricated/cog-go b/deprecated/cog-go similarity index 100% rename from depricated/cog-go rename to deprecated/cog-go diff --git a/depricated/cog-s3-deploy b/deprecated/cog-s3-deploy similarity index 100% rename from depricated/cog-s3-deploy rename to deprecated/cog-s3-deploy diff --git a/depricated/cog-serve b/deprecated/cog-serve similarity index 100% rename from depricated/cog-serve rename to deprecated/cog-serve diff --git a/depricated/cog-tag b/deprecated/cog-tag similarity index 100% rename from depricated/cog-tag rename to deprecated/cog-tag diff --git a/depricated/cog-watch b/deprecated/cog-watch similarity index 100% rename from depricated/cog-watch rename to deprecated/cog-watch From 5bc135ef21c1a12f671309a8f1f65d2560857a15 Mon Sep 17 00:00:00 2001 From: Paul Phan Date: Mon, 21 Jan 2019 17:10:46 -0500 Subject: [PATCH 6/8] Updated cog --- bin/cog | 10 +++++++--- bin/cog-help | 11 ++++------- tools/ask.sh | 1 + tools/create.sh | 1 + tools/exists.sh | 1 + tools/package.sh | 10 ++++++---- tools/rule.sh | 1 + 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/bin/cog b/bin/cog index efa733f..613f295 100755 --- a/bin/cog +++ b/bin/cog @@ -4,9 +4,13 @@ # symlinks. `readlink -f` isn't available on Mac, so this uses # Python to grab the fully resolved path of `cog` and then two # `dirname`s to back out to the true installed repo directory. -COG_DIRECTORY=$(dirname $(dirname $(python -c "import os; print(os.path.realpath('${BASH_SOURCE[0]}'))"))) -export COG_DIRECTORY; - +export COG_DIRECTORY=$(dirname $(dirname $(python -c "import os; print(os.path.realpath('${BASH_SOURCE[0]}'))"))); +# Color Format +export GREEN='\033[0;32m' +export YELLOW='\033[0;33m' +export BLUE='\033[0;34m' +export BOLD='\033[0;22m' +export NC='\033[0m' # No Color # Include all scripts inside the tools folder for file in $COG_DIRECTORY/tools/*; do diff --git a/bin/cog-help b/bin/cog-help index c6e5a72..f4bf97b 100755 --- a/bin/cog-help +++ b/bin/cog-help @@ -2,13 +2,6 @@ # Set tabs space tabs 4 -# Color Format -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -BLUE='\033[0;34m' -BOLD='\033[0;22m' -NC='\033[0m' # No Color - displayGlobalCommands() { echo -e "${YELLOW}Global commands:${NC}" echo "" @@ -52,6 +45,9 @@ nameLength() { # Default help screen +echo "" +echo -e "$(packageName) ${GREEN}$(packageVersion)${NC}"; + echo ' MMMMMMMMMMMMMMM MMMMMMMMMMMMMMM MMMMMMMMMMN MMMMMMMMMMN @@ -62,6 +58,7 @@ echo ' MMMMMMMMMMMMMMM MMMMMMMMMMMMMMM ' displayGlobalCommands; +echo "" displayProjectCommands; echo "" echo "" diff --git a/tools/ask.sh b/tools/ask.sh index e8b4670..c67428b 100644 --- a/tools/ask.sh +++ b/tools/ask.sh @@ -20,3 +20,4 @@ ask() { esac done } +export -f ask; diff --git a/tools/create.sh b/tools/create.sh index 8576363..786e9e0 100644 --- a/tools/create.sh +++ b/tools/create.sh @@ -36,3 +36,4 @@ fi echo "[3/3] ✨ Finished. cog-$ARG_FILENAME script was created in ./bin/" } +export -f createScript; diff --git a/tools/exists.sh b/tools/exists.sh index bf55728..734f430 100644 --- a/tools/exists.sh +++ b/tools/exists.sh @@ -1,3 +1,4 @@ exists () { type "$1" &> /dev/null ; } +export -f exists; diff --git a/tools/package.sh b/tools/package.sh index e1c7174..b9891ba 100644 --- a/tools/package.sh +++ b/tools/package.sh @@ -1,8 +1,10 @@ -name() { - awk '/name/{gsub(/("|",)/,"",$0); print $2; exit};' package.json +packageName() { + awk '/name/{gsub(/("|",)/,"",$0); print $2; exit};' $COG_DIRECTORY/package.json } -version() { - awk '/version/{gsub(/("|",)/,"",$2); print $2; exit};' package.json +packageVersion() { + awk '/version/{gsub(/("|",)/,"",$2); print $2; exit};' $COG_DIRECTORY/package.json } +export -f packageName; +export -f packageVersion; \ No newline at end of file diff --git a/tools/rule.sh b/tools/rule.sh index 80554f2..45d6253 100644 --- a/tools/rule.sh +++ b/tools/rule.sh @@ -1,3 +1,4 @@ rule() { eval printf %.0s= '{1..'"${COLUMNS:-$(tput cols)}"\}; echo } +export -f rule; \ No newline at end of file From 11ed4d498cb6ec4662c0cf9f0d339866c6afa5d8 Mon Sep 17 00:00:00 2001 From: Paul Phan Date: Thu, 24 Jan 2019 17:08:13 -0500 Subject: [PATCH 7/8] Fixed make script --- bin/cog-test | 2 ++ tools/create.sh | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100755 bin/cog-test diff --git a/bin/cog-test b/bin/cog-test new file mode 100755 index 0000000..8ee5ac1 --- /dev/null +++ b/bin/cog-test @@ -0,0 +1,2 @@ +#!/bin/bash +# Description: Add your descripton here diff --git a/tools/create.sh b/tools/create.sh index 786e9e0..d56024a 100644 --- a/tools/create.sh +++ b/tools/create.sh @@ -26,8 +26,10 @@ if [ ! -f "cog-$ARG_FILENAME" ]; then echo "[2/3] ⌨️ Making cog-$ARG_FILENAME Executable..." chmod u+x cog-$ARG_FILENAME - echo "#!/bin/bash" > cog-$ARG_FILENAME - echo "# Description: Add your descripton here" > cog-$ARG_FILENAME + echo "#!/bin/bash" >> cog-$ARG_FILENAME + echo "#################################################" >> cog-$ARG_FILENAME + echo "# Description: Add your descripton here" >> cog-$ARG_FILENAME + echo "#################################################" >> cog-$ARG_FILENAME else echo "⚠️ File already exist. Please try again" exit 0 From 21d40d3deb175ab4394fc2bcc9e1c7ee847d935c Mon Sep 17 00:00:00 2001 From: Paul Phan Date: Tue, 5 Feb 2019 15:18:02 -0500 Subject: [PATCH 8/8] Removed test script --- bin/cog-test | 2 -- 1 file changed, 2 deletions(-) delete mode 100755 bin/cog-test diff --git a/bin/cog-test b/bin/cog-test deleted file mode 100755 index 8ee5ac1..0000000 --- a/bin/cog-test +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -# Description: Add your descripton here