-
Notifications
You must be signed in to change notification settings - Fork 0
/
vmaker
executable file
·104 lines (78 loc) · 2.71 KB
/
vmaker
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
# Function to create a new project
create_blank_project() {
folder_name=".devcontainer"
# Check if the folder already exists
if [ -d "$folder_name" ]; then
echo "Folder '$folder_name' already exists in the current directory."
else
# Create the folder
mkdir "$folder_name"
echo "Folder '$folder_name' created successfully."
# Create a default.json file inside the folder
touch "$folder_name/devcontainer.json"
echo "devcontainer.json created successfully."
fi
exit
}
# Function to create a blank Dockerfile
create_blank_dockerfile() {
folder_name=".devcontainer"
# Check if the folder already exists
if [ -d "$folder_name/Dockerfile" ]; then
echo "Folder '$folder_name' already exists in the current directory."
else
# Create a Dockerfile inside the folder
touch "$folder_name/Dockerfile"
echo "Dockerfile created successfully."
fi
}
# Function to create a blank docker-compose.yml
create_blank_compose() {
folder_name=".devcontainer"
# Check if the folder already exists
if [ -d "$folder_name/docker-compose.yml" ]; then
echo "Folder '$folder_name' already exists in the current directory."
else
# Create a Dockerfile inside the folder
touch "$folder_name/docker-compose.yml"
echo "Compose file created successfully."
fi
}
# Function to create a laravel project
create_laravel_project() {
sleep 1; clear
# Get the directory containing this script
SCRIPT_DIR="$(dirname "$0")"
# Assuming the stubs directory is located alongside the script
STUBS_DIR="$SCRIPT_DIR/.stubs"
# Get the current directory
current_path=$(pwd)
# Print the current directory
echo "Current directory: $current_path"
# Extract the last component of the current directory path (the directory name)
current_dir=$(basename "$current_path")
# Print the directory name
echo "Current directory name: $current_dir"
create_blank_project
create_blank_dockerfile
create_blank_compose
DIR=$current_dir
export DIR
envsubst < "$STUBS_DIR/devcontainer/_laravel.stub" > ".devcontainer/devcontainer.json"
sed -i "s|\"\$DIR\"|\"$DIR\"|g" .devcontainer/devcontainer.json
unset DIR
exit
}
# Interactive menu
PS3="Select an option: "
options=("Create a Blank Project" "Create Laravel Project" "Create NextJs Project" "Quit")
select opt in "${options[@]}"; do
case $REPLY in
1) sleep 1; clear; create_blank_project ;;
2) create_laravel_project ;;
3) create_nextjs_container ;;
4) echo "Exiting..."; exit ;;
*) echo "Invalid option. Please select again." ;;
esac
done