Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions scripts/dev.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

NODE_ID=0
DIR_HOME=$(pwd)
DIR_CC_REACT="$DIR_HOME/packages/cc-react"
DIR_PLAYGROUND="$DIR_HOME/playground"

source "${DIR_HOME}/scripts/log.sh"

function start() {
clear
echo -e "\033[102;30mCleaning for fresh start...\e[0m"
info "Cleaning for fresh start..."
rm -rf "$DIR_CC_REACT/dist"
rm -rf "$DIR_PLAYGROUND/dist"
rm -rf "$DIR_PLAYGROUND/public/js"
mkdir "$DIR_PLAYGROUND/public/js"
mkdir -p "$DIR_PLAYGROUND/public/js"

if [ ! -d "$DIR_CC_REACT/node_modules" ]; then
echo -e "\033[103;30mMissing 'node_modules' folder in 'cc-react', installing...\e[0m"
info "Missing 'node_modules' folder in 'cc-react', installing..."
cd "$DIR_CC_REACT"
npm install > /dev/null 2>&1
fi

if [ ! -d "$DIR_PLAYGROUND/node_modules" ]; then
echo -e "\033[103;30mMissing 'node_modules' folder in the 'playground', installing...\e[0m"
info "Missing 'node_modules' folder in the 'playground', installing..."
cd "$DIR_PLAYGROUND"
npm install > /dev/null 2>&1
fi

echo -e "\033[102;30mLinking 'cc-react' package to the 'playground'...\e[0m"
info "Linking 'cc-react' package to the 'playground'..."
cd "$DIR_CC_REACT"
npm link > /dev/null
cd "$DIR_PLAYGROUND"
npm link @ccleanershot/cc-react > /dev/null

cd "$DIR_CC_REACT"
npx tsc -w > build.log 2>&1 &
echo -e "\033[102;30mWaiting for TypeScript's Watch Mode in 'cc-react'...\e[0m"
info "Waiting for TypeScript's Watch Mode in 'cc-react'..."
grep -m 1 "Found" <(tail -f build.log) > /dev/null

cd "$DIR_PLAYGROUND"
npx tsc -w > build.log 2>&1 &
echo -e "\033[102;30mWaiting for TypeScript's Watch Mode in the 'playground'...\e[0m"
info "Waiting for TypeScript's Watch Mode in the 'playground'..."
grep -m 1 "Found" <(tail -f build.log) > /dev/null


Expand All @@ -57,14 +61,16 @@ function execute() {


function before_execute() {
kill $NODE_ID
kill "$NODE_ID"
clear
}


start "\033[1;31mExecution started. Executing commands...\e[0m"
start "\e[1;31mExecution started. Executing commands...\e[0m"

while inotifywait -q -r -e modify,create,delete,move "$DIR_CC_REACT/dist" "$DIR_PLAYGROUND/dist" > /dev/null; do
before_execute
execute "\033[1;31mDirectory changes detected. Re-executing commands...\e[0m"
done
execute "\e[1;31mDirectory changes detected. Re-executing commands...\e[0m"
done


22 changes: 22 additions & 0 deletions scripts/log.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

Color_Reset='\e[0m'

Red='\e[0;41m'
Green='\e[0;42m'
Yellow='\e[0;43m'


function error(){
echo -e "${Red}Error ${Color_Reset}" "$*" >&2
exit 1;
}

function info() {
echo -e "$*"
}


function success() {
echo -e "${Green}Success${Color_Reset} $*"
}
14 changes: 9 additions & 5 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

DIR_HOME=$(pwd)
DIR_CC_REACT="$DIR_HOME/packages/cc-react"
DIR_PLAYGROUND="$DIR_HOME/playground"
DIR_TESTS="$DIR_HOME/testing"

source "${DIR_HOME}/scripts/log.sh"

clear
cd "$DIR_TESTS/environments"
ENVIRONMENTS=$(echo *)
Expand All @@ -18,14 +22,14 @@ for environment in $ENVIRONMENTS; do
BUILD_LOG="$FOLDER/logs/build.log"
RUN_LOG="$FOLDER/logs/run.log"

echo -e "\033[102;30m($environment) Removing old containers...\e[0m"
info "($environment) Removing old containers..."
docker rm "$DOCKER_NAME" > /dev/null
echo -e "\033[102;30m($environment) Building new images (output in $BUILD_LOG)...\e[0m"
info "($environment) Building new images (output in $BUILD_LOG)..."
docker build -t "$DOCKER_TAG" --debug --file "$FOLDER/$environment.Dockerfile" --progress=plain . &> "$BUILD_LOG"
echo -e "\033[102;30m($environment) Running new images (output in $RUN_LOG)...\e[0m"
info "($environment) Running new images (output in $RUN_LOG)..."
docker run --name "$DOCKER_NAME" "$DOCKER_TAG" > /dev/null
docker logs "$DOCKER_NAME" > "$RUN_LOG"
) &
done

wait
wait
14 changes: 9 additions & 5 deletions scripts/upload.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

DIR_HOME=$(pwd)
DIR_CC_REACT="$DIR_HOME/packages/cc-react"
DIR_PLAYGROUND="$DIR_HOME/playground"

source "${DIR_HOME}/scripts/log.sh"

clear
cd "$DIR_CC_REACT"
echo -e "\033[102;30mCleaning all 'dist'...\e[0m"
info "Cleaning all 'dist'..."
rm -rf "$DIR_CC_REACT/dist"
echo -e "\033[102;30mCleaning all 'node_modules'...\e[0m"
info "Cleaning all 'node_modules'..."
rm -rf "$DIR_CC_REACT/node_modules"
echo -e "\033[102;30mRe-installing packages...\e[0m"
info "Re-installing packages..."
npm install
npx tsc
npm publish --access=public
npm publish --access=public