Skip to content

Commit 120bac7

Browse files
committed
ci: fix fresh install
1 parent 6c39597 commit 120bac7

2 files changed

Lines changed: 32 additions & 27 deletions

File tree

bin/init.sh

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,48 @@ TARGET_DIR=$(dirname "$DEVCONTAINER_FOLDER")
1717
echo "Using devcontainer folder: $DEVCONTAINER_FOLDER"
1818
echo "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
3330
select_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
5863
SELECTED_VERSION=""
5964
if 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) [$
8792
DEVCONTAINER_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"
9297
echo "services: {}" > "$TARGET_DIR/docker-compose.yml"
9398

9499
## Copy over devcontainer and set the name and version

devcontainer.json.sample

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"dockerComposeFile": [
44
"docker-compose.yml",
55
"magento2-devcontainer/compose/2.4.8/docker-compose.yml",
6-
"magento2-devcontainer/docker-compose.shared.yml",
7-
"magento2-devcontainer/docker-compose.local.yml"
6+
"docker-compose.shared.yml",
7+
"docker-compose.local.yml"
88
],
99
"workspaceFolder": "/workspace",
1010
"service": "php",

0 commit comments

Comments
 (0)