From f5af86e42af9355ae9e13e595eb915d16fd3495d Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 5 Oct 2024 18:40:08 +0200 Subject: [PATCH] deps: install bashunit:beta, create-pr:0.6, dumper:0.1 --- .env | 3 ++- .gitignore | 18 ++++++++++++++++-- entry-point | 2 +- install-dependencies.sh | 26 ++++++++++++++++++++++++-- src/dev/.gitkeep | 0 src/dev/debug.sh | 18 ------------------ tests/bootstrap.sh | 1 + tests/helpers.sh | 10 ---------- tests/unit/helpers_test.sh | 9 --------- 9 files changed, 44 insertions(+), 43 deletions(-) create mode 100644 src/dev/.gitkeep delete mode 100644 src/dev/debug.sh create mode 100644 tests/bootstrap.sh delete mode 100644 tests/helpers.sh delete mode 100644 tests/unit/helpers_test.sh diff --git a/.env b/.env index 3218831..21a3c44 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ # bashunit BASHUNIT_DEFAULT_PATH="tests" -BASHUNIT_TESTS_ENV="tests/helpers.sh" +BASHUNIT_TESTS_ENV="tests/bootstrap.sh" +BASHUNIT_LOG_PATH=local/out.log diff --git a/.gitignore b/.gitignore index 0f91796..4cf17e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,18 @@ -bin/ -lib/ +########### +# IDE +########### .idea/ .vscode/ + +########### +# Project +########### + +# generated single executable after build +bin/ + +# third party tools +lib/ + +# third party dev-deps +src/dev/* diff --git a/entry-point b/entry-point index a6b0bfe..c9d52db 100755 --- a/entry-point +++ b/entry-point @@ -7,7 +7,7 @@ declare -r BASH_SKELETON_VERSION="0.1.0" BASH_SKELETON_ROOT_DIR="$(dirname "${BASH_SOURCE[0]}")" export BASH_SKELETON_ROOT_DIR -source "$BASH_SKELETON_ROOT_DIR/src/dev/debug.sh" +source "$BASH_SKELETON_ROOT_DIR/src/dev/dumper.sh" source "$BASH_SKELETON_ROOT_DIR/src/main.sh" # Initialize _ARGS as an array _ARGS=() diff --git a/install-dependencies.sh b/install-dependencies.sh index 85312d6..612f022 100755 --- a/install-dependencies.sh +++ b/install-dependencies.sh @@ -1,4 +1,26 @@ #!/bin/bash -## bashunit -curl -s https://bashunit.typeddevs.com/install.sh | bash -s lib 0.16.0 +# bashunit +curl -s https://bashunit.typeddevs.com/install.sh | bash -s lib beta + +function download() { + local url=$1 + local destination=$2 + local name=${3:-$(basename "$destination")} + + if curl -s -L "$url" -o "$destination"; then + echo "> $name installed successfully in '$(dirname "$destination")'" + chmod +x "$destination" + else + echo "Failed to install $name!" + exit 1 + fi +} + +# create-pr +download "https://github.com/Chemaclass/create-pr/releases/download/0.6/create-pr" \ + "lib/create-pr" + +# bash-dumper +download "https://github.com/Chemaclass/bash-dumper/releases/download/0.1/dumper.sh" \ + "src/dev/dumper.sh" diff --git a/src/dev/.gitkeep b/src/dev/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/dev/debug.sh b/src/dev/debug.sh deleted file mode 100644 index 9bb3445..0000000 --- a/src/dev/debug.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# An alternative to echo when debugging. -# This is debug function; do not use in prod! -function dump() { - printf "[%s] %s: %s\n" "${_COLOR_SKIPPED}DUMP${_COLOR_DEFAULT}" \ - "${_COLOR_PASSED}${BASH_SOURCE[1]}:${BASH_LINENO[0]}" \ - "${_COLOR_DEFAULT}$*" -} - -# Dump and Die. -function dd() { - printf "[%s] %s: %s\n" "${_COLOR_FAILED}DUMP${_COLOR_DEFAULT}" \ - "${_COLOR_PASSED}${BASH_SOURCE[1]}:${BASH_LINENO[0]}" \ - "${_COLOR_DEFAULT}$*" - - kill -9 $$ -} diff --git a/tests/bootstrap.sh b/tests/bootstrap.sh new file mode 100644 index 0000000..a9bf588 --- /dev/null +++ b/tests/bootstrap.sh @@ -0,0 +1 @@ +#!/bin/bash diff --git a/tests/helpers.sh b/tests/helpers.sh deleted file mode 100644 index 50e9078..0000000 --- a/tests/helpers.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -euo pipefail - -function current_dir() { - dirname "${BASH_SOURCE[1]}" -} - -function current_filename() { - basename "${BASH_SOURCE[1]}" -} diff --git a/tests/unit/helpers_test.sh b/tests/unit/helpers_test.sh deleted file mode 100644 index b9ac5d0..0000000 --- a/tests/unit/helpers_test.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -function test_helper_current_dir() { - assert_same "tests/unit" "$(current_dir)" -} - -function test_helper_current_filename() { - assert_same "helpers_test.sh" "$(current_filename)" -}