@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
package/src/scripts/y.js CHANGED
@@ -1,23 +1,283 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * @fileoverview Shortcut for yarn commands.
4
+ * y - Shortcut for yarn commands
5
+ *
6
+ * Migrated from legacy dotfiles alias.
7
+ * Original: alias y="yarn"
8
+ *
9
+ * This script provides a single-character shortcut for the Yarn package manager,
10
+ * passing all arguments through to the `yarn` command. Yarn is a popular
11
+ * JavaScript package manager that is an alternative to npm.
12
+ *
13
+ * Examples:
14
+ * y -> yarn (runs default yarn command, typically install)
15
+ * y add lodash -> yarn add lodash
16
+ * y remove lodash -> yarn remove lodash
17
+ * y dev -> yarn dev (runs the "dev" script)
18
+ * y build -> yarn build (runs the "build" script)
19
+ * y --version -> yarn --version
20
+ *
5
21
  * @module scripts/y
6
22
  */
7
23
 
24
+ const os = require('../utils/common/os');
25
+ const { spawn } = require('child_process');
26
+ const { commandExists } = require('../utils/common/shell');
27
+
28
+ /**
29
+ * Pure Node.js implementation that works on any platform.
30
+ *
31
+ * This function spawns the `yarn` command with all provided arguments.
32
+ * It uses spawn with stdio: 'inherit' to:
33
+ * 1. Pass through all arguments exactly as provided
34
+ * 2. Preserve colored output from yarn
35
+ * 3. Allow interactive prompts if yarn needs user input
36
+ * 4. Properly forward stdin, stdout, and stderr
37
+ *
38
+ * The exit code from yarn is preserved and passed to the parent process,
39
+ * ensuring that CI/CD pipelines and scripts can detect yarn failures.
40
+ *
41
+ * @param {string[]} args - Command line arguments to pass to yarn
42
+ * @returns {Promise<void>}
43
+ */
44
+ async function do_y_nodejs(args) {
45
+ // First, check if yarn is installed
46
+ if (!commandExists('yarn')) {
47
+ console.error('Error: yarn is not installed or not in PATH.');
48
+ console.error('');
49
+ console.error('To install yarn, you can use one of the following methods:');
50
+ console.error('');
51
+ console.error(' Using npm (recommended if you have Node.js):');
52
+ console.error(' npm install -g yarn');
53
+ console.error('');
54
+ console.error(' Using Corepack (Node.js 16.10+):');
55
+ console.error(' corepack enable');
56
+ console.error('');
57
+ console.error(' Using Homebrew (macOS):');
58
+ console.error(' brew install yarn');
59
+ console.error('');
60
+ console.error(' Using apt (Ubuntu/Debian):');
61
+ console.error(' sudo apt install yarn');
62
+ console.error('');
63
+ console.error('For more information, visit: https://yarnpkg.com/getting-started/install');
64
+ process.exit(1);
65
+ }
66
+
67
+ // Spawn yarn with all arguments, inheriting stdio for full interactivity
68
+ // This preserves:
69
+ // - Colored output (yarn uses colors extensively)
70
+ // - Interactive prompts (e.g., yarn init questions)
71
+ // - Progress indicators and spinners
72
+ // - Proper terminal width detection
73
+ return new Promise((resolve, reject) => {
74
+ const child = spawn('yarn', args, {
75
+ stdio: 'inherit', // Pass through stdin, stdout, stderr
76
+ shell: false // Run yarn directly, not through a shell (more efficient)
77
+ });
78
+
79
+ child.on('close', (code) => {
80
+ // Preserve yarn's exit code so CI/CD can detect failures
81
+ // Exit code 0 = success, non-zero = failure
82
+ if (code !== 0) {
83
+ process.exit(code);
84
+ }
85
+ resolve();
86
+ });
87
+
88
+ child.on('error', (err) => {
89
+ // This typically happens if yarn is not found (though we check above)
90
+ // or if there's a permission issue
91
+ console.error(`Error executing yarn: ${err.message}`);
92
+ process.exit(1);
93
+ });
94
+ });
95
+ }
96
+
97
+ /**
98
+ * Execute yarn on macOS.
99
+ *
100
+ * Uses the pure Node.js implementation since yarn behaves identically
101
+ * on all platforms - it's a cross-platform tool by design.
102
+ *
103
+ * On macOS, yarn is typically installed via:
104
+ * - npm install -g yarn
105
+ * - brew install yarn
106
+ * - Corepack (corepack enable)
107
+ *
108
+ * @param {string[]} args - Command line arguments to pass to yarn
109
+ * @returns {Promise<void>}
110
+ */
111
+ async function do_y_macos(args) {
112
+ return do_y_nodejs(args);
113
+ }
114
+
115
+ /**
116
+ * Execute yarn on Ubuntu.
117
+ *
118
+ * Uses the pure Node.js implementation since yarn behaves identically
119
+ * on all platforms - it's a cross-platform tool by design.
120
+ *
121
+ * On Ubuntu, yarn is typically installed via:
122
+ * - npm install -g yarn
123
+ * - sudo apt install yarn (from official yarn repository)
124
+ * - Corepack (corepack enable)
125
+ *
126
+ * @param {string[]} args - Command line arguments to pass to yarn
127
+ * @returns {Promise<void>}
128
+ */
129
+ async function do_y_ubuntu(args) {
130
+ return do_y_nodejs(args);
131
+ }
132
+
133
+ /**
134
+ * Execute yarn on Raspberry Pi OS.
135
+ *
136
+ * Uses the pure Node.js implementation since yarn behaves identically
137
+ * on all platforms - it's a cross-platform tool by design.
138
+ *
139
+ * On Raspberry Pi OS, yarn is typically installed via:
140
+ * - npm install -g yarn
141
+ * - Corepack (corepack enable)
142
+ *
143
+ * @param {string[]} args - Command line arguments to pass to yarn
144
+ * @returns {Promise<void>}
145
+ */
146
+ async function do_y_raspbian(args) {
147
+ return do_y_nodejs(args);
148
+ }
149
+
150
+ /**
151
+ * Execute yarn on Amazon Linux.
152
+ *
153
+ * Uses the pure Node.js implementation since yarn behaves identically
154
+ * on all platforms - it's a cross-platform tool by design.
155
+ *
156
+ * On Amazon Linux, yarn is typically installed via:
157
+ * - npm install -g yarn
158
+ * - Corepack (corepack enable)
159
+ *
160
+ * @param {string[]} args - Command line arguments to pass to yarn
161
+ * @returns {Promise<void>}
162
+ */
163
+ async function do_y_amazon_linux(args) {
164
+ return do_y_nodejs(args);
165
+ }
166
+
167
+ /**
168
+ * Execute yarn in Windows Command Prompt.
169
+ *
170
+ * Uses the pure Node.js implementation since yarn behaves identically
171
+ * on all platforms - it's a cross-platform tool by design.
172
+ *
173
+ * On Windows, yarn is typically installed via:
174
+ * - npm install -g yarn
175
+ * - choco install yarn (Chocolatey)
176
+ * - winget install Yarn.Yarn
177
+ * - Corepack (corepack enable)
178
+ *
179
+ * Note: On Windows, yarn is typically installed as yarn.cmd or yarn.ps1,
180
+ * but spawn will find it correctly through the PATH.
181
+ *
182
+ * @param {string[]} args - Command line arguments to pass to yarn
183
+ * @returns {Promise<void>}
184
+ */
185
+ async function do_y_cmd(args) {
186
+ return do_y_nodejs(args);
187
+ }
188
+
8
189
  /**
9
- * Executes yarn with the provided arguments.
10
- * Acts as a shorthand for common yarn operations.
190
+ * Execute yarn in Windows PowerShell.
191
+ *
192
+ * Uses the pure Node.js implementation since yarn behaves identically
193
+ * on all platforms - it's a cross-platform tool by design.
11
194
  *
12
195
  * @param {string[]} args - Command line arguments to pass to yarn
13
196
  * @returns {Promise<void>}
14
197
  */
15
- async function main(args) {
16
- // TODO: Implement yarn shortcut
198
+ async function do_y_powershell(args) {
199
+ return do_y_nodejs(args);
200
+ }
201
+
202
+ /**
203
+ * Execute yarn in Git Bash on Windows.
204
+ *
205
+ * Uses the pure Node.js implementation since yarn behaves identically
206
+ * on all platforms - it's a cross-platform tool by design.
207
+ *
208
+ * Git Bash can access Windows-installed yarn through the PATH.
209
+ *
210
+ * @param {string[]} args - Command line arguments to pass to yarn
211
+ * @returns {Promise<void>}
212
+ */
213
+ async function do_y_gitbash(args) {
214
+ return do_y_nodejs(args);
215
+ }
216
+
217
+ /**
218
+ * Main entry point - detects environment and executes appropriate implementation.
219
+ *
220
+ * The "y" command is a shortcut for yarn, the JavaScript package manager.
221
+ * All arguments are passed through to yarn unchanged.
222
+ *
223
+ * This script is idempotent by nature - running yarn commands multiple times
224
+ * will produce consistent results (yarn itself handles idempotency for
225
+ * operations like install).
226
+ *
227
+ * Common usage patterns:
228
+ * y - Install dependencies (equivalent to yarn install)
229
+ * y add <package> - Add a new dependency
230
+ * y remove <package> - Remove a dependency
231
+ * y <script> - Run a script from package.json
232
+ * y upgrade - Upgrade dependencies
233
+ * y --help - Show yarn help
234
+ *
235
+ * @param {string[]} args - Command line arguments to pass to yarn
236
+ * @returns {Promise<void>}
237
+ */
238
+ async function do_y(args) {
239
+ const platform = os.detect();
240
+
241
+ const handlers = {
242
+ 'macos': do_y_macos,
243
+ 'ubuntu': do_y_ubuntu,
244
+ 'debian': do_y_ubuntu,
245
+ 'raspbian': do_y_raspbian,
246
+ 'amazon_linux': do_y_amazon_linux,
247
+ 'rhel': do_y_amazon_linux,
248
+ 'fedora': do_y_ubuntu,
249
+ 'linux': do_y_ubuntu,
250
+ 'wsl': do_y_ubuntu,
251
+ 'cmd': do_y_cmd,
252
+ 'windows': do_y_cmd,
253
+ 'powershell': do_y_powershell,
254
+ 'gitbash': do_y_gitbash
255
+ };
256
+
257
+ const handler = handlers[platform.type];
258
+ if (!handler) {
259
+ // Yarn is cross-platform, so try the Node.js implementation anyway
260
+ console.error(`Note: Platform '${platform.type}' not explicitly supported, attempting to run yarn...`);
261
+ await do_y_nodejs(args);
262
+ return;
263
+ }
264
+
265
+ await handler(args);
17
266
  }
18
267
 
19
- module.exports = { main };
268
+ module.exports = {
269
+ main: do_y,
270
+ do_y,
271
+ do_y_nodejs,
272
+ do_y_macos,
273
+ do_y_ubuntu,
274
+ do_y_raspbian,
275
+ do_y_amazon_linux,
276
+ do_y_cmd,
277
+ do_y_powershell,
278
+ do_y_gitbash
279
+ };
20
280
 
21
281
  if (require.main === module) {
22
- main(process.argv.slice(2));
282
+ do_y(process.argv.slice(2));
23
283
  }
@@ -72,7 +72,8 @@ function detect() {
72
72
  }
73
73
 
74
74
  // RHEL-based (Amazon Linux, CentOS, Fedora, RHEL)
75
- if (fs.existsSync('/etc/redhat-release')) {
75
+ // Check for /etc/redhat-release OR /etc/system-release (Amazon Linux 2023 uses system-release)
76
+ if (fs.existsSync('/etc/redhat-release') || fs.existsSync('/etc/system-release')) {
76
77
  if (distro === 'amzn' || distro === 'amazon') {
77
78
  result.type = 'amazon_linux';
78
79
  } else if (distro === 'fedora') {
@@ -189,6 +190,96 @@ function getTempDir() {
189
190
  return os.tmpdir();
190
191
  }
191
192
 
193
+ /**
194
+ * Checks if a graphical desktop environment is available on the current system.
195
+ *
196
+ * This function determines whether GUI applications can be displayed:
197
+ * - macOS: Always returns true (Aqua/Quartz desktop is always available)
198
+ * - Windows (native): Always returns true (Windows Desktop is always available)
199
+ * - Git Bash: Always returns true (runs on Windows which has a desktop)
200
+ * - Linux: Checks for X11, Wayland, or installed desktop environment packages
201
+ * - WSL: Checks for WSLg or X server availability via DISPLAY/WAYLAND_DISPLAY
202
+ *
203
+ * Use this function before installing GUI applications to ensure the system
204
+ * can actually display them. Headless servers and containers typically
205
+ * return false.
206
+ *
207
+ * @returns {boolean} True if a desktop environment is available, false otherwise
208
+ *
209
+ * @example
210
+ * const os = require('../utils/common/os');
211
+ * if (!os.isDesktopAvailable()) {
212
+ * console.log('This tool requires a desktop environment.');
213
+ * return;
214
+ * }
215
+ */
216
+ function isDesktopAvailable() {
217
+ const platform = detect();
218
+
219
+ // macOS always has a desktop environment (Aqua/Quartz)
220
+ if (platform.type === 'macos') {
221
+ return true;
222
+ }
223
+
224
+ // Windows (native) always has a desktop environment
225
+ if (platform.type === 'windows') {
226
+ return true;
227
+ }
228
+
229
+ // Git Bash runs on Windows, which has a desktop
230
+ if (platform.type === 'gitbash') {
231
+ return true;
232
+ }
233
+
234
+ // For Linux-based systems (including WSL), check for display availability
235
+ // This covers ubuntu, debian, raspbian, amazon_linux, rhel, fedora, wsl
236
+ if (platform.type === 'wsl' ||
237
+ platform.type === 'ubuntu' ||
238
+ platform.type === 'debian' ||
239
+ platform.type === 'raspbian' ||
240
+ platform.type === 'amazon_linux' ||
241
+ platform.type === 'rhel' ||
242
+ platform.type === 'fedora' ||
243
+ platform.type === 'linux') {
244
+
245
+ // Check for Wayland display (modern Linux desktops)
246
+ if (process.env.WAYLAND_DISPLAY) {
247
+ return true;
248
+ }
249
+
250
+ // Check for X11 display
251
+ if (process.env.DISPLAY) {
252
+ return true;
253
+ }
254
+
255
+ // Check XDG session type (set by display managers)
256
+ const sessionType = process.env.XDG_SESSION_TYPE;
257
+ if (sessionType === 'x11' || sessionType === 'wayland') {
258
+ return true;
259
+ }
260
+
261
+ // Check for desktop environment indicators
262
+ if (process.env.XDG_CURRENT_DESKTOP || process.env.DESKTOP_SESSION) {
263
+ return true;
264
+ }
265
+
266
+ // For WSL specifically, check for WSLg availability
267
+ // WSLg sets WAYLAND_DISPLAY or DISPLAY when available
268
+ if (platform.type === 'wsl') {
269
+ // WSLg creates /mnt/wslg directory when GUI support is available
270
+ if (fs.existsSync('/mnt/wslg')) {
271
+ return true;
272
+ }
273
+ }
274
+
275
+ // No desktop environment detected
276
+ return false;
277
+ }
278
+
279
+ // Unknown platform - assume no desktop available
280
+ return false;
281
+ }
282
+
192
283
  module.exports = {
193
284
  detect,
194
285
  isWindows,
@@ -198,5 +289,6 @@ module.exports = {
198
289
  getArch,
199
290
  getDistro,
200
291
  getHomeDir,
201
- getTempDir
292
+ getTempDir,
293
+ isDesktopAvailable
202
294
  };
@@ -32,7 +32,8 @@ async function install(packageName, options = {}) {
32
32
  }
33
33
 
34
34
  const autoConfirm = options.autoConfirm !== false ? '-y' : '';
35
- const result = await shell.exec(`sudo apt-get install ${autoConfirm} ${packageName}`);
35
+ // Use DEBIAN_FRONTEND=noninteractive to avoid prompts during installation
36
+ const result = await shell.exec(`sudo DEBIAN_FRONTEND=noninteractive apt-get install ${autoConfirm} ${packageName}`);
36
37
  return {
37
38
  success: result.code === 0,
38
39
  output: result.stdout || result.stderr
@@ -55,7 +56,8 @@ async function remove(packageName, options = {}) {
55
56
  }
56
57
 
57
58
  const command = options.purge ? 'purge' : 'remove';
58
- const result = await shell.exec(`sudo apt-get ${command} -y ${packageName}`);
59
+ // Use DEBIAN_FRONTEND=noninteractive to avoid prompts during removal
60
+ const result = await shell.exec(`sudo DEBIAN_FRONTEND=noninteractive apt-get ${command} -y ${packageName}`);
59
61
  return {
60
62
  success: result.code === 0,
61
63
  output: result.stdout || result.stderr
@@ -74,7 +76,8 @@ async function update() {
74
76
  };
75
77
  }
76
78
 
77
- const result = await shell.exec('sudo apt-get update');
79
+ // Use DEBIAN_FRONTEND=noninteractive to avoid prompts during update
80
+ const result = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update');
78
81
  return {
79
82
  success: result.code === 0,
80
83
  output: result.stdout || result.stderr
@@ -94,9 +97,10 @@ async function upgrade(packageName) {
94
97
  };
95
98
  }
96
99
 
100
+ // Use DEBIAN_FRONTEND=noninteractive to avoid prompts during upgrade
97
101
  const command = packageName
98
- ? `sudo apt-get install -y --only-upgrade ${packageName}`
99
- : 'sudo apt-get upgrade -y';
102
+ ? `sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --only-upgrade ${packageName}`
103
+ : 'sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y';
100
104
 
101
105
  const result = await shell.exec(command);
102
106
  return {
@@ -138,7 +142,8 @@ async function getPackageVersion(packageName) {
138
142
  async function addRepository(repo) {
139
143
  if (!shell.commandExists('add-apt-repository')) {
140
144
  // Try to install software-properties-common first
141
- const installResult = await shell.exec('sudo apt-get install -y software-properties-common');
145
+ // Use DEBIAN_FRONTEND=noninteractive to avoid prompts
146
+ const installResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common');
142
147
  if (installResult.code !== 0) {
143
148
  return {
144
149
  success: false,
@@ -275,7 +280,8 @@ async function listInstalled() {
275
280
  * @returns {Promise<{ success: boolean, output: string }>}
276
281
  */
277
282
  async function clean() {
278
- const result = await shell.exec('sudo apt-get clean && sudo apt-get autoremove -y');
283
+ // Use DEBIAN_FRONTEND=noninteractive to avoid prompts
284
+ const result = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get clean && sudo DEBIAN_FRONTEND=noninteractive apt-get autoremove -y');
279
285
  return {
280
286
  success: result.code === 0,
281
287
  output: result.stdout || result.stderr