@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
@@ -3,42 +3,797 @@
3
3
  /**
4
4
  * @fileoverview Install Sublime Text.
5
5
  * @module installs/sublime-text
6
+ *
7
+ * Sublime Text is a sophisticated text editor for code, markup, and prose.
8
+ * Known for its speed, elegant interface, and powerful features including
9
+ * Goto Anything, multiple selections, and distraction-free mode.
10
+ *
11
+ * This installer provides:
12
+ * - macOS: Sublime Text via Homebrew cask
13
+ * - Ubuntu/Debian: Sublime Text from official APT repository
14
+ * - Raspberry Pi OS: Sublime Text from official APT repository (64-bit only)
15
+ * - Amazon Linux/RHEL: Sublime Text from official RPM repository
16
+ * - Windows: Sublime Text via Chocolatey
17
+ * - WSL: Sublime Text directly within WSL
18
+ * - Git Bash: Sublime Text on Windows host via PowerShell
19
+ *
20
+ * IMPORTANT: Sublime Text 4 only supports 64-bit operating systems.
6
21
  */
7
22
 
8
23
  const os = require('../utils/common/os');
24
+ const shell = require('../utils/common/shell');
25
+ const brew = require('../utils/macos/brew');
26
+ const choco = require('../utils/windows/choco');
27
+
28
+ /**
29
+ * Indicates whether this installer requires a desktop environment.
30
+ * Sublime Text is a GUI text editor and requires a display.
31
+ * @type {boolean}
32
+ */
33
+ const REQUIRES_DESKTOP = true;
34
+
35
+ /**
36
+ * The Homebrew cask name for Sublime Text on macOS.
37
+ * @constant {string}
38
+ */
39
+ const HOMEBREW_CASK_NAME = 'sublime-text';
40
+
41
+ /**
42
+ * The Chocolatey package name for Sublime Text on Windows.
43
+ * @constant {string}
44
+ */
45
+ const CHOCO_PACKAGE_NAME = 'sublimetext4';
46
+
47
+ /**
48
+ * The APT package name for Sublime Text on Debian-based systems.
49
+ * @constant {string}
50
+ */
51
+ const APT_PACKAGE_NAME = 'sublime-text';
52
+
53
+ /**
54
+ * Check if Sublime Text CLI (subl) is available in PATH.
55
+ *
56
+ * This is a quick check that works across all platforms. The presence
57
+ * of the subl command indicates Sublime Text is installed and accessible
58
+ * from the command line.
59
+ *
60
+ * @returns {boolean} True if the subl command is available, false otherwise
61
+ */
62
+ function isSublimeCommandAvailable() {
63
+ return shell.commandExists('subl');
64
+ }
65
+
66
+ /**
67
+ * Check if Sublime Text is installed and get the version.
68
+ *
69
+ * Executes 'subl --version' to verify Sublime Text is properly installed
70
+ * and operational. Returns the version/build string if successful.
71
+ *
72
+ * @returns {Promise<string|null>} Sublime Text version string, or null if not installed
73
+ */
74
+ async function getSublimeVersion() {
75
+ if (!isSublimeCommandAvailable()) {
76
+ return null;
77
+ }
78
+
79
+ const result = await shell.exec('subl --version');
80
+ if (result.code === 0 && result.stdout) {
81
+ // Output format: "Sublime Text Build 4200"
82
+ return result.stdout.trim();
83
+ }
84
+ return null;
85
+ }
86
+
87
+ /**
88
+ * Set up Sublime Text's official APT repository on Debian-based systems.
89
+ *
90
+ * This function:
91
+ * 1. Installs prerequisites (apt-transport-https, ca-certificates, curl, gnupg)
92
+ * 2. Creates the keyrings directory if it doesn't exist
93
+ * 3. Downloads and installs Sublime Text's GPG key
94
+ * 4. Adds Sublime Text's APT repository to sources
95
+ * 5. Updates the package cache
96
+ *
97
+ * @returns {Promise<void>}
98
+ * @throws {Error} If any step fails
99
+ */
100
+ async function setupSublimeAptRepository() {
101
+ console.log('Setting up Sublime Text APT repository...');
102
+
103
+ // Install prerequisites
104
+ console.log('Installing prerequisites (apt-transport-https, ca-certificates, curl, gnupg)...');
105
+ const prereqResult = await shell.exec(
106
+ 'sudo DEBIAN_FRONTEND=noninteractive apt-get update -y && ' +
107
+ 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y apt-transport-https ca-certificates curl gnupg'
108
+ );
109
+ if (prereqResult.code !== 0) {
110
+ throw new Error(`Failed to install prerequisites: ${prereqResult.stderr}`);
111
+ }
112
+
113
+ // Create keyrings directory if it doesn't exist
114
+ console.log('Setting up GPG keyring...');
115
+ const keyringDirResult = await shell.exec('sudo mkdir -p /etc/apt/keyrings');
116
+ if (keyringDirResult.code !== 0) {
117
+ throw new Error(`Failed to create keyring directory: ${keyringDirResult.stderr}`);
118
+ }
119
+
120
+ // Download and install Sublime Text's GPG key
121
+ // Using the modern signed-by method with ASC key file
122
+ const gpgResult = await shell.exec(
123
+ 'wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo tee /etc/apt/keyrings/sublimehq-pub.asc > /dev/null'
124
+ );
125
+ if (gpgResult.code !== 0) {
126
+ throw new Error(`Failed to add Sublime Text GPG key: ${gpgResult.stderr}`);
127
+ }
128
+
129
+ // Add the Sublime Text repository using the modern DEB822 format
130
+ console.log('Adding Sublime Text repository...');
131
+ const repoContent = "Types: deb\\nURIs: https://download.sublimetext.com/\\nSuites: apt/stable/\\nSigned-By: /etc/apt/keyrings/sublimehq-pub.asc";
132
+ const repoResult = await shell.exec(
133
+ `echo -e '${repoContent}' | sudo tee /etc/apt/sources.list.d/sublime-text.sources`
134
+ );
135
+ if (repoResult.code !== 0) {
136
+ throw new Error(`Failed to add Sublime Text repository: ${repoResult.stderr}`);
137
+ }
138
+
139
+ // Update package cache
140
+ console.log('Updating package cache...');
141
+ const updateResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update -y');
142
+ if (updateResult.code !== 0) {
143
+ throw new Error(`Failed to update package cache: ${updateResult.stderr}`);
144
+ }
145
+ }
9
146
 
10
147
  /**
11
- * Install Sublime Text across supported platforms.
148
+ * Install Sublime Text via APT package manager.
149
+ *
150
+ * Installs the sublime-text package from the official Sublime Text repository.
151
+ * The repository must be set up before calling this function.
152
+ *
153
+ * @returns {Promise<void>}
154
+ * @throws {Error} If installation fails
155
+ */
156
+ async function installSublimeApt() {
157
+ console.log('Installing Sublime Text...');
158
+
159
+ const result = await shell.exec(
160
+ `sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ${APT_PACKAGE_NAME}`
161
+ );
162
+
163
+ if (result.code !== 0) {
164
+ throw new Error(
165
+ `Failed to install Sublime Text.\n` +
166
+ `Output: ${result.stderr}\n\n` +
167
+ `Troubleshooting:\n` +
168
+ ` 1. Run 'sudo apt-get update' and retry\n` +
169
+ ` 2. Check if the Sublime Text repository was added correctly:\n` +
170
+ ` cat /etc/apt/sources.list.d/sublime-text.sources\n` +
171
+ ` 3. Verify the GPG key exists: ls -la /etc/apt/keyrings/sublimehq-pub.asc`
172
+ );
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Install Sublime Text on macOS using Homebrew.
178
+ *
179
+ * Prerequisites:
180
+ * - macOS 10.15 (Catalina) or later
181
+ * - Homebrew package manager installed
182
+ * - Administrator privileges for Homebrew operations
183
+ *
184
+ * The installation uses the Homebrew cask 'sublime-text' which downloads
185
+ * and installs Sublime Text to /Applications/Sublime Text.app.
186
+ *
187
+ * @returns {Promise<void>}
188
+ * @throws {Error} If Homebrew is not installed or installation fails
189
+ */
190
+ async function install_macos() {
191
+ console.log('Checking if Sublime Text is already installed...');
192
+
193
+ // Check if Sublime Text is already installed via command line
194
+ const existingVersion = await getSublimeVersion();
195
+ if (existingVersion) {
196
+ console.log(`${existingVersion} is already installed, skipping installation.`);
197
+ return;
198
+ }
199
+
200
+ // Also check if the cask is installed (Sublime Text may be installed but subl not in PATH)
201
+ const caskInstalled = await brew.isCaskInstalled(HOMEBREW_CASK_NAME);
202
+ if (caskInstalled) {
203
+ console.log('Sublime Text is already installed via Homebrew, skipping installation.');
204
+ console.log('');
205
+ console.log('NOTE: If the "subl" command is not working, create a symlink:');
206
+ console.log(' sudo ln -sf "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl');
207
+ return;
208
+ }
209
+
210
+ // Verify Homebrew is available
211
+ if (!brew.isInstalled()) {
212
+ throw new Error(
213
+ 'Homebrew is not installed. Please install Homebrew first using:\n' +
214
+ ' dev install homebrew\n' +
215
+ 'Then retry installing Sublime Text.'
216
+ );
217
+ }
218
+
219
+ console.log('Installing Sublime Text via Homebrew...');
220
+
221
+ // Install Sublime Text cask using --quiet to suppress non-essential output
222
+ const result = await shell.exec('brew install --quiet --cask sublime-text');
223
+
224
+ if (result.code !== 0) {
225
+ throw new Error(
226
+ `Failed to install Sublime Text via Homebrew.\n` +
227
+ `Output: ${result.stderr || result.stdout}\n\n` +
228
+ `Troubleshooting:\n` +
229
+ ` 1. Run 'brew update && brew cleanup' and retry\n` +
230
+ ` 2. If you see permission errors, run:\n` +
231
+ ` sudo chown -R $(whoami) /usr/local/Caskroom\n` +
232
+ ` 3. On Apple Silicon, if the app is "damaged", run:\n` +
233
+ ` xattr -cr "/Applications/Sublime Text.app"`
234
+ );
235
+ }
236
+
237
+ console.log('Sublime Text installed successfully.');
238
+ console.log('');
239
+ console.log('You can launch Sublime Text from Applications or via command line:');
240
+ console.log(' open -a "Sublime Text"');
241
+ console.log('');
242
+ console.log('If the "subl" command is not available, create a symlink:');
243
+ console.log(' sudo ln -sf "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl');
244
+ }
245
+
246
+ /**
247
+ * Install Sublime Text on Ubuntu/Debian using APT.
248
+ *
249
+ * Prerequisites:
250
+ * - Ubuntu 18.04+ or Debian 10+ (64-bit)
251
+ * - sudo privileges
252
+ * - wget installed (for GPG key download)
253
+ *
254
+ * This function installs Sublime Text from the official Sublime Text
255
+ * APT repository. It first sets up the repository and GPG key, then
256
+ * installs the package.
257
+ *
258
+ * @returns {Promise<void>}
259
+ * @throws {Error} If installation fails
260
+ */
261
+ async function install_ubuntu() {
262
+ console.log('Checking if Sublime Text is already installed...');
263
+
264
+ // Check if Sublime Text is already installed
265
+ const existingVersion = await getSublimeVersion();
266
+ if (existingVersion) {
267
+ console.log(`${existingVersion} is already installed, skipping installation.`);
268
+ return;
269
+ }
270
+
271
+ // Set up Sublime Text's APT repository
272
+ await setupSublimeAptRepository();
273
+
274
+ // Install Sublime Text
275
+ await installSublimeApt();
276
+
277
+ // Verify installation
278
+ const version = await getSublimeVersion();
279
+ if (!version) {
280
+ throw new Error(
281
+ 'Installation appeared to complete but Sublime Text was not found.\n\n' +
282
+ 'Please try:\n' +
283
+ ' 1. Restart your terminal session\n' +
284
+ ' 2. Run: subl --version'
285
+ );
286
+ }
287
+
288
+ console.log(`${version} installed successfully.`);
289
+ console.log('');
290
+ console.log('You can launch Sublime Text via:');
291
+ console.log(' subl');
292
+ }
293
+
294
+ /**
295
+ * Install Sublime Text on Ubuntu running in WSL (Windows Subsystem for Linux).
296
+ *
297
+ * Prerequisites:
298
+ * - Windows 10 version 2004 or higher, or Windows 11
299
+ * - WSL 2 enabled with Ubuntu distribution installed
300
+ * - sudo privileges within WSL
301
+ *
302
+ * NOTE: GUI applications in WSL require WSLg (Windows 11) or an X server
303
+ * (Windows 10). Without a display server, Sublime Text cannot launch
304
+ * its graphical interface.
305
+ *
306
+ * @returns {Promise<void>}
307
+ * @throws {Error} If installation fails
308
+ */
309
+ async function install_ubuntu_wsl() {
310
+ console.log('Detected Ubuntu running in WSL (Windows Subsystem for Linux).');
311
+ console.log('');
312
+ console.log('Installing Sublime Text directly within WSL...');
313
+ console.log('');
314
+
315
+ // Check if Sublime Text is already installed
316
+ const existingVersion = await getSublimeVersion();
317
+ if (existingVersion) {
318
+ console.log(`${existingVersion} is already installed, skipping installation.`);
319
+ return;
320
+ }
321
+
322
+ // Set up Sublime Text's APT repository
323
+ await setupSublimeAptRepository();
324
+
325
+ // Install Sublime Text
326
+ await installSublimeApt();
327
+
328
+ // Verify installation
329
+ const version = await getSublimeVersion();
330
+ if (!version) {
331
+ throw new Error(
332
+ 'Installation appeared to complete but Sublime Text was not found.\n\n' +
333
+ 'Please try:\n' +
334
+ ' 1. Restart your terminal session\n' +
335
+ ' 2. Run: subl --version'
336
+ );
337
+ }
338
+
339
+ console.log(`${version} installed successfully.`);
340
+ console.log('');
341
+ console.log('IMPORTANT for WSL users:');
342
+ console.log('');
343
+ console.log('1. GUI applications require WSLg (Windows 11) or an X server (Windows 10).');
344
+ console.log('');
345
+ console.log('2. On Windows 11 with WSLg, simply run:');
346
+ console.log(' subl');
347
+ console.log('');
348
+ console.log('3. On Windows 10, you need an X server like VcXsrv:');
349
+ console.log(' - Install VcXsrv and launch XLaunch');
350
+ console.log(' - Set DISPLAY variable: export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk "{print \\$2}"):0');
351
+ console.log(' - Then run: subl');
352
+ console.log('');
353
+ console.log('4. If you see scaling issues, try:');
354
+ console.log(' export GDK_SCALE=2');
355
+ console.log(' export GDK_DPI_SCALE=0.5');
356
+ }
357
+
358
+ /**
359
+ * Install Sublime Text on Raspberry Pi OS using APT.
360
+ *
361
+ * Prerequisites:
362
+ * - Raspberry Pi OS (64-bit) - Bookworm or Bullseye
363
+ * - Raspberry Pi 3B+ or later (64-bit capable hardware)
364
+ * - sudo privileges
365
+ *
366
+ * IMPORTANT: Sublime Text 4 requires a 64-bit operating system.
367
+ * It does not support 32-bit Raspberry Pi OS (armv7l architecture).
368
+ *
369
+ * @returns {Promise<void>}
370
+ * @throws {Error} If installation fails or system is 32-bit
371
+ */
372
+ async function install_raspbian() {
373
+ console.log('Checking if Sublime Text is already installed...');
374
+
375
+ // Check if Sublime Text is already installed
376
+ const existingVersion = await getSublimeVersion();
377
+ if (existingVersion) {
378
+ console.log(`${existingVersion} is already installed, skipping installation.`);
379
+ return;
380
+ }
381
+
382
+ // Check architecture - Sublime Text 4 requires 64-bit
383
+ const archResult = await shell.exec('uname -m');
384
+ const arch = archResult.stdout.trim();
385
+
386
+ if (arch === 'armv7l') {
387
+ console.log('Sublime Text is not available for 32-bit Raspberry Pi OS.');
388
+ console.log('');
389
+ console.log('Sublime Text 4 requires a 64-bit operating system.');
390
+ console.log('Your current architecture: ' + arch + ' (32-bit)');
391
+ console.log('');
392
+ console.log('To use Sublime Text on Raspberry Pi:');
393
+ console.log(' 1. Download 64-bit Raspberry Pi OS from raspberrypi.com');
394
+ console.log(' 2. Flash it to a new SD card');
395
+ console.log(' 3. Retry this installation');
396
+ return;
397
+ }
398
+
399
+ console.log(`Detected 64-bit architecture: ${arch}`);
400
+
401
+ // Set up Sublime Text's APT repository
402
+ await setupSublimeAptRepository();
403
+
404
+ // Install Sublime Text
405
+ await installSublimeApt();
406
+
407
+ // Verify installation
408
+ const version = await getSublimeVersion();
409
+ if (!version) {
410
+ throw new Error(
411
+ 'Installation appeared to complete but Sublime Text was not found.\n\n' +
412
+ 'Please try:\n' +
413
+ ' 1. Restart your terminal session\n' +
414
+ ' 2. Run: subl --version'
415
+ );
416
+ }
417
+
418
+ console.log(`${version} installed successfully.`);
419
+ console.log('');
420
+ console.log('You can launch Sublime Text from the Programming menu or via:');
421
+ console.log(' subl');
422
+ console.log('');
423
+ console.log('NOTE: If Sublime Text runs slowly, consider:');
424
+ console.log(' - Adding swap space if memory is limited');
425
+ console.log(' - Disabling hardware acceleration in preferences:');
426
+ console.log(' { "hardware_acceleration": "none" }');
427
+ }
428
+
429
+ /**
430
+ * Install Sublime Text on Amazon Linux/RHEL using DNF or YUM.
431
+ *
432
+ * Prerequisites:
433
+ * - Amazon Linux 2023, Amazon Linux 2, RHEL 8+, CentOS 8+, or Fedora (64-bit)
434
+ * - sudo privileges
435
+ *
436
+ * IMPORTANT: Sublime Text does not provide ARM64 RPM packages.
437
+ * This installation method only works on x86_64 systems.
438
+ *
439
+ * @returns {Promise<void>}
440
+ * @throws {Error} If installation fails
441
+ */
442
+ async function install_amazon_linux() {
443
+ console.log('Checking if Sublime Text is already installed...');
444
+
445
+ // Check if Sublime Text is already installed
446
+ const existingVersion = await getSublimeVersion();
447
+ if (existingVersion) {
448
+ console.log(`${existingVersion} is already installed, skipping installation.`);
449
+ return;
450
+ }
451
+
452
+ // Check architecture - Sublime Text only provides x86_64 RPMs
453
+ const archResult = await shell.exec('uname -m');
454
+ const arch = archResult.stdout.trim();
455
+
456
+ if (arch !== 'x86_64') {
457
+ console.log(`Sublime Text is not available for ${arch} architecture on Amazon Linux/RHEL.`);
458
+ console.log('');
459
+ console.log('Sublime Text only provides x86_64 RPM packages.');
460
+ return;
461
+ }
462
+
463
+ // Detect package manager (dnf for AL2023/Fedora, yum for AL2)
464
+ const hasDnf = shell.commandExists('dnf');
465
+ const hasYum = shell.commandExists('yum');
466
+ const packageManager = hasDnf ? 'dnf' : (hasYum ? 'yum' : null);
467
+
468
+ if (!packageManager) {
469
+ throw new Error(
470
+ 'Neither dnf nor yum package manager found.\n' +
471
+ 'This installer supports Amazon Linux 2023 (dnf), Amazon Linux 2 (yum), RHEL, and Fedora.'
472
+ );
473
+ }
474
+
475
+ console.log(`Detected package manager: ${packageManager}`);
476
+
477
+ // Import Sublime Text GPG key
478
+ console.log('Importing Sublime Text GPG key...');
479
+ const gpgResult = await shell.exec(
480
+ 'sudo rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg'
481
+ );
482
+ if (gpgResult.code !== 0) {
483
+ throw new Error(`Failed to import GPG key: ${gpgResult.stderr}`);
484
+ }
485
+
486
+ // Add Sublime Text repository
487
+ console.log('Adding Sublime Text repository...');
488
+ let repoResult;
489
+
490
+ if (hasDnf) {
491
+ // Check for dnf5 (Fedora 41+) which uses different syntax
492
+ const dnf5Check = await shell.exec('dnf --version 2>/dev/null | head -1');
493
+ const isDnf5 = dnf5Check.stdout && dnf5Check.stdout.includes('dnf5');
494
+
495
+ if (isDnf5) {
496
+ // dnf5 syntax for Fedora 41+
497
+ repoResult = await shell.exec(
498
+ 'sudo dnf config-manager addrepo --from-repofile=https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo'
499
+ );
500
+ } else {
501
+ // Standard dnf syntax
502
+ repoResult = await shell.exec(
503
+ 'sudo dnf config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo'
504
+ );
505
+ }
506
+ } else {
507
+ // Ensure yum-config-manager is available
508
+ const hasConfigManager = shell.commandExists('yum-config-manager');
509
+ if (!hasConfigManager) {
510
+ console.log('Installing yum-utils for repository management...');
511
+ const yumUtilsResult = await shell.exec('sudo yum install -y yum-utils');
512
+ if (yumUtilsResult.code !== 0) {
513
+ throw new Error('Failed to install yum-utils: ' + yumUtilsResult.stderr);
514
+ }
515
+ }
516
+
517
+ repoResult = await shell.exec(
518
+ 'sudo yum-config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo'
519
+ );
520
+ }
521
+
522
+ if (repoResult.code !== 0) {
523
+ throw new Error(`Failed to add Sublime Text repository: ${repoResult.stderr}`);
524
+ }
525
+
526
+ // Install Sublime Text
527
+ console.log('Installing Sublime Text...');
528
+ const installResult = await shell.exec(`sudo ${packageManager} install -y sublime-text`);
529
+
530
+ if (installResult.code !== 0) {
531
+ throw new Error(
532
+ `Failed to install Sublime Text.\n` +
533
+ `Output: ${installResult.stderr}\n\n` +
534
+ `Troubleshooting:\n` +
535
+ ` 1. Run 'sudo ${packageManager} clean all' and retry\n` +
536
+ ` 2. Verify the GPG key was imported:\n` +
537
+ ` rpm -qa gpg-pubkey* | xargs rpm -qi | grep -i sublime`
538
+ );
539
+ }
540
+
541
+ // Verify installation
542
+ const version = await getSublimeVersion();
543
+ if (!version) {
544
+ throw new Error(
545
+ 'Installation appeared to complete but Sublime Text was not found.\n\n' +
546
+ 'Please try:\n' +
547
+ ' 1. Restart your terminal session\n' +
548
+ ' 2. Run: subl --version'
549
+ );
550
+ }
551
+
552
+ console.log(`${version} installed successfully.`);
553
+ console.log('');
554
+ console.log('You can launch Sublime Text via:');
555
+ console.log(' subl');
556
+ }
557
+
558
+ /**
559
+ * Install Sublime Text on Windows using Chocolatey.
560
+ *
561
+ * Prerequisites:
562
+ * - Windows 10 or Windows 11 (64-bit)
563
+ * - Administrator PowerShell or Command Prompt
564
+ * - Chocolatey package manager installed
565
+ *
566
+ * The installation uses Chocolatey package 'sublimetext4'.
567
+ *
568
+ * @returns {Promise<void>}
569
+ * @throws {Error} If Chocolatey is not installed or installation fails
570
+ */
571
+ async function install_windows() {
572
+ console.log('Checking if Sublime Text is already installed...');
573
+
574
+ // Check if Sublime Text is already installed
575
+ const existingVersion = await getSublimeVersion();
576
+ if (existingVersion) {
577
+ console.log(`${existingVersion} is already installed, skipping installation.`);
578
+ return;
579
+ }
580
+
581
+ // Check if the Chocolatey package is installed
582
+ const packageInstalled = await choco.isPackageInstalled(CHOCO_PACKAGE_NAME);
583
+ if (packageInstalled) {
584
+ console.log('Sublime Text is already installed via Chocolatey, skipping installation.');
585
+ console.log('');
586
+ console.log('NOTE: If the "subl" command is not working, add Sublime Text to your PATH:');
587
+ console.log(' C:\\Program Files\\Sublime Text');
588
+ return;
589
+ }
590
+
591
+ // Verify Chocolatey is available
592
+ if (!choco.isInstalled()) {
593
+ throw new Error(
594
+ 'Chocolatey is not installed. Please install Chocolatey first:\n\n' +
595
+ 'Run the following in an Administrator PowerShell:\n' +
596
+ ' Set-ExecutionPolicy Bypass -Scope Process -Force; ' +
597
+ '[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; ' +
598
+ 'iex ((New-Object System.Net.WebClient).DownloadString(\'https://community.chocolatey.org/install.ps1\'))\n\n' +
599
+ 'Then retry installing Sublime Text.'
600
+ );
601
+ }
602
+
603
+ console.log('Installing Sublime Text via Chocolatey...');
604
+
605
+ // Install Sublime Text using the -y flag for non-interactive installation
606
+ const result = await choco.install(CHOCO_PACKAGE_NAME);
607
+
608
+ if (!result.success) {
609
+ throw new Error(
610
+ `Failed to install Sublime Text via Chocolatey.\n` +
611
+ `Output: ${result.output}\n\n` +
612
+ `Troubleshooting:\n` +
613
+ ` 1. Ensure you are running as Administrator\n` +
614
+ ` 2. Try manual installation: choco install sublimetext4 -y --force`
615
+ );
616
+ }
617
+
618
+ console.log('Sublime Text installed successfully.');
619
+ console.log('');
620
+ console.log('You may need to open a new terminal window for the "subl" command to work.');
621
+ console.log('');
622
+ console.log('If "subl" is not recognized, add Sublime Text to your PATH:');
623
+ console.log(' C:\\Program Files\\Sublime Text');
624
+ console.log('');
625
+ console.log('Or via PowerShell:');
626
+ console.log(' $sublPath = "C:\\Program Files\\Sublime Text"');
627
+ console.log(' [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$sublPath", [EnvironmentVariableTarget]::User)');
628
+ }
629
+
630
+ /**
631
+ * Install Sublime Text from Git Bash on Windows.
632
+ *
633
+ * Git Bash runs within Windows, so this function installs Sublime Text
634
+ * on the Windows host using Chocolatey via PowerShell interop.
635
+ *
636
+ * Prerequisites:
637
+ * - Windows 10 or Windows 11 (64-bit)
638
+ * - Git Bash installed (comes with Git for Windows)
639
+ * - Chocolatey package manager installed on Windows
640
+ * - Administrator privileges
641
+ *
642
+ * @returns {Promise<void>}
643
+ * @throws {Error} If installation fails
644
+ */
645
+ async function install_gitbash() {
646
+ console.log('Detected Git Bash on Windows.');
647
+ console.log('Installing Sublime Text on the Windows host...');
648
+ console.log('');
649
+
650
+ // Check if Sublime Text is already available
651
+ const existingVersion = await getSublimeVersion();
652
+ if (existingVersion) {
653
+ console.log(`${existingVersion} is already installed, skipping installation.`);
654
+ return;
655
+ }
656
+
657
+ // Install via PowerShell using Chocolatey
658
+ console.log('Installing Sublime Text via Chocolatey...');
659
+
660
+ const installResult = await shell.exec(
661
+ 'powershell.exe -NoProfile -Command "choco install sublimetext4 -y"'
662
+ );
663
+
664
+ if (installResult.code !== 0) {
665
+ throw new Error(
666
+ `Failed to install Sublime Text.\n` +
667
+ `Output: ${installResult.stdout || installResult.stderr}\n\n` +
668
+ `Troubleshooting:\n` +
669
+ ` 1. Ensure Chocolatey is installed on Windows\n` +
670
+ ` 2. Run Git Bash as Administrator and retry\n` +
671
+ ` 3. Try installing directly from PowerShell:\n` +
672
+ ` choco install sublimetext4 -y`
673
+ );
674
+ }
675
+
676
+ console.log('Sublime Text installed successfully.');
677
+ console.log('');
678
+ console.log('If "subl" is not available in Git Bash, add an alias to ~/.bashrc:');
679
+ console.log(' echo \'alias subl="/c/Program\\ Files/Sublime\\ Text/subl.exe"\' >> ~/.bashrc');
680
+ console.log(' source ~/.bashrc');
681
+ console.log('');
682
+ console.log('To prevent Git Bash from hanging when opening files:');
683
+ console.log(' subl myfile.txt &');
684
+ }
685
+
686
+ /**
687
+ * Check if Sublime Text is installed on the current platform.
688
+ *
689
+ * This function performs platform-specific checks to determine if Sublime Text
690
+ * is already installed on the system by checking for the 'subl' command.
691
+ *
692
+ * @returns {Promise<boolean>} True if Sublime Text is installed, false otherwise
693
+ */
694
+ async function isInstalled() {
695
+ const platform = os.detect();
696
+
697
+ if (platform.type === 'macos') {
698
+ const caskInstalled = await brew.isCaskInstalled(HOMEBREW_CASK_NAME);
699
+ if (caskInstalled) return true;
700
+ }
701
+
702
+ if (platform.type === 'windows' || platform.type === 'gitbash') {
703
+ return choco.isPackageInstalled(CHOCO_PACKAGE_NAME);
704
+ }
705
+
706
+ // For all platforms, check if subl command is available
707
+ return isSublimeCommandAvailable();
708
+ }
709
+
710
+ /**
711
+ * Check if this installer is supported on the current platform.
712
+ * Sublime Text is available on all major platforms.
713
+ * @returns {boolean} True if installation is supported on this platform
714
+ */
715
+ function isEligible() {
716
+ const platform = os.detect();
717
+
718
+ // First check if the platform is supported
719
+ const supportedPlatforms = ['macos', 'ubuntu', 'debian', 'wsl', 'raspbian', 'amazon_linux', 'rhel', 'fedora', 'windows', 'gitbash'];
720
+ if (!supportedPlatforms.includes(platform.type)) {
721
+ return false;
722
+ }
723
+
724
+ // This installer requires a desktop environment
725
+ if (REQUIRES_DESKTOP && !os.isDesktopAvailable()) {
726
+ return false;
727
+ }
728
+
729
+ return true;
730
+ }
731
+
732
+ /**
733
+ * Main installation entry point.
734
+ *
735
+ * Detects the current platform and runs the appropriate installer function.
736
+ * Handles platform-specific mappings to ensure all supported platforms
737
+ * have appropriate installation logic.
738
+ *
739
+ * Supported platforms:
740
+ * - macOS: Sublime Text via Homebrew cask
741
+ * - Ubuntu/Debian: Sublime Text from official APT repository
742
+ * - Raspberry Pi OS: Sublime Text from official APT repository (64-bit only)
743
+ * - Amazon Linux/RHEL: Sublime Text from official RPM repository
744
+ * - Windows: Sublime Text via Chocolatey
745
+ * - WSL (Ubuntu): Sublime Text within WSL
746
+ * - Git Bash: Sublime Text on Windows host
12
747
  *
13
748
  * @returns {Promise<void>}
14
749
  */
15
750
  async function install() {
16
751
  const platform = os.detect();
17
752
 
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 };
753
+ // Map platform types to their installer functions
754
+ // This mapping handles aliases (e.g., debian maps to ubuntu for APT-based installs)
755
+ const installers = {
756
+ 'macos': install_macos,
757
+ 'ubuntu': install_ubuntu,
758
+ 'debian': install_ubuntu,
759
+ 'wsl': install_ubuntu_wsl,
760
+ 'raspbian': install_raspbian,
761
+ 'amazon_linux': install_amazon_linux,
762
+ 'rhel': install_amazon_linux,
763
+ 'fedora': install_amazon_linux,
764
+ 'windows': install_windows,
765
+ 'gitbash': install_gitbash
766
+ };
767
+
768
+ const installer = installers[platform.type];
769
+
770
+ if (!installer) {
771
+ console.log(`Sublime Text is not available for ${platform.type}.`);
772
+ return;
773
+ }
774
+
775
+ await installer();
776
+ }
777
+
778
+ // Export all functions for use as a module and for testing
779
+ module.exports = {
780
+ REQUIRES_DESKTOP,
781
+ install,
782
+ isInstalled,
783
+ isEligible,
784
+ install_macos,
785
+ install_ubuntu,
786
+ install_ubuntu_wsl,
787
+ install_raspbian,
788
+ install_amazon_linux,
789
+ install_windows,
790
+ install_gitbash
791
+ };
41
792
 
793
+ // Allow direct execution: node sublime-text.js
42
794
  if (require.main === module) {
43
- install();
795
+ install().catch(err => {
796
+ console.error(err.message);
797
+ process.exit(1);
798
+ });
44
799
  }