@fredlackey/devutils 0.0.17 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/README.md +32 -150
  2. package/package.json +5 -82
  3. package/bin/dev.js +0 -16
  4. package/files/README.md +0 -0
  5. package/files/claude/.claude/commands/setup-context.md +0 -3
  6. package/files/monorepos/_archive/README.md +0 -36
  7. package/files/monorepos/_legacy/README.md +0 -36
  8. package/files/monorepos/ai-docs/README.md +0 -33
  9. package/files/monorepos/apps/README.md +0 -24
  10. package/files/monorepos/docs/README.md +0 -40
  11. package/files/monorepos/packages/README.md +0 -25
  12. package/files/monorepos/research/README.md +0 -29
  13. package/files/monorepos/scripts/README.md +0 -24
  14. package/src/cli.js +0 -72
  15. package/src/commands/README.md +0 -41
  16. package/src/commands/configure.js +0 -199
  17. package/src/commands/identity.js +0 -1630
  18. package/src/commands/ignore.js +0 -247
  19. package/src/commands/install.js +0 -526
  20. package/src/commands/setup.js +0 -246
  21. package/src/commands/status.js +0 -223
  22. package/src/commands/update.js +0 -142
  23. package/src/commands/version.js +0 -100
  24. package/src/completion.js +0 -284
  25. package/src/constants.js +0 -45
  26. package/src/ignore/claude-code.txt +0 -10
  27. package/src/ignore/docker.txt +0 -18
  28. package/src/ignore/linux.txt +0 -23
  29. package/src/ignore/macos.txt +0 -36
  30. package/src/ignore/node.txt +0 -55
  31. package/src/ignore/terraform.txt +0 -37
  32. package/src/ignore/vscode.txt +0 -18
  33. package/src/ignore/windows.txt +0 -35
  34. package/src/index.js +0 -0
  35. package/src/installs/README.md +0 -399
  36. package/src/installs/adobe-creative-cloud.js +0 -546
  37. package/src/installs/adobe-creative-cloud.md +0 -605
  38. package/src/installs/appcleaner.js +0 -321
  39. package/src/installs/appcleaner.md +0 -699
  40. package/src/installs/apt-transport-https.js +0 -390
  41. package/src/installs/apt-transport-https.md +0 -678
  42. package/src/installs/atomicparsley.js +0 -642
  43. package/src/installs/atomicparsley.md +0 -795
  44. package/src/installs/aws-cli.js +0 -797
  45. package/src/installs/aws-cli.md +0 -727
  46. package/src/installs/balena-etcher.js +0 -710
  47. package/src/installs/balena-etcher.md +0 -761
  48. package/src/installs/bambu-studio.js +0 -1143
  49. package/src/installs/bambu-studio.md +0 -780
  50. package/src/installs/bash-completion.js +0 -575
  51. package/src/installs/bash-completion.md +0 -833
  52. package/src/installs/bash.js +0 -417
  53. package/src/installs/bash.md +0 -993
  54. package/src/installs/beyond-compare.js +0 -603
  55. package/src/installs/beyond-compare.md +0 -813
  56. package/src/installs/brave-browser.js +0 -968
  57. package/src/installs/brave-browser.md +0 -650
  58. package/src/installs/build-essential.js +0 -529
  59. package/src/installs/build-essential.md +0 -977
  60. package/src/installs/ca-certificates.js +0 -618
  61. package/src/installs/ca-certificates.md +0 -937
  62. package/src/installs/caffeine.js +0 -508
  63. package/src/installs/caffeine.md +0 -839
  64. package/src/installs/camtasia.js +0 -596
  65. package/src/installs/camtasia.md +0 -762
  66. package/src/installs/chatgpt.js +0 -476
  67. package/src/installs/chatgpt.md +0 -814
  68. package/src/installs/chocolatey.js +0 -456
  69. package/src/installs/chocolatey.md +0 -661
  70. package/src/installs/chrome-canary.js +0 -419
  71. package/src/installs/chrome-canary.md +0 -641
  72. package/src/installs/chromium.js +0 -667
  73. package/src/installs/chromium.md +0 -838
  74. package/src/installs/claude-code.js +0 -576
  75. package/src/installs/claude-code.md +0 -1173
  76. package/src/installs/cloudflare-warp.js +0 -900
  77. package/src/installs/cloudflare-warp.md +0 -1047
  78. package/src/installs/comet-browser.js +0 -588
  79. package/src/installs/comet-browser.md +0 -731
  80. package/src/installs/curl.js +0 -379
  81. package/src/installs/curl.md +0 -714
  82. package/src/installs/cursor.js +0 -579
  83. package/src/installs/cursor.md +0 -970
  84. package/src/installs/dbeaver.js +0 -924
  85. package/src/installs/dbeaver.md +0 -939
  86. package/src/installs/dbschema.js +0 -692
  87. package/src/installs/dbschema.md +0 -925
  88. package/src/installs/dependencies.md +0 -453
  89. package/src/installs/development-tools.js +0 -600
  90. package/src/installs/development-tools.md +0 -977
  91. package/src/installs/docker.js +0 -1029
  92. package/src/installs/docker.md +0 -1109
  93. package/src/installs/drawio.js +0 -1019
  94. package/src/installs/drawio.md +0 -795
  95. package/src/installs/elmedia-player.js +0 -347
  96. package/src/installs/elmedia-player.md +0 -556
  97. package/src/installs/ffmpeg.js +0 -889
  98. package/src/installs/ffmpeg.md +0 -852
  99. package/src/installs/file.js +0 -464
  100. package/src/installs/file.md +0 -987
  101. package/src/installs/gemini-cli.js +0 -811
  102. package/src/installs/gemini-cli.md +0 -1153
  103. package/src/installs/git.js +0 -400
  104. package/src/installs/git.md +0 -907
  105. package/src/installs/gitego.js +0 -949
  106. package/src/installs/gitego.md +0 -1172
  107. package/src/installs/go.js +0 -931
  108. package/src/installs/go.md +0 -958
  109. package/src/installs/google-antigravity.js +0 -913
  110. package/src/installs/google-antigravity.md +0 -1075
  111. package/src/installs/google-chrome.js +0 -833
  112. package/src/installs/google-chrome.md +0 -862
  113. package/src/installs/gpg.js +0 -480
  114. package/src/installs/gpg.md +0 -1056
  115. package/src/installs/homebrew.js +0 -1033
  116. package/src/installs/homebrew.md +0 -988
  117. package/src/installs/imageoptim.js +0 -968
  118. package/src/installs/imageoptim.md +0 -1119
  119. package/src/installs/installers.json +0 -4032
  120. package/src/installs/installers.json.tmp +0 -3953
  121. package/src/installs/jq.js +0 -400
  122. package/src/installs/jq.md +0 -809
  123. package/src/installs/keyboard-maestro.js +0 -719
  124. package/src/installs/keyboard-maestro.md +0 -825
  125. package/src/installs/kiro.js +0 -864
  126. package/src/installs/kiro.md +0 -1015
  127. package/src/installs/latex.js +0 -789
  128. package/src/installs/latex.md +0 -1095
  129. package/src/installs/lftp.js +0 -356
  130. package/src/installs/lftp.md +0 -907
  131. package/src/installs/lsb-release.js +0 -346
  132. package/src/installs/lsb-release.md +0 -814
  133. package/src/installs/messenger.js +0 -847
  134. package/src/installs/messenger.md +0 -900
  135. package/src/installs/microsoft-office.js +0 -568
  136. package/src/installs/microsoft-office.md +0 -760
  137. package/src/installs/microsoft-teams.js +0 -801
  138. package/src/installs/microsoft-teams.md +0 -886
  139. package/src/installs/moom.js +0 -326
  140. package/src/installs/moom.md +0 -570
  141. package/src/installs/node.js +0 -904
  142. package/src/installs/node.md +0 -1153
  143. package/src/installs/nordpass.js +0 -716
  144. package/src/installs/nordpass.md +0 -921
  145. package/src/installs/nordvpn.js +0 -892
  146. package/src/installs/nordvpn.md +0 -1052
  147. package/src/installs/nvm.js +0 -995
  148. package/src/installs/nvm.md +0 -1057
  149. package/src/installs/ohmyzsh.js +0 -529
  150. package/src/installs/ohmyzsh.md +0 -1094
  151. package/src/installs/openssh.js +0 -804
  152. package/src/installs/openssh.md +0 -1056
  153. package/src/installs/pandoc.js +0 -662
  154. package/src/installs/pandoc.md +0 -1036
  155. package/src/installs/parallels-desktop.js +0 -431
  156. package/src/installs/parallels-desktop.md +0 -446
  157. package/src/installs/pinentry.js +0 -510
  158. package/src/installs/pinentry.md +0 -1142
  159. package/src/installs/pngyu.js +0 -869
  160. package/src/installs/pngyu.md +0 -896
  161. package/src/installs/postman.js +0 -799
  162. package/src/installs/postman.md +0 -940
  163. package/src/installs/procps.js +0 -425
  164. package/src/installs/procps.md +0 -851
  165. package/src/installs/safari-tech-preview.js +0 -374
  166. package/src/installs/safari-tech-preview.md +0 -533
  167. package/src/installs/sfnt2woff.js +0 -658
  168. package/src/installs/sfnt2woff.md +0 -795
  169. package/src/installs/shellcheck.js +0 -481
  170. package/src/installs/shellcheck.md +0 -1005
  171. package/src/installs/slack.js +0 -741
  172. package/src/installs/slack.md +0 -865
  173. package/src/installs/snagit.js +0 -585
  174. package/src/installs/snagit.md +0 -844
  175. package/src/installs/software-properties-common.js +0 -372
  176. package/src/installs/software-properties-common.md +0 -805
  177. package/src/installs/spotify.js +0 -877
  178. package/src/installs/spotify.md +0 -901
  179. package/src/installs/studio-3t.js +0 -823
  180. package/src/installs/studio-3t.md +0 -918
  181. package/src/installs/sublime-text.js +0 -804
  182. package/src/installs/sublime-text.md +0 -914
  183. package/src/installs/superwhisper.js +0 -706
  184. package/src/installs/superwhisper.md +0 -630
  185. package/src/installs/tailscale.js +0 -745
  186. package/src/installs/tailscale.md +0 -1100
  187. package/src/installs/tar.js +0 -389
  188. package/src/installs/tar.md +0 -946
  189. package/src/installs/termius.js +0 -798
  190. package/src/installs/termius.md +0 -844
  191. package/src/installs/terraform.js +0 -779
  192. package/src/installs/terraform.md +0 -899
  193. package/src/installs/tfenv.js +0 -778
  194. package/src/installs/tfenv.md +0 -1091
  195. package/src/installs/tidal.js +0 -771
  196. package/src/installs/tidal.md +0 -864
  197. package/src/installs/tmux.js +0 -346
  198. package/src/installs/tmux.md +0 -1030
  199. package/src/installs/tree.js +0 -411
  200. package/src/installs/tree.md +0 -833
  201. package/src/installs/unzip.js +0 -460
  202. package/src/installs/unzip.md +0 -879
  203. package/src/installs/vim.js +0 -421
  204. package/src/installs/vim.md +0 -1040
  205. package/src/installs/vlc.js +0 -821
  206. package/src/installs/vlc.md +0 -927
  207. package/src/installs/vscode.js +0 -843
  208. package/src/installs/vscode.md +0 -1002
  209. package/src/installs/wget.js +0 -420
  210. package/src/installs/wget.md +0 -791
  211. package/src/installs/whatsapp.js +0 -729
  212. package/src/installs/whatsapp.md +0 -854
  213. package/src/installs/winpty.js +0 -352
  214. package/src/installs/winpty.md +0 -620
  215. package/src/installs/woff2.js +0 -553
  216. package/src/installs/woff2.md +0 -977
  217. package/src/installs/wsl.js +0 -572
  218. package/src/installs/wsl.md +0 -699
  219. package/src/installs/xcode-clt.js +0 -520
  220. package/src/installs/xcode-clt.md +0 -351
  221. package/src/installs/xcode.js +0 -560
  222. package/src/installs/xcode.md +0 -573
  223. package/src/installs/yarn.js +0 -824
  224. package/src/installs/yarn.md +0 -1074
  225. package/src/installs/yq.js +0 -654
  226. package/src/installs/yq.md +0 -944
  227. package/src/installs/yt-dlp.js +0 -701
  228. package/src/installs/yt-dlp.md +0 -946
  229. package/src/installs/yum-utils.js +0 -297
  230. package/src/installs/yum-utils.md +0 -648
  231. package/src/installs/zoom.js +0 -759
  232. package/src/installs/zoom.md +0 -884
  233. package/src/installs/zsh.js +0 -455
  234. package/src/installs/zsh.md +0 -1008
  235. package/src/scripts/README.md +0 -617
  236. package/src/scripts/STATUS.md +0 -208
  237. package/src/scripts/afk.js +0 -411
  238. package/src/scripts/backup-all.js +0 -746
  239. package/src/scripts/backup-source.js +0 -727
  240. package/src/scripts/brewd.js +0 -389
  241. package/src/scripts/brewi.js +0 -520
  242. package/src/scripts/brewr.js +0 -527
  243. package/src/scripts/brews.js +0 -477
  244. package/src/scripts/brewu.js +0 -504
  245. package/src/scripts/c.js +0 -201
  246. package/src/scripts/ccurl.js +0 -341
  247. package/src/scripts/certbot-crontab-init.js +0 -504
  248. package/src/scripts/certbot-init.js +0 -657
  249. package/src/scripts/ch.js +0 -355
  250. package/src/scripts/claude-danger.js +0 -268
  251. package/src/scripts/clean-dev.js +0 -435
  252. package/src/scripts/clear-dns-cache.js +0 -541
  253. package/src/scripts/clone.js +0 -435
  254. package/src/scripts/code-all.js +0 -437
  255. package/src/scripts/count-files.js +0 -211
  256. package/src/scripts/count-folders.js +0 -211
  257. package/src/scripts/count.js +0 -264
  258. package/src/scripts/d.js +0 -219
  259. package/src/scripts/datauri.js +0 -389
  260. package/src/scripts/delete-files.js +0 -380
  261. package/src/scripts/docker-clean.js +0 -426
  262. package/src/scripts/dp.js +0 -442
  263. package/src/scripts/e.js +0 -390
  264. package/src/scripts/empty-trash.js +0 -513
  265. package/src/scripts/evm.js +0 -444
  266. package/src/scripts/fetch-github-repos.js +0 -456
  267. package/src/scripts/get-channel.js +0 -345
  268. package/src/scripts/get-course.js +0 -399
  269. package/src/scripts/get-dependencies.js +0 -306
  270. package/src/scripts/get-folder.js +0 -799
  271. package/src/scripts/get-tunes.js +0 -426
  272. package/src/scripts/get-video.js +0 -367
  273. package/src/scripts/git-backup.js +0 -577
  274. package/src/scripts/git-clone.js +0 -493
  275. package/src/scripts/git-pup.js +0 -319
  276. package/src/scripts/git-push.js +0 -396
  277. package/src/scripts/h.js +0 -622
  278. package/src/scripts/hide-desktop-icons.js +0 -499
  279. package/src/scripts/hide-hidden-files.js +0 -538
  280. package/src/scripts/install-dependencies-from.js +0 -456
  281. package/src/scripts/ips.js +0 -663
  282. package/src/scripts/iso.js +0 -370
  283. package/src/scripts/killni.js +0 -577
  284. package/src/scripts/ll.js +0 -467
  285. package/src/scripts/local-ip.js +0 -325
  286. package/src/scripts/m.js +0 -524
  287. package/src/scripts/map.js +0 -309
  288. package/src/scripts/mkd.js +0 -351
  289. package/src/scripts/ncu-update-all.js +0 -457
  290. package/src/scripts/nginx-init.js +0 -718
  291. package/src/scripts/npmi.js +0 -382
  292. package/src/scripts/o.js +0 -511
  293. package/src/scripts/org-by-date.js +0 -338
  294. package/src/scripts/p.js +0 -224
  295. package/src/scripts/packages.js +0 -330
  296. package/src/scripts/path.js +0 -225
  297. package/src/scripts/ports.js +0 -597
  298. package/src/scripts/q.js +0 -305
  299. package/src/scripts/refresh-files.js +0 -394
  300. package/src/scripts/remove-smaller-files.js +0 -516
  301. package/src/scripts/rename-files-with-date.js +0 -533
  302. package/src/scripts/resize-image.js +0 -539
  303. package/src/scripts/rm-safe.js +0 -669
  304. package/src/scripts/s.js +0 -540
  305. package/src/scripts/set-git-public.js +0 -365
  306. package/src/scripts/show-desktop-icons.js +0 -475
  307. package/src/scripts/show-hidden-files.js +0 -472
  308. package/src/scripts/tpa.js +0 -280
  309. package/src/scripts/tpo.js +0 -280
  310. package/src/scripts/u.js +0 -505
  311. package/src/scripts/vpush.js +0 -437
  312. package/src/scripts/y.js +0 -283
  313. package/src/utils/README.md +0 -95
  314. package/src/utils/common/apps.js +0 -143
  315. package/src/utils/common/display.js +0 -157
  316. package/src/utils/common/network.js +0 -185
  317. package/src/utils/common/os.js +0 -294
  318. package/src/utils/common/package-manager.js +0 -301
  319. package/src/utils/common/privileges.js +0 -138
  320. package/src/utils/common/shell.js +0 -216
  321. package/src/utils/macos/apps.js +0 -228
  322. package/src/utils/macos/brew.js +0 -315
  323. package/src/utils/ubuntu/apt.js +0 -307
  324. package/src/utils/ubuntu/desktop.js +0 -292
  325. package/src/utils/ubuntu/snap.js +0 -344
  326. package/src/utils/ubuntu/systemd.js +0 -286
  327. package/src/utils/windows/choco.js +0 -465
  328. package/src/utils/windows/env.js +0 -246
  329. package/src/utils/windows/registry.js +0 -269
  330. package/src/utils/windows/shell.js +0 -240
  331. package/src/utils/windows/winget.js +0 -489
@@ -1,1033 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * @fileoverview Install Homebrew package manager.
5
- * @module installs/homebrew
6
- *
7
- * Homebrew is a free and open-source package management system that simplifies
8
- * the installation of software on macOS and Linux. Originally created for macOS,
9
- * Homebrew has expanded to support Linux distributions via Linuxbrew.
10
- *
11
- * This installer provides:
12
- * - Native Homebrew installation on macOS (Intel and Apple Silicon)
13
- * - Linuxbrew installation on Ubuntu/Debian (x86_64)
14
- * - Linuxbrew installation on Amazon Linux (x86_64)
15
- * - Linuxbrew installation on Raspberry Pi OS (ARM64/ARM32 with limitations)
16
- * - Linuxbrew installation within WSL (Ubuntu)
17
- *
18
- * IMPORTANT PLATFORM NOTES:
19
- * - macOS: Full support with pre-compiled bottles for fast installation
20
- * - Ubuntu/Debian (x86_64): Full support with bottles via Linuxbrew
21
- * - Amazon Linux (x86_64): Full support with bottles via Linuxbrew
22
- * - Raspberry Pi OS (ARM64): Limited support; no bottles, packages compile from source
23
- * - Raspberry Pi OS (ARM32): Minimal support; requires system Ruby, no bottles
24
- * - Windows (Native): Not supported; use WSL for Homebrew on Windows
25
- * - Git Bash: Not supported; use WSL for Homebrew on Windows
26
- */
27
-
28
- const os = require('../utils/common/os');
29
- const shell = require('../utils/common/shell');
30
- const fs = require('fs');
31
- const path = require('path');
32
-
33
- /**
34
- * The URL for the Homebrew installation script.
35
- * This is the official installer maintained by the Homebrew project.
36
- */
37
- const HOMEBREW_INSTALL_URL = 'https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh';
38
-
39
- /**
40
- * Installation paths for Homebrew on different platforms.
41
- * These are the default locations where Homebrew installs itself.
42
- */
43
- const HOMEBREW_PATHS = {
44
- // macOS Apple Silicon (M1/M2/M3/M4)
45
- macos_arm: '/opt/homebrew',
46
- // macOS Intel
47
- macos_intel: '/usr/local',
48
- // Linux (including WSL)
49
- linux: '/home/linuxbrew/.linuxbrew'
50
- };
51
-
52
- /**
53
- * Required build dependencies for installing Homebrew on Debian-based Linux systems.
54
- * These packages are required to compile packages from source and run the installer.
55
- */
56
- const DEBIAN_BUILD_DEPENDENCIES = [
57
- 'build-essential', // Compilers and build tools (gcc, g++, make)
58
- 'procps', // Process utilities required by Homebrew
59
- 'curl', // For downloading the installer
60
- 'file', // File type detection utility
61
- 'git' // Version control system used by Homebrew
62
- ];
63
-
64
- /**
65
- * Required build dependencies for installing Homebrew on RHEL-based Linux systems.
66
- * These packages are required to compile packages from source and run the installer.
67
- */
68
- const RHEL_BUILD_DEPENDENCIES = [
69
- 'procps-ng', // Process utilities (Amazon Linux 2023 uses procps-ng)
70
- 'curl', // For downloading the installer
71
- 'file', // File type detection utility
72
- 'git' // Version control system used by Homebrew
73
- ];
74
-
75
- /**
76
- * Check if Homebrew is already installed by looking for the brew command.
77
- *
78
- * This is the primary method to detect if Homebrew is installed and functional.
79
- * It checks if 'brew' exists in the PATH and is executable.
80
- *
81
- * @returns {boolean} True if Homebrew is installed and available, false otherwise
82
- */
83
- function isBrewInstalled() {
84
- return shell.commandExists('brew');
85
- }
86
-
87
- /**
88
- * Get the installed Homebrew version.
89
- *
90
- * Executes 'brew --version' to retrieve the version string if Homebrew
91
- * is installed. Returns null if Homebrew is not installed or the command fails.
92
- *
93
- * @returns {Promise<string|null>} The Homebrew version string, or null if not installed
94
- */
95
- async function getBrewVersion() {
96
- if (!isBrewInstalled()) {
97
- return null;
98
- }
99
-
100
- const result = await shell.exec('brew --version');
101
- if (result.code === 0 && result.stdout) {
102
- // Output format: "Homebrew 4.4.15"
103
- const match = result.stdout.match(/Homebrew\s+([\d.]+)/);
104
- return match ? match[1] : result.stdout.trim().split('\n')[0];
105
- }
106
- return null;
107
- }
108
-
109
- /**
110
- * Check if Homebrew installation directory exists.
111
- *
112
- * This is a secondary check that looks for the Homebrew directory structure
113
- * even if the 'brew' command is not in PATH. Useful for detecting partial
114
- * installations that may need PATH configuration.
115
- *
116
- * @param {string} platform - The platform type ('macos', 'linux', etc.)
117
- * @returns {boolean} True if the Homebrew directory exists, false otherwise
118
- */
119
- function doesBrewDirectoryExist(platform) {
120
- if (platform === 'macos') {
121
- // Check both Apple Silicon and Intel paths
122
- const arch = os.getArch();
123
- const brewPath = arch === 'arm64' ? HOMEBREW_PATHS.macos_arm : HOMEBREW_PATHS.macos_intel;
124
- return fs.existsSync(path.join(brewPath, 'bin', 'brew'));
125
- }
126
-
127
- // Linux (Ubuntu, Debian, Amazon Linux, Raspberry Pi, WSL)
128
- return fs.existsSync(path.join(HOMEBREW_PATHS.linux, 'bin', 'brew'));
129
- }
130
-
131
- /**
132
- * Get the appropriate shell configuration file path for the current user.
133
- *
134
- * Determines which shell configuration file to modify for PATH configuration.
135
- * Checks the SHELL environment variable to determine the user's default shell.
136
- *
137
- * @returns {string} The path to the shell configuration file
138
- */
139
- function getShellConfigFile() {
140
- const homeDir = os.getHomeDir();
141
- const currentShell = process.env.SHELL || '';
142
-
143
- // Check for zsh (default on modern macOS)
144
- if (currentShell.includes('zsh')) {
145
- return path.join(homeDir, '.zshrc');
146
- }
147
-
148
- // Default to bash configuration files
149
- // On macOS, .bash_profile is used for login shells; on Linux, .bashrc
150
- if (process.platform === 'darwin') {
151
- return path.join(homeDir, '.bash_profile');
152
- }
153
-
154
- return path.join(homeDir, '.bashrc');
155
- }
156
-
157
- /**
158
- * Get the Homebrew shellenv command for PATH configuration.
159
- *
160
- * Returns the appropriate command to add Homebrew to the shell PATH.
161
- * The command varies based on the platform and processor architecture.
162
- *
163
- * @param {string} platform - The platform type ('macos', 'linux', etc.)
164
- * @returns {string} The shellenv command to add to shell configuration
165
- */
166
- function getShellenvCommand(platform) {
167
- if (platform === 'macos') {
168
- const arch = os.getArch();
169
- if (arch === 'arm64') {
170
- // Apple Silicon Mac
171
- return 'eval "$(/opt/homebrew/bin/brew shellenv)"';
172
- }
173
- // Intel Mac
174
- return 'eval "$(/usr/local/bin/brew shellenv)"';
175
- }
176
-
177
- // Linux (Ubuntu, Debian, Amazon Linux, Raspberry Pi, WSL)
178
- return 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"';
179
- }
180
-
181
- /**
182
- * Configure PATH for Homebrew by adding shellenv to shell configuration file.
183
- *
184
- * This function adds the Homebrew shellenv command to the appropriate shell
185
- * configuration file if it's not already present. It also runs the shellenv
186
- * command to make Homebrew available in the current session.
187
- *
188
- * @param {string} platform - The platform type ('macos', 'linux', etc.)
189
- * @returns {Promise<void>}
190
- */
191
- async function configureBrewPath(platform) {
192
- const shellConfigFile = getShellConfigFile();
193
- const shellenvCommand = getShellenvCommand(platform);
194
-
195
- console.log(`Configuring Homebrew in ${shellConfigFile}...`);
196
-
197
- // Check if the shellenv command is already in the config file
198
- let configContent = '';
199
- try {
200
- if (fs.existsSync(shellConfigFile)) {
201
- configContent = fs.readFileSync(shellConfigFile, 'utf8');
202
- }
203
- } catch (error) {
204
- // File doesn't exist or can't be read; we'll create it
205
- }
206
-
207
- // Only add the command if it's not already present
208
- if (!configContent.includes('brew shellenv')) {
209
- const lineToAdd = `\n# Homebrew\n${shellenvCommand}\n`;
210
-
211
- try {
212
- fs.appendFileSync(shellConfigFile, lineToAdd);
213
- console.log(`Added Homebrew to ${shellConfigFile}`);
214
- } catch (error) {
215
- console.log(`Warning: Could not update ${shellConfigFile}`);
216
- console.log(`Please add this line manually: ${shellenvCommand}`);
217
- }
218
- } else {
219
- console.log('Homebrew PATH configuration already exists in shell config.');
220
- }
221
-
222
- // Run shellenv to make brew available in the current process
223
- // Note: This won't persist to the parent shell, but it enables verification
224
- if (platform === 'macos') {
225
- const arch = os.getArch();
226
- const brewPath = arch === 'arm64' ? '/opt/homebrew/bin' : '/usr/local/bin';
227
- process.env.PATH = `${brewPath}:${process.env.PATH}`;
228
- } else {
229
- process.env.PATH = `/home/linuxbrew/.linuxbrew/bin:${process.env.PATH}`;
230
- }
231
- }
232
-
233
- /**
234
- * Install Homebrew on macOS.
235
- *
236
- * Prerequisites:
237
- * - macOS 14 (Sonoma) or later for full support (older versions may work)
238
- * - Apple Silicon (M1/M2/M3/M4) or 64-bit Intel processor
239
- * - Command Line Tools for Xcode (installed automatically if not present)
240
- * - Bash shell available (default on macOS)
241
- *
242
- * The installer automatically:
243
- * 1. Downloads Homebrew to /opt/homebrew (Apple Silicon) or /usr/local (Intel)
244
- * 2. Installs the Command Line Tools for Xcode if not present
245
- * 3. Configures the Homebrew environment
246
- *
247
- * @returns {Promise<void>}
248
- */
249
- async function install_macos() {
250
- console.log('Checking if Homebrew is already installed...');
251
-
252
- // Check if Homebrew is already installed via command
253
- const existingVersion = await getBrewVersion();
254
- if (existingVersion) {
255
- console.log(`Homebrew ${existingVersion} is already installed, skipping installation.`);
256
- return;
257
- }
258
-
259
- // Check if Homebrew directory exists but PATH is not configured
260
- if (doesBrewDirectoryExist('macos')) {
261
- console.log('Homebrew appears to be installed but not in PATH.');
262
- console.log('Configuring PATH...');
263
- await configureBrewPath('macos');
264
-
265
- // Verify it works now
266
- const versionAfterConfig = await getBrewVersion();
267
- if (versionAfterConfig) {
268
- console.log(`Homebrew ${versionAfterConfig} is now configured and ready.`);
269
- return;
270
- }
271
- }
272
-
273
- console.log('Installing Homebrew on macOS...');
274
- console.log('');
275
- console.log('This will install:');
276
- console.log(' - Homebrew package manager');
277
- console.log(' - Xcode Command Line Tools (if not already installed)');
278
- console.log('');
279
-
280
- // Run the official Homebrew installer in non-interactive mode
281
- // NONINTERACTIVE=1 prevents prompts for confirmation
282
- console.log('Downloading and running the Homebrew installer...');
283
- console.log('This may take several minutes...');
284
- console.log('');
285
-
286
- const installResult = await shell.exec(
287
- `NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL ${HOMEBREW_INSTALL_URL})"`,
288
- { timeout: 600000 } // 10 minute timeout for slow connections
289
- );
290
-
291
- if (installResult.code !== 0) {
292
- throw new Error(
293
- `Failed to install Homebrew.\n` +
294
- `Output: ${installResult.stderr || installResult.stdout}\n\n` +
295
- `Troubleshooting:\n` +
296
- ` 1. If Xcode Command Line Tools installation hung, run:\n` +
297
- ` xcode-select --install\n` +
298
- ` Then retry installing Homebrew.\n` +
299
- ` 2. For permission errors, ensure you own the target directory:\n` +
300
- ` sudo chown -R $(whoami) /opt/homebrew # Apple Silicon\n` +
301
- ` sudo chown -R $(whoami) /usr/local/Homebrew # Intel\n` +
302
- ` 3. Check your internet connection and retry.`
303
- );
304
- }
305
-
306
- // Configure PATH
307
- await configureBrewPath('macos');
308
-
309
- // Verify installation
310
- const version = await getBrewVersion();
311
- if (!version) {
312
- // Even if version check fails, the installation might be successful
313
- // Give user instructions to complete setup
314
- console.log('');
315
- console.log('Homebrew installation completed.');
316
- console.log('');
317
- console.log('IMPORTANT: To use Homebrew, either:');
318
- console.log(' 1. Open a new terminal window, OR');
319
- console.log(' 2. Run this command in your current terminal:');
320
- console.log(` ${getShellenvCommand('macos')}`);
321
- console.log('');
322
- console.log('Then verify with: brew --version');
323
- return;
324
- }
325
-
326
- console.log(`Homebrew ${version} installed successfully.`);
327
- console.log('');
328
- console.log('IMPORTANT: To use Homebrew in your current terminal, run:');
329
- console.log(` ${getShellenvCommand('macos')}`);
330
- console.log('');
331
- console.log('Or simply open a new terminal window.');
332
- console.log('');
333
- console.log('Verify with: brew --version');
334
- console.log('Run diagnostics: brew doctor');
335
- }
336
-
337
- /**
338
- * Install build dependencies on Ubuntu/Debian systems.
339
- *
340
- * Installs the required packages for Homebrew to function on Debian-based systems.
341
- * These packages include compilers, build tools, and utilities needed by Homebrew.
342
- *
343
- * @returns {Promise<void>}
344
- * @throws {Error} If package installation fails
345
- */
346
- async function installDebianBuildDependencies() {
347
- console.log('Installing required build dependencies...');
348
-
349
- // Update package lists first
350
- const updateResult = await shell.exec(
351
- 'sudo DEBIAN_FRONTEND=noninteractive apt-get update -y'
352
- );
353
- if (updateResult.code !== 0) {
354
- console.log('Warning: apt-get update had issues, continuing anyway...');
355
- }
356
-
357
- // Install build dependencies
358
- const packages = DEBIAN_BUILD_DEPENDENCIES.join(' ');
359
- const installResult = await shell.exec(
360
- `sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ${packages}`
361
- );
362
-
363
- if (installResult.code !== 0) {
364
- throw new Error(
365
- `Failed to install build dependencies.\n` +
366
- `Output: ${installResult.stderr}\n\n` +
367
- `Required packages: ${packages}\n` +
368
- `Please install them manually with:\n` +
369
- ` sudo apt-get update && sudo apt-get install -y ${packages}`
370
- );
371
- }
372
-
373
- console.log('Build dependencies installed successfully.');
374
- }
375
-
376
- /**
377
- * Install Homebrew on Ubuntu/Debian systems.
378
- *
379
- * Prerequisites:
380
- * - Ubuntu 20.04 LTS or later, or Debian 10 (Buster) or later (64-bit x86_64)
381
- * - sudo privileges
382
- * - curl and git installed (handled automatically)
383
- *
384
- * Homebrew on Linux (Linuxbrew) installs to /home/linuxbrew/.linuxbrew and
385
- * provides pre-compiled bottles for x86_64 architecture, enabling fast installation.
386
- *
387
- * @returns {Promise<void>}
388
- */
389
- async function install_ubuntu() {
390
- console.log('Checking if Homebrew is already installed...');
391
-
392
- // Check if Homebrew is already installed via command
393
- const existingVersion = await getBrewVersion();
394
- if (existingVersion) {
395
- console.log(`Homebrew ${existingVersion} is already installed, skipping installation.`);
396
- return;
397
- }
398
-
399
- // Check if Homebrew directory exists but PATH is not configured
400
- if (doesBrewDirectoryExist('linux')) {
401
- console.log('Homebrew appears to be installed but not in PATH.');
402
- console.log('Configuring PATH...');
403
- await configureBrewPath('linux');
404
-
405
- // Verify it works now
406
- const versionAfterConfig = await getBrewVersion();
407
- if (versionAfterConfig) {
408
- console.log(`Homebrew ${versionAfterConfig} is now configured and ready.`);
409
- return;
410
- }
411
- }
412
-
413
- console.log('Installing Homebrew on Ubuntu/Debian...');
414
- console.log('');
415
-
416
- // Install build dependencies
417
- await installDebianBuildDependencies();
418
-
419
- console.log('');
420
- console.log('Downloading and running the Homebrew installer...');
421
- console.log('This may take several minutes...');
422
- console.log('');
423
-
424
- // Run the official Homebrew installer in non-interactive mode
425
- const installResult = await shell.exec(
426
- `NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL ${HOMEBREW_INSTALL_URL})"`,
427
- { timeout: 600000 } // 10 minute timeout
428
- );
429
-
430
- if (installResult.code !== 0) {
431
- throw new Error(
432
- `Failed to install Homebrew.\n` +
433
- `Output: ${installResult.stderr || installResult.stdout}\n\n` +
434
- `Troubleshooting:\n` +
435
- ` 1. Ensure all dependencies are installed:\n` +
436
- ` sudo apt-get install -y build-essential procps curl file git\n` +
437
- ` 2. Check your internet connection\n` +
438
- ` 3. If you see tar errors, run:\n` +
439
- ` sudo apt-get install -y tar`
440
- );
441
- }
442
-
443
- // Configure PATH
444
- await configureBrewPath('linux');
445
-
446
- // Verify installation
447
- const version = await getBrewVersion();
448
- if (!version) {
449
- console.log('');
450
- console.log('Homebrew installation completed.');
451
- console.log('');
452
- console.log('IMPORTANT: To use Homebrew, either:');
453
- console.log(' 1. Open a new terminal window, OR');
454
- console.log(' 2. Run this command in your current terminal:');
455
- console.log(` ${getShellenvCommand('linux')}`);
456
- console.log('');
457
- console.log('Then verify with: brew --version');
458
- return;
459
- }
460
-
461
- console.log(`Homebrew ${version} installed successfully.`);
462
- console.log('');
463
- console.log('IMPORTANT: To use Homebrew in your current terminal, run:');
464
- console.log(` ${getShellenvCommand('linux')}`);
465
- console.log('');
466
- console.log('Or simply open a new terminal window.');
467
- console.log('');
468
- console.log('Verify with: brew --version');
469
- console.log('Run diagnostics: brew doctor');
470
- }
471
-
472
- /**
473
- * Install Homebrew on Raspberry Pi OS.
474
- *
475
- * Prerequisites:
476
- * - Raspberry Pi OS Bookworm or Bullseye (64-bit recommended)
477
- * - Raspberry Pi 3B+ or later (64-bit capable hardware recommended)
478
- * - At least 2 GB RAM (4 GB recommended)
479
- * - sudo privileges
480
- *
481
- * IMPORTANT: Homebrew on ARM Linux is a Tier 3 platform:
482
- * - No pre-compiled binary packages (bottles) are available
483
- * - All packages must be compiled from source
484
- * - Installation takes significantly longer than on x86_64 platforms
485
- * - 32-bit (armv7l) requires system Ruby to be installed first
486
- *
487
- * @returns {Promise<void>}
488
- */
489
- async function install_raspbian() {
490
- console.log('Checking if Homebrew is already installed...');
491
-
492
- // Check if Homebrew is already installed via command
493
- const existingVersion = await getBrewVersion();
494
- if (existingVersion) {
495
- console.log(`Homebrew ${existingVersion} is already installed, skipping installation.`);
496
- return;
497
- }
498
-
499
- // Check if Homebrew directory exists but PATH is not configured
500
- if (doesBrewDirectoryExist('linux')) {
501
- console.log('Homebrew appears to be installed but not in PATH.');
502
- console.log('Configuring PATH...');
503
- await configureBrewPath('linux');
504
-
505
- // Verify it works now
506
- const versionAfterConfig = await getBrewVersion();
507
- if (versionAfterConfig) {
508
- console.log(`Homebrew ${versionAfterConfig} is now configured and ready.`);
509
- return;
510
- }
511
- }
512
-
513
- // Detect architecture to provide appropriate warnings
514
- const archResult = await shell.exec('uname -m');
515
- const arch = archResult.stdout.trim();
516
-
517
- console.log('Installing Homebrew on Raspberry Pi OS...');
518
- console.log('');
519
- console.log('IMPORTANT: Homebrew on ARM is a Tier 3 platform.');
520
- console.log('- No pre-compiled bottles are available');
521
- console.log('- All packages will compile from source');
522
- console.log('- Installation and package installation will be slow');
523
- console.log('');
524
-
525
- // Install build dependencies
526
- await installDebianBuildDependencies();
527
-
528
- // For 32-bit Raspberry Pi OS, we need to install system Ruby first
529
- if (arch === 'armv7l') {
530
- console.log('');
531
- console.log('Detected 32-bit Raspberry Pi OS (armv7l).');
532
- console.log('Installing system Ruby (required for 32-bit ARM)...');
533
-
534
- const rubyResult = await shell.exec(
535
- 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ruby ruby-dev'
536
- );
537
- if (rubyResult.code !== 0) {
538
- throw new Error(
539
- `Failed to install Ruby, which is required for Homebrew on 32-bit ARM.\n` +
540
- `Please install Ruby manually:\n` +
541
- ` sudo apt-get install -y ruby ruby-dev\n` +
542
- `Then retry installing Homebrew.`
543
- );
544
- }
545
- console.log('Ruby installed successfully.');
546
- }
547
-
548
- console.log('');
549
- console.log('Downloading and running the Homebrew installer...');
550
- console.log('This may take several minutes (or longer on slower hardware)...');
551
- console.log('');
552
-
553
- // Run the official Homebrew installer in non-interactive mode
554
- const installResult = await shell.exec(
555
- `NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL ${HOMEBREW_INSTALL_URL})"`,
556
- { timeout: 1200000 } // 20 minute timeout for slower Raspberry Pi hardware
557
- );
558
-
559
- if (installResult.code !== 0) {
560
- throw new Error(
561
- `Failed to install Homebrew.\n` +
562
- `Output: ${installResult.stderr || installResult.stdout}\n\n` +
563
- `Troubleshooting:\n` +
564
- ` 1. Ensure all dependencies are installed:\n` +
565
- ` sudo apt-get install -y build-essential procps curl file git\n` +
566
- ` 2. For 32-bit (armv7l), ensure Ruby is installed:\n` +
567
- ` sudo apt-get install -y ruby ruby-dev\n` +
568
- ` 3. If compilation fails with out-of-memory errors, add swap space:\n` +
569
- ` sudo fallocate -l 2G /swapfile\n` +
570
- ` sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile\n` +
571
- ` 4. Check your internet connection and retry.`
572
- );
573
- }
574
-
575
- // Configure PATH
576
- await configureBrewPath('linux');
577
-
578
- // Verify installation
579
- const version = await getBrewVersion();
580
- if (!version) {
581
- console.log('');
582
- console.log('Homebrew installation completed.');
583
- console.log('');
584
- console.log('IMPORTANT: To use Homebrew, either:');
585
- console.log(' 1. Open a new terminal window, OR');
586
- console.log(' 2. Run this command in your current terminal:');
587
- console.log(` ${getShellenvCommand('linux')}`);
588
- console.log('');
589
- console.log('Then verify with: brew --version');
590
- return;
591
- }
592
-
593
- console.log(`Homebrew ${version} installed successfully.`);
594
- console.log('');
595
- console.log('IMPORTANT: To use Homebrew in your current terminal, run:');
596
- console.log(` ${getShellenvCommand('linux')}`);
597
- console.log('');
598
- console.log('Or simply open a new terminal window.');
599
- console.log('');
600
- console.log('NOTE: Package installation will be slow on Raspberry Pi because');
601
- console.log('all packages compile from source. Consider using apt for common tools.');
602
- console.log('');
603
- console.log('Verify with: brew --version');
604
- console.log('Run diagnostics: brew doctor (expect some warnings about ARM platform)');
605
- }
606
-
607
- /**
608
- * Install build dependencies on Amazon Linux/RHEL systems.
609
- *
610
- * Installs the required packages for Homebrew to function on RHEL-based systems.
611
- * Detects whether to use dnf (Amazon Linux 2023) or yum (Amazon Linux 2).
612
- *
613
- * @returns {Promise<void>}
614
- * @throws {Error} If package installation fails
615
- */
616
- async function installRhelBuildDependencies() {
617
- console.log('Installing required build dependencies...');
618
-
619
- // Detect package manager (dnf for AL2023, yum for AL2)
620
- const hasDnf = shell.commandExists('dnf');
621
- const packageManager = hasDnf ? 'dnf' : 'yum';
622
-
623
- console.log(`Using package manager: ${packageManager}`);
624
-
625
- // Install Development Tools group
626
- console.log('Installing Development Tools group...');
627
- const groupResult = await shell.exec(
628
- `sudo ${packageManager} groupinstall -y "Development Tools"`
629
- );
630
- if (groupResult.code !== 0) {
631
- console.log('Warning: Could not install Development Tools group, trying individual packages...');
632
- // Try installing gcc and make individually
633
- await shell.exec(`sudo ${packageManager} install -y gcc gcc-c++ make`);
634
- }
635
-
636
- // Install other required dependencies
637
- // Note: Amazon Linux 2023 uses procps-ng, AL2 uses procps
638
- const procpsPkg = hasDnf ? 'procps-ng' : 'procps';
639
- const packages = [procpsPkg, 'curl', 'file', 'git'].join(' ');
640
-
641
- const installResult = await shell.exec(
642
- `sudo ${packageManager} install -y ${packages}`
643
- );
644
-
645
- if (installResult.code !== 0) {
646
- throw new Error(
647
- `Failed to install build dependencies.\n` +
648
- `Output: ${installResult.stderr}\n\n` +
649
- `Please install them manually with:\n` +
650
- ` sudo ${packageManager} groupinstall -y "Development Tools"\n` +
651
- ` sudo ${packageManager} install -y ${packages}`
652
- );
653
- }
654
-
655
- console.log('Build dependencies installed successfully.');
656
- }
657
-
658
- /**
659
- * Install Homebrew on Amazon Linux/RHEL systems.
660
- *
661
- * Prerequisites:
662
- * - Amazon Linux 2023 (AL2023) or Amazon Linux 2 (AL2)
663
- * - 64-bit x86_64 architecture
664
- * - sudo privileges
665
- * - EC2 instance or compatible environment
666
- *
667
- * Amazon Linux 2023 uses DNF as the default package manager.
668
- * Amazon Linux 2 uses YUM.
669
- *
670
- * @returns {Promise<void>}
671
- */
672
- async function install_amazon_linux() {
673
- console.log('Checking if Homebrew is already installed...');
674
-
675
- // Check if Homebrew is already installed via command
676
- const existingVersion = await getBrewVersion();
677
- if (existingVersion) {
678
- console.log(`Homebrew ${existingVersion} is already installed, skipping installation.`);
679
- return;
680
- }
681
-
682
- // Check if Homebrew directory exists but PATH is not configured
683
- if (doesBrewDirectoryExist('linux')) {
684
- console.log('Homebrew appears to be installed but not in PATH.');
685
- console.log('Configuring PATH...');
686
- await configureBrewPath('linux');
687
-
688
- // Verify it works now
689
- const versionAfterConfig = await getBrewVersion();
690
- if (versionAfterConfig) {
691
- console.log(`Homebrew ${versionAfterConfig} is now configured and ready.`);
692
- return;
693
- }
694
- }
695
-
696
- console.log('Installing Homebrew on Amazon Linux...');
697
- console.log('');
698
-
699
- // Set locale to avoid warnings during installation
700
- process.env.LC_ALL = 'en_US.UTF-8';
701
- process.env.LANG = 'en_US.UTF-8';
702
-
703
- // Install build dependencies
704
- await installRhelBuildDependencies();
705
-
706
- console.log('');
707
- console.log('Downloading and running the Homebrew installer...');
708
- console.log('This may take several minutes...');
709
- console.log('');
710
-
711
- // Run the official Homebrew installer in non-interactive mode
712
- const installResult = await shell.exec(
713
- `NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL ${HOMEBREW_INSTALL_URL})"`,
714
- { timeout: 600000 } // 10 minute timeout
715
- );
716
-
717
- if (installResult.code !== 0) {
718
- throw new Error(
719
- `Failed to install Homebrew.\n` +
720
- `Output: ${installResult.stderr || installResult.stdout}\n\n` +
721
- `Troubleshooting:\n` +
722
- ` 1. Ensure Development Tools are installed:\n` +
723
- ` sudo dnf groupinstall -y "Development Tools" # Amazon Linux 2023\n` +
724
- ` sudo yum groupinstall -y "Development Tools" # Amazon Linux 2\n` +
725
- ` 2. Install required dependencies:\n` +
726
- ` sudo dnf install -y procps-ng curl file git # Amazon Linux 2023\n` +
727
- ` sudo yum install -y procps curl file git # Amazon Linux 2\n` +
728
- ` 3. Set locale if you see locale warnings:\n` +
729
- ` export LC_ALL=en_US.UTF-8 && export LANG=en_US.UTF-8\n` +
730
- ` 4. Check your internet connection and retry.`
731
- );
732
- }
733
-
734
- // Configure PATH
735
- await configureBrewPath('linux');
736
-
737
- // Verify installation
738
- const version = await getBrewVersion();
739
- if (!version) {
740
- console.log('');
741
- console.log('Homebrew installation completed.');
742
- console.log('');
743
- console.log('IMPORTANT: To use Homebrew, either:');
744
- console.log(' 1. Open a new terminal window, OR');
745
- console.log(' 2. Run this command in your current terminal:');
746
- console.log(` ${getShellenvCommand('linux')}`);
747
- console.log('');
748
- console.log('Then verify with: brew --version');
749
- return;
750
- }
751
-
752
- console.log(`Homebrew ${version} installed successfully.`);
753
- console.log('');
754
- console.log('IMPORTANT: To use Homebrew in your current terminal, run:');
755
- console.log(` ${getShellenvCommand('linux')}`);
756
- console.log('');
757
- console.log('Or simply open a new terminal window.');
758
- console.log('');
759
- console.log('Verify with: brew --version');
760
- console.log('Run diagnostics: brew doctor');
761
- }
762
-
763
- /**
764
- * Handle Homebrew installation on native Windows.
765
- *
766
- * Homebrew does not run natively on Windows. This function informs the user
767
- * that they need to use WSL (Windows Subsystem for Linux) to use Homebrew.
768
- *
769
- * @returns {Promise<void>}
770
- */
771
- async function install_windows() {
772
- console.log('Homebrew is not available for native Windows.');
773
- console.log('');
774
- console.log('To use Homebrew on Windows, install Windows Subsystem for Linux (WSL):');
775
- console.log('');
776
- console.log('1. Open PowerShell as Administrator and run:');
777
- console.log(' wsl --install -d Ubuntu');
778
- console.log('');
779
- console.log('2. Restart your computer when prompted.');
780
- console.log('');
781
- console.log('3. After restart, open Ubuntu from the Start menu and complete setup.');
782
- console.log('');
783
- console.log('4. Then run this installer again from within WSL.');
784
- return;
785
- }
786
-
787
- /**
788
- * Install Homebrew on Ubuntu running in WSL (Windows Subsystem for Linux).
789
- *
790
- * Prerequisites:
791
- * - Windows 10 version 2004 (build 19041) or higher, or Windows 11
792
- * - WSL 2 enabled (WSL 1 has known issues with Homebrew)
793
- * - Ubuntu distribution installed in WSL
794
- * - sudo privileges within WSL
795
- *
796
- * The installation process is identical to native Ubuntu, but this function
797
- * provides WSL-specific messaging and warnings.
798
- *
799
- * @returns {Promise<void>}
800
- */
801
- async function install_ubuntu_wsl() {
802
- console.log('Detected Ubuntu running in WSL (Windows Subsystem for Linux).');
803
- console.log('');
804
-
805
- // Check if Homebrew is already installed via command
806
- const existingVersion = await getBrewVersion();
807
- if (existingVersion) {
808
- console.log(`Homebrew ${existingVersion} is already installed, skipping installation.`);
809
- return;
810
- }
811
-
812
- // Check if Homebrew directory exists but PATH is not configured
813
- if (doesBrewDirectoryExist('linux')) {
814
- console.log('Homebrew appears to be installed but not in PATH.');
815
- console.log('Configuring PATH...');
816
- await configureBrewPath('linux');
817
-
818
- // Verify it works now
819
- const versionAfterConfig = await getBrewVersion();
820
- if (versionAfterConfig) {
821
- console.log(`Homebrew ${versionAfterConfig} is now configured and ready.`);
822
- return;
823
- }
824
- }
825
-
826
- console.log('Installing Homebrew in WSL...');
827
- console.log('');
828
- console.log('NOTE: For best performance, ensure you are using WSL 2.');
829
- console.log('Check with: wsl.exe -l -v');
830
- console.log('');
831
-
832
- // Install build dependencies
833
- await installDebianBuildDependencies();
834
-
835
- console.log('');
836
- console.log('Downloading and running the Homebrew installer...');
837
- console.log('This may take several minutes...');
838
- console.log('');
839
-
840
- // Run the official Homebrew installer in non-interactive mode
841
- const installResult = await shell.exec(
842
- `NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL ${HOMEBREW_INSTALL_URL})"`,
843
- { timeout: 600000 } // 10 minute timeout
844
- );
845
-
846
- if (installResult.code !== 0) {
847
- throw new Error(
848
- `Failed to install Homebrew in WSL.\n` +
849
- `Output: ${installResult.stderr || installResult.stdout}\n\n` +
850
- `Troubleshooting:\n` +
851
- ` 1. Ensure WSL 2 is being used (WSL 1 has known issues):\n` +
852
- ` Run in PowerShell: wsl --set-version Ubuntu 2\n` +
853
- ` 2. Ensure all dependencies are installed:\n` +
854
- ` sudo apt-get install -y build-essential procps curl file git\n` +
855
- ` 3. If apt-get update fails with network errors, restart WSL:\n` +
856
- ` Run in PowerShell: wsl --shutdown\n` +
857
- ` Then reopen Ubuntu.\n` +
858
- ` 4. Check your internet connection and retry.`
859
- );
860
- }
861
-
862
- // Configure PATH
863
- await configureBrewPath('linux');
864
-
865
- // Verify installation
866
- const version = await getBrewVersion();
867
- if (!version) {
868
- console.log('');
869
- console.log('Homebrew installation completed.');
870
- console.log('');
871
- console.log('IMPORTANT: To use Homebrew, either:');
872
- console.log(' 1. Open a new terminal window, OR');
873
- console.log(' 2. Run this command in your current terminal:');
874
- console.log(` ${getShellenvCommand('linux')}`);
875
- console.log('');
876
- console.log('Then verify with: brew --version');
877
- return;
878
- }
879
-
880
- console.log(`Homebrew ${version} installed successfully in WSL.`);
881
- console.log('');
882
- console.log('IMPORTANT: To use Homebrew in your current terminal, run:');
883
- console.log(` ${getShellenvCommand('linux')}`);
884
- console.log('');
885
- console.log('Or simply open a new terminal window.');
886
- console.log('');
887
- console.log('WSL Tips:');
888
- console.log(' - Store files in ~/... (Linux filesystem) for best performance');
889
- console.log(' - Accessing /mnt/c/... (Windows filesystem) is slower');
890
- console.log(' - Configure git line endings: git config --global core.autocrlf input');
891
- console.log('');
892
- console.log('Verify with: brew --version');
893
- console.log('Run diagnostics: brew doctor');
894
- }
895
-
896
- /**
897
- * Handle Homebrew installation in Git Bash.
898
- *
899
- * Homebrew does not run in Git Bash. This function informs the user
900
- * that they need to use WSL (Windows Subsystem for Linux) to use Homebrew.
901
- *
902
- * @returns {Promise<void>}
903
- */
904
- async function install_gitbash() {
905
- console.log('Homebrew is not available for Git Bash.');
906
- console.log('');
907
- console.log('Git Bash is a Windows terminal emulator that provides a bash-like');
908
- console.log('environment but does not include a full Linux userspace required');
909
- console.log('by Homebrew.');
910
- console.log('');
911
- console.log('To use Homebrew on Windows, install Windows Subsystem for Linux (WSL):');
912
- console.log('');
913
- console.log('1. Open PowerShell as Administrator and run:');
914
- console.log(' wsl --install -d Ubuntu');
915
- console.log('');
916
- console.log('2. Restart your computer when prompted.');
917
- console.log('');
918
- console.log('3. After restart, open Ubuntu from the Start menu and complete setup.');
919
- console.log('');
920
- console.log('4. Then run this installer from within WSL.');
921
- return;
922
- }
923
-
924
- /**
925
- * Check if Homebrew is currently installed on the system.
926
- *
927
- * This function checks for Homebrew installation across all supported platforms:
928
- * - macOS: Checks if brew command exists or Homebrew directory exists
929
- * - Linux/WSL: Checks if brew command exists or Linuxbrew directory exists
930
- * - Windows/Git Bash: Always returns false (Homebrew not supported)
931
- *
932
- * @returns {Promise<boolean>} True if Homebrew is installed, false otherwise
933
- */
934
- async function isInstalled() {
935
- const platform = os.detect();
936
-
937
- // Windows and Git Bash don't support Homebrew
938
- if (platform.type === 'windows' || platform.type === 'gitbash') {
939
- return false;
940
- }
941
-
942
- // Check if brew command exists
943
- if (isBrewInstalled()) {
944
- return true;
945
- }
946
-
947
- // Also check if Homebrew directory exists (may not be in PATH)
948
- if (platform.type === 'macos') {
949
- return doesBrewDirectoryExist('macos');
950
- }
951
-
952
- // Linux platforms (including WSL)
953
- return doesBrewDirectoryExist('linux');
954
- }
955
-
956
- /**
957
- * Check if this installer is supported on the current platform.
958
- * Homebrew is supported on macOS and Linux (including WSL).
959
- * Windows and Git Bash are NOT supported (use WSL instead).
960
- * @returns {boolean} True if installation is supported on this platform
961
- */
962
- function isEligible() {
963
- const platform = os.detect();
964
- // Homebrew does NOT run natively on Windows or Git Bash
965
- return ['macos', 'ubuntu', 'debian', 'wsl', 'raspbian', 'amazon_linux', 'rhel', 'fedora'].includes(platform.type);
966
- }
967
-
968
- /**
969
- * Main installation entry point.
970
- *
971
- * Detects the current platform and runs the appropriate installer function.
972
- * Handles platform-specific mappings to ensure all supported platforms
973
- * have appropriate installation logic.
974
- *
975
- * Supported platforms:
976
- * - macOS: Native Homebrew installation
977
- * - Ubuntu/Debian: Linuxbrew installation
978
- * - Raspberry Pi OS: Linuxbrew installation (with ARM limitations)
979
- * - Amazon Linux/RHEL: Linuxbrew installation
980
- * - WSL (Ubuntu): Linuxbrew installation within WSL
981
- * - Windows (Native): Not supported, advises WSL
982
- * - Git Bash: Not supported, advises WSL
983
- *
984
- * @returns {Promise<void>}
985
- */
986
- async function install() {
987
- const platform = os.detect();
988
-
989
- // Map platform types to their installer functions
990
- const installers = {
991
- 'macos': install_macos,
992
- 'ubuntu': install_ubuntu,
993
- 'debian': install_ubuntu,
994
- 'wsl': install_ubuntu_wsl,
995
- 'raspbian': install_raspbian,
996
- 'amazon_linux': install_amazon_linux,
997
- 'rhel': install_amazon_linux,
998
- 'fedora': install_amazon_linux,
999
- 'windows': install_windows,
1000
- 'gitbash': install_gitbash
1001
- };
1002
-
1003
- const installer = installers[platform.type];
1004
-
1005
- if (!installer) {
1006
- console.log(`Homebrew is not available for ${platform.type}.`);
1007
- return;
1008
- }
1009
-
1010
- await installer();
1011
- }
1012
-
1013
- // Export all functions for use as a module and for testing
1014
- module.exports = {
1015
- install,
1016
- isInstalled,
1017
- isEligible,
1018
- install_macos,
1019
- install_ubuntu,
1020
- install_ubuntu_wsl,
1021
- install_raspbian,
1022
- install_amazon_linux,
1023
- install_windows,
1024
- install_gitbash
1025
- };
1026
-
1027
- // Allow direct execution: node homebrew.js
1028
- if (require.main === module) {
1029
- install().catch(err => {
1030
- console.error(err.message);
1031
- process.exit(1);
1032
- });
1033
- }