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