diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 13db129..6b42430 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,6 +1,4 @@ -# CONTRIBUTING - -# Contributing to the Nipe! +# Contributing to the **moshell.sh**! ## Branches diff --git a/README.md b/README.md index b8dc444..6695af5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@


- Project banner + Project banner

Fork, customize and take your shell everywhere.

@@ -33,7 +33,7 @@ ### Summary Make your customizations and take them everywhere. What is the difference between "dotfiles"? -moshell.sh is a framework to persist its customizations without complexity. +**moshell.sh** is a framework to persist its customizations without complexity! --- diff --git a/CHANGELOG.md b/docs/CHANGELOG.md similarity index 58% rename from CHANGELOG.md rename to docs/CHANGELOG.md index 082cce0..6158f88 100644 --- a/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,21 @@ +## release(2.3.2) - 2023-08-18 + +> [Commit d656095](https://github.com/andersonbosa/moshell.sh/commit/d656095) + +- feat: add automated push to version_manager.sh tool + +## release(2.3.2) - 2023-08-18 + +> - [Commit d656095](https://github.com/andersonbosa/moshell.sh/commit/d656095) + +- feat: add automated push to version_manager.sh tool + +## release(2.3.2) - 2023-08-18 + +> - [Commit d656095](https://github.com/andersonbosa/moshell.sh/commit/d656095) + +- feat: add automated push to version_manager.sh tool + ## release(2.0.0) - 2023-08-17 - feat(plugins): add conditional loading and enhance logging - feat(scripts): improve Docker container usage and add usage help @@ -12,6 +30,3 @@ - chore: refactor initialization and paths in moshell.sh - chore: refactor initialization and paths in moshell.sh - fix: add VI as default editor - - - diff --git a/USAGE_TRACKING_POLICY.md b/docs/USAGE_TRACKING_POLICY.md similarity index 100% rename from USAGE_TRACKING_POLICY.md rename to docs/USAGE_TRACKING_POLICY.md diff --git a/docs/banner.svg b/docs/assets/banner.svg similarity index 100% rename from docs/banner.svg rename to docs/assets/banner.svg diff --git a/moshell.sh/core/flags.sh b/moshell.sh/core/flags.sh index bb786ab..aae7ae8 100644 --- a/moshell.sh/core/flags.sh +++ b/moshell.sh/core/flags.sh @@ -24,7 +24,7 @@ export _MOSHELL_FLAG_ENABLE_LOAD_CUSTOMS=1 # default=1 # Enable customizations ## # Enable anonymous tracking usage -# - Futher details on: https://github.com/andersonbosa/moshell.sh/blob/main/USAGE_TRACKING_POLICY.md +# - Futher details on: https://github.com/andersonbosa/moshell.sh/blob/main/docs/USAGE_TRACKING_POLICY.md ## export _MOSHELL_FLAG_ENABLE_TRACKING_SERVICE=1 # default=1 export _MOSHELL_FLAG_ENABLE_TRACKING_FINGERPRINT=1 # default=1 diff --git a/moshell.sh/custom/andersonbosa/aliases.sh b/moshell.sh/custom/andersonbosa/aliases.sh index 68512f9..43260cc 100644 --- a/moshell.sh/custom/andersonbosa/aliases.sh +++ b/moshell.sh/custom/andersonbosa/aliases.sh @@ -1,2 +1,9 @@ +alias copy="clipcopy" -alias copy="clipcopy" \ No newline at end of file +function pince() { + local pince_dir_path="$HOME/tools/PINCE/" + echo "[+] Entering: $pince_dir_path" + cd $pince_dir_path + sh PINCE.sh + cd - +} diff --git a/moshell.sh/custom/index.sh b/moshell.sh/custom/index.sh index 6cad762..8c1efd6 100644 --- a/moshell.sh/custom/index.sh +++ b/moshell.sh/custom/index.sh @@ -9,6 +9,7 @@ fi # NOTE: The order matters source "$_MOSHELL_DIR_CUSTOM/andersonbosa/ai_prompts.sh" +source "$_MOSHELL_DIR_CUSTOM/andersonbosa/aliases.sh" source "$_MOSHELL_DIR_CUSTOM/andersonbosa/docker.sh" source "$_MOSHELL_DIR_CUSTOM/andersonbosa/generators.sh" source "$_MOSHELL_DIR_CUSTOM/andersonbosa/randoms.sh" diff --git a/moshell.sh/moshell.sh b/moshell.sh/moshell.sh index 473b80d..5ab7d61 100755 --- a/moshell.sh/moshell.sh +++ b/moshell.sh/moshell.sh @@ -11,6 +11,7 @@ export _MOSHELL_DIR_BASE_PATH=$ABSOLUTE_PATH_TO_THIS_FILE export _MOSHELL_DIR_CORE="$_MOSHELL_DIR_BASE_PATH/core" export _MOSHELL_DIR_PLUGINS="$_MOSHELL_DIR_BASE_PATH/plugins" export _MOSHELL_DIR_CUSTOM="$_MOSHELL_DIR_BASE_PATH/custom" +export _MOSHELL_DIR_TOOLS="$_MOSHELL_DIR_BASE_PATH/tools" # To infinity and beyond! source $_MOSHELL_DIR_CORE/index.sh diff --git a/moshell.sh/tools/changelog.sh b/moshell.sh/tools/changelog.sh old mode 100644 new mode 100755 index b0c2543..0320ffa --- a/moshell.sh/tools/changelog.sh +++ b/moshell.sh/tools/changelog.sh @@ -1,44 +1,103 @@ #!/usr/bin/env bash -# -*- coding: utf-8 -*- +# +# Author: @andersonbosa +# Description: +# XXX +# -# Constants -LAST_CONSIDERATED_CMMIT=$1 +ABSOLUTE_SCRIPT_FILE_PATH="${BASH_SOURCE:-$0}" +ABSOLUTE_SCRIPT_DIR_PATH=$(dirname "$ABSOLUTE_SCRIPT_FILE_PATH") -# Generate a changelog from Git commit messages -ABSOLUTE_PATH_TO_THIS_FILE="${BASH_SOURCE:-$0}" -ABSOLUTE_DIR_PATH_TO_THIS_FILE=$(dirname $ABSOLUTE_PATH_TO_THIS_FILE) +function __moshell:tools::changelog::get_last_release_commit() { + local release_version_regex="$1" -# Set the output file for the changelog -changelog_file="$ABSOLUTE_DIR_PATH_TO_THIS_FILE/../../CHANGELOG.md" + if [[ -z "$release_version_regex" ]]; then + local default_regex="release([0-9]\+\.[0-9]\+\.[0-9]\+)" + release_version_regex=$default_regex + fi -# Add spaces to changelog file ->>"$changelog_file" + local awk_query_2_item_on_the_row='NR==2' + local last_release_commit=$(git log --grep="$release_version_regex" --pretty=format:"%H" | awk "$awk_query_2_item_on_the_row") -# Specify the list of keys to include in the changelog -keys=("build" "chore" "docs" "feat" "fix" "perf" "refactor" "style" "test" "release") + echo "$last_release_commit" +} # Function to add header levels based on the key -function add_header() { - local key="$1" - local message="$2" - - if [ "$key" == "release" ]; then - echo "## $message - $(date --iso-8601=date)" >>"$changelog_file" - else - echo "- $message" >>"$changelog_file" - fi +function __moshell:tools::changelog::parse_commit_format() { + local commit_hash="$1" + local author="$2" + local date="$3" + shift 3 # Shifts the first 3 arguments + local commit_message="$@" + local link_to_repository="https://github.com/andersonbosa/moshell.sh" + + # Specify the list of keys to include in the changelog + declare -a semantic_keys=("build" "chore" "docs" "feat" "fix" "perf" "refactor" "style" "test" "release") + + case "$commit_message" in + release*) + cat < - [Commit $commit_hash]($link_to_repository/commit/$commit_hash)\r +EOF + ;; + *) + echo -e "\n- $commit_message\r" + ;; + esac +} + +function __moshell:tools::changelog::parse_line_to_changelog() { + local line="$@" + + local fields_delimiter="," + IFS="$fields_delimiter" read -r -a fields <<<"$line" + + local commit_hash="${fields[0]}" + local author="${fields[1]}" + local date="${fields[2]}" + local message="${fields[3]}" + + # echo -e $commit_hash $author $date $message + __moshell:tools::changelog::parse_commit_format $commit_hash $author $date $message } -# Iterate over commits and extract messages -git log --pretty=format:"%s" HEAD $LAST_CONSIDERATED_CMMIT | while read -r commit_message; do - for key in "${keys[@]}"; do - if [[ "$commit_message" == "$key"* ]]; then - add_header "$key" "$commit_message" - break - fi - done -done +function __moshell:tools::changelog::main() { + LAST_CONSIDERATED_COMMIT=$(__moshell:tools::changelog::get_last_release_commit) + # echo "[+] Using commit: $LAST_CONSIDERATED_COMMIT" + + local changelog_file="$_MOSHELL_DIR_BASE_PATH/../docs/CHANGELOG.md" + local changelog_file_content_backup="" + + if [ -f "$changelog_file" ]; then + changelog_file_content_backup=$(cat "$changelog_file") + fi + + # Cleans/init the file + >"$changelog_file" -echo -e "\n\n" >>"$changelog_file" + local tmp_file=$(mktemp) + git log --pretty=format:"%h,%an,%as,%s" "$LAST_CONSIDERATED_COMMIT..HEAD" >"$tmp_file" + + local tmp_file_reversed=$(mktemp) + awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }' $tmp_file >$tmp_file_reversed + # TODO: add awk as script dependency + + while IFS=$line_delimiter read -r line; do + parsed_line=$(__moshell:tools::changelog::parse_line_to_changelog $line) + # echo -e "parsed_line: $parsed_line" + # echo -e "line: $line" + echo -e "$parsed_line" >>$changelog_file + done <<<$(cat $tmp_file) + + rm $tmp_file $tmp_file_reversed &>/dev/null + # cat $tmp_file + # echo "------" + # cat $reversed_tmp_file #&>/dev/null + + echo -e "\r$changelog_file_content_backup" >>"$changelog_file" + # echo "[+] Changelog generated and saved to: '$changelog_file'" +} -echo "Changelog generated and saved to $changelog_file" +__moshell:tools::changelog::main diff --git a/moshell.sh/tools/uninstall.sh b/moshell.sh/tools/uninstall.sh old mode 100644 new mode 100755 diff --git a/moshell.sh/tools/version_manager.sh b/moshell.sh/tools/version_manager.sh old mode 100644 new mode 100755 index 5401e81..8a36488 --- a/moshell.sh/tools/version_manager.sh +++ b/moshell.sh/tools/version_manager.sh @@ -1,10 +1,18 @@ -#!/bin/bash +#!/usr/bin/env bash +# +# Author: @andersonbosa +# Description: +# XXX +# + +ABSOLUTE_SCRIPT_FILE_PATH="${BASH_SOURCE:-$0}" +ABSOLUTE_SCRIPT_DIR_PATH=$(dirname $ABSOLUTE_SCRIPT_FILE_PATH) -echo "-------------------------------------------------------------------------" +function __moshell:tools::version_manager::increment_version() { + local version_to_increment="$1" -function _moshell:tools::increment_version() { # Read the current version from the "version" file - current_version=$(cat version) + current_version=$(cat $_MOSHELL_DIR_BASE_PATH/version) # Split the version into major, minor, and patch parts IFS='.' read -ra version_parts <<<"$current_version" @@ -12,13 +20,20 @@ function _moshell:tools::increment_version() { minor="${version_parts[1]}" patch="${version_parts[2]}" - # Prompt the user for the version increment type - echo "[+] Current version: $current_version" - echo "[+] Select version increment:" - echo "1. Major" - echo "2. Minor" - echo "3. Patch" - read -p "Enter your choice (1/2/3): " choice + echo "[+] Current version is: $current_version" + + if [[ -z "${version_to_increment}" ]]; then + # Prompt the user for the version increment type + echo "[+] Current version: $current_version" + echo "[+] Select version increment:" + echo "1. Major" + echo "2. Minor" + echo "3. Patch" + read -p "Enter your choice (1/2/3): " choice + else + # set from user input + choice=$version_to_increment + fi # Increment the selected version part case $choice in @@ -40,17 +55,73 @@ function _moshell:tools::increment_version() { # Update the version file with the new version new_version="$major.$minor.$patch" - echo "$new_version" >version + echo "$new_version" >$_MOSHELL_DIR_BASE_PATH/version - echo "[+] Version incremented to $new_version" + echo "[+] Version incremented to: $new_version" } -_moshell:tools::increment_version - -# Check if "--push" parameter was provided -if [[ $1 == "--push" ]]; then - # Commit and push the changes to Git repository +function __moshell::tools::version_manager::push_version() { + # NOTE: talvez no futuro use a git add version - git commit -m "release($new_version)" + git commit -m "release($(cat $_MOSHELL_DIR_BASE_PATH/version))" git push -u origin $(git branch --show-current) + exit 0 +} + +#!/bin/bash + +# Define a function to display usage information +function __moshell::tools::version_manager::show_usage() { + echo "Usage: $(basename $0) [OPTIONS]" + echo + echo "Options:" + echo " -1, --patch Increment the patch version" + echo " -2, --minor Increment the minor version" + echo " -3, --major Increment the major version" + echo " -P, --push Release NEW VERSION to the git repository" + echo " -h, --help Show this usage message" + exit 0 +} + +############################################################################### + +if [[ -z "${1}" ]]; then + __moshell::tools::version_manager::show_usage fi + +POSITIONAL=() +while (($# > 0)); do + case "${1}" in + -h | --help) + __moshell::tools::version_manager::show_usage + ;; + -1 | --patch) + subcmd_param="1" + __moshell:tools::version_manager::increment_version $subcmd_param + shift + ;; + -2 | --minor) + subcmd_param="2" + __moshell:tools::version_manager::increment_version $subcmd_param + shift + ;; + -3 | --major) + subcmd_param="3" + __moshell:tools::version_manager::increment_version $subcmd_param + shift + ;; + -R | --release) + # Commit and push the changes to Git repository as NEW VERSION RELEASE + __moshell::tools::version_manager::push_version + ;; + *) # unknown flag/switch + + POSITIONAL+=("${1}") + shift + ;; + esac +done + +set -- "${POSITIONAL[@]}" # restore positional params + +echo "${POSITIONAL[@]}" diff --git a/moshell.sh/version b/moshell.sh/version index 359a5b9..197c4d5 100644 --- a/moshell.sh/version +++ b/moshell.sh/version @@ -1 +1 @@ -2.0.0 \ No newline at end of file +2.4.0 diff --git a/version b/version deleted file mode 100644 index f90b1af..0000000 --- a/version +++ /dev/null @@ -1 +0,0 @@ -2.3.2