Skip to content

Commit

Permalink
feat(version): update version to 2.4.0
Browse files Browse the repository at this point in the history
- Updated the version file to reflect the new version as `2.4.0`

feat(contributing): update project name in CONTRIBUTING.md

- Updated the project name to "**moshell.sh**" in the `CONTRIBUTING.md` file.

feat(readme): update banner image path in README.md

- Corrected the path to the banner image in the `README.md` file.
- Changed `docs/banner.svg` to `docs/assets/banner.svg`.

docs(changelog): restructure CHANGELOG.md format

- Renamed `CHANGELOG.md` to `docs/CHANGELOG.md` for better organization.
- Rearranged the content using the conventional commit format.

docs(usage): relocate USAGE_TRACKING_POLICY.md

- Renamed `USAGE_TRACKING_POLICY.md` to `docs/USAGE_TRACKING_POLICY.md`.
- Moved the file to the `docs` directory for improved documentation structure.

style(index): reformat custom script sourcing in index.sh

- Added a new alias script and rearranged the custom script sourcing in `index.sh`.
- Reorganized the sourcing order for better readability.

chore(flags): update tracking service documentation link

- Updated the link to the usage tracking policy in the `flags.sh` file.
- Changed the link to point to `https://github.com/andersonbosa/moshell.sh/blob/main/docs/USAGE_TRACKING_POLICY.md`.

feat(aliases): add 'pince' function to aliases.sh

- Added a new alias function 'pince' to the `aliases.sh` script.
- The 'pince' function allows easy navigation to the 'PINCE' directory.

tools(changelog): improve changelog generation script

- Refactored the `changelog.sh` script for better readability and maintainability.
- The script now parses commit information and generates a changelog based on semantic keys.

tools(version_manager): enhance version management script

- Improved the `version_manager.sh` script for better user interaction.
- The script can now increment the major, minor, or patch version based on user input.
- Added an option to directly push the new version to the repository.
  • Loading branch information
andersonbosa committed Aug 19, 2023
1 parent d656095 commit 17b3c67
Show file tree
Hide file tree
Showing 14 changed files with 214 additions and 63 deletions.
4 changes: 1 addition & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# CONTRIBUTING

# Contributing to the Nipe!
# Contributing to the **moshell.sh**!

## Branches

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<section align="center">
<br>
<br>
<img src="docs/banner.svg" title="Project banner" alt="Project banner" />
<img src="docs/assets/banner.svg" title="Project banner" alt="Project banner" />

<p>
<p>Fork, customize and take your shell everywhere.</p>
Expand Down Expand Up @@ -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!

---

Expand Down
21 changes: 18 additions & 3 deletions CHANGELOG.md → docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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



File renamed without changes.
File renamed without changes
2 changes: 1 addition & 1 deletion moshell.sh/core/flags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion moshell.sh/custom/andersonbosa/aliases.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
alias copy="clipcopy"

alias copy="clipcopy"
function pince() {
local pince_dir_path="$HOME/tools/PINCE/"
echo "[+] Entering: $pince_dir_path"
cd $pince_dir_path
sh PINCE.sh
cd -
}
1 change: 1 addition & 0 deletions moshell.sh/custom/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions moshell.sh/moshell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
123 changes: 91 additions & 32 deletions moshell.sh/tools/changelog.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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 <<EOF
## $commit_message - $date
> - [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
Empty file modified moshell.sh/tools/uninstall.sh
100644 → 100755
Empty file.
109 changes: 90 additions & 19 deletions moshell.sh/tools/version_manager.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
#!/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"
major="${version_parts[0]}"
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
Expand All @@ -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[@]}"
2 changes: 1 addition & 1 deletion moshell.sh/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.4.0
1 change: 0 additions & 1 deletion version

This file was deleted.

0 comments on commit 17b3c67

Please sign in to comment.