@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.
- package/README.md +5 -5
- package/package.json +1 -1
- package/src/commands/install.js +374 -36
- package/src/installs/adobe-creative-cloud.js +527 -25
- package/src/installs/adobe-creative-cloud.md +605 -0
- package/src/installs/appcleaner.js +303 -26
- package/src/installs/appcleaner.md +699 -0
- package/src/installs/apt-transport-https.js +390 -0
- package/src/installs/apt-transport-https.md +678 -0
- package/src/installs/atomicparsley.js +624 -26
- package/src/installs/atomicparsley.md +795 -0
- package/src/installs/aws-cli.js +779 -26
- package/src/installs/aws-cli.md +727 -0
- package/src/installs/balena-etcher.js +688 -26
- package/src/installs/balena-etcher.md +761 -0
- package/src/installs/bambu-studio.js +912 -26
- package/src/installs/bambu-studio.md +780 -0
- package/src/installs/bash-completion.js +554 -23
- package/src/installs/bash-completion.md +833 -0
- package/src/installs/bash.js +399 -26
- package/src/installs/bash.md +993 -0
- package/src/installs/beyond-compare.js +585 -26
- package/src/installs/beyond-compare.md +813 -0
- package/src/installs/build-essential.js +511 -26
- package/src/installs/build-essential.md +977 -0
- package/src/installs/ca-certificates.js +618 -0
- package/src/installs/ca-certificates.md +937 -0
- package/src/installs/caffeine.js +490 -26
- package/src/installs/caffeine.md +839 -0
- package/src/installs/camtasia.js +577 -25
- package/src/installs/camtasia.md +762 -0
- package/src/installs/chatgpt.js +458 -26
- package/src/installs/chatgpt.md +814 -0
- package/src/installs/chocolatey.js +447 -0
- package/src/installs/chocolatey.md +661 -0
- package/src/installs/chrome-canary.js +472 -26
- package/src/installs/chrome-canary.md +641 -0
- package/src/installs/chromium.js +645 -26
- package/src/installs/chromium.md +838 -0
- package/src/installs/claude-code.js +558 -26
- package/src/installs/claude-code.md +1173 -0
- package/src/installs/curl.js +361 -26
- package/src/installs/curl.md +714 -0
- package/src/installs/cursor.js +561 -26
- package/src/installs/cursor.md +970 -0
- package/src/installs/dbschema.js +674 -26
- package/src/installs/dbschema.md +925 -0
- package/src/installs/dependencies.md +435 -0
- package/src/installs/development-tools.js +600 -0
- package/src/installs/development-tools.md +977 -0
- package/src/installs/docker.js +1010 -25
- package/src/installs/docker.md +1109 -0
- package/src/installs/drawio.js +1001 -26
- package/src/installs/drawio.md +795 -0
- package/src/installs/elmedia-player.js +328 -25
- package/src/installs/elmedia-player.md +556 -0
- package/src/installs/ffmpeg.js +870 -25
- package/src/installs/ffmpeg.md +852 -0
- package/src/installs/file.js +464 -0
- package/src/installs/file.md +987 -0
- package/src/installs/gemini-cli.js +793 -26
- package/src/installs/gemini-cli.md +1153 -0
- package/src/installs/git.js +382 -26
- package/src/installs/git.md +907 -0
- package/src/installs/gitego.js +931 -26
- package/src/installs/gitego.md +1172 -0
- package/src/installs/go.js +913 -26
- package/src/installs/go.md +958 -0
- package/src/installs/google-chrome.js +801 -25
- package/src/installs/google-chrome.md +862 -0
- package/src/installs/gpg.js +412 -73
- package/src/installs/gpg.md +1056 -0
- package/src/installs/homebrew.js +1015 -26
- package/src/installs/homebrew.md +988 -0
- package/src/installs/imageoptim.js +950 -26
- package/src/installs/imageoptim.md +1119 -0
- package/src/installs/installers.json +2297 -0
- package/src/installs/jq.js +382 -26
- package/src/installs/jq.md +809 -0
- package/src/installs/keyboard-maestro.js +701 -26
- package/src/installs/keyboard-maestro.md +825 -0
- package/src/installs/latex.js +771 -26
- package/src/installs/latex.md +1095 -0
- package/src/installs/lftp.js +338 -26
- package/src/installs/lftp.md +907 -0
- package/src/installs/lsb-release.js +346 -0
- package/src/installs/lsb-release.md +814 -0
- package/src/installs/messenger.js +829 -26
- package/src/installs/messenger.md +900 -0
- package/src/installs/microsoft-office.js +550 -26
- package/src/installs/microsoft-office.md +760 -0
- package/src/installs/microsoft-teams.js +782 -25
- package/src/installs/microsoft-teams.md +886 -0
- package/src/installs/node.js +886 -26
- package/src/installs/node.md +1153 -0
- package/src/installs/nordpass.js +698 -26
- package/src/installs/nordpass.md +921 -0
- package/src/installs/nvm.js +977 -26
- package/src/installs/nvm.md +1057 -0
- package/src/installs/openssh.js +734 -64
- package/src/installs/openssh.md +1056 -0
- package/src/installs/pandoc.js +644 -26
- package/src/installs/pandoc.md +1036 -0
- package/src/installs/pinentry.js +492 -26
- package/src/installs/pinentry.md +1142 -0
- package/src/installs/pngyu.js +851 -26
- package/src/installs/pngyu.md +896 -0
- package/src/installs/postman.js +781 -26
- package/src/installs/postman.md +940 -0
- package/src/installs/procps.js +425 -0
- package/src/installs/procps.md +851 -0
- package/src/installs/safari-tech-preview.js +355 -25
- package/src/installs/safari-tech-preview.md +533 -0
- package/src/installs/sfnt2woff.js +640 -26
- package/src/installs/sfnt2woff.md +795 -0
- package/src/installs/shellcheck.js +463 -26
- package/src/installs/shellcheck.md +1005 -0
- package/src/installs/slack.js +722 -25
- package/src/installs/slack.md +865 -0
- package/src/installs/snagit.js +566 -25
- package/src/installs/snagit.md +844 -0
- package/src/installs/software-properties-common.js +372 -0
- package/src/installs/software-properties-common.md +805 -0
- package/src/installs/spotify.js +858 -25
- package/src/installs/spotify.md +901 -0
- package/src/installs/studio-3t.js +803 -26
- package/src/installs/studio-3t.md +918 -0
- package/src/installs/sublime-text.js +780 -25
- package/src/installs/sublime-text.md +914 -0
- package/src/installs/superwhisper.js +687 -25
- package/src/installs/superwhisper.md +630 -0
- package/src/installs/tailscale.js +727 -26
- package/src/installs/tailscale.md +1100 -0
- package/src/installs/tar.js +389 -0
- package/src/installs/tar.md +946 -0
- package/src/installs/termius.js +780 -26
- package/src/installs/termius.md +844 -0
- package/src/installs/terraform.js +761 -26
- package/src/installs/terraform.md +899 -0
- package/src/installs/tidal.js +752 -25
- package/src/installs/tidal.md +864 -0
- package/src/installs/tmux.js +328 -26
- package/src/installs/tmux.md +1030 -0
- package/src/installs/tree.js +393 -26
- package/src/installs/tree.md +833 -0
- package/src/installs/unzip.js +460 -0
- package/src/installs/unzip.md +879 -0
- package/src/installs/vim.js +403 -26
- package/src/installs/vim.md +1040 -0
- package/src/installs/vlc.js +803 -26
- package/src/installs/vlc.md +927 -0
- package/src/installs/vscode.js +825 -26
- package/src/installs/vscode.md +1002 -0
- package/src/installs/wget.js +415 -0
- package/src/installs/wget.md +791 -0
- package/src/installs/whatsapp.js +710 -25
- package/src/installs/whatsapp.md +854 -0
- package/src/installs/winpty.js +352 -0
- package/src/installs/winpty.md +620 -0
- package/src/installs/woff2.js +535 -26
- package/src/installs/woff2.md +977 -0
- package/src/installs/wsl.js +572 -0
- package/src/installs/wsl.md +699 -0
- package/src/installs/xcode-clt.js +520 -0
- package/src/installs/xcode-clt.md +351 -0
- package/src/installs/xcode.js +542 -26
- package/src/installs/xcode.md +573 -0
- package/src/installs/yarn.js +806 -26
- package/src/installs/yarn.md +1074 -0
- package/src/installs/yq.js +636 -26
- package/src/installs/yq.md +944 -0
- package/src/installs/yt-dlp.js +683 -26
- package/src/installs/yt-dlp.md +946 -0
- package/src/installs/yum-utils.js +297 -0
- package/src/installs/yum-utils.md +648 -0
- package/src/installs/zoom.js +740 -25
- package/src/installs/zoom.md +884 -0
- package/src/scripts/README.md +567 -45
- package/src/scripts/STATUS.md +208 -0
- package/src/scripts/afk.js +395 -7
- package/src/scripts/backup-all.js +731 -9
- package/src/scripts/backup-source.js +711 -8
- package/src/scripts/brewd.js +373 -7
- package/src/scripts/brewi.js +505 -9
- package/src/scripts/brewr.js +512 -9
- package/src/scripts/brews.js +462 -9
- package/src/scripts/brewu.js +488 -7
- package/src/scripts/c.js +185 -7
- package/src/scripts/ccurl.js +325 -8
- package/src/scripts/certbot-crontab-init.js +488 -8
- package/src/scripts/certbot-init.js +641 -9
- package/src/scripts/ch.js +339 -7
- package/src/scripts/claude-danger.js +253 -8
- package/src/scripts/clean-dev.js +419 -8
- package/src/scripts/clear-dns-cache.js +525 -7
- package/src/scripts/clone.js +417 -7
- package/src/scripts/code-all.js +420 -7
- package/src/scripts/count-files.js +195 -8
- package/src/scripts/count-folders.js +195 -8
- package/src/scripts/count.js +248 -8
- package/src/scripts/d.js +203 -7
- package/src/scripts/datauri.js +373 -8
- package/src/scripts/delete-files.js +363 -7
- package/src/scripts/docker-clean.js +410 -8
- package/src/scripts/dp.js +426 -7
- package/src/scripts/e.js +375 -9
- package/src/scripts/empty-trash.js +497 -7
- package/src/scripts/evm.js +428 -9
- package/src/scripts/fetch-github-repos.js +441 -10
- package/src/scripts/get-channel.js +329 -8
- package/src/scripts/get-course.js +384 -11
- package/src/scripts/get-dependencies.js +290 -9
- package/src/scripts/get-folder.js +783 -10
- package/src/scripts/get-tunes.js +411 -10
- package/src/scripts/get-video.js +352 -9
- package/src/scripts/git-backup.js +561 -9
- package/src/scripts/git-clone.js +477 -9
- package/src/scripts/git-pup.js +303 -7
- package/src/scripts/git-push.js +380 -8
- package/src/scripts/h.js +607 -9
- package/src/scripts/hide-desktop-icons.js +483 -7
- package/src/scripts/hide-hidden-files.js +522 -7
- package/src/scripts/install-dependencies-from.js +440 -9
- package/src/scripts/ips.js +647 -10
- package/src/scripts/iso.js +354 -8
- package/src/scripts/killni.js +561 -7
- package/src/scripts/ll.js +451 -8
- package/src/scripts/local-ip.js +310 -8
- package/src/scripts/m.js +508 -8
- package/src/scripts/map.js +293 -8
- package/src/scripts/mkd.js +287 -7
- package/src/scripts/ncu-update-all.js +441 -8
- package/src/scripts/nginx-init.js +702 -12
- package/src/scripts/npmi.js +366 -7
- package/src/scripts/o.js +495 -8
- package/src/scripts/org-by-date.js +321 -7
- package/src/scripts/p.js +208 -7
- package/src/scripts/packages.js +313 -8
- package/src/scripts/path.js +209 -7
- package/src/scripts/ports.js +582 -8
- package/src/scripts/q.js +290 -8
- package/src/scripts/refresh-files.js +378 -10
- package/src/scripts/remove-smaller-files.js +500 -8
- package/src/scripts/rename-files-with-date.js +517 -9
- package/src/scripts/resize-image.js +523 -9
- package/src/scripts/rm-safe.js +653 -8
- package/src/scripts/s.js +525 -9
- package/src/scripts/set-git-public.js +349 -7
- package/src/scripts/show-desktop-icons.js +459 -7
- package/src/scripts/show-hidden-files.js +456 -7
- package/src/scripts/tpa.js +265 -8
- package/src/scripts/tpo.js +264 -7
- package/src/scripts/u.js +489 -7
- package/src/scripts/vpush.js +422 -8
- package/src/scripts/y.js +267 -7
- package/src/utils/common/os.js +94 -2
- package/src/utils/ubuntu/apt.js +13 -7
- package/src/utils/windows/choco.js +82 -26
- package/src/utils/windows/winget.js +89 -27
package/src/installs/xcode.js
CHANGED
|
@@ -1,44 +1,560 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @fileoverview Install Xcode
|
|
4
|
+
* @fileoverview Install Xcode (Full IDE) on macOS.
|
|
5
5
|
* @module installs/xcode
|
|
6
|
+
*
|
|
7
|
+
* Xcode is Apple's integrated development environment (IDE) for developing software
|
|
8
|
+
* for all Apple platforms: iOS, iPadOS, macOS, watchOS, tvOS, and visionOS.
|
|
9
|
+
*
|
|
10
|
+
* This installer uses the `xcodes` CLI tool to download and install Xcode from
|
|
11
|
+
* Apple's servers. The xcodes tool provides version management and faster downloads
|
|
12
|
+
* (via aria2) compared to the Mac App Store.
|
|
13
|
+
*
|
|
14
|
+
* IMPORTANT PLATFORM LIMITATION:
|
|
15
|
+
* Xcode is an Apple-exclusive product and ONLY runs on macOS. There is no legitimate
|
|
16
|
+
* way to install or run Xcode on Windows, Linux, or other operating systems. Apple
|
|
17
|
+
* does not support virtualization of macOS on non-Apple hardware.
|
|
18
|
+
*
|
|
19
|
+
* What this installer provides:
|
|
20
|
+
* - Installation of the full Xcode IDE (~40+ GB)
|
|
21
|
+
* - Swift and Objective-C compilers
|
|
22
|
+
* - Interface Builder, Instruments, and other development tools
|
|
23
|
+
* - Simulators for all Apple platforms
|
|
24
|
+
* - SDKs for iOS, macOS, watchOS, tvOS, and visionOS
|
|
25
|
+
*
|
|
26
|
+
* IMPORTANT: This is for the FULL Xcode IDE. For the lightweight Command Line Tools
|
|
27
|
+
* only (~2.5 GB), use `dev install xcode-clt` instead.
|
|
28
|
+
*
|
|
29
|
+
* Prerequisites:
|
|
30
|
+
* - macOS version compatible with target Xcode version
|
|
31
|
+
* - Apple ID for downloading from Apple servers
|
|
32
|
+
* - At least 50 GB free disk space
|
|
33
|
+
* - Homebrew package manager
|
|
6
34
|
*/
|
|
7
35
|
|
|
8
36
|
const os = require('../utils/common/os');
|
|
37
|
+
const shell = require('../utils/common/shell');
|
|
38
|
+
const brew = require('../utils/macos/brew');
|
|
39
|
+
const fs = require('fs');
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Whether this installer requires a desktop environment to function.
|
|
43
|
+
* Xcode is a GUI integrated development environment (IDE).
|
|
44
|
+
*/
|
|
45
|
+
const REQUIRES_DESKTOP = true;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The path where Xcode is typically installed on macOS.
|
|
49
|
+
* The standard location is /Applications/Xcode.app.
|
|
50
|
+
*/
|
|
51
|
+
const XCODE_APP_PATH = '/Applications/Xcode.app';
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The path to the Xcode developer directory within the app bundle.
|
|
55
|
+
* This path is used by xcode-select to point to the active developer tools.
|
|
56
|
+
*/
|
|
57
|
+
const XCODE_DEVELOPER_PATH = '/Applications/Xcode.app/Contents/Developer';
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The Homebrew formula name for the xcodes CLI tool.
|
|
61
|
+
* xcodes is a third-party tool that manages Xcode installations.
|
|
62
|
+
*/
|
|
63
|
+
const XCODES_FORMULA = 'xcodesorg/made/xcodes';
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The Homebrew formula name for aria2 download accelerator.
|
|
67
|
+
* aria2 enables 3-5x faster Xcode downloads via parallel connections.
|
|
68
|
+
*/
|
|
69
|
+
const ARIA2_FORMULA = 'aria2';
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Check if the full Xcode IDE is installed on macOS.
|
|
73
|
+
*
|
|
74
|
+
* This function verifies Xcode installation by:
|
|
75
|
+
* 1. Checking if Xcode.app exists in /Applications
|
|
76
|
+
* 2. Verifying the app bundle structure contains expected binaries
|
|
77
|
+
*
|
|
78
|
+
* Note: This checks for the full Xcode IDE, not just Command Line Tools.
|
|
79
|
+
* The presence of /Library/Developer/CommandLineTools is NOT sufficient.
|
|
80
|
+
*
|
|
81
|
+
* @returns {boolean} True if full Xcode IDE is installed, false otherwise
|
|
82
|
+
*/
|
|
83
|
+
function isXcodeInstalled() {
|
|
84
|
+
// Check if the Xcode.app bundle exists
|
|
85
|
+
if (!fs.existsSync(XCODE_APP_PATH)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Verify the developer directory exists within the app bundle
|
|
90
|
+
// This ensures it's a complete Xcode installation, not a stub
|
|
91
|
+
if (!fs.existsSync(XCODE_DEVELOPER_PATH)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Verify a core Xcode binary exists (xcodebuild)
|
|
96
|
+
const xcodebuildPath = `${XCODE_DEVELOPER_PATH}/usr/bin/xcodebuild`;
|
|
97
|
+
return fs.existsSync(xcodebuildPath);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get the installed Xcode version using xcodebuild command.
|
|
102
|
+
*
|
|
103
|
+
* Executes `xcodebuild -version` to retrieve version information.
|
|
104
|
+
* Output format is typically:
|
|
105
|
+
* Xcode 16.2
|
|
106
|
+
* Build version 16C5032a
|
|
107
|
+
*
|
|
108
|
+
* @returns {Promise<string|null>} The Xcode version string (e.g., "16.2"), or null if not installed
|
|
109
|
+
*/
|
|
110
|
+
async function getXcodeVersion() {
|
|
111
|
+
// Check if xcodebuild command exists and Xcode is properly configured
|
|
112
|
+
const result = await shell.exec('xcodebuild -version 2>/dev/null');
|
|
113
|
+
|
|
114
|
+
if (result.code !== 0 || !result.stdout) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Parse the version from the output
|
|
119
|
+
// Expected format: "Xcode 16.2\nBuild version 16C5032a"
|
|
120
|
+
const versionMatch = result.stdout.match(/Xcode\s+(\d+\.?\d*\.?\d*)/);
|
|
121
|
+
if (versionMatch) {
|
|
122
|
+
return versionMatch[1];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Check if the xcodes CLI tool is installed.
|
|
130
|
+
*
|
|
131
|
+
* xcodes is a command-line tool for managing Xcode installations.
|
|
132
|
+
* It provides faster downloads and version management compared to
|
|
133
|
+
* the Mac App Store.
|
|
134
|
+
*
|
|
135
|
+
* @returns {boolean} True if xcodes is available, false otherwise
|
|
136
|
+
*/
|
|
137
|
+
function isXcodesInstalled() {
|
|
138
|
+
return shell.commandExists('xcodes');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Install the xcodes CLI tool and aria2 download accelerator via Homebrew.
|
|
143
|
+
*
|
|
144
|
+
* This function installs:
|
|
145
|
+
* - xcodes: CLI tool for downloading and managing Xcode versions
|
|
146
|
+
* - aria2: Download accelerator for 3-5x faster Xcode downloads
|
|
147
|
+
*
|
|
148
|
+
* @returns {Promise<void>}
|
|
149
|
+
* @throws {Error} If Homebrew is not installed or installation fails
|
|
150
|
+
*/
|
|
151
|
+
async function installXcodesTools() {
|
|
152
|
+
// Verify Homebrew is available before attempting installation
|
|
153
|
+
if (!brew.isInstalled()) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
'Homebrew is not installed. Please install Homebrew first using:\n' +
|
|
156
|
+
' dev install homebrew\n' +
|
|
157
|
+
'Then retry installing Xcode.'
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
console.log('Installing xcodes CLI tool and aria2 download accelerator...');
|
|
162
|
+
|
|
163
|
+
// First, tap the xcodes repository
|
|
164
|
+
// This adds the third-party repository containing the xcodes formula
|
|
165
|
+
const tapResult = await brew.tap('xcodesorg/made');
|
|
166
|
+
if (!tapResult.success) {
|
|
167
|
+
throw new Error(
|
|
168
|
+
`Failed to add xcodes tap.\n` +
|
|
169
|
+
`Output: ${tapResult.output}\n\n` +
|
|
170
|
+
`Try running manually: brew tap xcodesorg/made`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Install xcodes CLI tool
|
|
175
|
+
console.log('Installing xcodes CLI tool...');
|
|
176
|
+
const xcodesResult = await brew.install('xcodes');
|
|
177
|
+
if (!xcodesResult.success) {
|
|
178
|
+
throw new Error(
|
|
179
|
+
`Failed to install xcodes.\n` +
|
|
180
|
+
`Output: ${xcodesResult.output}\n\n` +
|
|
181
|
+
`Try running manually: brew install xcodesorg/made/xcodes`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Install aria2 for faster downloads (optional but recommended)
|
|
186
|
+
console.log('Installing aria2 download accelerator...');
|
|
187
|
+
const aria2Result = await brew.install(ARIA2_FORMULA);
|
|
188
|
+
if (!aria2Result.success) {
|
|
189
|
+
// aria2 failure is not critical, just warn
|
|
190
|
+
console.log('Warning: Could not install aria2. Downloads will be slower.');
|
|
191
|
+
console.log('You can install it manually later: brew install aria2');
|
|
192
|
+
} else {
|
|
193
|
+
console.log('aria2 installed - Xcode downloads will use parallel connections.');
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Verify xcodes installation
|
|
197
|
+
if (!isXcodesInstalled()) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
'xcodes installation appeared to succeed but the command is not available.\n\n' +
|
|
200
|
+
'Try restarting your terminal and running:\n' +
|
|
201
|
+
' which xcodes\n' +
|
|
202
|
+
' xcodes version'
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
console.log('xcodes CLI tool installed successfully.');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Install the full Xcode IDE on macOS using xcodes.
|
|
211
|
+
*
|
|
212
|
+
* Prerequisites:
|
|
213
|
+
* - macOS version compatible with target Xcode version
|
|
214
|
+
* - Homebrew package manager installed
|
|
215
|
+
* - Apple ID credentials (environment variables or interactive prompt)
|
|
216
|
+
* - At least 50 GB free disk space
|
|
217
|
+
*
|
|
218
|
+
* Installation process:
|
|
219
|
+
* 1. Check if Xcode is already installed (idempotency)
|
|
220
|
+
* 2. Install xcodes and aria2 if not present
|
|
221
|
+
* 3. Download and install the latest Xcode via xcodes
|
|
222
|
+
* 4. Accept the Xcode license agreement
|
|
223
|
+
* 5. Run first-launch setup to install additional components
|
|
224
|
+
* 6. Verify the installation succeeded
|
|
225
|
+
*
|
|
226
|
+
* NOTE: This function will require Apple ID credentials. If XCODES_USERNAME
|
|
227
|
+
* and XCODES_PASSWORD environment variables are not set, xcodes will prompt
|
|
228
|
+
* interactively (and optionally save credentials to Keychain).
|
|
229
|
+
*
|
|
230
|
+
* @returns {Promise<void>}
|
|
231
|
+
* @throws {Error} If installation fails
|
|
232
|
+
*/
|
|
233
|
+
async function install_macos() {
|
|
234
|
+
console.log('Checking if Xcode is already installed...');
|
|
235
|
+
|
|
236
|
+
// Check if Xcode is already installed - this ensures idempotency
|
|
237
|
+
if (isXcodeInstalled()) {
|
|
238
|
+
const version = await getXcodeVersion();
|
|
239
|
+
if (version) {
|
|
240
|
+
console.log(`Xcode ${version} is already installed, skipping...`);
|
|
241
|
+
} else {
|
|
242
|
+
console.log('Xcode is already installed, skipping...');
|
|
243
|
+
}
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
console.log('Xcode is not installed. Starting installation...');
|
|
248
|
+
console.log('');
|
|
249
|
+
console.log('This will install:');
|
|
250
|
+
console.log(' - Full Xcode IDE (~40+ GB)');
|
|
251
|
+
console.log(' - Swift and Objective-C compilers');
|
|
252
|
+
console.log(' - Interface Builder and Instruments');
|
|
253
|
+
console.log(' - iOS, macOS, watchOS, tvOS, and visionOS SDKs');
|
|
254
|
+
console.log(' - Simulators for all Apple platforms');
|
|
255
|
+
console.log('');
|
|
256
|
+
console.log('IMPORTANT: You will need an Apple ID to download Xcode.');
|
|
257
|
+
console.log('');
|
|
258
|
+
|
|
259
|
+
// Install xcodes CLI tool if not already present
|
|
260
|
+
if (!isXcodesInstalled()) {
|
|
261
|
+
await installXcodesTools();
|
|
262
|
+
} else {
|
|
263
|
+
console.log('xcodes CLI tool is already installed.');
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
console.log('');
|
|
267
|
+
console.log('Downloading and installing the latest Xcode...');
|
|
268
|
+
console.log('This may take 30-60 minutes depending on your internet connection.');
|
|
269
|
+
console.log('');
|
|
270
|
+
|
|
271
|
+
// Check for Apple ID credentials in environment variables
|
|
272
|
+
const hasCredentials = process.env.XCODES_USERNAME && process.env.XCODES_PASSWORD;
|
|
273
|
+
if (!hasCredentials) {
|
|
274
|
+
console.log('NOTE: Apple ID credentials not found in environment variables.');
|
|
275
|
+
console.log('You will be prompted to enter your Apple ID and password.');
|
|
276
|
+
console.log('Credentials will be saved to your macOS Keychain for future use.');
|
|
277
|
+
console.log('');
|
|
278
|
+
console.log('To set credentials non-interactively:');
|
|
279
|
+
console.log(' export XCODES_USERNAME="your-apple-id@example.com"');
|
|
280
|
+
console.log(' export XCODES_PASSWORD="your-password-or-app-specific-password"');
|
|
281
|
+
console.log('');
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Install the latest Xcode using xcodes
|
|
285
|
+
// The --latest flag installs the most recent stable release
|
|
286
|
+
// This command may prompt for Apple ID credentials if not set
|
|
287
|
+
const installResult = await shell.exec('xcodes install --latest', {
|
|
288
|
+
timeout: 3600000 // 60 minute timeout for large download
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// Check if installation succeeded
|
|
292
|
+
// Note: xcodes may output to stderr for progress, so we check the exit code
|
|
293
|
+
if (installResult.code !== 0) {
|
|
294
|
+
// Check if Xcode was actually installed despite the error code
|
|
295
|
+
// (some warnings may cause non-zero exit but installation succeeds)
|
|
296
|
+
if (isXcodeInstalled()) {
|
|
297
|
+
console.log('');
|
|
298
|
+
console.log('Installation completed with warnings.');
|
|
299
|
+
} else {
|
|
300
|
+
console.log('');
|
|
301
|
+
console.log('Xcode download/installation failed.');
|
|
302
|
+
console.log('');
|
|
303
|
+
console.log('Error output:');
|
|
304
|
+
console.log(installResult.stderr || installResult.stdout || 'No error details available');
|
|
305
|
+
console.log('');
|
|
306
|
+
console.log('Troubleshooting:');
|
|
307
|
+
console.log(' 1. Verify your Apple ID credentials are correct');
|
|
308
|
+
console.log(' 2. If using two-factor authentication, generate an app-specific password:');
|
|
309
|
+
console.log(' https://appleid.apple.com/account/manage');
|
|
310
|
+
console.log(' 3. Check available disk space (need ~50 GB free)');
|
|
311
|
+
console.log(' 4. Try running manually:');
|
|
312
|
+
console.log(' xcodes install --latest');
|
|
313
|
+
console.log('');
|
|
314
|
+
console.log('To install a specific version:');
|
|
315
|
+
console.log(' xcodes list');
|
|
316
|
+
console.log(' xcodes install 16.2');
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Verify Xcode is now installed
|
|
322
|
+
if (!isXcodeInstalled()) {
|
|
323
|
+
console.log('');
|
|
324
|
+
console.log('Download completed but Xcode was not found at /Applications/Xcode.app');
|
|
325
|
+
console.log('');
|
|
326
|
+
console.log('Please check:');
|
|
327
|
+
console.log(' 1. Available disk space');
|
|
328
|
+
console.log(' 2. Output from: xcodes installed');
|
|
329
|
+
console.log(' 3. Contents of /Applications folder');
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
console.log('');
|
|
334
|
+
console.log('Xcode downloaded and installed successfully.');
|
|
335
|
+
console.log('');
|
|
336
|
+
|
|
337
|
+
// Accept the Xcode license agreement
|
|
338
|
+
console.log('Accepting Xcode license agreement...');
|
|
339
|
+
const licenseResult = await shell.exec('sudo xcodebuild -license accept');
|
|
340
|
+
if (licenseResult.code !== 0) {
|
|
341
|
+
console.log('Warning: Could not automatically accept license.');
|
|
342
|
+
console.log('Please run manually: sudo xcodebuild -license accept');
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Run first-launch setup to install additional components
|
|
346
|
+
console.log('Installing additional components...');
|
|
347
|
+
const firstLaunchResult = await shell.exec('sudo xcodebuild -runFirstLaunch', {
|
|
348
|
+
timeout: 600000 // 10 minute timeout
|
|
349
|
+
});
|
|
350
|
+
if (firstLaunchResult.code !== 0) {
|
|
351
|
+
console.log('Warning: Could not complete first-launch setup.');
|
|
352
|
+
console.log('Please run manually: sudo xcodebuild -runFirstLaunch');
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Set the developer directory to point to the full Xcode installation
|
|
356
|
+
console.log('Setting active developer directory...');
|
|
357
|
+
const selectResult = await shell.exec(`sudo xcode-select -s "${XCODE_DEVELOPER_PATH}"`);
|
|
358
|
+
if (selectResult.code !== 0) {
|
|
359
|
+
console.log('Warning: Could not set developer directory.');
|
|
360
|
+
console.log(`Please run manually: sudo xcode-select -s "${XCODE_DEVELOPER_PATH}"`);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Get and display the installed version
|
|
364
|
+
const installedVersion = await getXcodeVersion();
|
|
365
|
+
console.log('');
|
|
366
|
+
if (installedVersion) {
|
|
367
|
+
console.log(`Xcode ${installedVersion} installed successfully.`);
|
|
368
|
+
} else {
|
|
369
|
+
console.log('Xcode installed successfully.');
|
|
370
|
+
}
|
|
371
|
+
console.log('');
|
|
372
|
+
console.log('Post-installation notes:');
|
|
373
|
+
console.log(' 1. Launch Xcode from /Applications or Spotlight to complete setup');
|
|
374
|
+
console.log(' 2. Sign in with your Apple ID in Xcode > Settings > Accounts');
|
|
375
|
+
console.log(' 3. Download additional simulators in Xcode > Settings > Platforms');
|
|
376
|
+
console.log('');
|
|
377
|
+
console.log('Verify installation:');
|
|
378
|
+
console.log(' xcodebuild -version');
|
|
379
|
+
console.log(' swift --version');
|
|
380
|
+
console.log(' xcode-select -p');
|
|
381
|
+
}
|
|
9
382
|
|
|
10
383
|
/**
|
|
11
|
-
*
|
|
384
|
+
* Handle Xcode installation request on Ubuntu/Debian.
|
|
385
|
+
*
|
|
386
|
+
* Xcode is an Apple-exclusive product and is NOT available for Ubuntu or Debian.
|
|
387
|
+
* This function returns gracefully with a simple informational message.
|
|
388
|
+
*
|
|
389
|
+
* @returns {Promise<void>}
|
|
390
|
+
*/
|
|
391
|
+
async function install_ubuntu() {
|
|
392
|
+
console.log('Xcode is not available for Ubuntu.');
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Handle Xcode installation request on Ubuntu running in WSL.
|
|
398
|
+
*
|
|
399
|
+
* Xcode is an Apple-exclusive product and cannot run in WSL. WSL runs a Linux
|
|
400
|
+
* kernel, not macOS, and cannot run macOS applications.
|
|
401
|
+
*
|
|
402
|
+
* @returns {Promise<void>}
|
|
403
|
+
*/
|
|
404
|
+
async function install_ubuntu_wsl() {
|
|
405
|
+
console.log('Xcode is not available for WSL.');
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Handle Xcode installation request on Raspberry Pi OS.
|
|
411
|
+
*
|
|
412
|
+
* Xcode is an Apple-exclusive product and is NOT available for Raspberry Pi OS.
|
|
413
|
+
* The ARM architecture of Raspberry Pi is not compatible with Xcode, which only
|
|
414
|
+
* runs on macOS with Apple Silicon or Intel processors.
|
|
415
|
+
*
|
|
416
|
+
* @returns {Promise<void>}
|
|
417
|
+
*/
|
|
418
|
+
async function install_raspbian() {
|
|
419
|
+
console.log('Xcode is not available for Raspberry Pi OS.');
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Handle Xcode installation request on Amazon Linux/RHEL.
|
|
425
|
+
*
|
|
426
|
+
* Xcode is an Apple-exclusive product and is NOT available for Amazon Linux
|
|
427
|
+
* or RHEL. Apple does not provide Xcode for any Linux distribution.
|
|
428
|
+
*
|
|
429
|
+
* @returns {Promise<void>}
|
|
430
|
+
*/
|
|
431
|
+
async function install_amazon_linux() {
|
|
432
|
+
console.log('Xcode is not available for Amazon Linux.');
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Handle Xcode installation request on Windows.
|
|
438
|
+
*
|
|
439
|
+
* Xcode is an Apple-exclusive product and is NOT available for Windows.
|
|
440
|
+
* Apple does not provide Xcode for Windows, and there is no legitimate way
|
|
441
|
+
* to run Xcode on Windows.
|
|
442
|
+
*
|
|
443
|
+
* @returns {Promise<void>}
|
|
444
|
+
*/
|
|
445
|
+
async function install_windows() {
|
|
446
|
+
console.log('Xcode is not available for Windows.');
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Handle Xcode installation request in Git Bash.
|
|
452
|
+
*
|
|
453
|
+
* Xcode is an Apple-exclusive product and is NOT available for Git Bash on
|
|
454
|
+
* Windows. Git Bash provides a Unix-like shell environment on Windows but
|
|
455
|
+
* cannot run macOS applications.
|
|
456
|
+
*
|
|
457
|
+
* @returns {Promise<void>}
|
|
458
|
+
*/
|
|
459
|
+
async function install_gitbash() {
|
|
460
|
+
console.log('Xcode is not available for Git Bash.');
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Check if Xcode is installed on the current system.
|
|
466
|
+
* @returns {Promise<boolean>} True if Xcode is installed
|
|
467
|
+
*/
|
|
468
|
+
async function isInstalled() {
|
|
469
|
+
const platform = os.detect();
|
|
470
|
+
if (platform.type === 'macos') {
|
|
471
|
+
return isXcodeInstalled();
|
|
472
|
+
}
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Check if this installer is supported on the current platform.
|
|
478
|
+
* Xcode is ONLY available on macOS.
|
|
479
|
+
* @returns {boolean} True if installation is supported on this platform
|
|
480
|
+
*/
|
|
481
|
+
function isEligible() {
|
|
482
|
+
const platform = os.detect();
|
|
483
|
+
if (platform.type !== 'macos') {
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
if (REQUIRES_DESKTOP && !os.isDesktopAvailable()) {
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
return true;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Main installation entry point - detects platform and runs appropriate installer.
|
|
494
|
+
*
|
|
495
|
+
* This function automatically detects the current operating system and invokes
|
|
496
|
+
* the corresponding platform-specific installation function. Since Xcode is
|
|
497
|
+
* macOS-only, all non-macOS platforms receive a polite informational message.
|
|
498
|
+
*
|
|
499
|
+
* Supported platforms:
|
|
500
|
+
* - macOS: Full Xcode IDE installation via xcodes
|
|
501
|
+
*
|
|
502
|
+
* Unsupported platforms (returns gracefully with message):
|
|
503
|
+
* - Ubuntu/Debian
|
|
504
|
+
* - Ubuntu on WSL
|
|
505
|
+
* - Raspberry Pi OS
|
|
506
|
+
* - Amazon Linux/RHEL/Fedora
|
|
507
|
+
* - Windows (native)
|
|
508
|
+
* - Git Bash
|
|
12
509
|
*
|
|
13
510
|
* @returns {Promise<void>}
|
|
14
511
|
*/
|
|
15
512
|
async function install() {
|
|
16
513
|
const platform = os.detect();
|
|
17
514
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
515
|
+
// Map platform types to their corresponding installer functions
|
|
516
|
+
// All non-macOS platforms will receive a "not available" message
|
|
517
|
+
const installers = {
|
|
518
|
+
'macos': install_macos,
|
|
519
|
+
'ubuntu': install_ubuntu,
|
|
520
|
+
'debian': install_ubuntu,
|
|
521
|
+
'wsl': install_ubuntu_wsl,
|
|
522
|
+
'raspbian': install_raspbian,
|
|
523
|
+
'amazon_linux': install_amazon_linux,
|
|
524
|
+
'fedora': install_amazon_linux,
|
|
525
|
+
'rhel': install_amazon_linux,
|
|
526
|
+
'windows': install_windows,
|
|
527
|
+
'gitbash': install_gitbash,
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
const installer = installers[platform.type];
|
|
531
|
+
|
|
532
|
+
// Handle unknown platforms gracefully without throwing an error
|
|
533
|
+
if (!installer) {
|
|
534
|
+
console.log(`Xcode is not available for ${platform.type}.`);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
await installer();
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
module.exports = {
|
|
542
|
+
REQUIRES_DESKTOP,
|
|
543
|
+
install,
|
|
544
|
+
isInstalled,
|
|
545
|
+
isEligible,
|
|
546
|
+
install_macos,
|
|
547
|
+
install_ubuntu,
|
|
548
|
+
install_ubuntu_wsl,
|
|
549
|
+
install_raspbian,
|
|
550
|
+
install_amazon_linux,
|
|
551
|
+
install_windows,
|
|
552
|
+
install_gitbash,
|
|
553
|
+
};
|
|
41
554
|
|
|
42
555
|
if (require.main === module) {
|
|
43
|
-
install()
|
|
556
|
+
install().catch(err => {
|
|
557
|
+
console.error(err.message);
|
|
558
|
+
process.exit(1);
|
|
559
|
+
});
|
|
44
560
|
}
|