@fredlackey/devutils 0.0.1 → 0.0.3

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 (259) hide show
  1. package/README.md +5 -5
  2. package/package.json +1 -1
  3. package/src/commands/install.js +374 -36
  4. package/src/installs/adobe-creative-cloud.js +527 -25
  5. package/src/installs/adobe-creative-cloud.md +605 -0
  6. package/src/installs/appcleaner.js +303 -26
  7. package/src/installs/appcleaner.md +699 -0
  8. package/src/installs/apt-transport-https.js +390 -0
  9. package/src/installs/apt-transport-https.md +678 -0
  10. package/src/installs/atomicparsley.js +624 -26
  11. package/src/installs/atomicparsley.md +795 -0
  12. package/src/installs/aws-cli.js +779 -26
  13. package/src/installs/aws-cli.md +727 -0
  14. package/src/installs/balena-etcher.js +688 -26
  15. package/src/installs/balena-etcher.md +761 -0
  16. package/src/installs/bambu-studio.js +912 -26
  17. package/src/installs/bambu-studio.md +780 -0
  18. package/src/installs/bash-completion.js +554 -23
  19. package/src/installs/bash-completion.md +833 -0
  20. package/src/installs/bash.js +399 -26
  21. package/src/installs/bash.md +993 -0
  22. package/src/installs/beyond-compare.js +585 -26
  23. package/src/installs/beyond-compare.md +813 -0
  24. package/src/installs/build-essential.js +511 -26
  25. package/src/installs/build-essential.md +977 -0
  26. package/src/installs/ca-certificates.js +618 -0
  27. package/src/installs/ca-certificates.md +937 -0
  28. package/src/installs/caffeine.js +490 -26
  29. package/src/installs/caffeine.md +839 -0
  30. package/src/installs/camtasia.js +577 -25
  31. package/src/installs/camtasia.md +762 -0
  32. package/src/installs/chatgpt.js +458 -26
  33. package/src/installs/chatgpt.md +814 -0
  34. package/src/installs/chocolatey.js +447 -0
  35. package/src/installs/chocolatey.md +661 -0
  36. package/src/installs/chrome-canary.js +472 -26
  37. package/src/installs/chrome-canary.md +641 -0
  38. package/src/installs/chromium.js +645 -26
  39. package/src/installs/chromium.md +838 -0
  40. package/src/installs/claude-code.js +558 -26
  41. package/src/installs/claude-code.md +1173 -0
  42. package/src/installs/curl.js +361 -26
  43. package/src/installs/curl.md +714 -0
  44. package/src/installs/cursor.js +561 -26
  45. package/src/installs/cursor.md +970 -0
  46. package/src/installs/dbschema.js +674 -26
  47. package/src/installs/dbschema.md +925 -0
  48. package/src/installs/dependencies.md +435 -0
  49. package/src/installs/development-tools.js +600 -0
  50. package/src/installs/development-tools.md +977 -0
  51. package/src/installs/docker.js +1010 -25
  52. package/src/installs/docker.md +1109 -0
  53. package/src/installs/drawio.js +1001 -26
  54. package/src/installs/drawio.md +795 -0
  55. package/src/installs/elmedia-player.js +328 -25
  56. package/src/installs/elmedia-player.md +556 -0
  57. package/src/installs/ffmpeg.js +870 -25
  58. package/src/installs/ffmpeg.md +852 -0
  59. package/src/installs/file.js +464 -0
  60. package/src/installs/file.md +987 -0
  61. package/src/installs/gemini-cli.js +793 -26
  62. package/src/installs/gemini-cli.md +1153 -0
  63. package/src/installs/git.js +382 -26
  64. package/src/installs/git.md +907 -0
  65. package/src/installs/gitego.js +931 -26
  66. package/src/installs/gitego.md +1172 -0
  67. package/src/installs/go.js +913 -26
  68. package/src/installs/go.md +958 -0
  69. package/src/installs/google-chrome.js +801 -25
  70. package/src/installs/google-chrome.md +862 -0
  71. package/src/installs/gpg.js +412 -73
  72. package/src/installs/gpg.md +1056 -0
  73. package/src/installs/homebrew.js +1015 -26
  74. package/src/installs/homebrew.md +988 -0
  75. package/src/installs/imageoptim.js +950 -26
  76. package/src/installs/imageoptim.md +1119 -0
  77. package/src/installs/installers.json +2297 -0
  78. package/src/installs/jq.js +382 -26
  79. package/src/installs/jq.md +809 -0
  80. package/src/installs/keyboard-maestro.js +701 -26
  81. package/src/installs/keyboard-maestro.md +825 -0
  82. package/src/installs/latex.js +771 -26
  83. package/src/installs/latex.md +1095 -0
  84. package/src/installs/lftp.js +338 -26
  85. package/src/installs/lftp.md +907 -0
  86. package/src/installs/lsb-release.js +346 -0
  87. package/src/installs/lsb-release.md +814 -0
  88. package/src/installs/messenger.js +829 -26
  89. package/src/installs/messenger.md +900 -0
  90. package/src/installs/microsoft-office.js +550 -26
  91. package/src/installs/microsoft-office.md +760 -0
  92. package/src/installs/microsoft-teams.js +782 -25
  93. package/src/installs/microsoft-teams.md +886 -0
  94. package/src/installs/node.js +886 -26
  95. package/src/installs/node.md +1153 -0
  96. package/src/installs/nordpass.js +698 -26
  97. package/src/installs/nordpass.md +921 -0
  98. package/src/installs/nvm.js +977 -26
  99. package/src/installs/nvm.md +1057 -0
  100. package/src/installs/openssh.js +734 -64
  101. package/src/installs/openssh.md +1056 -0
  102. package/src/installs/pandoc.js +644 -26
  103. package/src/installs/pandoc.md +1036 -0
  104. package/src/installs/pinentry.js +492 -26
  105. package/src/installs/pinentry.md +1142 -0
  106. package/src/installs/pngyu.js +851 -26
  107. package/src/installs/pngyu.md +896 -0
  108. package/src/installs/postman.js +781 -26
  109. package/src/installs/postman.md +940 -0
  110. package/src/installs/procps.js +425 -0
  111. package/src/installs/procps.md +851 -0
  112. package/src/installs/safari-tech-preview.js +355 -25
  113. package/src/installs/safari-tech-preview.md +533 -0
  114. package/src/installs/sfnt2woff.js +640 -26
  115. package/src/installs/sfnt2woff.md +795 -0
  116. package/src/installs/shellcheck.js +463 -26
  117. package/src/installs/shellcheck.md +1005 -0
  118. package/src/installs/slack.js +722 -25
  119. package/src/installs/slack.md +865 -0
  120. package/src/installs/snagit.js +566 -25
  121. package/src/installs/snagit.md +844 -0
  122. package/src/installs/software-properties-common.js +372 -0
  123. package/src/installs/software-properties-common.md +805 -0
  124. package/src/installs/spotify.js +858 -25
  125. package/src/installs/spotify.md +901 -0
  126. package/src/installs/studio-3t.js +803 -26
  127. package/src/installs/studio-3t.md +918 -0
  128. package/src/installs/sublime-text.js +780 -25
  129. package/src/installs/sublime-text.md +914 -0
  130. package/src/installs/superwhisper.js +687 -25
  131. package/src/installs/superwhisper.md +630 -0
  132. package/src/installs/tailscale.js +727 -26
  133. package/src/installs/tailscale.md +1100 -0
  134. package/src/installs/tar.js +389 -0
  135. package/src/installs/tar.md +946 -0
  136. package/src/installs/termius.js +780 -26
  137. package/src/installs/termius.md +844 -0
  138. package/src/installs/terraform.js +761 -26
  139. package/src/installs/terraform.md +899 -0
  140. package/src/installs/tidal.js +752 -25
  141. package/src/installs/tidal.md +864 -0
  142. package/src/installs/tmux.js +328 -26
  143. package/src/installs/tmux.md +1030 -0
  144. package/src/installs/tree.js +393 -26
  145. package/src/installs/tree.md +833 -0
  146. package/src/installs/unzip.js +460 -0
  147. package/src/installs/unzip.md +879 -0
  148. package/src/installs/vim.js +403 -26
  149. package/src/installs/vim.md +1040 -0
  150. package/src/installs/vlc.js +803 -26
  151. package/src/installs/vlc.md +927 -0
  152. package/src/installs/vscode.js +825 -26
  153. package/src/installs/vscode.md +1002 -0
  154. package/src/installs/wget.js +415 -0
  155. package/src/installs/wget.md +791 -0
  156. package/src/installs/whatsapp.js +710 -25
  157. package/src/installs/whatsapp.md +854 -0
  158. package/src/installs/winpty.js +352 -0
  159. package/src/installs/winpty.md +620 -0
  160. package/src/installs/woff2.js +535 -26
  161. package/src/installs/woff2.md +977 -0
  162. package/src/installs/wsl.js +572 -0
  163. package/src/installs/wsl.md +699 -0
  164. package/src/installs/xcode-clt.js +520 -0
  165. package/src/installs/xcode-clt.md +351 -0
  166. package/src/installs/xcode.js +542 -26
  167. package/src/installs/xcode.md +573 -0
  168. package/src/installs/yarn.js +806 -26
  169. package/src/installs/yarn.md +1074 -0
  170. package/src/installs/yq.js +636 -26
  171. package/src/installs/yq.md +944 -0
  172. package/src/installs/yt-dlp.js +683 -26
  173. package/src/installs/yt-dlp.md +946 -0
  174. package/src/installs/yum-utils.js +297 -0
  175. package/src/installs/yum-utils.md +648 -0
  176. package/src/installs/zoom.js +740 -25
  177. package/src/installs/zoom.md +884 -0
  178. package/src/scripts/README.md +567 -45
  179. package/src/scripts/STATUS.md +208 -0
  180. package/src/scripts/afk.js +395 -7
  181. package/src/scripts/backup-all.js +731 -9
  182. package/src/scripts/backup-source.js +711 -8
  183. package/src/scripts/brewd.js +373 -7
  184. package/src/scripts/brewi.js +505 -9
  185. package/src/scripts/brewr.js +512 -9
  186. package/src/scripts/brews.js +462 -9
  187. package/src/scripts/brewu.js +488 -7
  188. package/src/scripts/c.js +185 -7
  189. package/src/scripts/ccurl.js +325 -8
  190. package/src/scripts/certbot-crontab-init.js +488 -8
  191. package/src/scripts/certbot-init.js +641 -9
  192. package/src/scripts/ch.js +339 -7
  193. package/src/scripts/claude-danger.js +253 -8
  194. package/src/scripts/clean-dev.js +419 -8
  195. package/src/scripts/clear-dns-cache.js +525 -7
  196. package/src/scripts/clone.js +417 -7
  197. package/src/scripts/code-all.js +420 -7
  198. package/src/scripts/count-files.js +195 -8
  199. package/src/scripts/count-folders.js +195 -8
  200. package/src/scripts/count.js +248 -8
  201. package/src/scripts/d.js +203 -7
  202. package/src/scripts/datauri.js +373 -8
  203. package/src/scripts/delete-files.js +363 -7
  204. package/src/scripts/docker-clean.js +410 -8
  205. package/src/scripts/dp.js +426 -7
  206. package/src/scripts/e.js +375 -9
  207. package/src/scripts/empty-trash.js +497 -7
  208. package/src/scripts/evm.js +428 -9
  209. package/src/scripts/fetch-github-repos.js +441 -10
  210. package/src/scripts/get-channel.js +329 -8
  211. package/src/scripts/get-course.js +384 -11
  212. package/src/scripts/get-dependencies.js +290 -9
  213. package/src/scripts/get-folder.js +783 -10
  214. package/src/scripts/get-tunes.js +411 -10
  215. package/src/scripts/get-video.js +352 -9
  216. package/src/scripts/git-backup.js +561 -9
  217. package/src/scripts/git-clone.js +477 -9
  218. package/src/scripts/git-pup.js +303 -7
  219. package/src/scripts/git-push.js +380 -8
  220. package/src/scripts/h.js +607 -9
  221. package/src/scripts/hide-desktop-icons.js +483 -7
  222. package/src/scripts/hide-hidden-files.js +522 -7
  223. package/src/scripts/install-dependencies-from.js +440 -9
  224. package/src/scripts/ips.js +647 -10
  225. package/src/scripts/iso.js +354 -8
  226. package/src/scripts/killni.js +561 -7
  227. package/src/scripts/ll.js +451 -8
  228. package/src/scripts/local-ip.js +310 -8
  229. package/src/scripts/m.js +508 -8
  230. package/src/scripts/map.js +293 -8
  231. package/src/scripts/mkd.js +287 -7
  232. package/src/scripts/ncu-update-all.js +441 -8
  233. package/src/scripts/nginx-init.js +702 -12
  234. package/src/scripts/npmi.js +366 -7
  235. package/src/scripts/o.js +495 -8
  236. package/src/scripts/org-by-date.js +321 -7
  237. package/src/scripts/p.js +208 -7
  238. package/src/scripts/packages.js +313 -8
  239. package/src/scripts/path.js +209 -7
  240. package/src/scripts/ports.js +582 -8
  241. package/src/scripts/q.js +290 -8
  242. package/src/scripts/refresh-files.js +378 -10
  243. package/src/scripts/remove-smaller-files.js +500 -8
  244. package/src/scripts/rename-files-with-date.js +517 -9
  245. package/src/scripts/resize-image.js +523 -9
  246. package/src/scripts/rm-safe.js +653 -8
  247. package/src/scripts/s.js +525 -9
  248. package/src/scripts/set-git-public.js +349 -7
  249. package/src/scripts/show-desktop-icons.js +459 -7
  250. package/src/scripts/show-hidden-files.js +456 -7
  251. package/src/scripts/tpa.js +265 -8
  252. package/src/scripts/tpo.js +264 -7
  253. package/src/scripts/u.js +489 -7
  254. package/src/scripts/vpush.js +422 -8
  255. package/src/scripts/y.js +267 -7
  256. package/src/utils/common/os.js +94 -2
  257. package/src/utils/ubuntu/apt.js +13 -7
  258. package/src/utils/windows/choco.js +82 -26
  259. package/src/utils/windows/winget.js +89 -27
@@ -1,44 +1,663 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * @fileoverview Install Chromium.
4
+ * @fileoverview Install Chromium - the open-source web browser.
5
+ *
6
+ * Chromium is the free and open-source browser project that forms the
7
+ * foundation for Google Chrome and many other browsers. This installer
8
+ * provides idempotent installation across macOS, Ubuntu/Debian, Raspberry Pi OS,
9
+ * Amazon Linux, Windows, WSL, and Git Bash.
10
+ *
5
11
  * @module installs/chromium
6
12
  */
7
13
 
8
14
  const os = require('../utils/common/os');
15
+ const shell = require('../utils/common/shell');
16
+ const fs = require('fs');
17
+ const path = require('path');
18
+
19
+ /**
20
+ * Whether this installer requires a desktop environment to function.
21
+ * Chromium is a GUI web browser.
22
+ */
23
+ const REQUIRES_DESKTOP = true;
24
+
25
+ // Platform-specific utilities are loaded dynamically to avoid loading
26
+ // unnecessary modules on platforms where they are not needed
27
+
28
+ /**
29
+ * Checks if Chromium is already installed on macOS by looking for the
30
+ * application bundle in /Applications or ~/Applications.
31
+ *
32
+ * @returns {boolean} True if Chromium.app exists, false otherwise
33
+ */
34
+ function isChromiumInstalledOnMacOS() {
35
+ const appPaths = [
36
+ '/Applications/Chromium.app',
37
+ path.join(os.getHomeDir(), 'Applications', 'Chromium.app')
38
+ ];
39
+
40
+ for (const appPath of appPaths) {
41
+ if (fs.existsSync(appPath)) {
42
+ return true;
43
+ }
44
+ }
45
+
46
+ return false;
47
+ }
48
+
49
+ /**
50
+ * Install Chromium on macOS using Homebrew.
51
+ *
52
+ * Chromium is installed as a cask (GUI application) via Homebrew.
53
+ * The --no-quarantine flag is used to prevent macOS Gatekeeper from
54
+ * blocking the unsigned application.
55
+ *
56
+ * @returns {Promise<void>}
57
+ */
58
+ async function install_macos() {
59
+ const brew = require('../utils/macos/brew');
60
+
61
+ // Step 1: Check if Chromium is already installed
62
+ // We check for the .app bundle directly since that's more reliable
63
+ // than checking the cask status for GUI applications
64
+ if (isChromiumInstalledOnMacOS()) {
65
+ console.log('Chromium is already installed, skipping...');
66
+ return;
67
+ }
68
+
69
+ // Step 2: Verify Homebrew is available
70
+ if (!brew.isInstalled()) {
71
+ console.log('Homebrew is required to install Chromium on macOS.');
72
+ console.log('Please install Homebrew first: https://brew.sh');
73
+ return;
74
+ }
75
+
76
+ // Step 3: Install Chromium via Homebrew cask with --no-quarantine
77
+ // The --no-quarantine flag prevents Gatekeeper from blocking the app
78
+ // since Chromium is not signed by an Apple Developer certificate
79
+ console.log('Installing Chromium via Homebrew...');
80
+ const result = await shell.exec('brew install --cask --quiet chromium --no-quarantine');
81
+
82
+ if (result.code !== 0) {
83
+ console.log('Failed to install Chromium.');
84
+ console.log(result.stderr || result.stdout);
85
+ return;
86
+ }
87
+
88
+ // Step 4: Verify installation succeeded
89
+ if (!isChromiumInstalledOnMacOS()) {
90
+ console.log('Installation completed but Chromium.app was not found.');
91
+ return;
92
+ }
93
+
94
+ console.log('Chromium installed successfully.');
95
+ }
96
+
97
+ /**
98
+ * Install Chromium on Ubuntu/Debian using Snap.
99
+ *
100
+ * Since Ubuntu 20.04, the APT chromium-browser package is a transitional
101
+ * package that installs the Snap version. We use Snap directly for
102
+ * consistent behavior across Ubuntu and Debian systems.
103
+ *
104
+ * @returns {Promise<void>}
105
+ */
106
+ async function install_ubuntu() {
107
+ const snap = require('../utils/ubuntu/snap');
108
+
109
+ // Step 1: Check if Chromium is already installed via Snap
110
+ const isInstalled = await snap.isSnapInstalled('chromium');
111
+ if (isInstalled) {
112
+ console.log('Chromium is already installed, skipping...');
113
+ return;
114
+ }
115
+
116
+ // Step 2: Verify Snap is available
117
+ if (!snap.isInstalled()) {
118
+ console.log('Snap is required to install Chromium on Ubuntu/Debian.');
119
+ console.log('Installing snapd...');
120
+
121
+ // Attempt to install snapd via apt
122
+ const aptResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update -y && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y snapd');
123
+
124
+ if (aptResult.code !== 0 || !snap.isInstalled()) {
125
+ console.log('Failed to install snapd. Please install it manually.');
126
+ return;
127
+ }
128
+ }
129
+
130
+ // Step 3: Install Chromium via Snap
131
+ console.log('Installing Chromium via Snap...');
132
+ const result = await snap.install('chromium');
133
+
134
+ if (!result.success) {
135
+ console.log('Failed to install Chromium.');
136
+ console.log(result.output);
137
+ return;
138
+ }
139
+
140
+ // Step 4: Verify installation succeeded
141
+ const verifyInstalled = await snap.isSnapInstalled('chromium');
142
+ if (!verifyInstalled) {
143
+ console.log('Installation completed but Chromium was not found.');
144
+ return;
145
+ }
146
+
147
+ console.log('Chromium installed successfully.');
148
+ console.log('Note: You may need to log out and log back in for Chromium to appear in your application menu.');
149
+ }
150
+
151
+ /**
152
+ * Install Chromium on Ubuntu running in WSL (Windows Subsystem for Linux).
153
+ *
154
+ * Running GUI applications in WSL requires WSLg (Windows 11 or Windows 10 21H2+)
155
+ * or an X server on Windows. This function installs Chromium using Snap,
156
+ * similar to native Ubuntu installation.
157
+ *
158
+ * @returns {Promise<void>}
159
+ */
160
+ async function install_ubuntu_wsl() {
161
+ const snap = require('../utils/ubuntu/snap');
162
+ const apt = require('../utils/ubuntu/apt');
163
+
164
+ // Step 1: Check if Chromium is already installed
165
+ // In WSL, we check both snap and apt since the user might have installed via either
166
+ const snapInstalled = await snap.isSnapInstalled('chromium');
167
+ if (snapInstalled) {
168
+ console.log('Chromium is already installed via Snap, skipping...');
169
+ return;
170
+ }
171
+
172
+ // Also check if installed via APT (chromium-browser package)
173
+ const aptInstalled = await apt.isPackageInstalled('chromium-browser');
174
+ if (aptInstalled) {
175
+ console.log('Chromium is already installed via APT, skipping...');
176
+ return;
177
+ }
178
+
179
+ // Step 2: Try Snap first (preferred method)
180
+ if (snap.isInstalled()) {
181
+ console.log('Installing Chromium via Snap...');
182
+ const result = await snap.install('chromium');
183
+
184
+ if (result.success) {
185
+ const verifyInstalled = await snap.isSnapInstalled('chromium');
186
+ if (verifyInstalled) {
187
+ console.log('Chromium installed successfully.');
188
+ console.log('Note: WSLg (Windows 11 or Windows 10 21H2+) or an X server is required to run GUI applications.');
189
+ return;
190
+ }
191
+ }
192
+
193
+ // If Snap installation fails (common in WSL due to systemd issues),
194
+ // fall back to APT
195
+ console.log('Snap installation failed, trying APT...');
196
+ }
197
+
198
+ // Step 3: Fall back to APT if Snap is not available or fails
199
+ console.log('Installing Chromium via APT...');
200
+
201
+ // Update package lists first
202
+ const updateResult = await apt.update();
203
+ if (!updateResult.success) {
204
+ console.log('Warning: apt-get update failed, continuing anyway...');
205
+ }
206
+
207
+ // Install chromium-browser package
208
+ const result = await apt.install('chromium-browser');
209
+
210
+ if (!result.success) {
211
+ console.log('Failed to install Chromium.');
212
+ console.log(result.output);
213
+ return;
214
+ }
215
+
216
+ // Step 4: Verify installation
217
+ const verifyInstalled = await apt.isPackageInstalled('chromium-browser');
218
+ if (!verifyInstalled) {
219
+ console.log('Installation completed but Chromium was not found.');
220
+ return;
221
+ }
222
+
223
+ console.log('Chromium installed successfully.');
224
+ console.log('Note: WSLg (Windows 11 or Windows 10 21H2+) or an X server is required to run GUI applications.');
225
+ }
226
+
227
+ /**
228
+ * Install Chromium on Raspberry Pi OS using APT.
229
+ *
230
+ * Raspberry Pi OS includes Chromium in its official repositories with
231
+ * ARM-specific optimizations. APT is the preferred installation method
232
+ * for best performance on Raspberry Pi hardware.
233
+ *
234
+ * @returns {Promise<void>}
235
+ */
236
+ async function install_raspbian() {
237
+ const apt = require('../utils/ubuntu/apt');
238
+
239
+ // Step 1: Check if Chromium is already installed
240
+ // Raspberry Pi OS uses 'chromium-browser' as the package name
241
+ const isInstalled = await apt.isPackageInstalled('chromium-browser');
242
+ if (isInstalled) {
243
+ console.log('Chromium is already installed, skipping...');
244
+ return;
245
+ }
246
+
247
+ // Step 2: Update package lists to ensure we get the latest version
248
+ console.log('Updating package lists...');
249
+ const updateResult = await apt.update();
250
+ if (!updateResult.success) {
251
+ console.log('Warning: apt-get update failed, continuing anyway...');
252
+ }
253
+
254
+ // Step 3: Install chromium-browser package
255
+ console.log('Installing Chromium via APT...');
256
+ const result = await apt.install('chromium-browser');
257
+
258
+ if (!result.success) {
259
+ console.log('Failed to install Chromium.');
260
+ console.log(result.output);
261
+ return;
262
+ }
263
+
264
+ // Step 4: Verify installation succeeded
265
+ const verifyInstalled = await apt.isPackageInstalled('chromium-browser');
266
+ if (!verifyInstalled) {
267
+ console.log('Installation completed but Chromium was not found.');
268
+ return;
269
+ }
270
+
271
+ console.log('Chromium installed successfully.');
272
+ }
273
+
274
+ /**
275
+ * Install Chromium on Amazon Linux using DNF/YUM.
276
+ *
277
+ * Chromium is not available in the default Amazon Linux repositories.
278
+ * On Amazon Linux 2023, we install Google Chrome (based on Chromium)
279
+ * using the direct RPM download. On Amazon Linux 2, we use EPEL.
280
+ *
281
+ * Note: This installs Google Chrome Stable as a Chromium alternative
282
+ * since pure Chromium packages are not readily available for Amazon Linux.
283
+ *
284
+ * @returns {Promise<void>}
285
+ */
286
+ async function install_amazon_linux() {
287
+ // Step 1: Check if Chrome/Chromium is already installed
288
+ // Check for google-chrome-stable first (AL2023 method)
289
+ const chromeExists = shell.commandExists('google-chrome-stable');
290
+ if (chromeExists) {
291
+ console.log('Google Chrome (Chromium-based) is already installed, skipping...');
292
+ return;
293
+ }
294
+
295
+ // Also check for chromium-browser (AL2 EPEL method)
296
+ const chromiumExists = shell.commandExists('chromium-browser');
297
+ if (chromiumExists) {
298
+ console.log('Chromium is already installed, skipping...');
299
+ return;
300
+ }
301
+
302
+ // Step 2: Determine which Amazon Linux version we're on
303
+ // Amazon Linux 2023 uses dnf, Amazon Linux 2 uses yum
304
+ const hasDnf = shell.commandExists('dnf');
305
+
306
+ if (hasDnf) {
307
+ // Amazon Linux 2023: Install Google Chrome via direct RPM
308
+ console.log('Installing Google Chrome (Chromium-based) via DNF...');
309
+
310
+ // First, install required dependencies
311
+ const depsResult = await shell.exec('sudo dnf install -y libXcomposite libXdamage libXrandr libgbm libxkbcommon pango alsa-lib atk at-spi2-atk cups-libs libdrm');
312
+ if (depsResult.code !== 0) {
313
+ console.log('Warning: Some dependencies may not have installed correctly.');
314
+ }
315
+
316
+ // Install Chrome from Google's RPM repository
317
+ const result = await shell.exec('sudo dnf install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm');
318
+
319
+ if (result.code !== 0) {
320
+ console.log('Failed to install Google Chrome.');
321
+ console.log(result.stderr || result.stdout);
322
+ return;
323
+ }
324
+
325
+ // Verify installation
326
+ const verifyInstalled = shell.commandExists('google-chrome-stable');
327
+ if (!verifyInstalled) {
328
+ console.log('Installation completed but Google Chrome was not found.');
329
+ return;
330
+ }
331
+
332
+ console.log('Google Chrome (Chromium-based) installed successfully.');
333
+ console.log('Run with: google-chrome-stable');
334
+
335
+ } else {
336
+ // Amazon Linux 2: Install via EPEL repository
337
+ console.log('Installing Chromium via YUM (EPEL)...');
338
+
339
+ // Enable EPEL repository
340
+ const epelResult = await shell.exec('sudo amazon-linux-extras install -y epel');
341
+ if (epelResult.code !== 0) {
342
+ console.log('Failed to enable EPEL repository.');
343
+ console.log(epelResult.stderr || epelResult.stdout);
344
+ return;
345
+ }
346
+
347
+ // Install Chromium
348
+ const result = await shell.exec('sudo yum install -y chromium');
349
+
350
+ if (result.code !== 0) {
351
+ console.log('Failed to install Chromium.');
352
+ console.log(result.stderr || result.stdout);
353
+ return;
354
+ }
355
+
356
+ // Verify installation
357
+ const verifyInstalled = shell.commandExists('chromium-browser');
358
+ if (!verifyInstalled) {
359
+ console.log('Installation completed but Chromium was not found.');
360
+ return;
361
+ }
362
+
363
+ console.log('Chromium installed successfully.');
364
+ console.log('Note: Amazon Linux 2 reached end of standard support on June 30, 2025.');
365
+ }
366
+ }
367
+
368
+ /**
369
+ * Install Chromium on Windows using Chocolatey.
370
+ *
371
+ * The Chocolatey 'chromium' package installs development snapshot builds.
372
+ * For a more stable Chromium-based browser, consider using 'ungoogled-chromium'.
373
+ *
374
+ * @returns {Promise<void>}
375
+ */
376
+ async function install_windows() {
377
+ const choco = require('../utils/windows/choco');
378
+
379
+ // Step 1: Check if Chromium is already installed via Chocolatey
380
+ const isInstalled = await choco.isPackageInstalled('chromium');
381
+ if (isInstalled) {
382
+ console.log('Chromium is already installed, skipping...');
383
+ return;
384
+ }
385
+
386
+ // Also check if the chromium command exists (might be installed via other means)
387
+ if (shell.commandExists('chromium')) {
388
+ console.log('Chromium is already installed, skipping...');
389
+ return;
390
+ }
391
+
392
+ // Step 2: Verify Chocolatey is available
393
+ if (!choco.isInstalled()) {
394
+ console.log('Chocolatey is required to install Chromium on Windows.');
395
+ console.log('Please install Chocolatey first: https://chocolatey.org/install');
396
+ return;
397
+ }
398
+
399
+ // Step 3: Install Chromium via Chocolatey
400
+ console.log('Installing Chromium via Chocolatey...');
401
+ const result = await choco.install('chromium');
402
+
403
+ if (!result.success) {
404
+ console.log('Failed to install Chromium.');
405
+ console.log(result.output);
406
+ return;
407
+ }
408
+
409
+ // Step 4: Verify installation succeeded
410
+ const verifyInstalled = await choco.isPackageInstalled('chromium');
411
+ if (!verifyInstalled) {
412
+ console.log('Installation completed but Chromium was not found.');
413
+ return;
414
+ }
415
+
416
+ console.log('Chromium installed successfully.');
417
+ console.log('Note: You may need to open a new terminal window for the chromium command to be available.');
418
+ }
419
+
420
+ /**
421
+ * Install Chromium on Git Bash (Windows) using Chocolatey.
422
+ *
423
+ * Git Bash runs in a Windows environment, so we use the same Chocolatey
424
+ * installation method as native Windows. The portable installation method
425
+ * is available as an alternative for environments without package managers.
426
+ *
427
+ * @returns {Promise<void>}
428
+ */
429
+ async function install_gitbash() {
430
+ // Git Bash runs on Windows, so we can use Chocolatey if available
431
+ const chocoPath = '/c/ProgramData/chocolatey/bin/choco.exe';
432
+
433
+ // Step 1: Check if Chromium is already accessible
434
+ if (shell.commandExists('chromium')) {
435
+ console.log('Chromium is already installed, skipping...');
436
+ return;
437
+ }
438
+
439
+ // Check for Chromium in common portable installation location
440
+ const portablePath = path.join(os.getHomeDir(), 'Applications', 'Chromium', 'chromium.exe');
441
+ if (fs.existsSync(portablePath)) {
442
+ console.log('Chromium is already installed (portable), skipping...');
443
+ return;
444
+ }
445
+
446
+ // Step 2: Try Chocolatey installation first
447
+ const chocoExists = fs.existsSync(chocoPath) || shell.commandExists('choco');
448
+
449
+ if (chocoExists) {
450
+ console.log('Installing Chromium via Chocolatey...');
451
+ const result = await shell.exec('choco install chromium -y');
452
+
453
+ if (result.code === 0) {
454
+ console.log('Chromium installed successfully.');
455
+ console.log('Note: You may need to open a new terminal window for the chromium command to be available.');
456
+ return;
457
+ }
458
+
459
+ console.log('Chocolatey installation failed, attempting portable installation...');
460
+ }
461
+
462
+ // Step 3: Fall back to portable installation using chrlauncher
463
+ console.log('Installing Chromium (portable) via chrlauncher...');
464
+
465
+ // Create installation directory
466
+ const installDir = path.join(os.getHomeDir(), 'Applications', 'Chromium');
467
+ if (!fs.existsSync(installDir)) {
468
+ fs.mkdirSync(installDir, { recursive: true });
469
+ }
470
+
471
+ // Download chrlauncher
472
+ const zipPath = path.join(installDir, 'chrlauncher.zip');
473
+ const downloadUrl = 'https://github.com/niclaslson/niclaslson.github.io/raw/refs/heads/main/files/chrlauncher_v3.4.7_64.zip';
474
+
475
+ const downloadResult = await shell.exec(`curl -L -o "${zipPath}" "${downloadUrl}"`);
476
+ if (downloadResult.code !== 0) {
477
+ console.log('Failed to download chrlauncher.');
478
+ console.log(downloadResult.stderr || downloadResult.stdout);
479
+ return;
480
+ }
481
+
482
+ // Extract the launcher
483
+ const unzipResult = await shell.exec(`unzip -o -q "${zipPath}" -d "${installDir}"`);
484
+ if (unzipResult.code !== 0) {
485
+ console.log('Failed to extract chrlauncher.');
486
+ console.log(unzipResult.stderr || unzipResult.stdout);
487
+ return;
488
+ }
489
+
490
+ // Clean up zip file
491
+ try {
492
+ fs.unlinkSync(zipPath);
493
+ } catch (err) {
494
+ // Ignore cleanup errors
495
+ }
496
+
497
+ console.log('Chromium portable installation prepared successfully.');
498
+ console.log(`Run the launcher to download Chromium: ${path.join(installDir, 'chrlauncher.exe')}`);
499
+ console.log('Add the following to your ~/.bashrc to include Chromium in PATH:');
500
+ console.log(` export PATH="$HOME/Applications/Chromium:$PATH"`);
501
+ }
502
+
503
+ /**
504
+ * Check if Chromium is installed on the current platform.
505
+ *
506
+ * This function performs platform-specific checks to determine if Chromium
507
+ * is already installed:
508
+ * - macOS: Checks for Chromium.app in /Applications
509
+ * - Windows: Checks for Chocolatey package or chromium command
510
+ * - Ubuntu/Debian/WSL: Checks for Snap package
511
+ * - Raspberry Pi: Checks for APT package
512
+ * - Amazon Linux: Checks for google-chrome-stable or chromium-browser command
513
+ *
514
+ * @returns {Promise<boolean>} True if Chromium is installed
515
+ */
516
+ async function isInstalled() {
517
+ const platform = os.detect();
518
+
519
+ // macOS: Check for Chromium.app
520
+ if (platform.type === 'macos') {
521
+ return isChromiumInstalledOnMacOS();
522
+ }
523
+
524
+ // Windows: Check for Chocolatey package or command
525
+ if (platform.type === 'windows') {
526
+ const choco = require('../utils/windows/choco');
527
+ const isPackageInstalled = await choco.isPackageInstalled('chromium');
528
+ if (isPackageInstalled) {
529
+ return true;
530
+ }
531
+ return shell.commandExists('chromium');
532
+ }
533
+
534
+ // Git Bash: Check for command or portable installation
535
+ if (platform.type === 'gitbash') {
536
+ if (shell.commandExists('chromium')) {
537
+ return true;
538
+ }
539
+ // Check portable installation location
540
+ const portablePath = path.join(os.getHomeDir(), 'Applications', 'Chromium', 'chromium.exe');
541
+ return fs.existsSync(portablePath);
542
+ }
543
+
544
+ // Ubuntu/Debian: Check for Snap package
545
+ if (['ubuntu', 'debian'].includes(platform.type)) {
546
+ const snap = require('../utils/ubuntu/snap');
547
+ return await snap.isSnapInstalled('chromium');
548
+ }
549
+
550
+ // WSL: Check for Snap or APT package
551
+ if (platform.type === 'wsl') {
552
+ const snap = require('../utils/ubuntu/snap');
553
+ const apt = require('../utils/ubuntu/apt');
554
+ const snapInstalled = await snap.isSnapInstalled('chromium');
555
+ if (snapInstalled) return true;
556
+ return await apt.isPackageInstalled('chromium-browser');
557
+ }
558
+
559
+ // Raspberry Pi: Check for APT package
560
+ if (platform.type === 'raspbian') {
561
+ const apt = require('../utils/ubuntu/apt');
562
+ return await apt.isPackageInstalled('chromium-browser');
563
+ }
564
+
565
+ // Amazon Linux/RHEL/Fedora: Check for Chrome or Chromium command
566
+ if (['amazon_linux', 'rhel', 'fedora'].includes(platform.type)) {
567
+ return shell.commandExists('google-chrome-stable') || shell.commandExists('chromium-browser');
568
+ }
569
+
570
+ return false;
571
+ }
9
572
 
10
573
  /**
11
- * Install Chromium across supported platforms.
574
+ * Check if this installer is supported on the current platform.
575
+ *
576
+ * Chromium can be installed on all supported platforms:
577
+ * - macOS (via Homebrew cask)
578
+ * - Ubuntu/Debian (via Snap)
579
+ * - Ubuntu on WSL (via Snap or APT)
580
+ * - Raspberry Pi OS (via APT)
581
+ * - Amazon Linux/RHEL/Fedora (via DNF/YUM or Chrome RPM)
582
+ * - Windows (via Chocolatey)
583
+ * - Git Bash (via Chocolatey or portable)
584
+ *
585
+ * @returns {boolean} True if installation is supported on this platform
586
+ */
587
+ function isEligible() {
588
+ const platform = os.detect();
589
+ const supportedPlatforms = ['macos', 'ubuntu', 'debian', 'wsl', 'raspbian', 'amazon_linux', 'rhel', 'fedora', 'windows', 'gitbash'];
590
+ if (!supportedPlatforms.includes(platform.type)) {
591
+ return false;
592
+ }
593
+ if (REQUIRES_DESKTOP && !os.isDesktopAvailable()) {
594
+ return false;
595
+ }
596
+ return true;
597
+ }
598
+
599
+ /**
600
+ * Main installation entry point - detects the current platform and
601
+ * runs the appropriate installer function.
602
+ *
603
+ * Supported platforms:
604
+ * - macOS: Homebrew cask
605
+ * - Ubuntu/Debian: Snap
606
+ * - Ubuntu on WSL: Snap or APT
607
+ * - Raspberry Pi OS: APT
608
+ * - Amazon Linux/RHEL: DNF (Chrome) or YUM (EPEL)
609
+ * - Windows: Chocolatey
610
+ * - Git Bash: Chocolatey or portable
12
611
  *
13
612
  * @returns {Promise<void>}
14
613
  */
15
614
  async function install() {
16
615
  const platform = os.detect();
17
616
 
18
- switch (platform.type) {
19
- case 'macos':
20
- // TODO: Implement macOS installation
21
- break;
22
- case 'debian':
23
- // TODO: Implement Debian/Ubuntu installation
24
- break;
25
- case 'rhel':
26
- // TODO: Implement RHEL/Amazon Linux installation
27
- break;
28
- case 'windows-wsl':
29
- // TODO: Implement WSL installation
30
- break;
31
- case 'windows':
32
- // TODO: Implement Windows installation
33
- break;
34
- default:
35
- console.error(`Unsupported platform: ${platform.type}`);
36
- process.exit(1);
37
- }
38
- }
39
-
40
- module.exports = { install };
617
+ // Map platform types to their installer functions
618
+ const installers = {
619
+ 'macos': install_macos,
620
+ 'ubuntu': install_ubuntu,
621
+ 'debian': install_ubuntu,
622
+ 'wsl': install_ubuntu_wsl,
623
+ 'raspbian': install_raspbian,
624
+ 'amazon_linux': install_amazon_linux,
625
+ 'rhel': install_amazon_linux,
626
+ 'fedora': install_amazon_linux,
627
+ 'windows': install_windows,
628
+ 'gitbash': install_gitbash,
629
+ };
630
+
631
+ const installer = installers[platform.type];
632
+
633
+ if (!installer) {
634
+ // Gracefully handle unsupported platforms without throwing errors
635
+ console.log(`Chromium is not available for ${platform.type}.`);
636
+ return;
637
+ }
638
+
639
+ await installer();
640
+ }
641
+
642
+ // Export all functions for testing and programmatic use
643
+ module.exports = {
644
+ REQUIRES_DESKTOP,
645
+ install,
646
+ isInstalled,
647
+ isEligible,
648
+ install_macos,
649
+ install_ubuntu,
650
+ install_ubuntu_wsl,
651
+ install_raspbian,
652
+ install_amazon_linux,
653
+ install_windows,
654
+ install_gitbash,
655
+ };
41
656
 
657
+ // Allow running directly from command line: node chromium.js
42
658
  if (require.main === module) {
43
- install();
659
+ install().catch(err => {
660
+ console.error(err.message);
661
+ process.exit(1);
662
+ });
44
663
  }