@fredlackey/devutils 0.0.14 → 0.0.15

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.
@@ -0,0 +1,326 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @fileoverview Install Moom - a powerful window management utility for macOS.
5
+ * @module installs/moom
6
+ *
7
+ * Moom is a window management application developed by Many Tricks that enables
8
+ * users to move, resize, and arrange application windows with precision using
9
+ * mouse interactions, keyboard shortcuts, or custom-defined layouts.
10
+ *
11
+ * Key features include:
12
+ * - Mouse-based control via the green zoom button pop-up palette
13
+ * - Snap windows to screen edges for quick positioning
14
+ * - Custom grids for precise window placement
15
+ * - Saved layouts for multi-monitor setups
16
+ * - Comprehensive keyboard shortcuts for window management
17
+ * - Multi-display support with display-aware features
18
+ *
19
+ * IMPORTANT PLATFORM LIMITATION:
20
+ * Moom is a macOS-ONLY application. Many Tricks develops Moom exclusively for
21
+ * macOS, and there is NO version for Windows, Linux, or any other operating
22
+ * system. Moom 4 (the current version) is available only from the Many Tricks
23
+ * website; it is NOT available on the Mac App Store due to sandboxing requirements.
24
+ *
25
+ * For other platforms, this installer will display a simple message and return
26
+ * gracefully without error (no alternatives are suggested per project guidelines).
27
+ */
28
+
29
+ const os = require('../utils/common/os');
30
+ const brew = require('../utils/macos/brew');
31
+ const macosApps = require('../utils/macos/apps');
32
+
33
+ /**
34
+ * Whether this installer requires a desktop environment to function.
35
+ * Moom is a GUI window management application that requires a desktop.
36
+ */
37
+ const REQUIRES_DESKTOP = true;
38
+
39
+ /**
40
+ * The name of the application bundle on macOS.
41
+ * Moom installs to /Applications/Moom.app
42
+ */
43
+ const MACOS_APP_NAME = 'Moom';
44
+
45
+ /**
46
+ * The full path to the macOS application bundle.
47
+ */
48
+ const MACOS_APP_PATH = '/Applications/Moom.app';
49
+
50
+ /**
51
+ * The Homebrew cask name for Moom.
52
+ * This is the official cask maintained by Homebrew.
53
+ */
54
+ const HOMEBREW_CASK_NAME = 'moom';
55
+
56
+ /**
57
+ * Install Moom on macOS using Homebrew.
58
+ *
59
+ * Prerequisites:
60
+ * - macOS 10.15 (Catalina) or later
61
+ * - Homebrew package manager installed
62
+ * - 64-bit processor (Intel or Apple Silicon natively supported)
63
+ * - Valid license for full functionality (trial available)
64
+ *
65
+ * The installation uses the Homebrew cask 'moom' which downloads and installs
66
+ * Moom to /Applications/Moom.app.
67
+ *
68
+ * NOTE: After installation, the user must:
69
+ * 1. Grant Accessibility permissions in System Settings > Privacy & Security
70
+ * 2. Purchase a license (US$15) or use the trial version
71
+ *
72
+ * @returns {Promise<void>}
73
+ */
74
+ async function install_macos() {
75
+ console.log('Checking if Moom is already installed...');
76
+
77
+ // Check if Moom.app is already installed in /Applications
78
+ // This handles cases where Moom was installed manually or via other methods
79
+ const isAlreadyInstalled = macosApps.isAppInstalled(MACOS_APP_NAME);
80
+ if (isAlreadyInstalled) {
81
+ console.log('Moom is already installed, skipping...');
82
+ return;
83
+ }
84
+
85
+ // Also check if the cask is installed via Homebrew
86
+ // This handles cases where the app might have been moved or renamed
87
+ const caskInstalled = await brew.isCaskInstalled(HOMEBREW_CASK_NAME);
88
+ if (caskInstalled) {
89
+ console.log('Moom is already installed via Homebrew, skipping...');
90
+ console.log('');
91
+ console.log('NOTE: If Moom is not in Applications, check:');
92
+ console.log(' brew info --cask moom');
93
+ return;
94
+ }
95
+
96
+ // Verify Homebrew is available before attempting installation
97
+ // Homebrew is required to install Moom via the cask system
98
+ if (!brew.isInstalled()) {
99
+ console.log('Homebrew is not installed. Please install Homebrew first.');
100
+ console.log('Run: dev install homebrew');
101
+ return;
102
+ }
103
+
104
+ console.log('Installing Moom via Homebrew...');
105
+
106
+ // Install the Moom cask (GUI application)
107
+ // The installCask function handles the --cask flag automatically
108
+ const result = await brew.installCask(HOMEBREW_CASK_NAME);
109
+
110
+ if (!result.success) {
111
+ console.log('Failed to install Moom:', result.output);
112
+ console.log('');
113
+ console.log('Troubleshooting:');
114
+ console.log(' 1. Run "brew update && brew cleanup" and retry');
115
+ console.log(' 2. If blocked by Gatekeeper, run: xattr -cr "/Applications/Moom.app"');
116
+ console.log(' 3. Try manual installation: brew install --cask moom');
117
+ return;
118
+ }
119
+
120
+ // Verify the installation succeeded by checking for the app bundle
121
+ const isInstalled = macosApps.isAppInstalled(MACOS_APP_NAME);
122
+ if (!isInstalled) {
123
+ console.log('Installation completed but Moom.app was not found in /Applications.');
124
+ console.log('Please check: brew info --cask moom');
125
+ return;
126
+ }
127
+
128
+ console.log('Moom installed successfully.');
129
+ console.log('');
130
+ console.log('IMPORTANT POST-INSTALLATION STEPS:');
131
+ console.log('1. Launch Moom from /Applications or Spotlight (Cmd+Space)');
132
+ console.log('2. Grant Accessibility permissions when prompted:');
133
+ console.log(' System Settings > Privacy & Security > Accessibility');
134
+ console.log('3. Purchase a license (US$15) or use the trial version');
135
+ console.log('');
136
+ console.log('Moom runs as a menu bar application. Click the Moom icon to configure.');
137
+ }
138
+
139
+ /**
140
+ * Handle installation request for Ubuntu/Debian.
141
+ *
142
+ * Moom is a macOS-only application and is NOT available for Ubuntu or Debian.
143
+ * This function returns gracefully with a message as per project guidelines.
144
+ *
145
+ * @returns {Promise<void>}
146
+ */
147
+ async function install_ubuntu() {
148
+ console.log('Moom is not available for Ubuntu.');
149
+ }
150
+
151
+ /**
152
+ * Handle installation request for Ubuntu running in WSL.
153
+ *
154
+ * Moom is a macOS-only application and cannot run in WSL or Windows.
155
+ * This function returns gracefully with a message as per project guidelines.
156
+ *
157
+ * @returns {Promise<void>}
158
+ */
159
+ async function install_ubuntu_wsl() {
160
+ console.log('Moom is not available for WSL.');
161
+ }
162
+
163
+ /**
164
+ * Handle installation request for Raspberry Pi OS.
165
+ *
166
+ * Moom is a macOS-only application and is NOT available for Raspberry Pi OS.
167
+ * This function returns gracefully with a message as per project guidelines.
168
+ *
169
+ * @returns {Promise<void>}
170
+ */
171
+ async function install_raspbian() {
172
+ console.log('Moom is not available for Raspberry Pi OS.');
173
+ }
174
+
175
+ /**
176
+ * Handle installation request for Amazon Linux/RHEL.
177
+ *
178
+ * Moom is a macOS-only application and is NOT available for Amazon Linux or RHEL.
179
+ * Additionally, these are server operating systems that typically do not have
180
+ * desktop environments where window management tools would be applicable.
181
+ * This function returns gracefully with a message as per project guidelines.
182
+ *
183
+ * @returns {Promise<void>}
184
+ */
185
+ async function install_amazon_linux() {
186
+ console.log('Moom is not available for Amazon Linux.');
187
+ }
188
+
189
+ /**
190
+ * Handle installation request for Windows.
191
+ *
192
+ * Moom is a macOS-only application and is NOT available for Windows.
193
+ * This function returns gracefully with a message as per project guidelines.
194
+ *
195
+ * @returns {Promise<void>}
196
+ */
197
+ async function install_windows() {
198
+ console.log('Moom is not available for Windows.');
199
+ }
200
+
201
+ /**
202
+ * Handle installation request for Git Bash on Windows.
203
+ *
204
+ * Git Bash runs on Windows where Moom is not available.
205
+ * Moom is a macOS-only application developed by Many Tricks.
206
+ * This function returns gracefully with a message as per project guidelines.
207
+ *
208
+ * @returns {Promise<void>}
209
+ */
210
+ async function install_gitbash() {
211
+ console.log('Moom is not available for Windows.');
212
+ }
213
+
214
+ /**
215
+ * Check if Moom is installed on the current platform.
216
+ *
217
+ * On macOS, checks if the Moom cask is installed via Homebrew or if
218
+ * Moom.app exists in /Applications.
219
+ * On all other platforms, returns false since Moom is macOS-only.
220
+ *
221
+ * @returns {Promise<boolean>} True if Moom is installed, false otherwise
222
+ */
223
+ async function isInstalled() {
224
+ const platform = os.detect();
225
+
226
+ // Moom is only available on macOS
227
+ if (platform.type !== 'macos') {
228
+ return false;
229
+ }
230
+
231
+ // Check if Moom.app exists in /Applications
232
+ if (macosApps.isAppInstalled(MACOS_APP_NAME)) {
233
+ return true;
234
+ }
235
+
236
+ // Fallback: check via Homebrew cask
237
+ return await brew.isCaskInstalled(HOMEBREW_CASK_NAME);
238
+ }
239
+
240
+ /**
241
+ * Check if this installer is supported on the current platform.
242
+ *
243
+ * Moom is ONLY supported on macOS. All other platforms (Windows, Linux,
244
+ * WSL, Raspberry Pi OS, Amazon Linux) are NOT supported.
245
+ *
246
+ * @returns {boolean} True if installation is supported on this platform
247
+ */
248
+ function isEligible() {
249
+ const platform = os.detect();
250
+
251
+ // Moom is only available on macOS
252
+ if (platform.type !== 'macos') {
253
+ return false;
254
+ }
255
+
256
+ // Moom requires a desktop environment (which macOS always has)
257
+ if (REQUIRES_DESKTOP && !os.isDesktopAvailable()) {
258
+ return false;
259
+ }
260
+
261
+ return true;
262
+ }
263
+
264
+ /**
265
+ * Main installation entry point - detects platform and runs appropriate installer.
266
+ *
267
+ * This function automatically detects the current operating system and distribution,
268
+ * then invokes the corresponding platform-specific installation function.
269
+ *
270
+ * Since Moom is macOS-only, non-macOS platforms will receive a simple message
271
+ * indicating that Moom is not available for their platform.
272
+ *
273
+ * @returns {Promise<void>}
274
+ */
275
+ async function install() {
276
+ const platform = os.detect();
277
+
278
+ // Map platform types to their installer functions
279
+ // All non-macOS platforms gracefully return with a message
280
+ const installers = {
281
+ 'macos': install_macos,
282
+ 'ubuntu': install_ubuntu,
283
+ 'debian': install_ubuntu,
284
+ 'ubuntu-wsl': install_ubuntu_wsl,
285
+ 'wsl': install_ubuntu_wsl,
286
+ 'raspbian': install_raspbian,
287
+ 'amazon_linux': install_amazon_linux,
288
+ 'amazon-linux': install_amazon_linux,
289
+ 'rhel': install_amazon_linux,
290
+ 'fedora': install_amazon_linux,
291
+ 'windows': install_windows,
292
+ 'gitbash': install_gitbash,
293
+ };
294
+
295
+ const installer = installers[platform.type];
296
+
297
+ // If no installer exists for this platform, exit gracefully without error
298
+ if (!installer) {
299
+ console.log(`Moom is not available for ${platform.type}.`);
300
+ return;
301
+ }
302
+
303
+ await installer();
304
+ }
305
+
306
+ module.exports = {
307
+ REQUIRES_DESKTOP,
308
+ install,
309
+ isInstalled,
310
+ isEligible,
311
+ install_macos,
312
+ install_ubuntu,
313
+ install_ubuntu_wsl,
314
+ install_raspbian,
315
+ install_amazon_linux,
316
+ install_windows,
317
+ install_gitbash,
318
+ };
319
+
320
+ // Allow direct execution of this script
321
+ if (require.main === module) {
322
+ install().catch(err => {
323
+ console.error(err.message);
324
+ process.exit(1);
325
+ });
326
+ }