Skip to content

Commit 266042d

Browse files
- Fix tests and add xcode install message
- Make installation messages clearer - Add apple install url (but automation is gated to login)
1 parent f977ccb commit 266042d

File tree

6 files changed

+376
-54
lines changed

6 files changed

+376
-54
lines changed

configs/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ Complete backend/polyglot environment:
5353
./osa-cli.zsh --config-file configs/backend-dev.json
5454
```
5555

56+
### `macos.json`
57+
General macOS development environment (no mobile platforms):
58+
- **Components**: Symlinks, oh-my-zsh, zsh-plugins, homebrew, mise, git, iTerm2, VSCode
59+
- **Runtimes**: Node.js 22, Python 3.13, Ruby 3.4.0, Java OpenJDK 21, Go 1.23
60+
- **Best for**: macOS-only development, avoiding iOS/CocoaPods, web/backend development
61+
62+
```bash
63+
./osa-cli.zsh --config-file configs/macos.json
64+
```
65+
5666
### `react-native.json`
5767
Complete React Native mobile development environment:
5868
- **Components**: All (symlinks, oh-my-zsh, zsh-plugins, homebrew, mise, git, iTerm2, VSCode, CocoaPods, Android tools)

configs/macos.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"version": "1.0",
3+
"description": "macOS Development Setup - General purpose macOS development",
4+
"profile": "macos",
5+
"components": {
6+
"symlinks": true,
7+
"oh_my_zsh": true,
8+
"zsh_plugins": true,
9+
"homebrew": true,
10+
"mise": true,
11+
"osa_snippets": true,
12+
"git": true,
13+
"iterm2": true,
14+
"vscode": true
15+
},
16+
"runtimes": {
17+
"node": {
18+
"enabled": true,
19+
"version": "22"
20+
},
21+
"python": {
22+
"enabled": true,
23+
"version": "3.13"
24+
},
25+
"ruby": {
26+
"enabled": true,
27+
"version": "3.4.0"
28+
},
29+
"java": {
30+
"enabled": true,
31+
"version": "openjdk-21"
32+
},
33+
"rust": {
34+
"enabled": false,
35+
"version": "stable"
36+
},
37+
"go": {
38+
"enabled": true,
39+
"version": "1.23"
40+
},
41+
"deno": {
42+
"enabled": false,
43+
"version": "latest"
44+
},
45+
"elixir": {
46+
"enabled": false,
47+
"version": "latest"
48+
},
49+
"erlang": {
50+
"enabled": false,
51+
"version": "latest"
52+
}
53+
}
54+
}

osa-cli.zsh

Lines changed: 65 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export OSA_SKIP_SNIPPETS=false
3838
# Git configuration flag (can be disabled with --disable-git)
3939
export OSA_SKIP_GIT_CONFIG=false
4040

41+
# CocoaPods flag (can be disabled with --skip-cocoapods for testing)
42+
export OSA_SKIP_COCOAPODS=false
43+
4144
# Setup profile name (tracks which preset was used: minimal, react-native, etc.)
4245
export OSA_SETUP_PROFILE="everything"
4346

@@ -120,19 +123,29 @@ load_json_config() {
120123

121124
# Load components
122125
local -a component_keys=(symlinks oh_my_zsh zsh_plugins homebrew mise osa_snippets git android iterm2 vscode cocoapods)
126+
local -a undefined_components
123127

124128
for key in "${component_keys[@]}"; do
125129
local enabled=$(jq -r ".components.${key} // false" "$resolved_path" 2>/dev/null)
130+
local var_name="OSA_SETUP_$(normalize_key "$key")"
131+
126132
if [[ "$enabled" == "true" ]]; then
127-
local var_name="OSA_SETUP_$(normalize_key "$key")"
128-
# Safe assignment without eval - use typeset/declare
129133
typeset -g "$var_name=true"
130134
else
131-
local var_name="OSA_SETUP_$(normalize_key "$key")"
132135
typeset -g "$var_name=false"
136+
# Track undefined components (not explicitly set in config)
137+
local component_exists=$(jq -r ".components | has(\"${key}\")" "$resolved_path" 2>/dev/null)
138+
if [[ "$component_exists" != "true" ]]; then
139+
undefined_components+=("$key")
140+
fi
133141
fi
134142
done
135143

144+
# Log undefined components that will be skipped (optional, can be removed if too verbose)
145+
if [[ ${#undefined_components[@]} -gt 0 ]] && [[ "$OSA_VERBOSE" == "true" ]]; then
146+
echo -e "${COLOR_CYAN}Skipping undefined components: ${undefined_components[*]}${COLOR_RESET}"
147+
fi
148+
136149
# Load runtimes
137150
local -a runtime_keys=(node python ruby java rust go deno elixir erlang)
138151

@@ -560,26 +573,18 @@ interactive_setup() {
560573

561574
# macOS pre-flight check: Xcode Command Line Tools
562575
if [[ "$OSA_IS_MACOS" == "true" ]]; then
563-
if ! command -v xcode-select &>/dev/null || ! xcode-select -p &>/dev/null; then
576+
# Check if xcode-select returns a valid path (CLT is installed)
577+
# xcode-select -p returns the path to CLT, or fails if not installed
578+
local xcode_path=$(xcode-select -p 2>/dev/null)
579+
if [[ -z "$xcode_path" ]] || [[ ! -d "$xcode_path" ]]; then
564580
echo -e "${COLOR_YELLOW}⚠️ Xcode Command Line Tools not found${COLOR_RESET}"
565581
echo ""
566582
echo "Homebrew and many development tools require Xcode CLT."
583+
echo "Install from Apple Developer:"
584+
echo " ${COLOR_BOLD}https://developer.apple.com/download/more/${COLOR_RESET}"
567585
echo ""
568-
echo "Two ways to install:"
586+
echo "Or try: ${COLOR_BOLD}xcode-select --install${COLOR_RESET}"
569587
echo ""
570-
echo " Option 1 (Easiest):"
571-
echo " ${COLOR_BOLD}xcode-select --install${COLOR_RESET}"
572-
echo ""
573-
echo " Option 2 (From Apple Developer):"
574-
echo " Visit: https://developer.apple.com/download/more/"
575-
echo " Search for 'Command Line Tools'"
576-
echo " Download and install (Apple login required)"
577-
echo ""
578-
579-
if ! ask_yes_no "Continue anyway?" "n"; then
580-
echo -e "${COLOR_RED}Setup cancelled.${COLOR_RESET}"
581-
return 1
582-
fi
583588
fi
584589
fi
585590

@@ -647,8 +652,12 @@ interactive_setup() {
647652
continue
648653
fi
649654

650-
# Special handling for CocoaPods - ask with version selection
655+
# Special handling for CocoaPods - ask with version selection (unless --skip-cocoapods)
651656
if [[ "$key" == "cocoapods" ]]; then
657+
if [[ "$OSA_SKIP_COCOAPODS" == "true" ]]; then
658+
echo -e "${COLOR_YELLOW}${COLOR_RESET} Skipping CocoaPods (--skip-cocoapods flag set)"
659+
continue
660+
fi
652661
if is_component_available "$key"; then
653662
# Source the interactive CocoaPods setup
654663
if source "$OSA_CLI_DIR/src/setup/install-cocoapods-interactive.zsh"; then
@@ -723,10 +732,27 @@ interactive_setup() {
723732

724733
# Automated setup using saved config
725734
automated_setup() {
726-
echo -e "${COLOR_BOLD}Running automated setup from saved configuration...${COLOR_RESET}\n"
735+
echo -e "${COLOR_BOLD}${COLOR_CYAN}▶ OSA Setup in progress...${COLOR_RESET}\n"
727736

728737
print_platform_info
729738

739+
# macOS pre-flight check: Xcode Command Line Tools
740+
if [[ "$OSA_IS_MACOS" == "true" ]]; then
741+
# Check if xcode-select returns a valid path (CLT is installed)
742+
# xcode-select -p returns the path to CLT, or fails if not installed
743+
local xcode_path=$(xcode-select -p 2>/dev/null)
744+
if [[ -z "$xcode_path" ]] || [[ ! -d "$xcode_path" ]]; then
745+
echo -e "${COLOR_YELLOW}⚠️ Xcode Command Line Tools not found${COLOR_RESET}"
746+
echo ""
747+
echo "Homebrew and many development tools require Xcode CLT."
748+
echo "Install from Apple Developer:"
749+
echo " ${COLOR_BOLD}https://developer.apple.com/download/more/${COLOR_RESET}"
750+
echo ""
751+
echo "Or try: ${COLOR_BOLD}xcode-select --install${COLOR_RESET}"
752+
echo ""
753+
fi
754+
fi
755+
730756
# Build components in the REQUIRED ORDER (array order matters!)
731757
local -a selected_components
732758

@@ -759,7 +785,7 @@ automated_setup() {
759785
selected_components+=("git")
760786
fi
761787

762-
if [[ "$OSA_SETUP_COCOAPODS" == "true" ]] && is_component_available "cocoapods"; then
788+
if [[ "$OSA_SETUP_COCOAPODS" == "true" ]] && [[ "$OSA_SKIP_COCOAPODS" != "true" ]] && is_component_available "cocoapods"; then
763789
selected_components+=("cocoapods")
764790
fi
765791

@@ -802,6 +828,9 @@ automated_setup() {
802828
echo " 1. Try it out: ${COLOR_BOLD}mise --version${COLOR_RESET}"
803829
echo " 2. Test in a new terminal (recommended): ${COLOR_BOLD}zsh${COLOR_RESET}"
804830
echo " 3. Happy coding! 🚀"
831+
832+
echo ""
833+
echo -e "${COLOR_BOLD}${COLOR_GREEN}✓ OSA setup completed successfully${COLOR_RESET}"
805834
}
806835

807836
# Show help
@@ -835,6 +864,7 @@ ${COLOR_BOLD}OPTIONS:${COLOR_RESET}
835864
--local Skip global mise setup (only setup local configs)
836865
--disable-osa-snippets Skip osa-snippets installation (enabled by default)
837866
--disable-git Skip Git configuration (default: configure git)
867+
--skip-cocoapods Skip CocoaPods installation (useful for testing)
838868
--doctor Validate installation and suggest fixes (no changes made)
839869
--report Generate system report for bug reporting
840870
--report-json Generate system report in JSON format
@@ -1003,6 +1033,14 @@ enable_minimal() {
10031033
OSA_SETUP_ZSH_PLUGINS=true
10041034
OSA_SETUP_MISE=true
10051035

1036+
# Disable all optional components
1037+
OSA_SETUP_GIT=false
1038+
OSA_SETUP_ANDROID=false
1039+
OSA_SETUP_COCOAPODS=false
1040+
OSA_SETUP_ITERM2=false
1041+
OSA_SETUP_VSCODE=false
1042+
OSA_SETUP_OSA_SNIPPETS=false
1043+
10061044
# Enable homebrew on macOS
10071045
if [[ "$OSA_IS_MACOS" == "true" ]]; then
10081046
OSA_SETUP_HOMEBREW=true
@@ -1449,7 +1487,6 @@ HOOK_EOF
14491487
# Main CLI logic
14501488
main() {
14511489
init_components
1452-
load_config
14531490

14541491
# Parse arguments
14551492
if [[ $# -eq 0 ]]; then
@@ -1536,6 +1573,10 @@ main() {
15361573
export OSA_SKIP_GIT_CONFIG=true
15371574
shift
15381575
;;
1576+
--skip-cocoapods)
1577+
export OSA_SKIP_COCOAPODS=true
1578+
shift
1579+
;;
15391580
# Options that take arguments
15401581
--config|--config-file|--config-json|--config-url|--enable|--disable)
15411582
if [[ -z "$primary_action" ]]; then
@@ -1634,6 +1675,8 @@ main() {
16341675
exit $?
16351676
;;
16361677
-a|--auto)
1678+
# Load saved config for auto mode
1679+
load_config
16371680
automated_setup
16381681
exit $?
16391682
;;

src/setup/git.zsh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212

1313
# Ensure git is installed (always, regardless of OSA_SKIP_GIT_CONFIG)
1414
# This is needed for basic OSA operations like cloning repos
15-
if [[ "$OSA_IS_MACOS" == "true" ]] && [[ $(command -v git) != "/usr/local/bin/git" ]]; then
16-
echo "Installing latest git with brew..."
17-
brew install git
15+
if [[ "$OSA_IS_MACOS" == "true" ]]; then
16+
# Check if git needs updating
17+
local installed_version=$(git --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
18+
local upstream_version=$(brew info git 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
19+
20+
# Only install if not installed or version is different
21+
if [[ -z "$installed_version" ]] || [[ "$installed_version" != "$upstream_version" ]]; then
22+
brew install git >/dev/null
23+
fi
1824
fi
1925

2026
# Skip git configuration if disabled

0 commit comments

Comments
 (0)