@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,930 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * @fileoverview Install Bambu Studio.
4
+ * @fileoverview Install Bambu Studio - a feature-rich 3D printing slicer software.
5
5
  * @module installs/bambu-studio
6
+ *
7
+ * Bambu Studio is an open-source 3D printing slicer developed by Bambu Lab.
8
+ * It converts 3D model files (STL, OBJ, 3MF, AMF) into G-code for 3D printers.
9
+ * Built upon PrusaSlicer, it provides project-based workflows, optimized slicing,
10
+ * and native AMS (Automatic Material System) integration for multi-color printing.
11
+ *
12
+ * IMPORTANT: Bambu Studio is a GUI application. It requires a desktop environment
13
+ * with OpenGL 2.0+ support and will not work on headless servers.
14
+ *
15
+ * Supported platforms:
16
+ * - macOS: Homebrew cask (brew install --cask bambu-studio)
17
+ * - Ubuntu/Debian: Flatpak from Flathub (com.bambulab.BambuStudio)
18
+ * - Raspberry Pi OS: Pi-Apps (64-bit only, requires aarch64)
19
+ * - Amazon Linux/RHEL: Flatpak from Flathub (not officially supported)
20
+ * - Windows: Chocolatey (choco install bambustudio)
21
+ * - WSL: Flatpak with WSLg for GUI support
22
+ * - Git Bash: Uses Windows Chocolatey
6
23
  */
7
24
 
25
+ const fs = require('fs');
26
+ const path = require('path');
8
27
  const os = require('../utils/common/os');
28
+ const shell = require('../utils/common/shell');
29
+ const brew = require('../utils/macos/brew');
30
+ const choco = require('../utils/windows/choco');
31
+ const macosApps = require('../utils/macos/apps');
32
+
33
+ /**
34
+ * Whether this installer requires a desktop environment to function.
35
+ * Bambu Studio is a GUI 3D printing slicer requiring OpenGL 2.0+.
36
+ */
37
+ const REQUIRES_DESKTOP = true;
38
+
39
+ /**
40
+ * The macOS application bundle name for Bambu Studio.
41
+ * Used to verify installation via the standard /Applications directory.
42
+ */
43
+ const MACOS_APP_NAME = 'BambuStudio';
44
+
45
+ /**
46
+ * The Homebrew cask name for Bambu Studio.
47
+ */
48
+ const HOMEBREW_CASK_NAME = 'bambu-studio';
49
+
50
+ /**
51
+ * The Flatpak application ID for Bambu Studio on Flathub.
52
+ */
53
+ const FLATPAK_APP_ID = 'com.bambulab.BambuStudio';
54
+
55
+ /**
56
+ * The Chocolatey package name for Bambu Studio on Windows.
57
+ */
58
+ const CHOCOLATEY_PACKAGE_NAME = 'bambustudio';
9
59
 
10
60
  /**
11
- * Install Bambu Studio across supported platforms.
61
+ * The Windows installation path for Bambu Studio.
62
+ */
63
+ const WINDOWS_INSTALL_PATH = 'C:\\Program Files\\Bambu Studio\\bambu-studio.exe';
64
+
65
+ /**
66
+ * Checks if Bambu Studio is already installed on macOS.
67
+ * Looks for the BambuStudio.app bundle in /Applications.
68
+ *
69
+ * @returns {boolean} True if Bambu Studio is installed on macOS
70
+ */
71
+ function isInstalledOnMacOS() {
72
+ return macosApps.isAppInstalled(MACOS_APP_NAME);
73
+ }
74
+
75
+ /**
76
+ * Checks if Flatpak is available on the system.
77
+ * Flatpak is required for Linux installations (Ubuntu, WSL, Amazon Linux).
78
+ *
79
+ * @returns {boolean} True if the flatpak command exists in PATH
80
+ */
81
+ function isFlatpakAvailable() {
82
+ return shell.commandExists('flatpak');
83
+ }
84
+
85
+ /**
86
+ * Checks if Bambu Studio is installed via Flatpak.
87
+ * Queries the Flatpak list for the Bambu Studio application ID.
88
+ *
89
+ * @returns {Promise<boolean>} True if Bambu Studio is installed via Flatpak
90
+ */
91
+ async function isInstalledViaFlatpak() {
92
+ if (!isFlatpakAvailable()) {
93
+ return false;
94
+ }
95
+
96
+ // Check if the Flatpak app is installed by looking for it in the list
97
+ const result = await shell.exec(`flatpak list --app | grep -i "${FLATPAK_APP_ID}"`);
98
+ return result.code === 0 && result.stdout.includes(FLATPAK_APP_ID);
99
+ }
100
+
101
+ /**
102
+ * Checks if Bambu Studio is already installed on Windows.
103
+ * Looks for the executable in the standard Program Files location.
104
+ *
105
+ * @returns {Promise<boolean>} True if Bambu Studio is installed on Windows
106
+ */
107
+ async function isInstalledOnWindows() {
108
+ // Check if the executable exists at the expected location
109
+ const result = await shell.exec(`powershell -NoProfile -Command "Test-Path '${WINDOWS_INSTALL_PATH}'"`);
110
+ return result.stdout.trim().toLowerCase() === 'true';
111
+ }
112
+
113
+ /**
114
+ * Checks if Bambu Studio is installed on Raspberry Pi via Pi-Apps.
115
+ * Pi-Apps installs Bambu Studio to a local binary location.
116
+ *
117
+ * @returns {Promise<boolean>} True if Bambu Studio is installed
118
+ */
119
+ async function isInstalledOnRaspbian() {
120
+ // Check for the bambu-studio command in PATH
121
+ if (shell.commandExists('bambu-studio')) {
122
+ return true;
123
+ }
124
+
125
+ // Check for desktop file created by Pi-Apps
126
+ const homeDir = os.getHomeDir();
127
+ const desktopFilePath = path.join(homeDir, '.local', 'share', 'applications');
128
+
129
+ try {
130
+ const files = fs.readdirSync(desktopFilePath);
131
+ for (const file of files) {
132
+ if (file.toLowerCase().includes('bambu')) {
133
+ return true;
134
+ }
135
+ }
136
+ } catch {
137
+ // Directory doesn't exist or can't be read - not installed
138
+ }
139
+
140
+ return false;
141
+ }
142
+
143
+ /**
144
+ * Installs Flatpak if not already present on a Debian-based system.
145
+ * This is a prerequisite for installing Bambu Studio on Linux via Flatpak.
146
+ *
147
+ * @returns {Promise<boolean>} True if Flatpak is available after this function
148
+ */
149
+ async function ensureFlatpakInstalled() {
150
+ if (isFlatpakAvailable()) {
151
+ return true;
152
+ }
153
+
154
+ console.log('Flatpak is not installed. Installing Flatpak...');
155
+
156
+ // Update apt cache first
157
+ const updateResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update -y');
158
+ if (updateResult.code !== 0) {
159
+ console.error('Failed to update apt cache:', updateResult.stderr);
160
+ return false;
161
+ }
162
+
163
+ // Install Flatpak
164
+ const installResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get install -y flatpak');
165
+ if (installResult.code !== 0) {
166
+ console.error('Failed to install Flatpak:', installResult.stderr);
167
+ return false;
168
+ }
169
+
170
+ console.log('Flatpak installed successfully.');
171
+ return true;
172
+ }
173
+
174
+ /**
175
+ * Checks if the system has a display environment (not headless).
176
+ * Flatpak requires a display environment and D-Bus to function properly.
177
+ *
178
+ * @returns {boolean} True if a display environment is detected
179
+ */
180
+ function hasDisplayEnvironment() {
181
+ // Check for common display environment variables
182
+ const hasDisplay = process.env.DISPLAY ||
183
+ process.env.WAYLAND_DISPLAY ||
184
+ process.env.XDG_CURRENT_DESKTOP;
185
+ return Boolean(hasDisplay);
186
+ }
187
+
188
+ /**
189
+ * Adds the Flathub repository if not already configured.
190
+ * Flathub is the source for the Bambu Studio Flatpak package.
191
+ *
192
+ * @returns {Promise<boolean>} True if Flathub is available after this function
193
+ */
194
+ async function ensureFlathubConfigured() {
195
+ // Check if Flathub is already configured
196
+ const checkResult = await shell.exec('flatpak remote-list | grep -i flathub');
197
+ if (checkResult.code === 0 && checkResult.stdout.includes('flathub')) {
198
+ return true;
199
+ }
200
+
201
+ console.log('Adding Flathub repository...');
202
+
203
+ // Add Flathub repository (--if-not-exists prevents errors if already added)
204
+ const addResult = await shell.exec(
205
+ 'flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo'
206
+ );
207
+
208
+ if (addResult.code !== 0) {
209
+ console.error('Failed to add Flathub repository:', addResult.stderr);
210
+
211
+ // Provide helpful context if this is likely a headless/Docker environment
212
+ if (addResult.stderr.includes('system bus') || addResult.stderr.includes('D-Bus')) {
213
+ console.log('');
214
+ console.log('This error typically occurs in headless or containerized environments.');
215
+ console.log('Bambu Studio is a GUI application and requires:');
216
+ console.log(' 1. A desktop environment (GNOME, KDE, XFCE, etc.)');
217
+ console.log(' 2. X11 or Wayland display server');
218
+ console.log(' 3. D-Bus system bus');
219
+ console.log('');
220
+ console.log('If you are in a Docker container or headless server, Bambu Studio');
221
+ console.log('cannot be installed or run. Use a desktop Linux system instead.');
222
+ }
223
+
224
+ return false;
225
+ }
226
+
227
+ console.log('Flathub repository added successfully.');
228
+ return true;
229
+ }
230
+
231
+ /**
232
+ * Installs Flatpak if not already present on Amazon Linux/RHEL.
233
+ * Uses dnf as the package manager.
234
+ *
235
+ * @returns {Promise<boolean>} True if Flatpak is available after this function
236
+ */
237
+ async function ensureFlatpakInstalledRHEL() {
238
+ if (isFlatpakAvailable()) {
239
+ return true;
240
+ }
241
+
242
+ console.log('Flatpak is not installed. Installing Flatpak...');
243
+
244
+ // Determine which package manager to use (dnf preferred over yum)
245
+ const packageManager = shell.commandExists('dnf') ? 'dnf' : 'yum';
246
+
247
+ const installResult = await shell.exec(`sudo ${packageManager} install -y flatpak`);
248
+ if (installResult.code !== 0) {
249
+ console.error('Failed to install Flatpak:', installResult.stderr);
250
+ return false;
251
+ }
252
+
253
+ console.log('Flatpak installed successfully.');
254
+ return true;
255
+ }
256
+
257
+ /**
258
+ * Install Bambu Studio on macOS using Homebrew Cask.
259
+ *
260
+ * Prerequisites:
261
+ * - macOS 11 (Big Sur) or later
262
+ * - Homebrew package manager installed
263
+ * - Terminal access
264
+ *
265
+ * The installation uses `brew install --cask bambu-studio` which downloads
266
+ * and installs the application to /Applications/BambuStudio.app.
267
+ *
268
+ * @returns {Promise<void>}
269
+ */
270
+ async function install_macos() {
271
+ // Check if Homebrew is available before attempting installation
272
+ if (!brew.isInstalled()) {
273
+ console.log('Homebrew is not installed. Please install Homebrew first:');
274
+ console.log(' /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"');
275
+ return;
276
+ }
277
+
278
+ // Check if already installed (idempotency check)
279
+ if (isInstalledOnMacOS()) {
280
+ console.log('Bambu Studio is already installed.');
281
+ return;
282
+ }
283
+
284
+ console.log('Installing Bambu Studio via Homebrew Cask...');
285
+
286
+ // Install using the brew cask command
287
+ const result = await brew.installCask(HOMEBREW_CASK_NAME);
288
+
289
+ if (!result.success) {
290
+ console.error('Failed to install Bambu Studio:', result.output);
291
+ console.log('');
292
+ console.log('Troubleshooting:');
293
+ console.log(' 1. Run "brew update" and retry');
294
+ console.log(' 2. If macOS blocks the app, go to System Settings > Privacy & Security');
295
+ console.log(' and click "Open Anyway"');
296
+ return;
297
+ }
298
+
299
+ // Verify installation succeeded
300
+ if (isInstalledOnMacOS()) {
301
+ console.log('Bambu Studio installed successfully.');
302
+ console.log('Location: /Applications/BambuStudio.app');
303
+ console.log('');
304
+ console.log('Launch with: open /Applications/BambuStudio.app');
305
+ } else {
306
+ console.error('Installation completed but Bambu Studio was not found in /Applications.');
307
+ }
308
+ }
309
+
310
+ /**
311
+ * Install Bambu Studio on Ubuntu/Debian using Flatpak from Flathub.
312
+ *
313
+ * IMPORTANT: There is no official APT or Snap package for Bambu Studio.
314
+ * Flatpak from Flathub is the recommended installation method for Linux.
315
+ *
316
+ * Prerequisites:
317
+ * - Ubuntu 20.04+ or Debian 11+ (64-bit)
318
+ * - X11 or Wayland display server
319
+ * - sudo privileges
320
+ *
321
+ * NOTE: A system restart (or logout/login) may be required after installing
322
+ * Flatpak for the first time before Bambu Studio can be launched.
323
+ *
324
+ * @returns {Promise<void>}
325
+ */
326
+ async function install_ubuntu() {
327
+ // Check if already installed via Flatpak (idempotency check)
328
+ const alreadyInstalled = await isInstalledViaFlatpak();
329
+ if (alreadyInstalled) {
330
+ console.log('Bambu Studio is already installed.');
331
+ return;
332
+ }
333
+
334
+ // Check for display environment before proceeding (Bambu Studio requires GUI)
335
+ if (!hasDisplayEnvironment()) {
336
+ console.log('Bambu Studio is a GUI application and requires a desktop environment.');
337
+ console.log('No display environment detected (DISPLAY, WAYLAND_DISPLAY, or XDG_CURRENT_DESKTOP).');
338
+ console.log('');
339
+ console.log('This application cannot be installed on:');
340
+ console.log(' - Headless servers');
341
+ console.log(' - Docker containers without display forwarding');
342
+ console.log(' - SSH sessions without X11 forwarding');
343
+ console.log('');
344
+ console.log('Please run this installer on a system with a desktop environment.');
345
+ return;
346
+ }
347
+
348
+ // Ensure Flatpak is installed (required for Bambu Studio on Linux)
349
+ const flatpakReady = await ensureFlatpakInstalled();
350
+ if (!flatpakReady) {
351
+ console.error('Could not install Flatpak. Please install it manually:');
352
+ console.log(' sudo apt-get update && sudo apt-get install -y flatpak');
353
+ return;
354
+ }
355
+
356
+ // Ensure Flathub repository is configured
357
+ const flathubReady = await ensureFlathubConfigured();
358
+ if (!flathubReady) {
359
+ console.error('Could not configure Flathub repository. Please add it manually:');
360
+ console.log(' flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo');
361
+ return;
362
+ }
363
+
364
+ console.log('Installing Bambu Studio via Flatpak...');
365
+ console.log('Note: This may take several minutes on first install.');
366
+
367
+ // Install Bambu Studio from Flathub
368
+ // The -y flag automatically confirms the installation
369
+ const installResult = await shell.exec(`flatpak install -y flathub ${FLATPAK_APP_ID}`);
370
+
371
+ if (installResult.code !== 0) {
372
+ console.error('Failed to install Bambu Studio:', installResult.stderr);
373
+ console.log('');
374
+ console.log('Troubleshooting:');
375
+ console.log(' 1. Try restarting your system and running the install again');
376
+ console.log(' 2. Run: flatpak update -y');
377
+ console.log(' 3. If Flathub fails, try re-adding it:');
378
+ console.log(' flatpak remote-delete flathub');
379
+ console.log(' flatpak remote-add flathub https://dl.flathub.org/repo/flathub.flatpakrepo');
380
+ return;
381
+ }
382
+
383
+ // Verify installation succeeded
384
+ const verifyInstalled = await isInstalledViaFlatpak();
385
+ if (verifyInstalled) {
386
+ console.log('Bambu Studio installed successfully.');
387
+ console.log('');
388
+ console.log('Launch with: flatpak run com.bambulab.BambuStudio');
389
+ console.log('');
390
+ console.log('Note: If this is your first Flatpak installation, you may need to');
391
+ console.log('restart your system or log out/in for the app to appear in menus.');
392
+ } else {
393
+ console.error('Installation completed but Bambu Studio was not found.');
394
+ console.log('Try running: flatpak list | grep -i bambu');
395
+ }
396
+ }
397
+
398
+ /**
399
+ * Install Bambu Studio on Raspberry Pi OS using Pi-Apps.
400
+ *
401
+ * IMPORTANT: Bambu Studio requires 64-bit Raspberry Pi OS (aarch64).
402
+ * It will NOT work on 32-bit (armv7l) installations.
403
+ *
404
+ * Prerequisites:
405
+ * - Raspberry Pi OS (64-bit only) - Bookworm or later recommended
406
+ * - Raspberry Pi 3B+ or later (64-bit capable hardware)
407
+ * - Desktop environment (GUI required)
408
+ * - Pi-Apps package manager (installed automatically if missing)
409
+ *
410
+ * NOTE: The Pi-Apps installation compiles from source on ARM, which can
411
+ * take significant time and system resources.
412
+ *
413
+ * @returns {Promise<void>}
414
+ */
415
+ async function install_raspbian() {
416
+ // Check if already installed (idempotency check)
417
+ const alreadyInstalled = await isInstalledOnRaspbian();
418
+ if (alreadyInstalled) {
419
+ console.log('Bambu Studio is already installed.');
420
+ return;
421
+ }
422
+
423
+ // Verify we are running on 64-bit Raspberry Pi OS
424
+ // Bambu Studio ARM builds only support aarch64 architecture
425
+ const archResult = await shell.exec('uname -m');
426
+ const architecture = archResult.stdout.trim();
427
+
428
+ if (architecture !== 'aarch64') {
429
+ console.log('Bambu Studio requires 64-bit Raspberry Pi OS (aarch64).');
430
+ console.log(`Current architecture: ${architecture}`);
431
+ console.log('');
432
+ console.log('Please install 64-bit Raspberry Pi OS from:');
433
+ console.log(' https://www.raspberrypi.com/software/operating-systems/');
434
+ return;
435
+ }
436
+
437
+ // Check if Pi-Apps is already installed
438
+ const homeDir = os.getHomeDir();
439
+ const piAppsPath = path.join(homeDir, 'pi-apps', 'manage');
440
+ const piAppsInstalled = fs.existsSync(piAppsPath);
441
+
442
+ if (!piAppsInstalled) {
443
+ console.log('Installing Pi-Apps (required for Bambu Studio on Raspberry Pi)...');
444
+
445
+ // Install Pi-Apps from the official repository
446
+ const piAppsResult = await shell.exec(
447
+ 'wget -qO- https://raw.githubusercontent.com/Botspot/pi-apps/master/install | bash'
448
+ );
449
+
450
+ if (piAppsResult.code !== 0) {
451
+ console.error('Failed to install Pi-Apps:', piAppsResult.stderr);
452
+ console.log('');
453
+ console.log('You may need to install required dependencies first:');
454
+ console.log(' sudo apt-get update && sudo apt-get install -y yad curl wget');
455
+ return;
456
+ }
457
+
458
+ console.log('Pi-Apps installed successfully.');
459
+ }
460
+
461
+ console.log('Installing Bambu Studio via Pi-Apps...');
462
+ console.log('Note: This may take a significant amount of time on Raspberry Pi hardware.');
463
+
464
+ // Install Bambu Studio using Pi-Apps CLI
465
+ // The app name in Pi-Apps is "Bambu Studio" (with space, case-sensitive)
466
+ const installResult = await shell.exec(`"${piAppsPath}" install "Bambu Studio"`);
467
+
468
+ if (installResult.code !== 0) {
469
+ console.error('Failed to install Bambu Studio via Pi-Apps:', installResult.stderr);
470
+ console.log('');
471
+ console.log('Troubleshooting:');
472
+ console.log(' 1. If you run out of memory, increase swap space:');
473
+ console.log(' sudo dphys-swapfile swapoff');
474
+ console.log(' sudo sed -i "s/CONF_SWAPSIZE=.*/CONF_SWAPSIZE=2048/" /etc/dphys-swapfile');
475
+ console.log(' sudo dphys-swapfile setup');
476
+ console.log(' sudo dphys-swapfile swapon');
477
+ console.log(' 2. Ensure you have at least 4GB RAM (Raspberry Pi 4/5 recommended)');
478
+ return;
479
+ }
480
+
481
+ // Verify installation succeeded
482
+ const verifyInstalled = await isInstalledOnRaspbian();
483
+ if (verifyInstalled) {
484
+ console.log('Bambu Studio installed successfully.');
485
+ console.log('');
486
+ console.log('Launch from the desktop menu under Engineering, or via: bambu-studio');
487
+ } else {
488
+ console.error('Installation completed but Bambu Studio was not found.');
489
+ }
490
+ }
491
+
492
+ /**
493
+ * Install Bambu Studio on Amazon Linux/RHEL using Flatpak.
494
+ *
495
+ * IMPORTANT: Amazon Linux is primarily a server OS without a desktop environment.
496
+ * Bambu Studio is a GUI application and requires a display. This platform is
497
+ * NOT recommended for Bambu Studio usage.
498
+ *
499
+ * Prerequisites:
500
+ * - Amazon Linux 2023, Amazon Linux 2, RHEL 8+, or Fedora 35+
501
+ * - Desktop environment with X11/Wayland support
502
+ * - Flatpak package manager
503
+ * - sudo privileges
504
+ *
505
+ * @returns {Promise<void>}
506
+ */
507
+ async function install_amazon_linux() {
508
+ // Check if already installed via Flatpak (idempotency check)
509
+ const alreadyInstalled = await isInstalledViaFlatpak();
510
+ if (alreadyInstalled) {
511
+ console.log('Bambu Studio is already installed.');
512
+ return;
513
+ }
514
+
515
+ console.log('Note: Amazon Linux is primarily a server OS. Bambu Studio requires');
516
+ console.log('a desktop environment with display capabilities.');
517
+ console.log('');
518
+
519
+ // Check for display environment before proceeding (Bambu Studio requires GUI)
520
+ if (!hasDisplayEnvironment()) {
521
+ console.log('Bambu Studio is a GUI application and requires a desktop environment.');
522
+ console.log('No display environment detected (DISPLAY, WAYLAND_DISPLAY, or XDG_CURRENT_DESKTOP).');
523
+ console.log('');
524
+ console.log('This application cannot be installed on:');
525
+ console.log(' - Headless servers');
526
+ console.log(' - Docker containers without display forwarding');
527
+ console.log(' - SSH sessions without X11 forwarding');
528
+ console.log('');
529
+ console.log('Please run this installer on a system with a desktop environment.');
530
+ return;
531
+ }
532
+
533
+ // Ensure Flatpak is installed
534
+ const flatpakReady = await ensureFlatpakInstalledRHEL();
535
+ if (!flatpakReady) {
536
+ console.error('Could not install Flatpak. Please install it manually:');
537
+ console.log(' sudo dnf install -y flatpak');
538
+ return;
539
+ }
540
+
541
+ // Ensure Flathub repository is configured
542
+ const flathubReady = await ensureFlathubConfigured();
543
+ if (!flathubReady) {
544
+ console.error('Could not configure Flathub repository. Please add it manually:');
545
+ console.log(' flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo');
546
+ return;
547
+ }
548
+
549
+ console.log('Installing Bambu Studio via Flatpak...');
550
+
551
+ // Install Bambu Studio from Flathub
552
+ const installResult = await shell.exec(`flatpak install -y flathub ${FLATPAK_APP_ID}`);
553
+
554
+ if (installResult.code !== 0) {
555
+ console.error('Failed to install Bambu Studio:', installResult.stderr);
556
+ console.log('');
557
+ console.log('Troubleshooting:');
558
+ console.log(' 1. Ensure you have a desktop environment installed:');
559
+ console.log(' sudo dnf groupinstall -y "GNOME Desktop Environment"');
560
+ console.log(' 2. Install required graphics drivers:');
561
+ console.log(' sudo dnf install -y mesa-libGL mesa-libGLU mesa-dri-drivers');
562
+ return;
563
+ }
564
+
565
+ // Verify installation succeeded
566
+ const verifyInstalled = await isInstalledViaFlatpak();
567
+ if (verifyInstalled) {
568
+ console.log('Bambu Studio installed successfully.');
569
+ console.log('');
570
+ console.log('Launch with: flatpak run com.bambulab.BambuStudio');
571
+ } else {
572
+ console.error('Installation completed but Bambu Studio was not found.');
573
+ }
574
+ }
575
+
576
+ /**
577
+ * Install Bambu Studio on Windows using Chocolatey.
578
+ *
579
+ * Prerequisites:
580
+ * - Windows 10 or Windows 11 (64-bit)
581
+ * - Chocolatey package manager installed
582
+ * - Administrator PowerShell or Command Prompt
583
+ *
584
+ * NOTE: The Chocolatey package depends on vcredist140 (Visual C++ Redistributable),
585
+ * which will be installed automatically if not present.
586
+ *
587
+ * @returns {Promise<void>}
588
+ */
589
+ async function install_windows() {
590
+ // Check if already installed (idempotency check)
591
+ const alreadyInstalled = await isInstalledOnWindows();
592
+ if (alreadyInstalled) {
593
+ console.log('Bambu Studio is already installed.');
594
+ return;
595
+ }
596
+
597
+ // Check if Chocolatey is available
598
+ if (!choco.isInstalled()) {
599
+ console.log('Chocolatey is not installed. Please install Chocolatey first:');
600
+ console.log('');
601
+ console.log('Run this command in an Administrator PowerShell:');
602
+ 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\'))');
603
+ return;
604
+ }
605
+
606
+ console.log('Installing Bambu Studio via Chocolatey...');
607
+
608
+ // Install using Chocolatey
609
+ // The -y flag automatically confirms the installation
610
+ const result = await choco.install(CHOCOLATEY_PACKAGE_NAME);
611
+
612
+ if (!result.success) {
613
+ console.error('Failed to install Bambu Studio:', result.output);
614
+ console.log('');
615
+ console.log('Troubleshooting:');
616
+ console.log(' 1. Ensure you are running as Administrator');
617
+ console.log(' 2. If Visual C++ Redistributable fails, install it manually:');
618
+ console.log(' choco install vcredist140 -y');
619
+ console.log(' 3. Update graphics drivers for OpenGL 2.0+ support');
620
+ return;
621
+ }
622
+
623
+ // Verify installation succeeded
624
+ const verifyInstalled = await isInstalledOnWindows();
625
+ if (verifyInstalled) {
626
+ console.log('Bambu Studio installed successfully.');
627
+ console.log('Location: C:\\Program Files\\Bambu Studio\\bambu-studio.exe');
628
+ console.log('');
629
+ console.log('Launch from the Start Menu or via:');
630
+ console.log(' Start-Process "C:\\Program Files\\Bambu Studio\\bambu-studio.exe"');
631
+ } else {
632
+ console.error('Installation completed but Bambu Studio was not found.');
633
+ console.log('You may need to close and reopen your terminal for PATH updates.');
634
+ }
635
+ }
636
+
637
+ /**
638
+ * Install Bambu Studio on Ubuntu running in WSL (Windows Subsystem for Linux).
639
+ *
640
+ * Uses Flatpak with WSLg for GUI support. WSLg enables Linux GUI applications
641
+ * to run with native Windows integration, appearing as regular Windows windows.
642
+ *
643
+ * Prerequisites:
644
+ * - Windows 10 Build 19044+ or Windows 11
645
+ * - WSL 2 with Ubuntu installed
646
+ * - WSLg enabled (default on Windows 11 and recent Windows 10 updates)
647
+ * - GPU drivers installed on Windows host
648
+ *
649
+ * @returns {Promise<void>}
650
+ */
651
+ async function install_ubuntu_wsl() {
652
+ // Check if already installed via Flatpak (idempotency check)
653
+ const alreadyInstalled = await isInstalledViaFlatpak();
654
+ if (alreadyInstalled) {
655
+ console.log('Bambu Studio is already installed.');
656
+ return;
657
+ }
658
+
659
+ console.log('Note: Bambu Studio in WSL requires WSLg for GUI support.');
660
+ console.log('If you encounter display issues, run "wsl --update" from Windows PowerShell.');
661
+ console.log('');
662
+
663
+ // Check for display environment before proceeding (Bambu Studio requires GUI)
664
+ if (!hasDisplayEnvironment()) {
665
+ console.log('Bambu Studio is a GUI application and requires a desktop environment.');
666
+ console.log('No display environment detected (DISPLAY, WAYLAND_DISPLAY, or XDG_CURRENT_DESKTOP).');
667
+ console.log('');
668
+ console.log('WSLg is required for GUI applications in WSL. Ensure:');
669
+ console.log(' 1. You are running Windows 10 Build 19044+ or Windows 11');
670
+ console.log(' 2. WSL is up to date: wsl --update (from Windows PowerShell)');
671
+ console.log(' 3. WSL 2 is being used: wsl --set-default-version 2');
672
+ console.log('');
673
+ console.log('After updating WSL, restart your WSL session and try again.');
674
+ return;
675
+ }
676
+
677
+ // Ensure Flatpak is installed
678
+ const flatpakReady = await ensureFlatpakInstalled();
679
+ if (!flatpakReady) {
680
+ console.error('Could not install Flatpak. Please install it manually:');
681
+ console.log(' sudo apt-get update && sudo apt-get install -y flatpak');
682
+ return;
683
+ }
684
+
685
+ // Ensure Flathub repository is configured
686
+ const flathubReady = await ensureFlathubConfigured();
687
+ if (!flathubReady) {
688
+ console.error('Could not configure Flathub repository. Please add it manually:');
689
+ console.log(' flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo');
690
+ return;
691
+ }
692
+
693
+ console.log('Installing Bambu Studio via Flatpak...');
694
+ console.log('Note: This may take several minutes on first install.');
695
+
696
+ // Install Bambu Studio from Flathub
697
+ const installResult = await shell.exec(`flatpak install -y flathub ${FLATPAK_APP_ID}`);
698
+
699
+ if (installResult.code !== 0) {
700
+ console.error('Failed to install Bambu Studio:', installResult.stderr);
701
+ console.log('');
702
+ console.log('Troubleshooting:');
703
+ console.log(' 1. Restart WSL: wsl --shutdown (from Windows PowerShell)');
704
+ console.log(' 2. Update WSL: wsl --update (from Windows PowerShell)');
705
+ console.log(' 3. If network issues, try:');
706
+ console.log(' wsl --shutdown && netsh winsock reset (Admin PowerShell)');
707
+ return;
708
+ }
709
+
710
+ // Verify installation succeeded
711
+ const verifyInstalled = await isInstalledViaFlatpak();
712
+ if (verifyInstalled) {
713
+ console.log('Bambu Studio installed successfully.');
714
+ console.log('');
715
+ console.log('Launch with: flatpak run com.bambulab.BambuStudio');
716
+ console.log('');
717
+ console.log('If the application window does not appear:');
718
+ console.log(' 1. Verify WSLg is enabled: wsl --version (from Windows PowerShell)');
719
+ console.log(' 2. Update GPU drivers on the Windows host');
720
+ console.log(' 3. For best performance, consider using the native Windows installation');
721
+ } else {
722
+ console.error('Installation completed but Bambu Studio was not found.');
723
+ }
724
+ }
725
+
726
+ /**
727
+ * Install Bambu Studio from Git Bash on Windows.
728
+ *
729
+ * Git Bash runs on Windows and can access Windows package managers.
730
+ * This function installs Bambu Studio using Chocolatey on the Windows host.
731
+ *
732
+ * Prerequisites:
733
+ * - Git Bash installed (comes with Git for Windows)
734
+ * - Chocolatey installed on Windows
735
+ * - Administrator privileges (run Git Bash as Administrator)
736
+ *
737
+ * @returns {Promise<void>}
738
+ */
739
+ async function install_gitbash() {
740
+ // Git Bash runs on Windows and can access Windows package managers
741
+ // Delegate to the Windows installation function
742
+ console.log('Installing Bambu Studio for Windows from Git Bash...');
743
+
744
+ // Check if already installed (idempotency check)
745
+ // Use a simple file existence check that works from Git Bash
746
+ const checkResult = await shell.exec('ls "/c/Program Files/Bambu Studio/bambu-studio.exe" 2>/dev/null');
747
+ if (checkResult.code === 0) {
748
+ console.log('Bambu Studio is already installed.');
749
+ return;
750
+ }
751
+
752
+ // Check if Chocolatey is available (might need to use full path in Git Bash)
753
+ const chocoPath = '/c/ProgramData/chocolatey/bin/choco.exe';
754
+ const chocoAvailable = shell.commandExists('choco') || fs.existsSync(chocoPath);
755
+
756
+ if (!chocoAvailable) {
757
+ console.log('Chocolatey is not installed. Please install Chocolatey first:');
758
+ console.log('');
759
+ console.log('Run this command in an Administrator PowerShell:');
760
+ 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\'))');
761
+ return;
762
+ }
763
+
764
+ console.log('Installing Bambu Studio via Chocolatey...');
765
+
766
+ // Try to use choco from PATH first, fall back to full path
767
+ const chocoCommand = shell.commandExists('choco') ? 'choco' : chocoPath;
768
+ const installResult = await shell.exec(`${chocoCommand} install ${CHOCOLATEY_PACKAGE_NAME} -y`);
769
+
770
+ if (installResult.code !== 0) {
771
+ console.error('Failed to install Bambu Studio:', installResult.stderr);
772
+ console.log('');
773
+ console.log('Troubleshooting:');
774
+ console.log(' 1. Run Git Bash as Administrator (right-click > Run as administrator)');
775
+ console.log(' 2. Try using the full Chocolatey path:');
776
+ console.log(` ${chocoPath} install ${CHOCOLATEY_PACKAGE_NAME} -y`);
777
+ return;
778
+ }
779
+
780
+ // Verify installation succeeded
781
+ const verifyResult = await shell.exec('ls "/c/Program Files/Bambu Studio/bambu-studio.exe" 2>/dev/null');
782
+ if (verifyResult.code === 0) {
783
+ console.log('Bambu Studio installed successfully.');
784
+ console.log('Location: C:\\Program Files\\Bambu Studio\\bambu-studio.exe');
785
+ console.log('');
786
+ console.log('Launch with: "/c/Program Files/Bambu Studio/bambu-studio.exe" &');
787
+ } else {
788
+ console.error('Installation completed but Bambu Studio was not found.');
789
+ console.log('Close and reopen Git Bash for PATH updates to take effect.');
790
+ }
791
+ }
792
+
793
+ /**
794
+ * Check if Bambu Studio is installed on the current platform.
795
+ *
796
+ * This function performs platform-specific checks to determine if Bambu Studio
797
+ * is already installed:
798
+ * - macOS: Checks for the app bundle in /Applications
799
+ * - Windows: Checks for the executable in Program Files
800
+ * - Linux: Checks for Flatpak installation
801
+ * - Raspberry Pi: Checks for Pi-Apps installation
802
+ *
803
+ * @returns {Promise<boolean>} True if Bambu Studio is installed
804
+ */
805
+ async function isInstalled() {
806
+ const platform = os.detect();
807
+
808
+ // macOS: Check for the app bundle
809
+ if (platform.type === 'macos') {
810
+ return isInstalledOnMacOS();
811
+ }
812
+
813
+ // Windows: Check for the executable
814
+ if (platform.type === 'windows') {
815
+ return await isInstalledOnWindows();
816
+ }
817
+
818
+ // Git Bash: Check for Windows installation
819
+ if (platform.type === 'gitbash') {
820
+ const checkResult = await shell.exec('ls "/c/Program Files/Bambu Studio/bambu-studio.exe" 2>/dev/null');
821
+ return checkResult.code === 0;
822
+ }
823
+
824
+ // Raspberry Pi: Check via Pi-Apps
825
+ if (platform.type === 'raspbian') {
826
+ return await isInstalledOnRaspbian();
827
+ }
828
+
829
+ // Linux platforms (Ubuntu, Debian, WSL, Amazon Linux, Fedora, RHEL): Check Flatpak
830
+ if (['ubuntu', 'debian', 'wsl', 'amazon_linux', 'fedora', 'rhel'].includes(platform.type)) {
831
+ return await isInstalledViaFlatpak();
832
+ }
833
+
834
+ return false;
835
+ }
836
+
837
+ /**
838
+ * Check if this installer is supported on the current platform.
839
+ *
840
+ * Bambu Studio can be installed on all supported platforms:
841
+ * - macOS (via Homebrew cask)
842
+ * - Ubuntu/Debian (via Flatpak from Flathub)
843
+ * - Raspberry Pi OS (via Pi-Apps, 64-bit only)
844
+ * - Amazon Linux/RHEL/Fedora (via Flatpak from Flathub)
845
+ * - Windows (via Chocolatey)
846
+ * - WSL (via Flatpak with WSLg)
847
+ * - Git Bash (via Windows Chocolatey)
848
+ *
849
+ * @returns {boolean} True if installation is supported on this platform
850
+ */
851
+ function isEligible() {
852
+ const platform = os.detect();
853
+ const supportedPlatforms = ['macos', 'ubuntu', 'debian', 'wsl', 'raspbian', 'amazon_linux', 'fedora', 'rhel', 'windows', 'gitbash'];
854
+ if (!supportedPlatforms.includes(platform.type)) {
855
+ return false;
856
+ }
857
+ if (REQUIRES_DESKTOP && !os.isDesktopAvailable()) {
858
+ return false;
859
+ }
860
+ return true;
861
+ }
862
+
863
+ /**
864
+ * Main installation entry point - detects platform and runs appropriate installer.
865
+ *
866
+ * This function automatically determines the current operating system and
867
+ * invokes the correct platform-specific installation function.
868
+ *
869
+ * Supported platforms:
870
+ * - macOS: Homebrew cask
871
+ * - Ubuntu/Debian: Flatpak from Flathub
872
+ * - Raspberry Pi OS: Pi-Apps (64-bit only)
873
+ * - Amazon Linux/RHEL: Flatpak from Flathub
874
+ * - Windows: Chocolatey
875
+ * - WSL: Flatpak with WSLg
876
+ * - Git Bash: Windows Chocolatey
12
877
  *
13
878
  * @returns {Promise<void>}
14
879
  */
15
880
  async function install() {
16
881
  const platform = os.detect();
17
882
 
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 };
883
+ // Map platform types to their respective installer functions
884
+ // This mapping handles aliases (e.g., debian maps to ubuntu)
885
+ const installers = {
886
+ 'macos': install_macos,
887
+ 'ubuntu': install_ubuntu,
888
+ 'debian': install_ubuntu,
889
+ 'wsl': install_ubuntu_wsl,
890
+ 'raspbian': install_raspbian,
891
+ 'amazon_linux': install_amazon_linux,
892
+ 'fedora': install_amazon_linux,
893
+ 'rhel': install_amazon_linux,
894
+ 'windows': install_windows,
895
+ 'gitbash': install_gitbash
896
+ };
897
+
898
+ const installer = installers[platform.type];
899
+
900
+ // Handle unsupported platforms gracefully (no errors, no alternatives)
901
+ if (!installer) {
902
+ console.log(`Bambu Studio is not available for ${platform.type}.`);
903
+ return;
904
+ }
905
+
906
+ await installer();
907
+ }
908
+
909
+ // Export all functions for use as a module and for testing
910
+ module.exports = {
911
+ REQUIRES_DESKTOP,
912
+ install,
913
+ isInstalled,
914
+ isEligible,
915
+ install_macos,
916
+ install_ubuntu,
917
+ install_ubuntu_wsl,
918
+ install_raspbian,
919
+ install_amazon_linux,
920
+ install_windows,
921
+ install_gitbash
922
+ };
41
923
 
924
+ // Allow direct execution of this script: node bambu-studio.js
42
925
  if (require.main === module) {
43
- install();
926
+ install().catch(err => {
927
+ console.error(err.message);
928
+ process.exit(1);
929
+ });
44
930
  }