@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,706 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * @fileoverview Install Balena Etcher.
4
+ * @fileoverview Install Balena Etcher - a powerful OS image flasher for SD cards and USB drives.
5
5
  * @module installs/balena-etcher
6
+ *
7
+ * Balena Etcher is a GUI application that safely flashes OS images to SD cards and USB drives.
8
+ * It validates writes to ensure data integrity and includes safeguards against accidental
9
+ * overwrites of system drives.
10
+ *
11
+ * Supported platforms:
12
+ * - macOS: Homebrew cask
13
+ * - Ubuntu/Debian: Direct .deb download from GitHub
14
+ * - Raspberry Pi OS: Pi-Apps (requires 64-bit)
15
+ * - Amazon Linux/RHEL: Direct .rpm download from GitHub
16
+ * - Windows: Chocolatey or winget
17
+ * - WSL: Direct .deb download (requires WSLg for GUI)
18
+ * - Git Bash: Uses Windows Chocolatey
6
19
  */
7
20
 
21
+ const fs = require('fs');
22
+ const path = require('path');
8
23
  const os = require('../utils/common/os');
24
+ const shell = require('../utils/common/shell');
25
+ const brew = require('../utils/macos/brew');
26
+ const apt = require('../utils/ubuntu/apt');
27
+ const choco = require('../utils/windows/choco');
28
+ const winget = require('../utils/windows/winget');
29
+ const macosApps = require('../utils/macos/apps');
30
+
31
+ /**
32
+ * Whether this installer requires a desktop environment to function.
33
+ * Balena Etcher is a GUI application for flashing OS images.
34
+ */
35
+ const REQUIRES_DESKTOP = true;
36
+
37
+ /**
38
+ * The current version of Balena Etcher to install when downloading directly.
39
+ * Update this value when a new version is released.
40
+ */
41
+ const ETCHER_VERSION = '2.1.4';
42
+
43
+ /**
44
+ * Download URLs for direct installation methods (non-package-manager installs).
45
+ */
46
+ const DOWNLOAD_URLS = {
47
+ deb: `https://github.com/balena-io/etcher/releases/download/v${ETCHER_VERSION}/balena-etcher_${ETCHER_VERSION}_amd64.deb`,
48
+ rpm: `https://github.com/balena-io/etcher/releases/download/v${ETCHER_VERSION}/balena-etcher-${ETCHER_VERSION}-1.x86_64.rpm`
49
+ };
50
+
51
+ /**
52
+ * Checks if Balena Etcher is already installed on macOS by looking for the application bundle.
53
+ * @returns {boolean} True if balenaEtcher.app exists in /Applications
54
+ */
55
+ function isInstalledOnMacOS() {
56
+ return macosApps.isAppInstalled('balenaEtcher');
57
+ }
58
+
59
+ /**
60
+ * Checks if Balena Etcher is already installed on Debian-based systems.
61
+ * Uses dpkg to query the package database.
62
+ * @returns {Promise<boolean>} True if the balena-etcher package is installed
63
+ */
64
+ async function isInstalledOnDebian() {
65
+ return apt.isPackageInstalled('balena-etcher');
66
+ }
67
+
68
+ /**
69
+ * Checks if Balena Etcher is already installed on RPM-based systems.
70
+ * Uses rpm to query the package database.
71
+ * @returns {Promise<boolean>} True if the balena-etcher package is installed
72
+ */
73
+ async function isInstalledOnRPM() {
74
+ const result = await shell.exec('rpm -q balena-etcher 2>/dev/null');
75
+ return result.code === 0;
76
+ }
77
+
78
+ /**
79
+ * Checks if Balena Etcher is already installed on Windows.
80
+ * Checks the standard installation directory.
81
+ * @returns {Promise<boolean>} True if balenaEtcher.exe exists in Program Files
82
+ */
83
+ async function isInstalledOnWindows() {
84
+ // Check common installation paths
85
+ const result = await shell.exec('powershell -Command "Test-Path \'C:\\Program Files\\balenaEtcher\\balenaEtcher.exe\'"');
86
+ return result.stdout.trim().toLowerCase() === 'true';
87
+ }
88
+
89
+ /**
90
+ * Checks if Balena Etcher is installed on Raspberry Pi via Pi-Apps.
91
+ * Looks for the balena-etcher-electron binary.
92
+ * @returns {Promise<boolean>} True if the binary exists
93
+ */
94
+ async function isInstalledOnRaspbian() {
95
+ // Pi-Apps installs to /usr/bin/balena-etcher-electron
96
+ return shell.commandExists('balena-etcher-electron') || shell.commandExists('balena-etcher');
97
+ }
98
+
99
+ /**
100
+ * Install Balena Etcher on macOS using Homebrew Cask.
101
+ *
102
+ * Prerequisites:
103
+ * - macOS 10.15 (Catalina) or later
104
+ * - Homebrew package manager installed
105
+ *
106
+ * @returns {Promise<void>}
107
+ */
108
+ async function install_macos() {
109
+ // Check if Homebrew is available
110
+ if (!brew.isInstalled()) {
111
+ console.log('Homebrew is not installed. Please install Homebrew first:');
112
+ console.log(' /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"');
113
+ return;
114
+ }
115
+
116
+ // Check if already installed (idempotency check)
117
+ if (isInstalledOnMacOS()) {
118
+ console.log('Balena Etcher is already installed.');
119
+ return;
120
+ }
121
+
122
+ console.log('Installing Balena Etcher via Homebrew Cask...');
123
+
124
+ // Install using the brew cask command
125
+ // Using --quiet to suppress non-essential output for cleaner automation
126
+ const result = await brew.installCask('balenaetcher');
127
+
128
+ if (!result.success) {
129
+ console.error('Failed to install Balena Etcher:', result.output);
130
+ return;
131
+ }
132
+
133
+ // Verify installation succeeded
134
+ if (isInstalledOnMacOS()) {
135
+ console.log('Balena Etcher installed successfully.');
136
+ console.log('Location: /Applications/balenaEtcher.app');
137
+ } else {
138
+ console.error('Installation completed but Balena Etcher was not found in /Applications.');
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Install Balena Etcher on Ubuntu/Debian using direct .deb download.
144
+ *
145
+ * The official APT repository is deprecated, so we download the .deb package
146
+ * directly from GitHub releases.
147
+ *
148
+ * Prerequisites:
149
+ * - Ubuntu 18.04+ or Debian 10+ (64-bit)
150
+ * - sudo privileges
151
+ * - wget installed
152
+ *
153
+ * @returns {Promise<void>}
154
+ */
155
+ async function install_ubuntu() {
156
+ // Check architecture FIRST - Balena Etcher only provides AMD64 packages for Linux
157
+ // This must be checked before attempting any installations
158
+ const arch = os.getArch();
159
+ if (arch !== 'x64') {
160
+ console.log(`Balena Etcher does not provide official ${arch} packages for Ubuntu/Debian.`);
161
+ console.log('');
162
+ console.log('Note: Official Balena Etcher releases only support x64 (AMD64) architecture.');
163
+ console.log('For ARM64 systems:');
164
+ console.log(' - Raspberry Pi: Use Pi-Apps (community ARM build)');
165
+ console.log(' - Other ARM64 Linux: Community builds available at:');
166
+ console.log(' https://github.com/Itai-Nelken/BalenaEtcher-arm');
167
+ console.log('');
168
+ console.log('Alternatively, consider using Raspberry Pi Imager (official ARM support):');
169
+ console.log(' sudo apt-get install -y rpi-imager');
170
+ return;
171
+ }
172
+
173
+ // Check if already installed (idempotency check)
174
+ const alreadyInstalled = await isInstalledOnDebian();
175
+ if (alreadyInstalled) {
176
+ console.log('Balena Etcher is already installed.');
177
+ return;
178
+ }
179
+
180
+ // Ensure wget is available for downloading
181
+ if (!shell.commandExists('wget')) {
182
+ console.log('Installing wget (required for download)...');
183
+ // Update package lists first
184
+ await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update -y');
185
+ const wgetResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get install -y wget');
186
+ if (wgetResult.code !== 0) {
187
+ console.error('Failed to install wget:', wgetResult.stderr);
188
+ return;
189
+ }
190
+ }
191
+
192
+ console.log('Downloading Balena Etcher .deb package...');
193
+
194
+ // Download the .deb package to /tmp
195
+ const downloadResult = await shell.exec(
196
+ `wget -q -O /tmp/balena-etcher.deb "${DOWNLOAD_URLS.deb}"`
197
+ );
198
+
199
+ if (downloadResult.code !== 0) {
200
+ console.error('Failed to download Balena Etcher:', downloadResult.stderr);
201
+ return;
202
+ }
203
+
204
+ console.log('Installing Balena Etcher...');
205
+
206
+ // Install the .deb package using apt-get
207
+ // DEBIAN_FRONTEND=noninteractive ensures no interactive prompts
208
+ const installResult = await shell.exec(
209
+ 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y /tmp/balena-etcher.deb'
210
+ );
211
+
212
+ // Clean up the downloaded file regardless of installation outcome
213
+ await shell.exec('rm -f /tmp/balena-etcher.deb');
214
+
215
+ if (installResult.code !== 0) {
216
+ console.error('Failed to install Balena Etcher:', installResult.stderr);
217
+ // Attempt to fix broken dependencies
218
+ console.log('Attempting to fix broken dependencies...');
219
+ await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get install -f -y');
220
+ return;
221
+ }
222
+
223
+ // Verify installation succeeded
224
+ const verifyInstalled = await isInstalledOnDebian();
225
+ if (verifyInstalled) {
226
+ console.log('Balena Etcher installed successfully.');
227
+ console.log('Launch with: balena-etcher');
228
+ } else {
229
+ console.error('Installation completed but Balena Etcher package was not found.');
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Install Balena Etcher on Raspberry Pi OS using Pi-Apps.
235
+ *
236
+ * IMPORTANT: Balena Etcher does NOT have an official ARM installer.
237
+ * Pi-Apps provides a community-compiled ARM64 version.
238
+ *
239
+ * Prerequisites:
240
+ * - Raspberry Pi OS (64-bit only - aarch64)
241
+ * - Raspberry Pi 3, 4, or 5
242
+ * - Desktop environment
243
+ *
244
+ * @returns {Promise<void>}
245
+ */
246
+ async function install_raspbian() {
247
+ // Check if already installed (idempotency check)
248
+ const alreadyInstalled = await isInstalledOnRaspbian();
249
+ if (alreadyInstalled) {
250
+ console.log('Balena Etcher is already installed.');
251
+ return;
252
+ }
253
+
254
+ // Verify we are running on 64-bit Raspberry Pi OS
255
+ // Balena Etcher ARM builds only support aarch64
256
+ const archResult = await shell.exec('uname -m');
257
+ const architecture = archResult.stdout.trim();
258
+
259
+ if (architecture !== 'aarch64') {
260
+ console.log('Balena Etcher requires 64-bit Raspberry Pi OS (aarch64).');
261
+ console.log(`Current architecture: ${architecture}`);
262
+ console.log('Please install 64-bit Raspberry Pi OS from:');
263
+ console.log(' https://www.raspberrypi.com/software/operating-systems/');
264
+ return;
265
+ }
266
+
267
+ // Check if Pi-Apps is already installed
268
+ const homeDir = os.getHomeDir();
269
+ const piAppsPath = path.join(homeDir, 'pi-apps', 'manage');
270
+ const piAppsInstalled = fs.existsSync(piAppsPath);
271
+
272
+ if (!piAppsInstalled) {
273
+ console.log('Installing Pi-Apps (required for Balena Etcher on Raspberry Pi)...');
274
+
275
+ // Install Pi-Apps from the official repository
276
+ const piAppsResult = await shell.exec(
277
+ 'wget -qO- https://raw.githubusercontent.com/Botspot/pi-apps/master/install | bash'
278
+ );
279
+
280
+ if (piAppsResult.code !== 0) {
281
+ console.error('Failed to install Pi-Apps:', piAppsResult.stderr);
282
+ console.log('You may need to install required dependencies first:');
283
+ console.log(' sudo apt-get update && sudo apt-get install -y yad curl wget');
284
+ return;
285
+ }
286
+ }
287
+
288
+ console.log('Installing Balena Etcher via Pi-Apps...');
289
+
290
+ // Install Balena Etcher using Pi-Apps CLI
291
+ // Note: The app name in Pi-Apps is 'BalenaEtcher' (case-sensitive)
292
+ const installResult = await shell.exec(
293
+ `"${piAppsPath}" install 'BalenaEtcher'`
294
+ );
295
+
296
+ if (installResult.code !== 0) {
297
+ console.error('Failed to install Balena Etcher via Pi-Apps:', installResult.stderr);
298
+ return;
299
+ }
300
+
301
+ // Verify installation succeeded
302
+ const verifyInstalled = await isInstalledOnRaspbian();
303
+ if (verifyInstalled) {
304
+ console.log('Balena Etcher installed successfully.');
305
+ console.log('Launch with: balena-etcher-electron');
306
+ } else {
307
+ console.error('Installation completed but Balena Etcher was not found.');
308
+ }
309
+ }
9
310
 
10
311
  /**
11
- * Install Balena Etcher across supported platforms.
312
+ * Install Balena Etcher on Amazon Linux/RHEL using direct .rpm download.
313
+ *
314
+ * Prerequisites:
315
+ * - Amazon Linux 2023, Amazon Linux 2, RHEL 8+, or Fedora 35+
316
+ * - 64-bit (x86_64) architecture
317
+ * - sudo privileges
318
+ * - Desktop environment (for GUI operation)
319
+ *
320
+ * @returns {Promise<void>}
321
+ */
322
+ async function install_amazon_linux() {
323
+ // Check architecture FIRST - Balena Etcher only provides x86_64 packages for Linux
324
+ // This must be checked before attempting any installations
325
+ const arch = os.getArch();
326
+ if (arch !== 'x64') {
327
+ console.log(`Balena Etcher does not provide official ${arch} packages for RHEL/Fedora/Amazon Linux.`);
328
+ console.log('');
329
+ console.log('Note: Official Balena Etcher releases only support x64 (x86_64) architecture.');
330
+ console.log('For ARM64 systems, community builds may be available at:');
331
+ console.log(' https://github.com/Itai-Nelken/BalenaEtcher-arm');
332
+ console.log('');
333
+ console.log('Alternatively, consider using other image writing tools with ARM support.');
334
+ return;
335
+ }
336
+
337
+ // Check if already installed (idempotency check)
338
+ const alreadyInstalled = await isInstalledOnRPM();
339
+ if (alreadyInstalled) {
340
+ console.log('Balena Etcher is already installed.');
341
+ return;
342
+ }
343
+
344
+ // Ensure wget is available for downloading
345
+ if (!shell.commandExists('wget')) {
346
+ console.log('Installing wget (required for download)...');
347
+ // Detect whether to use dnf or yum
348
+ const packageManager = shell.commandExists('dnf') ? 'dnf' : 'yum';
349
+ const wgetResult = await shell.exec(`sudo ${packageManager} install -y wget`);
350
+ if (wgetResult.code !== 0) {
351
+ console.error('Failed to install wget:', wgetResult.stderr);
352
+ return;
353
+ }
354
+ }
355
+
356
+ console.log('Downloading Balena Etcher .rpm package...');
357
+
358
+ // Download the .rpm package to /tmp
359
+ const downloadResult = await shell.exec(
360
+ `wget -q -O /tmp/balena-etcher.rpm "${DOWNLOAD_URLS.rpm}"`
361
+ );
362
+
363
+ if (downloadResult.code !== 0) {
364
+ console.error('Failed to download Balena Etcher:', downloadResult.stderr);
365
+ return;
366
+ }
367
+
368
+ console.log('Installing Balena Etcher...');
369
+
370
+ // Determine which package manager to use (dnf preferred over yum)
371
+ const packageManager = shell.commandExists('dnf') ? 'dnf' : 'yum';
372
+
373
+ // Install the .rpm package
374
+ const installResult = await shell.exec(
375
+ `sudo ${packageManager} install -y /tmp/balena-etcher.rpm`
376
+ );
377
+
378
+ // Clean up the downloaded file regardless of installation outcome
379
+ await shell.exec('rm -f /tmp/balena-etcher.rpm');
380
+
381
+ if (installResult.code !== 0) {
382
+ console.error('Failed to install Balena Etcher:', installResult.stderr);
383
+ console.log('You may need to install missing dependencies:');
384
+ console.log(' sudo dnf install -y libXScrnSaver gtk3 nss alsa-lib');
385
+ return;
386
+ }
387
+
388
+ // Verify installation succeeded
389
+ const verifyInstalled = await isInstalledOnRPM();
390
+ if (verifyInstalled) {
391
+ console.log('Balena Etcher installed successfully.');
392
+ console.log('Launch with: balena-etcher');
393
+ } else {
394
+ console.error('Installation completed but Balena Etcher package was not found.');
395
+ }
396
+ }
397
+
398
+ /**
399
+ * Install Balena Etcher on Windows using Chocolatey or winget.
400
+ *
401
+ * Prefers winget if available, falls back to Chocolatey.
402
+ *
403
+ * Prerequisites:
404
+ * - Windows 10 or Windows 11 (64-bit)
405
+ * - Chocolatey or winget package manager
406
+ * - Administrator privileges
407
+ *
408
+ * @returns {Promise<void>}
409
+ */
410
+ async function install_windows() {
411
+ // Check if already installed (idempotency check)
412
+ const alreadyInstalled = await isInstalledOnWindows();
413
+ if (alreadyInstalled) {
414
+ console.log('Balena Etcher is already installed.');
415
+ return;
416
+ }
417
+
418
+ // Try winget first (preferred on modern Windows)
419
+ if (winget.isInstalled()) {
420
+ console.log('Installing Balena Etcher via winget...');
421
+
422
+ const result = await winget.install('Balena.Etcher');
423
+
424
+ if (result.success) {
425
+ // Verify installation succeeded
426
+ const verifyInstalled = await isInstalledOnWindows();
427
+ if (verifyInstalled) {
428
+ console.log('Balena Etcher installed successfully.');
429
+ console.log('Location: C:\\Program Files\\balenaEtcher\\balenaEtcher.exe');
430
+ return;
431
+ }
432
+ }
433
+
434
+ // If winget failed, fall through to try Chocolatey
435
+ console.log('winget installation was not successful, trying Chocolatey...');
436
+ }
437
+
438
+ // Fall back to Chocolatey
439
+ if (choco.isInstalled()) {
440
+ console.log('Installing Balena Etcher via Chocolatey...');
441
+
442
+ // Chocolatey package name is 'etcher'
443
+ const result = await choco.install('etcher');
444
+
445
+ if (!result.success) {
446
+ console.error('Failed to install Balena Etcher:', result.output);
447
+ return;
448
+ }
449
+
450
+ // Verify installation succeeded
451
+ const verifyInstalled = await isInstalledOnWindows();
452
+ if (verifyInstalled) {
453
+ console.log('Balena Etcher installed successfully.');
454
+ console.log('Location: C:\\Program Files\\balenaEtcher\\balenaEtcher.exe');
455
+ } else {
456
+ console.error('Installation completed but Balena Etcher was not found.');
457
+ }
458
+ return;
459
+ }
460
+
461
+ // Neither package manager is available
462
+ console.log('Neither winget nor Chocolatey is installed.');
463
+ console.log('Please install one of them first:');
464
+ console.log('');
465
+ console.log('For Chocolatey (PowerShell as Administrator):');
466
+ console.log(' Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(\'https://community.chocolatey.org/install.ps1\'))');
467
+ }
468
+
469
+ /**
470
+ * Install Balena Etcher on Ubuntu running in WSL (Windows Subsystem for Linux).
471
+ *
472
+ * Uses the same installation method as Ubuntu, but notes that WSLg is required
473
+ * for GUI support and that USB device access is limited in WSL.
474
+ *
475
+ * Prerequisites:
476
+ * - WSL 2 with Ubuntu
477
+ * - Windows 11 or Windows 10 with WSLg enabled
478
+ * - sudo privileges
479
+ *
480
+ * @returns {Promise<void>}
481
+ */
482
+ async function install_ubuntu_wsl() {
483
+ // Check architecture FIRST - Balena Etcher only provides AMD64 packages for Linux
484
+ // This must be checked before attempting any installations
485
+ const arch = os.getArch();
486
+ if (arch !== 'x64') {
487
+ console.log(`Balena Etcher does not provide official ${arch} packages for WSL.`);
488
+ console.log('');
489
+ console.log('Note: Official Balena Etcher releases only support x64 (AMD64) architecture.');
490
+ console.log('For ARM64 WSL, consider installing Balena Etcher on Windows directly instead.');
491
+ return;
492
+ }
493
+
494
+ // Check if already installed (idempotency check)
495
+ const alreadyInstalled = await isInstalledOnDebian();
496
+ if (alreadyInstalled) {
497
+ console.log('Balena Etcher is already installed.');
498
+ return;
499
+ }
500
+
501
+ // WSL-specific note about USB limitations
502
+ console.log('Note: Balena Etcher in WSL has limited USB device access.');
503
+ console.log('For full USB support, consider installing on Windows directly.');
504
+ console.log('');
505
+
506
+ // Ensure wget is available for downloading
507
+ if (!shell.commandExists('wget')) {
508
+ console.log('Installing wget (required for download)...');
509
+ // Update apt cache first for WSL
510
+ await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update -y');
511
+ const wgetResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get install -y wget');
512
+ if (wgetResult.code !== 0) {
513
+ console.error('Failed to install wget:', wgetResult.stderr);
514
+ return;
515
+ }
516
+ }
517
+
518
+ console.log('Downloading Balena Etcher .deb package...');
519
+
520
+ // Download the .deb package to /tmp
521
+ const downloadResult = await shell.exec(
522
+ `wget -q -O /tmp/balena-etcher.deb "${DOWNLOAD_URLS.deb}"`
523
+ );
524
+
525
+ if (downloadResult.code !== 0) {
526
+ console.error('Failed to download Balena Etcher:', downloadResult.stderr);
527
+ return;
528
+ }
529
+
530
+ console.log('Installing Balena Etcher...');
531
+
532
+ // Update package list first (important for fresh WSL instances)
533
+ await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update -y');
534
+
535
+ // Install the .deb package using apt-get
536
+ const installResult = await shell.exec(
537
+ 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y /tmp/balena-etcher.deb'
538
+ );
539
+
540
+ // Clean up the downloaded file regardless of installation outcome
541
+ await shell.exec('rm -f /tmp/balena-etcher.deb');
542
+
543
+ if (installResult.code !== 0) {
544
+ console.error('Failed to install Balena Etcher:', installResult.stderr);
545
+ // Attempt to fix broken dependencies
546
+ console.log('Attempting to fix broken dependencies...');
547
+ await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get install -f -y');
548
+ return;
549
+ }
550
+
551
+ // Verify installation succeeded
552
+ const verifyInstalled = await isInstalledOnDebian();
553
+ if (verifyInstalled) {
554
+ console.log('Balena Etcher installed successfully.');
555
+ console.log('Launch with: balena-etcher');
556
+ console.log('');
557
+ console.log('Note: Requires WSLg for GUI support. If you encounter display errors:');
558
+ console.log(' 1. Ensure you are using WSL 2');
559
+ console.log(' 2. Run: wsl --update (in PowerShell)');
560
+ console.log(' 3. Restart WSL: wsl --shutdown && wsl');
561
+ } else {
562
+ console.error('Installation completed but Balena Etcher package was not found.');
563
+ }
564
+ }
565
+
566
+ /**
567
+ * Install Balena Etcher from Git Bash on Windows.
568
+ *
569
+ * Git Bash runs on Windows, so this function delegates to the Windows
570
+ * installation method using Chocolatey.
571
+ *
572
+ * Prerequisites:
573
+ * - Git Bash installed (comes with Git for Windows)
574
+ * - Chocolatey installed on Windows
575
+ * - Administrator privileges
576
+ *
577
+ * @returns {Promise<void>}
578
+ */
579
+ async function install_gitbash() {
580
+ // Git Bash runs on Windows and can access Windows package managers
581
+ // Delegate to Windows installation
582
+ console.log('Installing Balena Etcher for Windows from Git Bash...');
583
+ await install_windows();
584
+ }
585
+
586
+ /**
587
+ * Check if Balena Etcher is installed on the current platform.
588
+ *
589
+ * Uses platform-appropriate verification:
590
+ * - macOS: Checks for application bundle in /Applications
591
+ * - Ubuntu/Debian/WSL: Checks dpkg package database
592
+ * - Raspberry Pi OS: Checks for balena-etcher-electron command
593
+ * - Amazon Linux/RHEL/Fedora: Checks rpm package database
594
+ * - Windows: Checks for executable in Program Files
595
+ *
596
+ * @returns {Promise<boolean>} True if Balena Etcher is installed
597
+ */
598
+ async function isInstalled() {
599
+ const platform = os.detect();
600
+
601
+ const checks = {
602
+ 'macos': isInstalledOnMacOS,
603
+ 'ubuntu': isInstalledOnDebian,
604
+ 'debian': isInstalledOnDebian,
605
+ 'wsl': isInstalledOnDebian,
606
+ 'raspbian': isInstalledOnRaspbian,
607
+ 'amazon_linux': isInstalledOnRPM,
608
+ 'fedora': isInstalledOnRPM,
609
+ 'rhel': isInstalledOnRPM,
610
+ 'windows': isInstalledOnWindows,
611
+ 'gitbash': isInstalledOnWindows,
612
+ };
613
+
614
+ const checker = checks[platform.type];
615
+ if (!checker) {
616
+ return false;
617
+ }
618
+
619
+ // Handle both sync and async checkers
620
+ const result = checker();
621
+ return result instanceof Promise ? await result : result;
622
+ }
623
+
624
+ /**
625
+ * Check if this installer is supported on the current platform.
626
+ *
627
+ * Balena Etcher can be installed on all supported platforms:
628
+ * - macOS (via Homebrew cask)
629
+ * - Ubuntu/Debian (via direct .deb download)
630
+ * - Raspberry Pi OS (via Pi-Apps, 64-bit only)
631
+ * - Amazon Linux/RHEL/Fedora (via direct .rpm download)
632
+ * - Windows (via Chocolatey or winget)
633
+ * - WSL (via direct .deb download)
634
+ * - Git Bash (via Windows Chocolatey)
635
+ *
636
+ * @returns {boolean} True if installation is supported on this platform
637
+ */
638
+ function isEligible() {
639
+ const platform = os.detect();
640
+ const supportedPlatforms = ['macos', 'ubuntu', 'debian', 'wsl', 'raspbian', 'amazon_linux', 'fedora', 'rhel', 'windows', 'gitbash'];
641
+ if (!supportedPlatforms.includes(platform.type)) {
642
+ return false;
643
+ }
644
+ if (REQUIRES_DESKTOP && !os.isDesktopAvailable()) {
645
+ return false;
646
+ }
647
+ return true;
648
+ }
649
+
650
+ /**
651
+ * Main installation entry point - detects platform and runs appropriate installer.
652
+ *
653
+ * This function automatically determines the current operating system and
654
+ * invokes the correct platform-specific installation function.
12
655
  *
13
656
  * @returns {Promise<void>}
14
657
  */
15
658
  async function install() {
16
659
  const platform = os.detect();
17
660
 
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 };
661
+ // Map platform types to their respective installer functions
662
+ const installers = {
663
+ 'macos': install_macos,
664
+ 'ubuntu': install_ubuntu,
665
+ 'debian': install_ubuntu,
666
+ 'wsl': install_ubuntu_wsl,
667
+ 'raspbian': install_raspbian,
668
+ 'amazon_linux': install_amazon_linux,
669
+ 'fedora': install_amazon_linux,
670
+ 'rhel': install_amazon_linux,
671
+ 'windows': install_windows,
672
+ 'gitbash': install_gitbash
673
+ };
674
+
675
+ const installer = installers[platform.type];
676
+
677
+ // Handle unsupported platforms gracefully (no errors, no alternatives)
678
+ if (!installer) {
679
+ console.log(`Balena Etcher is not available for ${platform.type}.`);
680
+ return;
681
+ }
682
+
683
+ await installer();
684
+ }
685
+
686
+ module.exports = {
687
+ REQUIRES_DESKTOP,
688
+ install,
689
+ isEligible,
690
+ isInstalled,
691
+ install_macos,
692
+ install_ubuntu,
693
+ install_ubuntu_wsl,
694
+ install_raspbian,
695
+ install_amazon_linux,
696
+ install_windows,
697
+ install_gitbash
698
+ };
41
699
 
700
+ // Allow direct execution of this script
42
701
  if (require.main === module) {
43
- install();
702
+ install().catch(err => {
703
+ console.error(err.message);
704
+ process.exit(1);
705
+ });
44
706
  }