@fredlackey/devutils 0.0.14 → 0.0.16

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,431 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @fileoverview Install Parallels Desktop.
5
+ * @module installs/parallels-desktop
6
+ *
7
+ * Parallels Desktop is a desktop virtualization software exclusively designed
8
+ * for macOS. It enables Mac users to run Windows, Linux, and other operating
9
+ * systems as virtual machines (VMs) alongside macOS without rebooting.
10
+ *
11
+ * Key features include:
12
+ * - Seamless Integration: Run Windows applications directly from the macOS Dock
13
+ * - Coherence Mode: Windows applications appear as native macOS windows
14
+ * - Apple Silicon Support: Full native support for M-series Macs
15
+ * - Performance Optimization: Hardware-accelerated graphics and USB passthrough
16
+ * - Developer Tools: CLI for managing VMs programmatically
17
+ *
18
+ * IMPORTANT PLATFORM LIMITATION:
19
+ * Parallels Desktop is officially supported ONLY on macOS.
20
+ * There is NO support for Linux, Windows, or any other operating system as the HOST.
21
+ *
22
+ * For unsupported platforms, this installer will display a simple message
23
+ * and return gracefully without error.
24
+ */
25
+
26
+ const os = require('../utils/common/os');
27
+ const shell = require('../utils/common/shell');
28
+ const brew = require('../utils/macos/brew');
29
+ const fs = require('fs');
30
+
31
+ /**
32
+ * Whether this installer requires a desktop environment to function.
33
+ * Parallels Desktop is a GUI virtualization application for macOS.
34
+ */
35
+ const REQUIRES_DESKTOP = true;
36
+
37
+ /**
38
+ * The Homebrew cask name for Parallels Desktop.
39
+ * Note: The cask is named 'parallels' not 'parallels-desktop'.
40
+ */
41
+ const HOMEBREW_CASK_NAME = 'parallels';
42
+
43
+ /**
44
+ * The path where the Parallels Desktop application is installed on macOS.
45
+ * This is the standard installation location via Homebrew cask.
46
+ */
47
+ const MACOS_APP_PATH = '/Applications/Parallels Desktop.app';
48
+
49
+ /**
50
+ * Check if Parallels Desktop is installed on macOS.
51
+ *
52
+ * Checks for the application bundle at the standard installation location.
53
+ * This is more reliable than checking if the cask is listed because the
54
+ * app could have been installed manually or moved.
55
+ *
56
+ * @returns {boolean} True if Parallels Desktop is installed, false otherwise
57
+ */
58
+ function isInstalledMacOS() {
59
+ return fs.existsSync(MACOS_APP_PATH);
60
+ }
61
+
62
+ /**
63
+ * Check if the prlctl command-line tool is available.
64
+ *
65
+ * prlctl is the Parallels Desktop command-line interface for managing
66
+ * virtual machines. It is installed as part of Parallels Desktop.
67
+ *
68
+ * @returns {boolean} True if prlctl is available in PATH, false otherwise
69
+ */
70
+ function isPrlctlAvailable() {
71
+ return shell.commandExists('prlctl');
72
+ }
73
+
74
+ /**
75
+ * Get the installed Parallels Desktop version.
76
+ *
77
+ * Uses the prlctl command-line tool to query the version. Returns null
78
+ * if prlctl is not available or the version cannot be determined.
79
+ *
80
+ * @returns {Promise<string|null>} Version string (e.g., "26.2.1"), or null if not available
81
+ */
82
+ async function getVersion() {
83
+ // First check if prlctl exists before trying to run it
84
+ if (!isPrlctlAvailable()) {
85
+ return null;
86
+ }
87
+
88
+ const result = await shell.exec('prlctl --version');
89
+ if (result.code === 0 && result.stdout) {
90
+ // Output format: "prlctl version 26.2.1 (57371)"
91
+ const match = result.stdout.match(/prlctl version ([\d.]+)/);
92
+ return match ? match[1] : null;
93
+ }
94
+ return null;
95
+ }
96
+
97
+ /**
98
+ * Install Parallels Desktop on macOS using Homebrew.
99
+ *
100
+ * Prerequisites:
101
+ * - macOS 13 (Ventura) or later (for Parallels Desktop 26)
102
+ * - Apple Silicon (M-series) or Intel processor
103
+ * - Homebrew package manager installed
104
+ * - At least 4 GB RAM (16 GB recommended)
105
+ * - At least 600 MB disk space for the app, plus space for VMs
106
+ * - Administrator privileges (may prompt for password)
107
+ *
108
+ * The installation uses the Homebrew cask 'parallels' which downloads and
109
+ * installs Parallels Desktop to /Applications/Parallels Desktop.app.
110
+ *
111
+ * IMPORTANT: After installation, the user must:
112
+ * 1. Launch Parallels Desktop (may prompt for system extension approval)
113
+ * 2. Sign in or create a Parallels account
114
+ * 3. Activate a license or start a trial
115
+ *
116
+ * Parallels Desktop is commercial software requiring a paid license for
117
+ * continued use after the trial period.
118
+ *
119
+ * @returns {Promise<void>}
120
+ * @throws {Error} If Homebrew is not installed or installation fails
121
+ */
122
+ async function install_macos() {
123
+ console.log('Checking if Parallels Desktop is already installed...');
124
+
125
+ // Check if the application is already installed by looking for the app bundle
126
+ if (isInstalledMacOS()) {
127
+ console.log('Parallels Desktop is already installed, skipping installation.');
128
+
129
+ // Optionally show version if prlctl is available
130
+ const version = await getVersion();
131
+ if (version) {
132
+ console.log(`Installed version: ${version}`);
133
+ }
134
+ return;
135
+ }
136
+
137
+ // Also check if the cask is installed (covers edge case where app was removed but cask still listed)
138
+ const caskInstalled = await brew.isCaskInstalled(HOMEBREW_CASK_NAME);
139
+ if (caskInstalled) {
140
+ console.log('Parallels Desktop cask is installed but application is missing.');
141
+ console.log('Reinstalling via Homebrew...');
142
+
143
+ // Reinstall the cask
144
+ const reinstallResult = await shell.exec(`brew reinstall --cask ${HOMEBREW_CASK_NAME}`);
145
+ if (reinstallResult.code !== 0) {
146
+ throw new Error(
147
+ `Failed to reinstall Parallels Desktop.\n` +
148
+ `Output: ${reinstallResult.stderr}\n\n` +
149
+ `Please try manually: brew reinstall --cask parallels`
150
+ );
151
+ }
152
+
153
+ console.log('Parallels Desktop reinstalled successfully.');
154
+ return;
155
+ }
156
+
157
+ // Verify Homebrew is available before attempting installation
158
+ if (!brew.isInstalled()) {
159
+ throw new Error(
160
+ 'Homebrew is not installed. Please install Homebrew first using:\n' +
161
+ ' dev install homebrew\n' +
162
+ 'Then retry installing Parallels Desktop.'
163
+ );
164
+ }
165
+
166
+ console.log('Installing Parallels Desktop via Homebrew...');
167
+ console.log('This may take a few minutes as the download is approximately 600 MB...');
168
+
169
+ // Install the cask with quiet mode to reduce output noise
170
+ // Note: This may prompt for administrator password to install system extensions
171
+ const result = await brew.installCask(HOMEBREW_CASK_NAME);
172
+
173
+ if (!result.success) {
174
+ throw new Error(
175
+ `Failed to install Parallels Desktop via Homebrew.\n` +
176
+ `Output: ${result.output}\n\n` +
177
+ `Troubleshooting:\n` +
178
+ ` 1. Run 'brew update && brew cleanup' and retry\n` +
179
+ ` 2. Ensure you have sufficient disk space (at least 1 GB free)\n` +
180
+ ` 3. Try manual installation: brew reinstall --cask parallels\n` +
181
+ ` 4. If on macOS 14+, you may need to approve system extensions in System Settings`
182
+ );
183
+ }
184
+
185
+ // Verify the installation succeeded by checking if the app exists
186
+ if (!isInstalledMacOS()) {
187
+ throw new Error(
188
+ 'Installation appeared to complete but Parallels Desktop was not found at:\n' +
189
+ ` ${MACOS_APP_PATH}\n\n` +
190
+ 'Please try reinstalling manually: brew reinstall --cask parallels'
191
+ );
192
+ }
193
+
194
+ console.log('Parallels Desktop installed successfully.');
195
+ console.log('');
196
+ console.log('IMPORTANT: To complete setup:');
197
+ console.log(' 1. Launch Parallels Desktop from Applications or run: open -a "Parallels Desktop"');
198
+ console.log(' 2. On first launch, you may be prompted to allow system extensions');
199
+ console.log(' Go to System Settings > Privacy & Security and click "Allow"');
200
+ console.log(' 3. Sign in or create a Parallels account');
201
+ console.log(' 4. Activate your license or start a trial');
202
+ console.log('');
203
+ console.log('Note: Parallels Desktop is commercial software. A paid license is required');
204
+ console.log('for continued use after the trial period.');
205
+ console.log('');
206
+ console.log('To verify installation, run: prlctl --version');
207
+ }
208
+
209
+ /**
210
+ * Install Parallels Desktop on Ubuntu/Debian.
211
+ *
212
+ * IMPORTANT: Parallels Desktop is NOT supported on Ubuntu or Debian.
213
+ * Parallels Desktop is exclusively developed for macOS and cannot be installed
214
+ * on any Linux distribution as a host operating system.
215
+ *
216
+ * This function returns gracefully without error to maintain consistent
217
+ * behavior across all installers.
218
+ *
219
+ * @returns {Promise<void>}
220
+ */
221
+ async function install_ubuntu() {
222
+ console.log('Parallels Desktop is not available for Ubuntu/Debian.');
223
+ }
224
+
225
+ /**
226
+ * Install Parallels Desktop on Raspberry Pi OS.
227
+ *
228
+ * IMPORTANT: Parallels Desktop is NOT supported on Raspberry Pi OS.
229
+ * Parallels Desktop is exclusively developed for macOS. The ARM architecture
230
+ * of Raspberry Pi is not a limiting factor - Parallels simply does not develop
231
+ * software for any Linux distribution.
232
+ *
233
+ * This function returns gracefully without error to maintain consistent
234
+ * behavior across all installers.
235
+ *
236
+ * @returns {Promise<void>}
237
+ */
238
+ async function install_raspbian() {
239
+ console.log('Parallels Desktop is not available for Raspberry Pi OS.');
240
+ }
241
+
242
+ /**
243
+ * Install Parallels Desktop on Amazon Linux/RHEL.
244
+ *
245
+ * IMPORTANT: Parallels Desktop is NOT supported on Amazon Linux or RHEL.
246
+ * Parallels Desktop is exclusively developed for macOS and cannot be installed
247
+ * on any Linux distribution.
248
+ *
249
+ * This function returns gracefully without error to maintain consistent
250
+ * behavior across all installers.
251
+ *
252
+ * @returns {Promise<void>}
253
+ */
254
+ async function install_amazon_linux() {
255
+ console.log('Parallels Desktop is not available for Amazon Linux/RHEL.');
256
+ }
257
+
258
+ /**
259
+ * Install Parallels Desktop on Windows.
260
+ *
261
+ * IMPORTANT: Parallels Desktop is NOT supported on Windows.
262
+ * Parallels Desktop is exclusively developed for macOS.
263
+ *
264
+ * Historical Note: Parallels previously offered "Parallels Workstation" for
265
+ * Windows and Linux hosts, but this product was discontinued in 2013.
266
+ * There is no current Parallels product for Windows.
267
+ *
268
+ * This function returns gracefully without error to maintain consistent
269
+ * behavior across all installers.
270
+ *
271
+ * @returns {Promise<void>}
272
+ */
273
+ async function install_windows() {
274
+ console.log('Parallels Desktop is not available for Windows.');
275
+ }
276
+
277
+ /**
278
+ * Install Parallels Desktop on Ubuntu running in WSL.
279
+ *
280
+ * IMPORTANT: Parallels Desktop cannot be installed within WSL.
281
+ * WSL is a Linux compatibility layer running on Windows, and Parallels Desktop
282
+ * only runs on macOS as the host operating system.
283
+ *
284
+ * Note: Running virtualization software within WSL would require nested
285
+ * virtualization, which is not supported in WSL. Additionally, Parallels
286
+ * does not support any Linux distribution.
287
+ *
288
+ * This function returns gracefully without error to maintain consistent
289
+ * behavior across all installers.
290
+ *
291
+ * @returns {Promise<void>}
292
+ */
293
+ async function install_ubuntu_wsl() {
294
+ console.log('Parallels Desktop is not available for WSL (Windows Subsystem for Linux).');
295
+ }
296
+
297
+ /**
298
+ * Install Parallels Desktop from Git Bash on Windows.
299
+ *
300
+ * IMPORTANT: Parallels Desktop is NOT supported on Windows.
301
+ * Git Bash runs within Windows, and Parallels Desktop is exclusively
302
+ * developed for macOS.
303
+ *
304
+ * This function returns gracefully without error to maintain consistent
305
+ * behavior across all installers.
306
+ *
307
+ * @returns {Promise<void>}
308
+ */
309
+ async function install_gitbash() {
310
+ console.log('Parallels Desktop is not available for Windows.');
311
+ }
312
+
313
+ /**
314
+ * Check if Parallels Desktop is installed on the current platform.
315
+ *
316
+ * This function performs platform-specific checks to determine if Parallels
317
+ * Desktop is already installed:
318
+ * - macOS: Checks for the app bundle in /Applications
319
+ * - Other platforms: Always returns false (not supported)
320
+ *
321
+ * @returns {Promise<boolean>} True if Parallels Desktop is installed
322
+ */
323
+ async function isInstalled() {
324
+ const platform = os.detect();
325
+
326
+ // macOS: Check for the app bundle
327
+ if (platform.type === 'macos') {
328
+ return isInstalledMacOS();
329
+ }
330
+
331
+ // All other platforms: Not supported, return false
332
+ return false;
333
+ }
334
+
335
+ /**
336
+ * Check if this installer is supported on the current platform.
337
+ *
338
+ * Parallels Desktop can ONLY be installed on:
339
+ * - macOS (via Homebrew cask)
340
+ *
341
+ * All other platforms are explicitly not supported and will return false.
342
+ *
343
+ * @returns {boolean} True if installation is supported on this platform
344
+ */
345
+ function isEligible() {
346
+ const platform = os.detect();
347
+
348
+ // Parallels Desktop is only available on macOS
349
+ if (platform.type !== 'macos') {
350
+ return false;
351
+ }
352
+
353
+ // Also check if a desktop environment is available
354
+ // (always true on macOS, but included for consistency)
355
+ if (REQUIRES_DESKTOP && !os.isDesktopAvailable()) {
356
+ return false;
357
+ }
358
+
359
+ return true;
360
+ }
361
+
362
+ /**
363
+ * Main installation entry point.
364
+ *
365
+ * Detects the current platform and runs the appropriate installer function.
366
+ * Handles platform-specific mappings to ensure all platforms have appropriate
367
+ * installation logic (or graceful messaging for unsupported platforms).
368
+ *
369
+ * Supported platforms:
370
+ * - macOS: Full support via Homebrew cask
371
+ *
372
+ * Unsupported platforms (returns gracefully with message):
373
+ * - Ubuntu/Debian: Parallels is macOS-only
374
+ * - Raspberry Pi OS: Parallels is macOS-only
375
+ * - Amazon Linux/RHEL: Parallels is macOS-only
376
+ * - Windows: Parallels is macOS-only (Parallels Workstation discontinued in 2013)
377
+ * - WSL: Parallels is macOS-only
378
+ * - Git Bash: Parallels is macOS-only
379
+ *
380
+ * @returns {Promise<void>}
381
+ */
382
+ async function install() {
383
+ const platform = os.detect();
384
+
385
+ // Map platform types to their installer functions
386
+ // Only macOS has a real installer; all others return graceful messages
387
+ const installers = {
388
+ 'macos': install_macos,
389
+ 'ubuntu': install_ubuntu,
390
+ 'debian': install_ubuntu,
391
+ 'wsl': install_ubuntu_wsl,
392
+ 'raspbian': install_raspbian,
393
+ 'amazon_linux': install_amazon_linux,
394
+ 'rhel': install_amazon_linux,
395
+ 'fedora': install_amazon_linux,
396
+ 'windows': install_windows,
397
+ 'gitbash': install_gitbash
398
+ };
399
+
400
+ const installer = installers[platform.type];
401
+
402
+ if (!installer) {
403
+ console.log(`Parallels Desktop is not available for ${platform.type}.`);
404
+ return;
405
+ }
406
+
407
+ await installer();
408
+ }
409
+
410
+ // Export all functions for use as a module and for testing
411
+ module.exports = {
412
+ REQUIRES_DESKTOP,
413
+ install,
414
+ isInstalled,
415
+ isEligible,
416
+ install_macos,
417
+ install_ubuntu,
418
+ install_ubuntu_wsl,
419
+ install_raspbian,
420
+ install_amazon_linux,
421
+ install_windows,
422
+ install_gitbash
423
+ };
424
+
425
+ // Allow direct execution: node parallels-desktop.js
426
+ if (require.main === module) {
427
+ install().catch(err => {
428
+ console.error(err.message);
429
+ process.exit(1);
430
+ });
431
+ }