Skip to content

Commit 08b8b60

Browse files
committed
👌 IMPROVE: #105 Provide a Vue EXAMPLE
1 parent dadd2fe commit 08b8b60

File tree

3 files changed

+84
-11
lines changed

3 files changed

+84
-11
lines changed

‎.gp/bash/init-react-example.sh renamed to ‎.gp/bash/examples/init-react-example.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# init-react-example.sh
77
# Description:
8-
# Initial setup for the gitpod-laravel-starter react example.
8+
# Initial setup for the gitpod-laravel-starter React example.
99

1010
# Load logger
1111
. .gp/bash/workspace-init-logger.sh
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
#
3+
# SPDX-License-Identifier: MIT
4+
# Copyright © 2021 Apolo Pena
5+
#
6+
# init-react-example.sh
7+
# Description:
8+
# Initial setup for the gitpod-laravel-starter Vue example.
9+
10+
# Load logger
11+
. .gp/bash/workspace-init-logger.sh
12+
13+
lvm=$(bash .gp/bash/helpers.sh laravel_major_version)
14+
# Failsafe for unsupported versions
15+
(( lvm < 6 )) && exit 1
16+
17+
18+
declare -a exit_codes=()
19+
all_zeros='^0$|^0*0$'
20+
task_msg="Setting up Vue example: Material Dashboard"
21+
22+
log "$task_msg"
23+
24+
if (( lvm > 6 )); then
25+
composer require laravel-frontend-presets/material-dashboard
26+
else
27+
composer require laravel-frontend-presets/material-dashboard v1.0.9
28+
fi
29+
exit_codes+=($?)
30+
php artisan ui material
31+
exit_codes+=($?)
32+
composer dump-autoload
33+
exit_codes+=($?)
34+
php artisan migrate
35+
exit_codes+=($?)
36+
php artisan migrate --seed
37+
38+
if [[ $(echo "${exit_codes[@]}" | tr -d '[:space:]') =~ $all_zeros ]]; then
39+
log "SUCCESS: $task_msg"
40+
else
41+
log -e "ERROR: $task_msg"
42+
fi

‎.gp/bash/init-optional-scaffolding.sh

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,41 @@ if [[ -n $EXAMPLE ]]; then
3434
case $EXAMPLE in
3535
1)
3636
example_title="React Example with phpMyAdmin and extras - Questions and Answers"
37-
init_example=".gp/bash/init-react-example.sh"
37+
init_react_example=".gp/bash/examples/init-react-example.sh"
3838
install_react=1
3939
install_phpmyadmin=1
4040
install_react_router_dom=1
4141
rrd_ver='^5.2.0'
4242
;;
4343
2)
4444
example_title="React Example without phpMyAdmin and no extras - Questions and Answers"
45-
init_example=".gp/bash/init-react-example.sh"
45+
init_react_example=".gp/bash/examples/init-react-example.sh"
4646
install_react=1
4747
install_phpmyadmin=0
4848
install_react_router_dom=1
4949
rrd_ver='^5.2.0'
5050
;;
51+
10)
52+
example_title="Vue Example with phpMyAdmin and extras - Material Dashboard"
53+
init_vue_example=".gp/bash/examples/init-vue-example.sh"
54+
install_react=0
55+
install_vue=1
56+
vue_auth=1
57+
install_phpmyadmin=1
58+
;;
59+
11)
60+
example_title="Vue Example without phpMyAdmin and no extras - Material Dashboard"
61+
init_vue_example=".gp/bash/examples/init-vue-example.sh"
62+
install_react=0
63+
install_vue=1
64+
vue_auth=1
65+
install_phpmyadmin=0
66+
;;
5167
*)
5268
# Default example
5369
# Keep this block identical to case 1)
5470
example_title="React Example with phpMyAdmin and extras - Questions and Answers"
55-
init_example=".gp/bash/init-react-example.sh"
71+
init_react_example=".gp/bash/examples/init-react-example.sh"
5672
install_react=1
5773
install_phpmyadmin=1
5874
install_react_router_dom=1
@@ -67,7 +83,7 @@ fi
6783

6884
# phpmyadmin, test more for when this script fails in the middle with a non zero exit code
6985
if [[ $install_phpmyadmin == 1 ]];then
70-
if [[ -n $init_example ]];then
86+
if [[ -n $init_react_example || -n $init_vue_example ]];then
7187
# shellcheck source=.gp/bash/init-phpmyadmin.sh
7288
. "$init_phpmyadmin" 2>/dev/null || log_silent -e "ERROR: $(. $init_phpmyadmin 2>&1 1>/dev/null)"
7389
else
@@ -230,11 +246,26 @@ if [[ $laravel_major_ver != 5 ]]; then
230246
fi
231247
# END: optional frontend scaffolding installations
232248

233-
# Initialize optional example project
234-
if [[ -n $init_example ]];then
249+
# BEGIN: optional example setup
250+
251+
# Initialize optional react example project
252+
if [[ -n $init_react_example ]];then
235253
[[ $laravel_major_ver -ne 8 ]] \
236-
&& log -e "WARNING: Examples are only supported with Laravel version 8. Your laravel version is $laravel_major_ver" \
254+
&& log -e "WARNING: React examples are only supported by Laravel version 8. Your Laravel version is $laravel_major_ver" \
237255
&& log -e "WARNING: Ignoring the example requested: $example_title"
238-
# shellcheck source=.gp/bash/init-react-example.sh
239-
. "$init_example" 2>/dev/null || log_silent -e "ERROR: $(. $init_example 2>&1 1>/dev/null)"
240-
fi
256+
# shellcheck source=.gp/bash/examples/init-react-example.sh
257+
. "$init_react_example" 2>/dev/null || log_silent -e "ERROR: $(. $init_react_example 2>&1 1>/dev/null)"
258+
exit
259+
fi
260+
261+
# Initialize optional vue example project
262+
if [[ -n $init_vue_example ]];then
263+
(( laravel_major_ver < 6 )) \
264+
&& log -e "WARNING: Vue examples are only supported by Laravel version 6.* or higher. Your Laravel version is $laravel_major_ver" \
265+
&& log -e "WARNING: Ignoring the example requested: $example_title"
266+
# shellcheck source=.gp/bash/examples/init-vue-example.sh
267+
. "$init_vue_example" 2>/dev/null || log_silent -e "ERROR: $(. $init_vue_example 2>&1 1>/dev/null)"
268+
exit
269+
fi
270+
271+
# END: optional example setup

0 commit comments

Comments
 (0)