11#! /bin/bash
22
33# =============================================================================
4- # PACKAGE MANAGER
4+ # REQUIRED TOOLS INSTALLER
55# =============================================================================
6- # Functions for managing system packages and dependencies
7- # Usage: source this file and call package management functions
6+ # Functions for installing essential tools required for DockerKit functionality
7+ # Usage: source this file and call install_required_tools()
88# =============================================================================
99
1010set -euo pipefail
@@ -20,13 +20,13 @@ PKG_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2020source " $PKG_SCRIPT_DIR /../core/utils.sh"
2121source " $PKG_SCRIPT_DIR /../core/config.sh"
2222
23- check_system_dependencies () {
23+ install_required_tools () {
2424 local os_type
2525 os_type=$( detect_os)
2626
2727 case " $os_type " in
2828 macos|linux|wsl2)
29- check_required_tools
29+ install_required_dependencies
3030 ;;
3131 * )
3232 print_warning " Unsupported operating system: $os_type "
@@ -35,21 +35,21 @@ check_system_dependencies() {
3535 esac
3636}
3737
38- check_required_tools () {
38+ install_required_dependencies () {
3939 local required_tools=(" mkcert" )
4040 local all_ok=true
4141
4242 for tool in " ${required_tools[@]} " ; do
4343 if ! command_exists " $tool " ; then
44- print_info " $tool : Not found, installing..."
44+ print_info " $tool : not found, installing..."
4545 if ! install_missing_tool " $tool " ; then
46- print_error " $tool : Installation failed"
46+ print_error " $tool : installation failed"
4747 all_ok=false
4848 else
49- print_success " $tool : Installed successfully"
49+ print_success " $tool : installed successfully"
5050 fi
5151 else
52- print_success " $tool : Already installed"
52+ print_success " $tool : already installed"
5353 fi
5454 done
5555
@@ -85,7 +85,7 @@ install_mkcert_for_platform() {
8585 install_mkcert_linux
8686 ;;
8787 macos)
88- install_mkcert_macos_stub
88+ install_mkcert_macos
8989 ;;
9090 * )
9191 print_error " Unsupported platform for mkcert installation: $os_type "
@@ -136,18 +136,54 @@ install_mkcert_linux() {
136136 return " $EXIT_GENERAL_ERROR "
137137 fi
138138
139+ # Initialize CA after fresh installation
140+ print_info " Setting up local Certificate Authority..."
141+ if mkcert -install > /dev/null 2>&1 ; then
142+ print_success " Certificate Authority installed successfully"
143+ elif sudo mkcert -install > /dev/null 2>&1 ; then
144+ print_success " Certificate Authority installed successfully"
145+ else
146+ print_warning " Certificate Authority setup failed (you may need to run 'mkcert -install' manually)"
147+ fi
148+
139149 # Clean up temporary files
140150 rm -rf " $temp_dir " 2> /dev/null || true
141151
142152 return " $EXIT_SUCCESS "
143153}
144154
145- install_mkcert_macos_stub () {
146- print_warning " Automatic mkcert installation for macOS not implemented yet"
147- print_tip " Please install mkcert manually:"
148- print_tip " brew install mkcert"
155+ install_mkcert_macos () {
156+ # Check if Homebrew is installed
157+ if ! command_exists " brew" ; then
158+ print_error " mkcert installation requires Homebrew"
159+ print_info " Homebrew is not installed. Please install it first:"
160+ print_tip " Run this command in Terminal:"
161+ print_tip " /bin/bash -c \"\$ (curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\" "
162+ print_tip " "
163+ print_tip " After Homebrew installation, run setup again:"
164+ print_tip " make setup"
165+
166+ return " $EXIT_MISSING_DEPENDENCY "
167+ fi
149168
150- return " $EXIT_MISSING_DEPENDENCY "
169+ # Homebrew is available, check if mkcert is already installed
170+ if command_exists " mkcert" ; then
171+ return " $EXIT_SUCCESS "
172+ fi
173+
174+ # Install mkcert via Homebrew (suppress verbose output)
175+ if brew install --quiet mkcert > /dev/null 2>&1 ; then
176+ # Initialize CA after fresh installation
177+ print_info " Setting up local Certificate Authority..."
178+ if mkcert -install > /dev/null 2>&1 ; then
179+ print_success " Certificate Authority installed successfully"
180+ else
181+ print_warning " Certificate Authority setup failed (you may need to run 'mkcert -install' manually)"
182+ fi
183+ return " $EXIT_SUCCESS "
184+ else
185+ return " $EXIT_GENERAL_ERROR "
186+ fi
151187}
152188
153189check_sudo_access () {
0 commit comments