@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
|
@@ -1,23 +1,365 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* set-git-public - Set git user to the "public" identity from ~/.devutils
|
|
5
|
+
*
|
|
6
|
+
* Migrated from legacy dotfiles function.
|
|
7
|
+
* Original:
|
|
8
|
+
* set-git-public(){
|
|
9
|
+
* git config user.email "fred.lackey@gmail.com"
|
|
10
|
+
* git config user.name "Fred Lackey"
|
|
11
|
+
* }
|
|
12
|
+
*
|
|
13
|
+
* This script configures the local git repository to use the "public" identity
|
|
14
|
+
* stored in the ~/.devutils configuration file. It sets both user.name and
|
|
15
|
+
* user.email in the local (repository-level) git configuration.
|
|
16
|
+
*
|
|
17
|
+
* Prerequisites:
|
|
18
|
+
* 1. Must be run inside a git repository
|
|
19
|
+
* 2. Must have a "public" identity configured in ~/.devutils
|
|
20
|
+
* (Use `dev identity add public --name "Your Name" --email "you@example.com"`)
|
|
21
|
+
*
|
|
22
|
+
* The script is idempotent - running it multiple times produces the same result.
|
|
23
|
+
* It uses `git config` (without --global) to set repository-local configuration.
|
|
24
|
+
*
|
|
5
25
|
* @module scripts/set-git-public
|
|
6
26
|
*/
|
|
7
27
|
|
|
28
|
+
const os = require('../utils/common/os');
|
|
29
|
+
const { execSync } = require('child_process');
|
|
30
|
+
const fs = require('fs');
|
|
31
|
+
const path = require('path');
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Path to the devutils configuration file.
|
|
35
|
+
* This file stores user identities and other settings.
|
|
36
|
+
*/
|
|
37
|
+
const HOME_DIR = process.env.HOME || process.env.USERPROFILE;
|
|
38
|
+
const CONFIG_FILE = path.join(HOME_DIR, '.devutils');
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Load the devutils configuration from ~/.devutils
|
|
42
|
+
*
|
|
43
|
+
* @returns {object|null} The parsed configuration object, or null if not found/invalid
|
|
44
|
+
*/
|
|
45
|
+
function loadConfig() {
|
|
46
|
+
try {
|
|
47
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
48
|
+
const content = fs.readFileSync(CONFIG_FILE, 'utf8');
|
|
49
|
+
return JSON.parse(content);
|
|
50
|
+
}
|
|
51
|
+
} catch (err) {
|
|
52
|
+
// File doesn't exist or contains invalid JSON
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Check if the current directory is inside a git repository.
|
|
59
|
+
* Works on all platforms using `git rev-parse`.
|
|
60
|
+
*
|
|
61
|
+
* @returns {boolean} True if inside a git repository, false otherwise
|
|
62
|
+
*/
|
|
63
|
+
function isGitRepository() {
|
|
64
|
+
try {
|
|
65
|
+
execSync('git rev-parse --is-inside-work-tree', {
|
|
66
|
+
stdio: 'ignore',
|
|
67
|
+
// Use shell: true on Windows to handle command properly
|
|
68
|
+
shell: process.platform === 'win32'
|
|
69
|
+
});
|
|
70
|
+
return true;
|
|
71
|
+
} catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Set a local git configuration value.
|
|
78
|
+
* Uses `git config` without --global to set repository-level config.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} key - The git config key (e.g., "user.email")
|
|
81
|
+
* @param {string} value - The value to set
|
|
82
|
+
* @throws {Error} If the git config command fails
|
|
83
|
+
*/
|
|
84
|
+
function setGitConfig(key, value) {
|
|
85
|
+
// Quote the value to handle special characters and spaces
|
|
86
|
+
const quotedValue = `"${value.replace(/"/g, '\\"')}"`;
|
|
87
|
+
execSync(`git config ${key} ${quotedValue}`, {
|
|
88
|
+
stdio: 'inherit',
|
|
89
|
+
shell: process.platform === 'win32'
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get the current value of a local git configuration.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} key - The git config key to read
|
|
97
|
+
* @returns {string|null} The current value, or null if not set
|
|
98
|
+
*/
|
|
99
|
+
function getGitConfig(key) {
|
|
100
|
+
try {
|
|
101
|
+
const result = execSync(`git config --get ${key}`, {
|
|
102
|
+
encoding: 'utf8',
|
|
103
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
104
|
+
shell: process.platform === 'win32'
|
|
105
|
+
});
|
|
106
|
+
return result.trim();
|
|
107
|
+
} catch {
|
|
108
|
+
// Key not set or error reading
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Pure Node.js implementation for setting git public identity.
|
|
115
|
+
*
|
|
116
|
+
* This function contains the cross-platform logic that works on any platform.
|
|
117
|
+
* It reads the "public" identity from ~/.devutils and applies it to the
|
|
118
|
+
* local git repository configuration.
|
|
119
|
+
*
|
|
120
|
+
* The git commands are identical across all platforms, so all platform-specific
|
|
121
|
+
* functions delegate to this implementation.
|
|
122
|
+
*
|
|
123
|
+
* @param {string[]} args - Command line arguments (unused)
|
|
124
|
+
* @returns {Promise<void>}
|
|
125
|
+
*/
|
|
126
|
+
async function do_set_git_public_nodejs(args) {
|
|
127
|
+
// Step 1: Check if we're inside a git repository
|
|
128
|
+
if (!isGitRepository()) {
|
|
129
|
+
console.error('Error: Not inside a git repository.');
|
|
130
|
+
console.error('');
|
|
131
|
+
console.error('Please navigate to a git repository and try again.');
|
|
132
|
+
console.error('You can initialize a new repository with: git init');
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Step 2: Load the devutils configuration
|
|
137
|
+
const config = loadConfig();
|
|
138
|
+
if (!config) {
|
|
139
|
+
console.error('Error: No configuration file found at ~/.devutils');
|
|
140
|
+
console.error('');
|
|
141
|
+
console.error('Please run `dev configure` first to set up your profile,');
|
|
142
|
+
console.error('then run `dev identity add public` to create a public identity.');
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Step 3: Look for the "public" identity
|
|
147
|
+
const identities = config.identities || {};
|
|
148
|
+
const publicIdentity = identities['public'];
|
|
149
|
+
|
|
150
|
+
if (!publicIdentity) {
|
|
151
|
+
console.error('Error: No "public" identity found in ~/.devutils');
|
|
152
|
+
console.error('');
|
|
153
|
+
console.error('Available identities:', Object.keys(identities).join(', ') || '(none)');
|
|
154
|
+
console.error('');
|
|
155
|
+
console.error('To create a public identity, run:');
|
|
156
|
+
console.error(' dev identity add public --name "Your Name" --email "you@example.com"');
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Step 4: Validate the identity has required fields
|
|
161
|
+
if (!publicIdentity.name || !publicIdentity.email) {
|
|
162
|
+
console.error('Error: The "public" identity is missing required fields.');
|
|
163
|
+
console.error('');
|
|
164
|
+
console.error('Current values:');
|
|
165
|
+
console.error(` Name: ${publicIdentity.name || '(not set)'}`);
|
|
166
|
+
console.error(` Email: ${publicIdentity.email || '(not set)'}`);
|
|
167
|
+
console.error('');
|
|
168
|
+
console.error('To update the public identity, run:');
|
|
169
|
+
console.error(' dev identity add public --name "Your Name" --email "you@example.com" --force');
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Step 5: Get current values to check if update is needed (for idempotency reporting)
|
|
174
|
+
const currentName = getGitConfig('user.name');
|
|
175
|
+
const currentEmail = getGitConfig('user.email');
|
|
176
|
+
|
|
177
|
+
// Step 6: Set the git configuration values
|
|
178
|
+
try {
|
|
179
|
+
setGitConfig('user.name', publicIdentity.name);
|
|
180
|
+
setGitConfig('user.email', publicIdentity.email);
|
|
181
|
+
|
|
182
|
+
// Report what was done
|
|
183
|
+
console.log('Git identity set to public:');
|
|
184
|
+
console.log(` user.name: ${publicIdentity.name}`);
|
|
185
|
+
console.log(` user.email: ${publicIdentity.email}`);
|
|
186
|
+
|
|
187
|
+
// Note if values changed
|
|
188
|
+
if (currentName !== publicIdentity.name || currentEmail !== publicIdentity.email) {
|
|
189
|
+
if (currentName || currentEmail) {
|
|
190
|
+
console.log('');
|
|
191
|
+
console.log('Previous values:');
|
|
192
|
+
if (currentName) console.log(` user.name: ${currentName}`);
|
|
193
|
+
if (currentEmail) console.log(` user.email: ${currentEmail}`);
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
console.log('');
|
|
197
|
+
console.log('(values were already set to public identity)');
|
|
198
|
+
}
|
|
199
|
+
} catch (error) {
|
|
200
|
+
console.error('Error: Failed to set git configuration.');
|
|
201
|
+
console.error(error.message);
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Set git user to public identity on macOS.
|
|
208
|
+
*
|
|
209
|
+
* macOS uses the same git commands as other Unix-like systems.
|
|
210
|
+
* This delegates to the pure Node.js implementation.
|
|
211
|
+
*
|
|
212
|
+
* @param {string[]} args - Command line arguments (unused)
|
|
213
|
+
* @returns {Promise<void>}
|
|
214
|
+
*/
|
|
215
|
+
async function do_set_git_public_macos(args) {
|
|
216
|
+
return do_set_git_public_nodejs(args);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Set git user to public identity on Ubuntu.
|
|
221
|
+
*
|
|
222
|
+
* Ubuntu uses the same git commands as other Unix-like systems.
|
|
223
|
+
* This delegates to the pure Node.js implementation.
|
|
224
|
+
*
|
|
225
|
+
* @param {string[]} args - Command line arguments (unused)
|
|
226
|
+
* @returns {Promise<void>}
|
|
227
|
+
*/
|
|
228
|
+
async function do_set_git_public_ubuntu(args) {
|
|
229
|
+
return do_set_git_public_nodejs(args);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Set git user to public identity on Raspberry Pi OS.
|
|
234
|
+
*
|
|
235
|
+
* Raspberry Pi OS (Raspbian) uses the same git commands as other Debian-based systems.
|
|
236
|
+
* This delegates to the pure Node.js implementation.
|
|
237
|
+
*
|
|
238
|
+
* @param {string[]} args - Command line arguments (unused)
|
|
239
|
+
* @returns {Promise<void>}
|
|
240
|
+
*/
|
|
241
|
+
async function do_set_git_public_raspbian(args) {
|
|
242
|
+
return do_set_git_public_nodejs(args);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Set git user to public identity on Amazon Linux.
|
|
247
|
+
*
|
|
248
|
+
* Amazon Linux uses the same git commands as other Linux systems.
|
|
249
|
+
* This delegates to the pure Node.js implementation.
|
|
250
|
+
*
|
|
251
|
+
* @param {string[]} args - Command line arguments (unused)
|
|
252
|
+
* @returns {Promise<void>}
|
|
253
|
+
*/
|
|
254
|
+
async function do_set_git_public_amazon_linux(args) {
|
|
255
|
+
return do_set_git_public_nodejs(args);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Set git user to public identity on Windows Command Prompt.
|
|
260
|
+
*
|
|
261
|
+
* Windows uses the same git commands when git is installed.
|
|
262
|
+
* The shell: true option in execSync handles Windows-specific command execution.
|
|
263
|
+
* This delegates to the pure Node.js implementation.
|
|
264
|
+
*
|
|
265
|
+
* @param {string[]} args - Command line arguments (unused)
|
|
266
|
+
* @returns {Promise<void>}
|
|
267
|
+
*/
|
|
268
|
+
async function do_set_git_public_cmd(args) {
|
|
269
|
+
return do_set_git_public_nodejs(args);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Set git user to public identity on Windows PowerShell.
|
|
274
|
+
*
|
|
275
|
+
* PowerShell can execute git commands the same way as CMD.
|
|
276
|
+
* This delegates to the pure Node.js implementation.
|
|
277
|
+
*
|
|
278
|
+
* @param {string[]} args - Command line arguments (unused)
|
|
279
|
+
* @returns {Promise<void>}
|
|
280
|
+
*/
|
|
281
|
+
async function do_set_git_public_powershell(args) {
|
|
282
|
+
return do_set_git_public_nodejs(args);
|
|
283
|
+
}
|
|
284
|
+
|
|
8
285
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
286
|
+
* Set git user to public identity in Git Bash on Windows.
|
|
287
|
+
*
|
|
288
|
+
* Git Bash provides a Unix-like environment on Windows with git pre-installed.
|
|
289
|
+
* This delegates to the pure Node.js implementation.
|
|
11
290
|
*
|
|
12
291
|
* @param {string[]} args - Command line arguments (unused)
|
|
13
292
|
* @returns {Promise<void>}
|
|
14
293
|
*/
|
|
15
|
-
async function
|
|
16
|
-
|
|
294
|
+
async function do_set_git_public_gitbash(args) {
|
|
295
|
+
return do_set_git_public_nodejs(args);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Main entry point - detects environment and executes appropriate implementation.
|
|
300
|
+
*
|
|
301
|
+
* The "set-git-public" command configures the current git repository to use
|
|
302
|
+
* the "public" identity from the ~/.devutils configuration file. This is useful
|
|
303
|
+
* when working on open-source projects where you want to use your public
|
|
304
|
+
* email address for commits.
|
|
305
|
+
*
|
|
306
|
+
* For example, you might have:
|
|
307
|
+
* - A "work" identity with your company email
|
|
308
|
+
* - A "public" identity with your personal/public email
|
|
309
|
+
*
|
|
310
|
+
* Use `set-git-public` when cloning or starting work on public repositories.
|
|
311
|
+
*
|
|
312
|
+
* @param {string[]} args - Command line arguments (unused)
|
|
313
|
+
* @returns {Promise<void>}
|
|
314
|
+
*/
|
|
315
|
+
async function do_set_git_public(args) {
|
|
316
|
+
const platform = os.detect();
|
|
317
|
+
|
|
318
|
+
const handlers = {
|
|
319
|
+
'macos': do_set_git_public_macos,
|
|
320
|
+
'ubuntu': do_set_git_public_ubuntu,
|
|
321
|
+
'debian': do_set_git_public_ubuntu,
|
|
322
|
+
'raspbian': do_set_git_public_raspbian,
|
|
323
|
+
'amazon_linux': do_set_git_public_amazon_linux,
|
|
324
|
+
'rhel': do_set_git_public_amazon_linux,
|
|
325
|
+
'fedora': do_set_git_public_ubuntu,
|
|
326
|
+
'linux': do_set_git_public_ubuntu,
|
|
327
|
+
'wsl': do_set_git_public_ubuntu,
|
|
328
|
+
'cmd': do_set_git_public_cmd,
|
|
329
|
+
'windows': do_set_git_public_cmd,
|
|
330
|
+
'powershell': do_set_git_public_powershell,
|
|
331
|
+
'gitbash': do_set_git_public_gitbash
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
const handler = handlers[platform.type];
|
|
335
|
+
if (!handler) {
|
|
336
|
+
console.error(`Platform '${platform.type}' is not supported for this command.`);
|
|
337
|
+
console.error('');
|
|
338
|
+
console.error('Supported platforms:');
|
|
339
|
+
console.error(' - macOS');
|
|
340
|
+
console.error(' - Ubuntu, Debian, and other Linux distributions');
|
|
341
|
+
console.error(' - Raspberry Pi OS');
|
|
342
|
+
console.error(' - Amazon Linux, RHEL, Fedora');
|
|
343
|
+
console.error(' - Windows (CMD, PowerShell, Git Bash)');
|
|
344
|
+
process.exit(1);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
await handler(args);
|
|
17
348
|
}
|
|
18
349
|
|
|
19
|
-
module.exports = {
|
|
350
|
+
module.exports = {
|
|
351
|
+
main: do_set_git_public,
|
|
352
|
+
do_set_git_public,
|
|
353
|
+
do_set_git_public_nodejs,
|
|
354
|
+
do_set_git_public_macos,
|
|
355
|
+
do_set_git_public_ubuntu,
|
|
356
|
+
do_set_git_public_raspbian,
|
|
357
|
+
do_set_git_public_amazon_linux,
|
|
358
|
+
do_set_git_public_cmd,
|
|
359
|
+
do_set_git_public_powershell,
|
|
360
|
+
do_set_git_public_gitbash
|
|
361
|
+
};
|
|
20
362
|
|
|
21
363
|
if (require.main === module) {
|
|
22
|
-
|
|
364
|
+
do_set_git_public(process.argv.slice(2));
|
|
23
365
|
}
|