@@ -17,43 +17,48 @@ TARGET_DIR=$(dirname "$DEVCONTAINER_FOLDER")
1717echo " Using devcontainer folder: $DEVCONTAINER_FOLDER "
1818echo " Target directory: $TARGET_DIR "
1919
20- # # Get available Magento versions from compose folder
21- get_available_versions () {
22- local versions=()
23- while IFS= read -r -d ' ' dir; do
24- local version=$( basename " $dir " )
25- if [[ " $version " =~ ^[0-9]+\. [0-9]+\. [0-9]+$ ]]; then
26- versions+=(" $version " )
27- fi
28- done < <( find " $DEVCONTAINER_FOLDER /compose" -mindepth 1 -maxdepth 1 -type d -print0 2> /dev/null | sort -zV)
29- echo " ${versions[@]} "
30- }
20+ # # Available Magento versions (version:label)
21+ # # Set label to "default" for the default version, "beta" for beta versions
22+ VERSIONS=(
23+ " 2.4.6:"
24+ " 2.4.7:"
25+ " 2.4.8:default"
26+ " 2.4.9:beta"
27+ )
3128
3229# # Prompt user to select a Magento version
3330select_magento_version () {
34- local versions=($1 )
35- local default_version=" ${versions[-1]} " # Latest version as default
31+ local default_index=0
3632
37- echo " Available Magento versions:"
38- for i in " ${! versions[@]} " ; do
33+ echo " Available Magento versions:" >&2
34+ for i in " ${! VERSIONS[@]} " ; do
35+ local entry=" ${VERSIONS[$i]} "
36+ local version=" ${entry%%:* } "
37+ local label=" ${entry#*: } "
3938 local marker=" "
40- [ " ${versions[$i]} " = " $default_version " ] && marker=" (latest)"
41- echo " $(( i+ 1 )) ) ${versions[$i]} $marker "
39+
40+ if [ " $label " = " default" ]; then
41+ marker=" (latest)"
42+ default_index=$(( i + 1 ))
43+ elif [ " $label " = " beta" ]; then
44+ marker=" (beta)"
45+ fi
46+
47+ echo " $(( i+ 1 )) ) ${version} $marker " >&2
4248 done
4349
44- read -p " Select Magento version [${ # versions[@]} ]: " selection
45- selection=" ${selection:- ${ # versions[@]} } "
50+ read -p " Select Magento version [$default_index ]: " selection
51+ selection=" ${selection:- $default_index } "
4652
47- if [[ " $selection " =~ ^[0-9]+$ ]] && [ " $selection " -ge 1 ] && [ " $selection " -le ${# versions[@]} ]; then
48- echo " ${versions[$((selection-1))]} "
53+ if [[ " $selection " =~ ^[0-9]+$ ]] && [ " $selection " -ge 1 ] && [ " $selection " -le ${# VERSIONS[@]} ]; then
54+ local entry=" ${VERSIONS[$((selection-1))]} "
55+ echo " ${entry%%:* } "
4956 else
5057 echo " Invalid selection." >&2
5158 return 1
5259 fi
5360}
5461
55- AVAILABLE_VERSIONS=$( get_available_versions)
56-
5762# # Detect project Magento version
5863SELECTED_VERSION=" "
5964if load_project_magento_version 2> /dev/null; then
@@ -87,8 +92,8 @@ read -p "Enter a name for your devcontainer (it should be unique per project) [$
8792DEVCONTAINER_NAME=" ${DEVCONTAINER_NAME:- $FOLDER_NAME } "
8893
8994# # Copy over required docker-compose files
90- cp " $DEVCONTAINER_FOLDER /docker-compose.shared.yml.sample" " $DEVCONTAINER_FOLDER /docker-compose.shared.yml"
91- cp " $DEVCONTAINER_FOLDER /docker-compose.local.yml.sample" " $DEVCONTAINER_FOLDER /docker-compose.local.yml"
95+ cp " $DEVCONTAINER_FOLDER /docker-compose.shared.yml.sample" " $TARGET_DIR /docker-compose.shared.yml"
96+ cp " $DEVCONTAINER_FOLDER /docker-compose.local.yml.sample" " $TARGET_DIR /docker-compose.local.yml"
9297echo " services: {}" > " $TARGET_DIR /docker-compose.yml"
9398
9499# # Copy over devcontainer and set the name and version
0 commit comments