Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.

Commit 0ccb317

Browse files
committed
Greater UX using many interactive prompt selections /sq
1 parent de8609a commit 0ccb317

File tree

2 files changed

+85
-22
lines changed

2 files changed

+85
-22
lines changed

bashlava.sh

Lines changed: 84 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
# See bashlava for all details https://github.com/firepress-org/bashlava
44

5-
# There are SOME TODO in the code
5+
# There are 17 flags TODO in the code
66

77
# TODO
8-
#fct: m
9-
# CASE ask if the user wants 'e'
8+
# delete var 'version_with_rc'
9+
# this is an old logic when my release flow was not great
1010

1111
# TODO
1212
# when you code a you dont know by heart which condition to call
@@ -15,6 +15,9 @@
1515
# "App_"
1616
# alias
1717

18+
# TODO
19+
# release function is not stable when we tag. Sometimes it show the older release
20+
1821
# TODO
1922
# better management core vars
2023

@@ -65,7 +68,7 @@ function edge {
6568
git push --set-upstream origin edge -f
6669
App_Show_Version
6770
# UX fun
68-
my_message="<edge> was freshly branched out from ${default_branch}" App_Blue
71+
my_message="Done! checkout edge from ${default_branch}" App_Gray
6972
echo && my_message="NEXT MOVE suggestion: code something and 'c' " App_Green
7073
}
7174

@@ -76,7 +79,7 @@ function commit {
7679
git commit -m "${input_2}"
7780
git push
7881
# UX fun
79-
echo && my_message="NEXT MOVE suggestion: 'c' - 'pr' " App_Green
82+
echo && my_message="NEXT MOVE suggestion: 1) 'c' 2) 'pr' " App_Green
8083
}
8184

8285
function pr {
@@ -92,8 +95,14 @@ function pr {
9295
gh pr view --web
9396
Prompt_YesNo_ci
9497

95-
# UX fun
96-
echo && my_message="NEXT MOVE suggestion: 'ci' - 'mrg' " App_Green
98+
echo && my_message="NEXT MOVE suggestion: 1='ci' 2='mrg' 9=cancel (or any key)" && App_Green
99+
input_2="not_set" #reset input_2
100+
read user_input;
101+
case ${user_input} in
102+
1 | ci) ci;;
103+
2 | mrg) mrg;;
104+
*) my_message="Cancelled" && App_Gray;;
105+
esac
97106
}
98107

99108
function mrg {
@@ -107,7 +116,17 @@ function mrg {
107116
gh pr merge
108117
Prompt_YesNo_ci
109118
App_Show_Version
110-
echo && my_message="NEXT MOVE suggestion: 'ci' - 'sv' - 'v' - 't' " App_Green
119+
120+
echo && my_message="NEXT MOVE suggestion: 1='ci' 2='sv' 3='v' 4='t' 9=cancel (or any key)" && App_Green
121+
input_2="not_set" #reset input_2
122+
read user_input;
123+
case ${user_input} in
124+
1 | ci) ci;;
125+
2 | sv) sv;;
126+
3 | v) version;;
127+
4 | t) tag;;
128+
*) my_message="Cancelled" && App_Gray;;
129+
esac
111130
}
112131

113132
function ci {
@@ -124,13 +143,40 @@ function ci {
124143

125144
# Follow status within the terminal
126145
gh run watch
127-
# UX fun
128-
echo && my_message="NEXT MOVE suggestion: 'mrg' " App_Green
146+
147+
echo && my_message="NEXT MOVE suggestion: 1='mrg' 9=cancel (y/n)" && App_Green
148+
input_2="not_set" #reset input_2
149+
read user_input;
150+
case ${user_input} in
151+
1 | y | mrg) mrg;;
152+
*) my_message="Cancelled" && App_Gray;;
153+
esac
129154
}
130155

131156
function version {
132157
### The version is stored within the Dockerfile. For BashLaVa, this Dockerfile is just a config-env file
133158
Condition_No_Commits_Must_Be_Pending
159+
App_Show_Version
160+
161+
if [[ "${input_2}" == "not_set" ]]; then
162+
# The user did not provide a version
163+
echo && my_message="What is the version number (ex: 1.12.4)?" && App_Green
164+
read user_input;
165+
input_2="${user_input}"
166+
#
167+
echo && my_message="You confirm version: ${user_input} is right? (y/n)" && App_Green
168+
# warning: dont reset input_2
169+
read user_input;
170+
case ${user_input} in
171+
1 | y) echo "Good, lets continue" > /dev/null 2>&1;;
172+
*) my_message="Cancelled" && App_Gray;;
173+
esac
174+
elif [[ "${input_2}" != "not_set" ]]; then
175+
echo "Good, lets continue" > /dev/null 2>&1
176+
else
177+
my_message="FATAL: Condition_Attr_2_Must_Be_Provided" && App_Fatal
178+
fi
179+
134180
Condition_Attr_2_Must_Be_Provided
135181
Condition_Version_Must_Be_Valid
136182

@@ -150,34 +196,46 @@ function version {
150196
my_message="FATAL: version" && App_Fatal
151197
fi
152198

153-
### Apply updates
199+
### Apply updates in Dockerfile
154200
sed -i '' "s/^ARG VERSION=.*$/ARG VERSION=\"${version_trim}\"/" Dockerfile
155201
sed -i '' "s/^ARG RELEASE=.*$/ARG RELEASE=\"${input_2}\"/" Dockerfile
156202

157203
git add .
158204
git commit . -m "Update ${app_name} to version ${input_2}"
159205
git push && echo
160-
App_Show_Version && sleep 1
161-
log
162-
# UX fun
163-
echo && my_message="NEXT MOVE suggestion: 'pr' - 't' " App_Green
206+
App_Show_Version
207+
208+
echo && my_message="NEXT MOVE suggestion: 1='pr' 2='t' 9=cancel (or any key)" && App_Green
209+
input_2="not_set" #reset input_2
210+
read user_input;
211+
case ${user_input} in
212+
1 | pr) pr;;
213+
2 | t) tag;;
214+
*) my_message="Cancelled" && App_Gray;;
215+
esac
164216
}
165217

166218
function tag {
167219
Condition_No_Commits_Must_Be_Pending
168220
Condition_Attr_2_Must_Be_Empty
169221

170222
git tag ${app_version} && git push --tags && echo
171-
App_Show_Version && sleep 1 && echo
223+
App_Show_Version
172224

173-
my_message="Next, prepare release" App_Gray
225+
echo && my_message="Next, prepare release" App_Gray
174226
my_message="To quit the release notes: type ':qa + enter'" App_Gray && echo
175227

176228
gh release create && sleep 5
177229
App_Show_Version
178230
App_Show_Release
179-
# UX fun
180-
echo && my_message="NEXT MOVE suggestion: start over from 'e' " App_Green
231+
232+
echo && my_message="NEXT MOVE suggestion: 'e' (y/n)" && App_Green
233+
input_2="not_set" #reset input_2
234+
read user_input;
235+
case ${user_input} in
236+
1 | y | e) edge;;
237+
*) my_message="Abord" && App_Gray;;
238+
esac
181239
}
182240

183241
function squash {
@@ -349,6 +407,8 @@ function App_short_url {
349407
function App_Show_Version {
350408
echo && my_message="Check versions:" && App_Blue
351409

410+
App_Load_Vars_Dockerfile
411+
352412
### version in dockerfile
353413
my_message="${app_version} < VERSION in Dockerfile" App_Gray
354414
my_message="${app_release} < RELEASE in Dockerfile" App_Gray
@@ -715,7 +775,7 @@ function App_Reset_Custom_path {
715775
fi
716776
}
717777

718-
function App_Load_Vars {
778+
function App_Load_Vars_General {
719779
### Default var & path. Customize if need. Usefull if you want
720780
# to have multiple instance of bashLaVa on your machine
721781
bashlava_executable="bashlava.sh"
@@ -780,7 +840,9 @@ function App_Load_Vars {
780840
date_day="$(date +%Y-%m-%d)"
781841
date_month="$(date +%Y-%m)-XX"
782842
date_year="$(date +%Y)-XX-XX"
843+
}
783844

845+
function App_Load_Vars_Dockerfile {
784846
# Define vars from Dockerfile
785847
app_name=$(cat Dockerfile | grep APP_NAME= | head -n 1 | grep -o '".*"' | sed 's/"//g')
786848
app_version=$(cat Dockerfile | grep VERSION= | head -n 1 | grep -o '".*"' | sed 's/"//g')
@@ -813,7 +875,8 @@ function main() {
813875
trap script_trap_exit EXIT
814876
source "$(dirname "${BASH_SOURCE[0]}")/.bashcheck.sh"
815877

816-
App_Load_Vars
878+
App_Load_Vars_General
879+
App_Load_Vars_Dockerfile
817880
App_Check_Which_File_Exist
818881

819882
if [[ -z "$2" ]]; then #if empty

docs/release_workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
**Release workflow**
22

3-
- `v 1.2.3` ...... versionning + commit automatically
3+
- `v 1.2.3` ...... version code and write to the Dockerfile
44
- `t` ............ tag + opens the release page GUI on GitHub

0 commit comments

Comments
 (0)