|
9 | 9 | // CDN downloads (mxbuild tar.gz) contain Linux ELF binaries that cannot |
10 | 10 | // execute on Windows, so Studio Pro installations MUST be preferred. |
11 | 11 | // |
12 | | -// On Linux/macOS (CI, devcontainers), Studio Pro is not available. |
| 12 | +// On macOS, Studio Pro installs to "/Applications/Mendix Studio Pro X.Y.Z.app/". |
| 13 | +// CDN downloads are Linux ELF binaries and also cannot run on macOS. |
| 14 | +// Studio Pro installations are therefore preferred on macOS as well. |
| 15 | +// |
| 16 | +// On Linux (CI, devcontainers), Studio Pro is not available. |
13 | 17 | // CDN downloads are the primary source for mxbuild and runtime. |
14 | 18 | // |
15 | 19 | // Resolution priority (all platforms): |
16 | 20 | // 1. Explicit path (--mxbuild-path) |
17 | 21 | // 2. PATH lookup |
18 | | -// 3. OS-specific known locations (Studio Pro on Windows) |
| 22 | +// 3. OS-specific known locations (Studio Pro on Windows and macOS) |
19 | 23 | // 4. Cached CDN downloads (~/.mxcli/mxbuild/) |
20 | 24 | // |
21 | 25 | // Path discovery on Windows must NOT hardcode drive letters. Use environment |
@@ -136,16 +140,40 @@ func resolveMxBuild(explicitPath string, preferredVersion ...string) (string, er |
136 | 140 | } |
137 | 141 |
|
138 | 142 | // ResolveStudioProDir finds the Studio Pro installation directory for a specific |
139 | | -// Mendix version on Windows. Returns the installation root (e.g., |
140 | | -// "D:\Program Files\Mendix\11.6.4") or empty string if not found. |
141 | | -// On non-Windows platforms, always returns empty string. |
| 143 | +// Mendix version. Returns the installation root on Windows (e.g., |
| 144 | +// "D:\Program Files\Mendix\11.6.4") or the app Contents directory on macOS |
| 145 | +// (e.g., "/Applications/Mendix Studio Pro 11.10.0.app/Contents"). |
| 146 | +// Returns empty string if not found or on Linux. |
142 | 147 | func ResolveStudioProDir(version string) string { |
143 | | - if runtime.GOOS != "windows" { |
144 | | - return "" |
| 148 | + switch runtime.GOOS { |
| 149 | + case "windows": |
| 150 | + for _, dir := range windowsProgramDirs() { |
| 151 | + candidate := filepath.Join(dir, "Mendix", version) |
| 152 | + if info, err := os.Stat(filepath.Join(candidate, "modeler", "mxbuild.exe")); err == nil && !info.IsDir() { |
| 153 | + return candidate |
| 154 | + } |
| 155 | + } |
| 156 | + case "darwin": |
| 157 | + return resolveStudioProDirMacOS(version) |
145 | 158 | } |
146 | | - for _, dir := range windowsProgramDirs() { |
147 | | - candidate := filepath.Join(dir, "Mendix", version) |
148 | | - if info, err := os.Stat(filepath.Join(candidate, "modeler", "mxbuild.exe")); err == nil && !info.IsDir() { |
| 159 | + return "" |
| 160 | +} |
| 161 | + |
| 162 | +// resolveStudioProDirMacOS finds an installed Studio Pro on macOS that matches |
| 163 | +// the requested version. App bundles are named "Mendix Studio Pro X.Y.Z*.app" |
| 164 | +// where X.Y.Z is the base version (e.g., "11.10.0-rc.7 Beta" for 11.10.0). |
| 165 | +// Returns the bundle's Contents directory, or "" if not found. |
| 166 | +func resolveStudioProDirMacOS(version string) string { |
| 167 | + matches, _ := filepath.Glob("/Applications/Mendix Studio Pro *.app") |
| 168 | + re := regexp.MustCompile(`^Mendix Studio Pro (\d+\.\d+\.\d+)`) |
| 169 | + for _, match := range matches { |
| 170 | + base := strings.TrimSuffix(filepath.Base(match), ".app") |
| 171 | + m := re.FindStringSubmatch(base) |
| 172 | + if m == nil || m[1] != version { |
| 173 | + continue |
| 174 | + } |
| 175 | + candidate := filepath.Join(match, "Contents") |
| 176 | + if _, err := os.Stat(filepath.Join(candidate, "modeler", "mx")); err == nil { |
149 | 177 | return candidate |
150 | 178 | } |
151 | 179 | } |
@@ -189,7 +217,7 @@ func mendixSearchPaths(binaryName string) []string { |
189 | 217 | } |
190 | 218 | return paths |
191 | 219 | case "darwin": |
192 | | - return []string{filepath.Join("/Applications/Mendix/*/modeler", binaryName)} |
| 220 | + return []string{"/Applications/Mendix Studio Pro *.app/Contents/modeler/" + binaryName} |
193 | 221 | default: // linux |
194 | 222 | paths := []string{filepath.Join("/opt/mendix/*/modeler", binaryName)} |
195 | 223 | if home, err := os.UserHomeDir(); err == nil { |
|
0 commit comments