@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/vscode.js
CHANGED
|
@@ -1,44 +1,843 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @fileoverview Install Visual Studio Code.
|
|
4
|
+
* @fileoverview Install Visual Studio Code - a powerful code editor by Microsoft.
|
|
5
5
|
* @module installs/vscode
|
|
6
|
+
*
|
|
7
|
+
* Visual Studio Code (VS Code) is a free, open-source code editor developed by
|
|
8
|
+
* Microsoft. It provides a lightweight yet powerful development environment with
|
|
9
|
+
* built-in support for JavaScript, TypeScript, and Node.js, along with a rich
|
|
10
|
+
* ecosystem of extensions for other languages and tools.
|
|
11
|
+
*
|
|
12
|
+
* VS Code features:
|
|
13
|
+
* - Intelligent code completion (IntelliSense)
|
|
14
|
+
* - Integrated debugging
|
|
15
|
+
* - Git integration
|
|
16
|
+
* - Highly customizable interface
|
|
17
|
+
* - Extensive extension marketplace
|
|
18
|
+
*
|
|
19
|
+
* This installer provides:
|
|
20
|
+
* - macOS: VS Code via Homebrew cask
|
|
21
|
+
* - Ubuntu/Debian: VS Code via Microsoft's APT repository
|
|
22
|
+
* - Raspberry Pi OS: VS Code via APT (available in Raspberry Pi OS repository)
|
|
23
|
+
* - Amazon Linux/RHEL: VS Code via Microsoft's YUM/DNF repository
|
|
24
|
+
* - Windows: VS Code via Chocolatey
|
|
25
|
+
* - WSL (Ubuntu): VS Code via Microsoft's APT repository
|
|
26
|
+
* - Git Bash: VS Code installed on Windows host via Chocolatey
|
|
27
|
+
*
|
|
28
|
+
* IMPORTANT PLATFORM NOTES:
|
|
29
|
+
* - On Ubuntu/Debian, Microsoft's repository is used for the latest version
|
|
30
|
+
* - Raspberry Pi OS includes VS Code in its default repository for ARM compatibility
|
|
31
|
+
* - On Windows, a new terminal window must be opened after installation for
|
|
32
|
+
* PATH changes to take effect
|
|
6
33
|
*/
|
|
7
34
|
|
|
8
35
|
const os = require('../utils/common/os');
|
|
36
|
+
const shell = require('../utils/common/shell');
|
|
37
|
+
const brew = require('../utils/macos/brew');
|
|
38
|
+
const apt = require('../utils/ubuntu/apt');
|
|
39
|
+
const choco = require('../utils/windows/choco');
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Indicates whether this installer requires a desktop environment.
|
|
43
|
+
* Visual Studio Code is a GUI application and requires a display.
|
|
44
|
+
* @type {boolean}
|
|
45
|
+
*/
|
|
46
|
+
const REQUIRES_DESKTOP = true;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The Homebrew cask name for Visual Studio Code on macOS.
|
|
50
|
+
* This installs the full VS Code application to /Applications.
|
|
51
|
+
*/
|
|
52
|
+
const HOMEBREW_CASK_NAME = 'visual-studio-code';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The Chocolatey package name for Visual Studio Code on Windows.
|
|
56
|
+
* This is the official VS Code package maintained by the Chocolatey community.
|
|
57
|
+
*/
|
|
58
|
+
const CHOCO_PACKAGE_NAME = 'vscode';
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The APT package name for Visual Studio Code on Debian-based systems.
|
|
62
|
+
* This is the package name used in Microsoft's repository.
|
|
63
|
+
*/
|
|
64
|
+
const APT_PACKAGE_NAME = 'code';
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Microsoft's GPG key URL for package verification.
|
|
68
|
+
* This key is used to verify the authenticity of VS Code packages.
|
|
69
|
+
*/
|
|
70
|
+
const MICROSOFT_GPG_KEY_URL = 'https://packages.microsoft.com/keys/microsoft.asc';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Check if VS Code CLI is installed by verifying the 'code' command exists.
|
|
74
|
+
*
|
|
75
|
+
* This is a quick synchronous check that works across all platforms.
|
|
76
|
+
* It verifies that the 'code' executable is available in the system PATH.
|
|
77
|
+
*
|
|
78
|
+
* @returns {boolean} True if the code command is available, false otherwise
|
|
79
|
+
*/
|
|
80
|
+
function isCodeCommandAvailable() {
|
|
81
|
+
return shell.commandExists('code');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Check if VS Code is installed and get the version.
|
|
86
|
+
*
|
|
87
|
+
* Executes 'code --version' to verify VS Code is properly installed
|
|
88
|
+
* and operational. Returns the version string if successful.
|
|
89
|
+
*
|
|
90
|
+
* @returns {Promise<string|null>} VS Code version string (e.g., "1.107.1"), or null if not installed
|
|
91
|
+
*/
|
|
92
|
+
async function getVSCodeVersion() {
|
|
93
|
+
if (!isCodeCommandAvailable()) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const result = await shell.exec('code --version');
|
|
98
|
+
if (result.code === 0 && result.stdout) {
|
|
99
|
+
// Output format: First line is version (e.g., "1.107.1")
|
|
100
|
+
const lines = result.stdout.trim().split('\n');
|
|
101
|
+
return lines[0] || null;
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Set up Microsoft's APT repository for VS Code on Ubuntu/Debian.
|
|
108
|
+
*
|
|
109
|
+
* This function:
|
|
110
|
+
* 1. Installs prerequisites (wget, gpg, apt-transport-https)
|
|
111
|
+
* 2. Imports Microsoft's GPG key for package verification
|
|
112
|
+
* 3. Adds Microsoft's VS Code repository to APT sources
|
|
113
|
+
* 4. Updates the package cache
|
|
114
|
+
*
|
|
115
|
+
* @returns {Promise<void>}
|
|
116
|
+
* @throws {Error} If any step fails
|
|
117
|
+
*/
|
|
118
|
+
async function setupMicrosoftAptRepository() {
|
|
119
|
+
console.log('Setting up Microsoft APT repository for VS Code...');
|
|
120
|
+
|
|
121
|
+
// Install prerequisites needed to download and verify the repository
|
|
122
|
+
console.log('Installing prerequisites (wget, gpg, apt-transport-https)...');
|
|
123
|
+
const prereqResult = await shell.exec(
|
|
124
|
+
'sudo DEBIAN_FRONTEND=noninteractive apt-get update -y && ' +
|
|
125
|
+
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y wget gpg apt-transport-https'
|
|
126
|
+
);
|
|
127
|
+
if (prereqResult.code !== 0) {
|
|
128
|
+
throw new Error(`Failed to install prerequisites: ${prereqResult.stderr}`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Download and import Microsoft's GPG key
|
|
132
|
+
console.log('Importing Microsoft GPG key...');
|
|
133
|
+
const gpgResult = await shell.exec(
|
|
134
|
+
`wget -qO- ${MICROSOFT_GPG_KEY_URL} | gpg --dearmor > /tmp/microsoft.gpg && ` +
|
|
135
|
+
'sudo install -D -o root -g root -m 644 /tmp/microsoft.gpg /usr/share/keyrings/microsoft.gpg && ' +
|
|
136
|
+
'rm -f /tmp/microsoft.gpg'
|
|
137
|
+
);
|
|
138
|
+
if (gpgResult.code !== 0) {
|
|
139
|
+
throw new Error(`Failed to import Microsoft GPG key: ${gpgResult.stderr}`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Add Microsoft's APT repository using the DEB822 format for modern systems
|
|
143
|
+
console.log('Adding Microsoft VS Code repository...');
|
|
144
|
+
const repoContent = `Types: deb
|
|
145
|
+
URIs: https://packages.microsoft.com/repos/code
|
|
146
|
+
Suites: stable
|
|
147
|
+
Components: main
|
|
148
|
+
Architectures: amd64,arm64,armhf
|
|
149
|
+
Signed-By: /usr/share/keyrings/microsoft.gpg`;
|
|
150
|
+
|
|
151
|
+
const repoResult = await shell.exec(
|
|
152
|
+
`echo "${repoContent}" | sudo tee /etc/apt/sources.list.d/vscode.sources > /dev/null`
|
|
153
|
+
);
|
|
154
|
+
if (repoResult.code !== 0) {
|
|
155
|
+
throw new Error(`Failed to add Microsoft repository: ${repoResult.stderr}`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Update package cache to include the new repository
|
|
159
|
+
console.log('Updating package cache...');
|
|
160
|
+
const updateResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update -y');
|
|
161
|
+
if (updateResult.code !== 0) {
|
|
162
|
+
throw new Error(`Failed to update package cache: ${updateResult.stderr}`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
console.log('Microsoft APT repository configured successfully.');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Set up Microsoft's YUM/DNF repository for VS Code on Amazon Linux/RHEL.
|
|
170
|
+
*
|
|
171
|
+
* This function:
|
|
172
|
+
* 1. Imports Microsoft's GPG key using rpm
|
|
173
|
+
* 2. Creates the repository configuration file
|
|
174
|
+
*
|
|
175
|
+
* @returns {Promise<void>}
|
|
176
|
+
* @throws {Error} If any step fails
|
|
177
|
+
*/
|
|
178
|
+
async function setupMicrosoftYumRepository() {
|
|
179
|
+
console.log('Setting up Microsoft YUM repository for VS Code...');
|
|
180
|
+
|
|
181
|
+
// Import Microsoft's GPG key
|
|
182
|
+
console.log('Importing Microsoft GPG key...');
|
|
183
|
+
const gpgResult = await shell.exec(
|
|
184
|
+
`sudo rpm --import ${MICROSOFT_GPG_KEY_URL}`
|
|
185
|
+
);
|
|
186
|
+
if (gpgResult.code !== 0) {
|
|
187
|
+
throw new Error(`Failed to import Microsoft GPG key: ${gpgResult.stderr}`);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Create the repository configuration file
|
|
191
|
+
console.log('Adding Microsoft VS Code repository...');
|
|
192
|
+
const repoContent = `[code]
|
|
193
|
+
name=Visual Studio Code
|
|
194
|
+
baseurl=https://packages.microsoft.com/yumrepos/vscode
|
|
195
|
+
enabled=1
|
|
196
|
+
autorefresh=1
|
|
197
|
+
type=rpm-md
|
|
198
|
+
gpgcheck=1
|
|
199
|
+
gpgkey=${MICROSOFT_GPG_KEY_URL}`;
|
|
200
|
+
|
|
201
|
+
const repoResult = await shell.exec(
|
|
202
|
+
`echo -e "${repoContent}" | sudo tee /etc/yum.repos.d/vscode.repo > /dev/null`
|
|
203
|
+
);
|
|
204
|
+
if (repoResult.code !== 0) {
|
|
205
|
+
throw new Error(`Failed to add Microsoft repository: ${repoResult.stderr}`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
console.log('Microsoft YUM repository configured successfully.');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Install Visual Studio Code on macOS using Homebrew cask.
|
|
213
|
+
*
|
|
214
|
+
* Prerequisites:
|
|
215
|
+
* - macOS 10.15 (Catalina) or later
|
|
216
|
+
* - Homebrew package manager installed
|
|
217
|
+
* - Apple Silicon (M1/M2/M3/M4) or Intel processor
|
|
218
|
+
*
|
|
219
|
+
* This function installs VS Code as a macOS application via Homebrew cask.
|
|
220
|
+
* The 'code' command-line tool is typically added to PATH automatically
|
|
221
|
+
* on modern versions.
|
|
222
|
+
*
|
|
223
|
+
* @returns {Promise<void>}
|
|
224
|
+
*/
|
|
225
|
+
async function install_macos() {
|
|
226
|
+
console.log('Checking if Visual Studio Code is already installed...');
|
|
227
|
+
|
|
228
|
+
// Check if VS Code cask is already installed via Homebrew
|
|
229
|
+
const isCaskInstalled = await brew.isCaskInstalled(HOMEBREW_CASK_NAME);
|
|
230
|
+
if (isCaskInstalled) {
|
|
231
|
+
const version = await getVSCodeVersion();
|
|
232
|
+
console.log(`Visual Studio Code ${version || 'unknown version'} is already installed via Homebrew, skipping...`);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Also check if the code command exists (might be installed by other means)
|
|
237
|
+
const existingVersion = await getVSCodeVersion();
|
|
238
|
+
if (existingVersion) {
|
|
239
|
+
console.log(`Visual Studio Code ${existingVersion} is already installed, skipping...`);
|
|
240
|
+
console.log('');
|
|
241
|
+
console.log('Note: VS Code was not installed via Homebrew.');
|
|
242
|
+
console.log('If you want to manage it with Homebrew, first uninstall the existing version.');
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Verify Homebrew is available - it is required for macOS installation
|
|
247
|
+
if (!brew.isInstalled()) {
|
|
248
|
+
console.log('Homebrew is not installed. Please install Homebrew first.');
|
|
249
|
+
console.log('Run: dev install homebrew');
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Install VS Code using Homebrew cask
|
|
254
|
+
console.log('Installing Visual Studio Code via Homebrew...');
|
|
255
|
+
const result = await brew.installCask(HOMEBREW_CASK_NAME);
|
|
256
|
+
|
|
257
|
+
if (!result.success) {
|
|
258
|
+
console.log('Failed to install Visual Studio Code via Homebrew.');
|
|
259
|
+
console.log(result.output);
|
|
260
|
+
console.log('');
|
|
261
|
+
console.log('Troubleshooting:');
|
|
262
|
+
console.log(' 1. Run "brew update && brew cleanup" and retry');
|
|
263
|
+
console.log(' 2. If on Apple Silicon, ensure you have Rosetta 2: softwareupdate --install-rosetta');
|
|
264
|
+
console.log(' 3. Try manual installation: brew reinstall --cask visual-studio-code');
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Verify the installation succeeded
|
|
269
|
+
const verified = await brew.isCaskInstalled(HOMEBREW_CASK_NAME);
|
|
270
|
+
if (!verified) {
|
|
271
|
+
console.log('Installation may have failed: VS Code cask not found after install.');
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Display installed version
|
|
276
|
+
const version = await getVSCodeVersion();
|
|
277
|
+
|
|
278
|
+
console.log('Visual Studio Code installed successfully via Homebrew.');
|
|
279
|
+
console.log('');
|
|
280
|
+
if (version) {
|
|
281
|
+
console.log(`VS Code version: ${version}`);
|
|
282
|
+
console.log('');
|
|
283
|
+
}
|
|
284
|
+
console.log('NOTE: If "code" command is not found, you can add it to PATH by:');
|
|
285
|
+
console.log(' 1. Launch VS Code');
|
|
286
|
+
console.log(' 2. Open Command Palette (Cmd+Shift+P)');
|
|
287
|
+
console.log(' 3. Run "Shell Command: Install \'code\' command in PATH"');
|
|
288
|
+
console.log('');
|
|
289
|
+
console.log('Verify installation with: code --version');
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Install Visual Studio Code on Ubuntu/Debian using APT with Microsoft's repository.
|
|
294
|
+
*
|
|
295
|
+
* Prerequisites:
|
|
296
|
+
* - Ubuntu 20.04 (Focal) or later, or Debian 10 (Buster) or later (64-bit)
|
|
297
|
+
* - sudo privileges
|
|
298
|
+
* - wget and gpg utilities
|
|
299
|
+
*
|
|
300
|
+
* IMPORTANT: This function adds Microsoft's APT repository to ensure the
|
|
301
|
+
* latest version of VS Code is installed. Do not use 'apt install code'
|
|
302
|
+
* without first adding the repository.
|
|
303
|
+
*
|
|
304
|
+
* @returns {Promise<void>}
|
|
305
|
+
*/
|
|
306
|
+
async function install_ubuntu() {
|
|
307
|
+
console.log('Checking if Visual Studio Code is already installed...');
|
|
308
|
+
|
|
309
|
+
// Check if VS Code is already installed via APT
|
|
310
|
+
const isAptInstalled = await apt.isPackageInstalled(APT_PACKAGE_NAME);
|
|
311
|
+
if (isAptInstalled) {
|
|
312
|
+
const version = await getVSCodeVersion();
|
|
313
|
+
console.log(`Visual Studio Code ${version || 'unknown version'} is already installed, skipping...`);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Also check if the code command exists (might be installed by other means)
|
|
318
|
+
const existingVersion = await getVSCodeVersion();
|
|
319
|
+
if (existingVersion) {
|
|
320
|
+
console.log(`Visual Studio Code ${existingVersion} is already installed, skipping...`);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Set up Microsoft's APT repository
|
|
325
|
+
await setupMicrosoftAptRepository();
|
|
326
|
+
|
|
327
|
+
// Install VS Code from the Microsoft repository
|
|
328
|
+
console.log('Installing Visual Studio Code via APT...');
|
|
329
|
+
const installResult = await shell.exec(
|
|
330
|
+
`sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ${APT_PACKAGE_NAME}`
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
if (installResult.code !== 0) {
|
|
334
|
+
console.log('Failed to install Visual Studio Code via APT.');
|
|
335
|
+
console.log(installResult.stderr || installResult.stdout);
|
|
336
|
+
console.log('');
|
|
337
|
+
console.log('Troubleshooting:');
|
|
338
|
+
console.log(' 1. Run "sudo apt-get update" and retry');
|
|
339
|
+
console.log(' 2. Check if the Microsoft repository was added:');
|
|
340
|
+
console.log(' cat /etc/apt/sources.list.d/vscode.sources');
|
|
341
|
+
console.log(' 3. Verify the GPG key exists: ls -la /usr/share/keyrings/microsoft.gpg');
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Verify the installation succeeded
|
|
346
|
+
const version = await getVSCodeVersion();
|
|
347
|
+
if (!version) {
|
|
348
|
+
console.log('Installation may have failed: code command not found after install.');
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
console.log('Visual Studio Code installed successfully.');
|
|
353
|
+
console.log('');
|
|
354
|
+
console.log(`VS Code version: ${version}`);
|
|
355
|
+
console.log('');
|
|
356
|
+
console.log('Verify installation with: code --version');
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Install Visual Studio Code on Ubuntu running in WSL (Windows Subsystem for Linux).
|
|
361
|
+
*
|
|
362
|
+
* Prerequisites:
|
|
363
|
+
* - Windows 10 version 2004 or later, or Windows 11
|
|
364
|
+
* - WSL 2 enabled with Ubuntu distribution installed
|
|
365
|
+
* - sudo privileges within WSL
|
|
366
|
+
*
|
|
367
|
+
* This function installs VS Code natively within WSL for users who have
|
|
368
|
+
* WSLg (Windows 11) or an X server configured. For most users, Microsoft
|
|
369
|
+
* recommends installing VS Code on Windows and using the Remote-WSL extension.
|
|
370
|
+
*
|
|
371
|
+
* @returns {Promise<void>}
|
|
372
|
+
*/
|
|
373
|
+
async function install_ubuntu_wsl() {
|
|
374
|
+
console.log('Detected Ubuntu running in WSL (Windows Subsystem for Linux).');
|
|
375
|
+
console.log('');
|
|
376
|
+
|
|
377
|
+
// Check if VS Code is already available (either native or from Windows)
|
|
378
|
+
const existingVersion = await getVSCodeVersion();
|
|
379
|
+
if (existingVersion) {
|
|
380
|
+
console.log(`Visual Studio Code ${existingVersion} is already installed, skipping...`);
|
|
381
|
+
console.log('');
|
|
382
|
+
console.log('Note: The "code" command may be using VS Code installed on Windows.');
|
|
383
|
+
console.log('This is the recommended setup for WSL development.');
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// Install VS Code natively in WSL using the same method as Ubuntu
|
|
388
|
+
console.log('Installing Visual Studio Code natively in WSL...');
|
|
389
|
+
console.log('');
|
|
390
|
+
console.log('TIP: For best experience, consider installing VS Code on Windows');
|
|
391
|
+
console.log('and using the Remote-WSL extension. Simply run "code ." from WSL');
|
|
392
|
+
console.log('to connect VS Code on Windows to your WSL environment.');
|
|
393
|
+
console.log('');
|
|
394
|
+
|
|
395
|
+
// Set up Microsoft's APT repository
|
|
396
|
+
await setupMicrosoftAptRepository();
|
|
397
|
+
|
|
398
|
+
// Install VS Code from the Microsoft repository
|
|
399
|
+
console.log('Installing Visual Studio Code via APT...');
|
|
400
|
+
const installResult = await shell.exec(
|
|
401
|
+
`sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ${APT_PACKAGE_NAME}`
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
if (installResult.code !== 0) {
|
|
405
|
+
console.log('Failed to install Visual Studio Code via APT.');
|
|
406
|
+
console.log(installResult.stderr || installResult.stdout);
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Verify the installation succeeded
|
|
411
|
+
const version = await getVSCodeVersion();
|
|
412
|
+
if (!version) {
|
|
413
|
+
console.log('Installation may have failed: code command not found after install.');
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
console.log('Visual Studio Code installed successfully in WSL.');
|
|
418
|
+
console.log('');
|
|
419
|
+
console.log(`VS Code version: ${version}`);
|
|
420
|
+
console.log('');
|
|
421
|
+
console.log('NOTE: To run VS Code GUI, you need WSLg (Windows 11) or an X server.');
|
|
422
|
+
console.log('If VS Code does not launch, verify your display environment is configured.');
|
|
423
|
+
console.log('');
|
|
424
|
+
console.log('Verify installation with: code --version');
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Install Visual Studio Code on Raspberry Pi OS using APT.
|
|
429
|
+
*
|
|
430
|
+
* Prerequisites:
|
|
431
|
+
* - Raspberry Pi OS (64-bit recommended) - Bookworm or Bullseye
|
|
432
|
+
* - Raspberry Pi 3B+ or later (64-bit capable hardware recommended)
|
|
433
|
+
* - At least 1 GB RAM (2 GB or more recommended for comfortable usage)
|
|
434
|
+
* - sudo privileges
|
|
435
|
+
*
|
|
436
|
+
* VS Code is available in the official Raspberry Pi OS repository, which
|
|
437
|
+
* includes ARM-compatible builds. This eliminates the need to manually
|
|
438
|
+
* add Microsoft's repository.
|
|
439
|
+
*
|
|
440
|
+
* @returns {Promise<void>}
|
|
441
|
+
*/
|
|
442
|
+
async function install_raspbian() {
|
|
443
|
+
console.log('Checking if Visual Studio Code is already installed...');
|
|
444
|
+
|
|
445
|
+
// Check if VS Code is already installed
|
|
446
|
+
const existingVersion = await getVSCodeVersion();
|
|
447
|
+
if (existingVersion) {
|
|
448
|
+
console.log(`Visual Studio Code ${existingVersion} is already installed, skipping...`);
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// Check and report architecture for informational purposes
|
|
453
|
+
const archResult = await shell.exec('uname -m');
|
|
454
|
+
const arch = archResult.stdout.trim();
|
|
455
|
+
console.log(`Detected architecture: ${arch}`);
|
|
456
|
+
console.log('');
|
|
457
|
+
|
|
458
|
+
// Update package lists first
|
|
459
|
+
console.log('Updating package lists...');
|
|
460
|
+
const updateResult = await shell.exec('sudo DEBIAN_FRONTEND=noninteractive apt-get update -y');
|
|
461
|
+
if (updateResult.code !== 0) {
|
|
462
|
+
console.log('Warning: Failed to update package lists. Continuing with installation...');
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Install VS Code from Raspberry Pi OS repository
|
|
466
|
+
// The official Raspberry Pi OS repository includes ARM-compatible builds
|
|
467
|
+
console.log('Installing Visual Studio Code via APT...');
|
|
468
|
+
const installResult = await shell.exec(
|
|
469
|
+
`sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ${APT_PACKAGE_NAME}`
|
|
470
|
+
);
|
|
471
|
+
|
|
472
|
+
if (installResult.code !== 0) {
|
|
473
|
+
console.log('Failed to install Visual Studio Code via APT.');
|
|
474
|
+
console.log(installResult.stderr || installResult.stdout);
|
|
475
|
+
console.log('');
|
|
476
|
+
console.log('The package may not be available in the default repository.');
|
|
477
|
+
console.log('Attempting to install from Microsoft repository instead...');
|
|
478
|
+
console.log('');
|
|
479
|
+
|
|
480
|
+
// Fall back to Microsoft's repository
|
|
481
|
+
try {
|
|
482
|
+
await setupMicrosoftAptRepository();
|
|
483
|
+
const retryResult = await shell.exec(
|
|
484
|
+
`sudo DEBIAN_FRONTEND=noninteractive apt-get install -y ${APT_PACKAGE_NAME}`
|
|
485
|
+
);
|
|
486
|
+
if (retryResult.code !== 0) {
|
|
487
|
+
console.log('Failed to install Visual Studio Code from Microsoft repository.');
|
|
488
|
+
console.log(retryResult.stderr || retryResult.stdout);
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
} catch (error) {
|
|
492
|
+
console.log(`Failed to set up Microsoft repository: ${error.message}`);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// Verify the installation succeeded
|
|
498
|
+
const version = await getVSCodeVersion();
|
|
499
|
+
if (!version) {
|
|
500
|
+
console.log('Installation may have failed: code command not found after install.');
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
console.log('Visual Studio Code installed successfully.');
|
|
505
|
+
console.log('');
|
|
506
|
+
console.log(`VS Code version: ${version}`);
|
|
507
|
+
console.log('');
|
|
508
|
+
console.log('NOTE: If VS Code is slow, you can disable hardware acceleration:');
|
|
509
|
+
console.log(' 1. Open VS Code and press Ctrl+Shift+P');
|
|
510
|
+
console.log(' 2. Type "Preferences: Configure Runtime Arguments"');
|
|
511
|
+
console.log(' 3. Add: "disable-hardware-acceleration": true');
|
|
512
|
+
console.log('');
|
|
513
|
+
console.log('Verify installation with: code --version');
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Install Visual Studio Code on Amazon Linux/RHEL using DNF or YUM.
|
|
518
|
+
*
|
|
519
|
+
* Prerequisites:
|
|
520
|
+
* - Amazon Linux 2023 (AL2023), Amazon Linux 2 (AL2), RHEL 8+, or CentOS 8+
|
|
521
|
+
* - sudo privileges
|
|
522
|
+
* - 64-bit system
|
|
523
|
+
*
|
|
524
|
+
* This function automatically detects whether the system uses DNF (AL2023)
|
|
525
|
+
* or YUM (AL2) and uses the appropriate package manager.
|
|
526
|
+
*
|
|
527
|
+
* @returns {Promise<void>}
|
|
528
|
+
*/
|
|
529
|
+
async function install_amazon_linux() {
|
|
530
|
+
console.log('Checking if Visual Studio Code is already installed...');
|
|
531
|
+
|
|
532
|
+
// Check if VS Code is already installed
|
|
533
|
+
const existingVersion = await getVSCodeVersion();
|
|
534
|
+
if (existingVersion) {
|
|
535
|
+
console.log(`Visual Studio Code ${existingVersion} is already installed, skipping...`);
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// Detect package manager (dnf for AL2023, yum for AL2)
|
|
540
|
+
const hasDnf = shell.commandExists('dnf');
|
|
541
|
+
const hasYum = shell.commandExists('yum');
|
|
542
|
+
const packageManager = hasDnf ? 'dnf' : (hasYum ? 'yum' : null);
|
|
543
|
+
|
|
544
|
+
if (!packageManager) {
|
|
545
|
+
console.log('Neither dnf nor yum package manager found.');
|
|
546
|
+
console.log('This installer supports Amazon Linux 2023 (dnf) and Amazon Linux 2 (yum).');
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
console.log(`Detected package manager: ${packageManager}`);
|
|
551
|
+
|
|
552
|
+
// Set up Microsoft's YUM repository
|
|
553
|
+
await setupMicrosoftYumRepository();
|
|
554
|
+
|
|
555
|
+
// Update package cache (check-update returns 100 if updates are available, which is not an error)
|
|
556
|
+
console.log('Checking for updates...');
|
|
557
|
+
await shell.exec(`sudo ${packageManager} check-update || true`);
|
|
558
|
+
|
|
559
|
+
// Install VS Code
|
|
560
|
+
console.log('Installing Visual Studio Code via ' + packageManager + '...');
|
|
561
|
+
const installResult = await shell.exec(
|
|
562
|
+
`sudo ${packageManager} install -y ${APT_PACKAGE_NAME}`
|
|
563
|
+
);
|
|
564
|
+
|
|
565
|
+
if (installResult.code !== 0) {
|
|
566
|
+
console.log(`Failed to install Visual Studio Code via ${packageManager}.`);
|
|
567
|
+
console.log(installResult.stderr || installResult.stdout);
|
|
568
|
+
console.log('');
|
|
569
|
+
console.log('Troubleshooting:');
|
|
570
|
+
console.log(' 1. Verify the repository was added correctly:');
|
|
571
|
+
console.log(' cat /etc/yum.repos.d/vscode.repo');
|
|
572
|
+
console.log(` 2. Try: sudo ${packageManager} install -y code`);
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// Verify the installation succeeded
|
|
577
|
+
const version = await getVSCodeVersion();
|
|
578
|
+
if (!version) {
|
|
579
|
+
console.log('Installation may have failed: code command not found after install.');
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
console.log('Visual Studio Code installed successfully.');
|
|
584
|
+
console.log('');
|
|
585
|
+
console.log(`VS Code version: ${version}`);
|
|
586
|
+
console.log('');
|
|
587
|
+
console.log('Verify installation with: code --version');
|
|
588
|
+
}
|
|
9
589
|
|
|
10
590
|
/**
|
|
11
|
-
* Install Visual Studio Code
|
|
591
|
+
* Install Visual Studio Code on Windows using Chocolatey.
|
|
592
|
+
*
|
|
593
|
+
* Prerequisites:
|
|
594
|
+
* - Windows 10 version 1709 or later (64-bit), or Windows 11
|
|
595
|
+
* - Administrator PowerShell or Command Prompt
|
|
596
|
+
* - Chocolatey package manager installed
|
|
597
|
+
*
|
|
598
|
+
* The Chocolatey package automatically:
|
|
599
|
+
* - Adds VS Code to the system PATH
|
|
600
|
+
* - Creates "Open with Code" context menu entries
|
|
601
|
+
*
|
|
602
|
+
* IMPORTANT: A new terminal window must be opened after installation
|
|
603
|
+
* for PATH changes to take effect.
|
|
604
|
+
*
|
|
605
|
+
* @returns {Promise<void>}
|
|
606
|
+
*/
|
|
607
|
+
async function install_windows() {
|
|
608
|
+
console.log('Checking if Visual Studio Code is already installed...');
|
|
609
|
+
|
|
610
|
+
// Check if VS Code is already installed via Chocolatey
|
|
611
|
+
const isChocoInstalled = await choco.isPackageInstalled(CHOCO_PACKAGE_NAME);
|
|
612
|
+
if (isChocoInstalled) {
|
|
613
|
+
const version = await getVSCodeVersion();
|
|
614
|
+
console.log(`Visual Studio Code ${version || 'unknown version'} is already installed via Chocolatey, skipping...`);
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// Also check if the code command exists (might be installed by other means)
|
|
619
|
+
const existingVersion = await getVSCodeVersion();
|
|
620
|
+
if (existingVersion) {
|
|
621
|
+
console.log(`Visual Studio Code ${existingVersion} is already installed, skipping...`);
|
|
622
|
+
console.log('');
|
|
623
|
+
console.log('Note: VS Code was not installed via Chocolatey.');
|
|
624
|
+
console.log('If you want to manage it with Chocolatey, first uninstall the existing version.');
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// Verify Chocolatey is available - it is required for Windows installation
|
|
629
|
+
if (!choco.isInstalled()) {
|
|
630
|
+
console.log('Chocolatey is not installed. Please install Chocolatey first.');
|
|
631
|
+
console.log('');
|
|
632
|
+
console.log('To install Chocolatey, run in an Administrator PowerShell:');
|
|
633
|
+
console.log(" Set-ExecutionPolicy Bypass -Scope Process -Force; " +
|
|
634
|
+
"[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; " +
|
|
635
|
+
"iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))");
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// Install VS Code using Chocolatey
|
|
640
|
+
console.log('Installing Visual Studio Code via Chocolatey...');
|
|
641
|
+
console.log('This may take a few minutes...');
|
|
642
|
+
const result = await choco.install(CHOCO_PACKAGE_NAME);
|
|
643
|
+
|
|
644
|
+
if (!result.success) {
|
|
645
|
+
console.log('Failed to install Visual Studio Code via Chocolatey.');
|
|
646
|
+
console.log(result.output);
|
|
647
|
+
console.log('');
|
|
648
|
+
console.log('Troubleshooting:');
|
|
649
|
+
console.log(' 1. Ensure you are running as Administrator');
|
|
650
|
+
console.log(' 2. Try: choco install vscode -y --force');
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// Verify the installation succeeded by checking if the package is now installed
|
|
655
|
+
const verified = await choco.isPackageInstalled(CHOCO_PACKAGE_NAME);
|
|
656
|
+
if (!verified) {
|
|
657
|
+
console.log('Installation may have failed: vscode package not found after install.');
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
console.log('Visual Studio Code installed successfully via Chocolatey.');
|
|
662
|
+
console.log('');
|
|
663
|
+
console.log('IMPORTANT: Close and reopen your terminal for PATH changes to take effect.');
|
|
664
|
+
console.log('');
|
|
665
|
+
console.log('After reopening the terminal, verify with:');
|
|
666
|
+
console.log(' code --version');
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Install Visual Studio Code from Git Bash on Windows.
|
|
671
|
+
*
|
|
672
|
+
* Git Bash runs within Windows and inherits the Windows PATH, so once
|
|
673
|
+
* VS Code is installed on Windows, the 'code' command is automatically
|
|
674
|
+
* available in Git Bash.
|
|
675
|
+
*
|
|
676
|
+
* This function installs VS Code on the Windows host using Chocolatey
|
|
677
|
+
* via PowerShell interop.
|
|
678
|
+
*
|
|
679
|
+
* Prerequisites:
|
|
680
|
+
* - Windows 10 or Windows 11 (64-bit)
|
|
681
|
+
* - Git Bash installed (comes with Git for Windows)
|
|
682
|
+
* - Chocolatey package manager installed on Windows
|
|
683
|
+
* - Administrator privileges
|
|
684
|
+
*
|
|
685
|
+
* @returns {Promise<void>}
|
|
686
|
+
*/
|
|
687
|
+
async function install_gitbash() {
|
|
688
|
+
console.log('Detected Git Bash on Windows.');
|
|
689
|
+
console.log('');
|
|
690
|
+
|
|
691
|
+
// Check if VS Code is already available
|
|
692
|
+
const existingVersion = await getVSCodeVersion();
|
|
693
|
+
if (existingVersion) {
|
|
694
|
+
console.log(`Visual Studio Code ${existingVersion} is already installed, skipping...`);
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// Install via PowerShell using Chocolatey
|
|
699
|
+
console.log('Installing Visual Studio Code on the Windows host via Chocolatey...');
|
|
700
|
+
console.log('This may take a few minutes...');
|
|
701
|
+
|
|
702
|
+
const installResult = await shell.exec(
|
|
703
|
+
`powershell.exe -NoProfile -Command "choco install ${CHOCO_PACKAGE_NAME} -y"`
|
|
704
|
+
);
|
|
705
|
+
|
|
706
|
+
if (installResult.code !== 0) {
|
|
707
|
+
console.log('Failed to install Visual Studio Code.');
|
|
708
|
+
console.log(installResult.stdout || installResult.stderr);
|
|
709
|
+
console.log('');
|
|
710
|
+
console.log('Troubleshooting:');
|
|
711
|
+
console.log(' 1. Ensure Chocolatey is installed on Windows');
|
|
712
|
+
console.log(' 2. Run Git Bash as Administrator and retry');
|
|
713
|
+
console.log(' 3. Try installing directly from PowerShell:');
|
|
714
|
+
console.log(' choco install vscode -y');
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
console.log('Visual Studio Code installed successfully.');
|
|
719
|
+
console.log('');
|
|
720
|
+
console.log('IMPORTANT: Close and reopen Git Bash for PATH changes to take effect.');
|
|
721
|
+
console.log('');
|
|
722
|
+
console.log('Git Bash tips:');
|
|
723
|
+
console.log(' - For interactive features, use: winpty code --wait');
|
|
724
|
+
console.log(' - File paths with spaces need quoting');
|
|
725
|
+
console.log('');
|
|
726
|
+
console.log('After reopening Git Bash, verify with:');
|
|
727
|
+
console.log(' code --version');
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Check if VS Code is installed on the current system.
|
|
732
|
+
* @returns {Promise<boolean>} True if VS Code is installed
|
|
733
|
+
*/
|
|
734
|
+
async function isInstalled() {
|
|
735
|
+
const platform = os.detect();
|
|
736
|
+
if (platform.type === 'macos') {
|
|
737
|
+
return brew.isCaskInstalled(HOMEBREW_CASK_NAME);
|
|
738
|
+
}
|
|
739
|
+
if (platform.type === 'windows') {
|
|
740
|
+
return choco.isPackageInstalled(CHOCO_PACKAGE_NAME);
|
|
741
|
+
}
|
|
742
|
+
if (['ubuntu', 'debian', 'raspbian'].includes(platform.type)) {
|
|
743
|
+
return apt.isPackageInstalled(APT_PACKAGE_NAME);
|
|
744
|
+
}
|
|
745
|
+
return isCodeCommandAvailable();
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Check if this installer is supported on the current platform.
|
|
750
|
+
*
|
|
751
|
+
* VS Code is supported on all major platforms but requires a desktop
|
|
752
|
+
* environment since it is a GUI application. On headless servers or
|
|
753
|
+
* containers without a display, this function returns false.
|
|
754
|
+
*
|
|
755
|
+
* @returns {boolean} True if installation is supported on this platform
|
|
756
|
+
*/
|
|
757
|
+
function isEligible() {
|
|
758
|
+
const platform = os.detect();
|
|
759
|
+
|
|
760
|
+
// First check if the platform is supported
|
|
761
|
+
const supportedPlatforms = ['macos', 'ubuntu', 'debian', 'wsl', 'raspbian', 'amazon_linux', 'fedora', 'rhel', 'windows', 'gitbash'];
|
|
762
|
+
if (!supportedPlatforms.includes(platform.type)) {
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// This installer requires a desktop environment
|
|
767
|
+
if (REQUIRES_DESKTOP && !os.isDesktopAvailable()) {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
return true;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Main installation entry point - detects platform and runs appropriate installer.
|
|
776
|
+
*
|
|
777
|
+
* This function detects the current operating system and dispatches to the
|
|
778
|
+
* appropriate platform-specific installer function. VS Code is supported on
|
|
779
|
+
* all major platforms:
|
|
780
|
+
*
|
|
781
|
+
* - macOS: Homebrew cask
|
|
782
|
+
* - Ubuntu/Debian: APT with Microsoft repository
|
|
783
|
+
* - Ubuntu on WSL: APT with Microsoft repository
|
|
784
|
+
* - Raspberry Pi OS: APT (from Raspberry Pi OS or Microsoft repository)
|
|
785
|
+
* - Amazon Linux/RHEL: DNF/YUM with Microsoft repository
|
|
786
|
+
* - Windows: Chocolatey
|
|
787
|
+
* - Git Bash: Chocolatey on Windows host
|
|
12
788
|
*
|
|
13
789
|
* @returns {Promise<void>}
|
|
14
790
|
*/
|
|
15
791
|
async function install() {
|
|
16
792
|
const platform = os.detect();
|
|
17
793
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
794
|
+
// Map platform types to their corresponding installer functions
|
|
795
|
+
// Multiple platform types can map to the same installer (e.g., debian and ubuntu)
|
|
796
|
+
const installers = {
|
|
797
|
+
'macos': install_macos,
|
|
798
|
+
'ubuntu': install_ubuntu,
|
|
799
|
+
'debian': install_ubuntu,
|
|
800
|
+
'wsl': install_ubuntu_wsl,
|
|
801
|
+
'raspbian': install_raspbian,
|
|
802
|
+
'amazon_linux': install_amazon_linux,
|
|
803
|
+
'fedora': install_amazon_linux,
|
|
804
|
+
'rhel': install_amazon_linux,
|
|
805
|
+
'windows': install_windows,
|
|
806
|
+
'gitbash': install_gitbash,
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
// Look up the installer for the detected platform
|
|
810
|
+
const installer = installers[platform.type];
|
|
811
|
+
|
|
812
|
+
// If no installer exists for this platform, inform the user gracefully
|
|
813
|
+
if (!installer) {
|
|
814
|
+
console.log(`Visual Studio Code is not available for ${platform.type}.`);
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// Run the platform-specific installer
|
|
819
|
+
await installer();
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// Export all functions for use as a module and for testing
|
|
823
|
+
module.exports = {
|
|
824
|
+
REQUIRES_DESKTOP,
|
|
825
|
+
install,
|
|
826
|
+
isInstalled,
|
|
827
|
+
isEligible,
|
|
828
|
+
install_macos,
|
|
829
|
+
install_ubuntu,
|
|
830
|
+
install_ubuntu_wsl,
|
|
831
|
+
install_raspbian,
|
|
832
|
+
install_amazon_linux,
|
|
833
|
+
install_windows,
|
|
834
|
+
install_gitbash,
|
|
835
|
+
};
|
|
41
836
|
|
|
837
|
+
// Allow direct execution: node vscode.js
|
|
42
838
|
if (require.main === module) {
|
|
43
|
-
install()
|
|
839
|
+
install().catch(err => {
|
|
840
|
+
console.error(err.message);
|
|
841
|
+
process.exit(1);
|
|
842
|
+
});
|
|
44
843
|
}
|