-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset
executable file
·104 lines (90 loc) · 2.71 KB
/
reset
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
## Description: Reset the project or change the TYPO3 CMS version
## Usage: reset [flags] [args]
## Example: ddev reset\nddev reset 10\nddev reset 9
## Flags: [{"Name":"force","Shorthand":"f","Usage":"Do not ask any interactive question"}]
# Initialize local variables
FORCE=""
RECONFIGURE=""
CHOICE=""
# Set default versions
COMPOSER_VERSION="2"
MARIADB_VERSION="10.4"
PHP_VERSION="7.4"
TYPO3_VERSION="~10.4.0"
DASHBOARD_VERSION="*"
INTRODUCTION_VERSION="^4.2"
# Functions
reset_project () {
rm -rf config
rm -rf public
rm -rf var
rm -rf vendor
rm -r composer.lock
mkdir -p public/typo3conf
touch public/typo3conf/.gitkeep
ddev config --create-docroot --project-type typo3
ddev delete -Oy
}
reconfigure_project () {
if [ -z "${DASHBOARD_VERSION}" ] ; then
ddev composer remove typo3/cms-dashboard --no-update
else
ddev composer require typo3/cms-dashboard:"${DASHBOARD_VERSION}" --no-update
fi
ddev config --composer-version ${COMPOSER_VERSION} --mariadb-version ${MARIADB_VERSION} --php-version ${PHP_VERSION} --project-type typo3
ddev composer require typo3/cms-core:"${TYPO3_VERSION}" typo3/cms-introduction:"${INTRODUCTION_VERSION}" --no-update
reset_project
ddev start
}
# Parse options and arguments
while :; do
case ${1:-} in
-f|--force)
FORCE=true
;;
--) # End of all options.
shift
break
;;
-?*)
printf "WARN: Unknown option (ignored): %s\n" "$1" >&2
;;
*) # Default case: version argument or end of arguments.
if [ -z ${1} ] ; then
break
fi
case ${1:-} in
9|9.5)
COMPOSER_VERSION="1"
MARIADB_VERSION="10.4"
PHP_VERSION="7.4"
TYPO3_VERSION="~9.5.0"
DASHBOARD_VERSION=""
INTRODUCTION_VERSION="^4.0.1"
RECONFIGURE=true
;;
10|10.4)
RECONFIGURE=true
;;
*)
printf "ERROR: Unknown version argument: %s\nValid TYPO3 CMS versions are 10.4 or 9.5.\n" "$1" >&2
exit 1
;;
esac
;;
esac
shift
done
# Set user confirmation if force option not set
if [ ! "${FORCE}" = "true" ] ; then
printf "Warning, this will reset the project and remove all changes. Continue [yes/no]? "
read CHOICE
fi
if [ "${CHOICE}" = "yes" ] || [ "${FORCE}" = "true" ] ; then
if [ ! ${RECONFIGURE} ] ; then
reset_project
else
reconfigure_project
fi
fi