Skip to content

Commit

Permalink
UX: many improvements on v(), t(), dummy(), docs/
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalandy committed May 10, 2022
1 parent e067e80 commit f2300f4
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 48 deletions.
120 changes: 86 additions & 34 deletions bashlava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,15 @@ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
PRIORITY 1 ____________________________________________________________________________
_______________________________________________________________________________________
UX: Many optimizations
- Impact on: #4, #8
TODO
log() shows a short hash (not the full hash)
TODO
UX: mrg() gh cli, pass attributs -rebase to minimize prompts
UX: many improvements on v(), t(), dummy(), docs/
- UX: v_and_t() add the option to v() + t() in a single step
- UX: dummy() now writes two commits
- UX: /docs improve prompt syntax
- Impact on: #8
TODO
UX: release() pass attributs to minimize prompts
WIP
UX: Improve how we manage CONFIGS, vars, sane defaults, idempotent, logic overrides
UX: Improve how we manage CONFIGS, vars, sane defaults, logic overrides
- At the moment, its too complex for a new user to configure bashlava
- Avoid having multiple place to define them, source components, source .md
- Few array that are configs. They should be all together under the same block of code.
Expand All @@ -54,21 +49,6 @@ Functional impacts:
- Impact on: #4, #8, #10
TODO
optimize my_message when calling
Print_
Banner_
Instead of creating custom var simnply use %1 %2 <=dollar sign
function greet () {
echo "Hello @1"
}
greet "Shellman"
TODO private scripts
logical flags to manage under /private/*
Need to check if files exist /private/* when DIR private exist
Expand All @@ -80,6 +60,7 @@ overide like:
- custom_fct_help="false"
- set a new config flag: debug="true"
TODO
## App if app are installed
which git-crypt
Expand All @@ -97,6 +78,19 @@ TODO
fi
TODO
optimize my_message when calling
Print_
Banner_
Instead of creating custom var simnply use %1 %2 <=dollar sign
function greet () {
echo "Hello @1"
}
greet "Pascal"
TODO ci pipeline
- superlinter (includes shellcheck)
- create ci for using shellcheck
Expand Down Expand Up @@ -307,8 +301,10 @@ function mrg { # User_
case ${user_input} in
1 | v) version;;
2 | t) tag;;
3 | ci) ci;;
4 | e) edge;;
3 | e) edge;;
4 | ci) ci;;
8 | vt) v_and_t;;
9 | a) echo "WIP, will allow the user to: v + t + r + e in one step";;
*) my_message="Aborted" && Print_Gray;;
esac
}
Expand Down Expand Up @@ -369,7 +365,7 @@ function version { # User_

function tag { # User_
Condition_No_Commits_Pending
Condition_Attr_2_Must_Be_Empty
#Condition_Attr_2_Must_Be_Empty
_from_fct="t"

git tag ${app_version} && git push --tags && echo
Expand All @@ -386,6 +382,56 @@ function tag { # User_
esac
}

function v_and_t {
# version and tag
# TODO
# I can optimze this later with a flag
# I need to duplicate v() code because we prompt in version and in tag
### The version is stored within the Dockerfile. For BashLaVa, this Dockerfile is just a config-env file
Condition_No_Commits_Pending
_from_fct="v"

Show_Version

# set input_2 if not provided
if [[ "${input_2}" == "not_set" ]]; then
my_message="What is the version number (ex: 1.12.4.)?" && Print_Green
read -r user_input;
echo;
my_message="${user_input}" && Print_Green
input_2="${user_input}"
Condition_Version_Must_Be_Valid

elif [[ "${input_2}" != "not_set" ]]; then
echo "Good, lets continue" > /dev/null 2>&1
else
my_message="FATAL: (version)" && Print_Fatal
fi


if [[ "${input_2}" != "not_set" ]]; then

Condition_Attr_2_Must_Be_Provided
Condition_Version_Must_Be_Valid

### Update version within Dockerfile
sed -i '' "s/^ARG VERSION=.*$/ARG VERSION=\"${input_2}\"/" Dockerfile
# code optimization 0o0o, Add logic for /private scripts

git add .
git commit . -m "Update ${app_name} to version ${input_2}"
git push && echo
Show_Version
Show_What_Was_Done
tag

elif [[ "${input_2}" == "not_set" ]]; then
my_message="ERROR: This should not happen (version)" && Print_Warning_Stop
else
my_message="FATAL (version)" && Print_Fatal
fi
}

function tci { # User_
Condition_No_Commits_Pending
Condition_Attr_2_Must_Be_Empty
Expand Down Expand Up @@ -486,13 +532,19 @@ function dummy { # User_
Condition_Attr_2_Must_Be_Empty
Condition_No_Commits_Pending
_from_fct="d"

_in_file="README.md"
_hash=$(echo ${date_nano} | sha256sum | awk '{print $1}')
_hash_four_last="${_hash: -4}"

echo "Dummy Commit, ${date_sec}, ${_hash}" >> "${_in_file}"
git add -A && git commit -m "dummy commit ${_hash_four_last}" && git push
# create a commit X time the update
for lineID in $(seq 1 2); do
date_nano="$(date +%Y-%m-%d_%HH%Ms%S-%N)"
_hash=$(echo ${date_nano} | sha256sum | awk '{print $1}')
_hash_four_last="${_hash: -4}"
echo "Dummy Commit, ${date_sec}, ${_hash}" >> "${_in_file}"
git add -A && git commit -m "dummy commit ${_hash_four_last}"
sleep 1
done

git push
log
}

Expand Down
6 changes: 3 additions & 3 deletions docs/next_move_fct_ci.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
🚀 Do you want to `mrg`?
🚀 What do you want to do next?

- `1` ... |`y`,`mrg`
- `2` ... |`n`
- `1` ... |`mrg`
- `q` ... | quit
8 changes: 5 additions & 3 deletions docs/next_move_fct_mrg.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- `1` ... |`v`
- `2` ... |`t`
- `3` ... |`ci`
- `4` ... |`e`
- `5` ... |`q`uit
- `3` ... |`e`
- `4` ... |`ci`
- `8` ... |`vt` (combined)
- `9` ... |`a` (WIP will allow the user to: v + t + r + e in one step)
- `q` ... | quit
2 changes: 1 addition & 1 deletion docs/next_move_fct_pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

- `1` ... |`mrg`
- `2` ... |`ci`
- `3` ... |`q`uit
- `q` ... | quit
2 changes: 1 addition & 1 deletion docs/next_move_fct_release.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
🚀 What do you want to do next?

- `1` ... |`e`
- `2` ... |`q`uit
- `q` ... | quit
2 changes: 1 addition & 1 deletion docs/next_move_fct_tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

- `1` ... |`r`
- `2` ... |`ci`
- `3` ... |`q`uit
- `q` ... | quit
2 changes: 1 addition & 1 deletion docs/next_move_fct_tci.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

- `1` ... |`r`
- `2` ... |`ci`
- `3` ... |`q`uit
- `q` ... | quit
2 changes: 1 addition & 1 deletion docs/next_move_fct_v.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

- `1` ... |`t`
- `2` ... |`pr`
- `3` ... |`q`uit
- `q` ... | quit
2 changes: 1 addition & 1 deletion docs/prompt_fct_v_confirmation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Is version is valid?

- `1` ... |`y`
- `2` ... |`n`, I want to **fix it**
- `3` ... |`q`uit
- `q` ... | quit
2 changes: 1 addition & 1 deletion docs/prompt_show_fct.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Show functions by categories:
- `7`,`user` ... | User facing
- `8`,`util` ... | Utilities
- `9`,`a` ...... | All
- `0`,`q` ...... | quit
- `q` .......... | quit

Show files:

Expand Down
2 changes: 1 addition & 1 deletion docs/welcome_to_bashlava.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

- `1` ... |`h`,`help`
- `2` ... |`tt`,`test`
- `3` ... |`q`uit,`a`bord
- `q` ... | quit

Tip 💡: You can execute these commands directly: `bashlava h`,`bashlava test`, etc.

0 comments on commit f2300f4

Please sign in to comment.