gh-setup-git-identity 0.4.1 → 0.5.0
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/CHANGELOG.md +23 -0
- package/README.md +45 -8
- package/package.json +1 -1
- package/src/cli.js +78 -6
- package/src/index.js +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# gh-setup-git-identity
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 071e6d3: feat: add --verify option to verify git identity configuration
|
|
8
|
+
|
|
9
|
+
- Added `--verify` CLI option to run all 3 verification commands at once
|
|
10
|
+
- Users can now use `gh-setup-git-identity --verify` instead of running individual commands
|
|
11
|
+
- Works with `--local` flag for local repository configuration
|
|
12
|
+
- Updated README with verification documentation and code blocks
|
|
13
|
+
|
|
14
|
+
## 0.4.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 72d4185: Improve output formatting with better organization and verification commands
|
|
19
|
+
|
|
20
|
+
- Added blank lines between major sections for better visual grouping
|
|
21
|
+
- Applied consistent indentation (2 spaces) to detail lines under section headers
|
|
22
|
+
- Added helpful verification commands suggestion at the end of output
|
|
23
|
+
- Updated README.md to reflect the new output format
|
|
24
|
+
- Makes output more readable and professional while providing actionable next steps
|
|
25
|
+
|
|
3
26
|
## 0.4.1
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -74,6 +74,9 @@ gh-setup-git-identity --local
|
|
|
74
74
|
# Preview what would be configured (dry run)
|
|
75
75
|
gh-setup-git-identity --dry-run
|
|
76
76
|
|
|
77
|
+
# Verify current git identity configuration
|
|
78
|
+
gh-setup-git-identity --verify
|
|
79
|
+
|
|
77
80
|
# Enable verbose output
|
|
78
81
|
gh-setup-git-identity --verbose
|
|
79
82
|
```
|
|
@@ -87,6 +90,7 @@ Options:
|
|
|
87
90
|
--global, -g Set git config globally (default: true)
|
|
88
91
|
--local, -l Set git config locally (in current repository)
|
|
89
92
|
--dry-run, --dry Dry run - show what would be done without making changes
|
|
93
|
+
--verify Verify current git identity configuration
|
|
90
94
|
--verbose, -v Enable verbose output
|
|
91
95
|
--help, -h Show help
|
|
92
96
|
--version Show version number
|
|
@@ -117,20 +121,53 @@ printf "y" | gh auth login -h github.com -s repo,workflow,user,read:org,gist --g
|
|
|
117
121
|
|
|
118
122
|
```
|
|
119
123
|
Fetching GitHub user information...
|
|
120
|
-
GitHub user: your-username
|
|
121
|
-
GitHub email: your-email@example.com
|
|
124
|
+
GitHub user: your-username
|
|
125
|
+
GitHub email: your-email@example.com
|
|
122
126
|
|
|
123
127
|
Configuring git (global)...
|
|
124
|
-
Git identity configured successfully!
|
|
128
|
+
Git identity configured successfully!
|
|
125
129
|
|
|
126
|
-
Git configured:
|
|
130
|
+
Git configured:
|
|
131
|
+
user.name: your-username
|
|
132
|
+
user.email: your-email@example.com
|
|
133
|
+
Scope: global (--global)
|
|
127
134
|
|
|
128
|
-
|
|
129
|
-
user.email: your-email@example.com
|
|
135
|
+
Git identity setup complete!
|
|
130
136
|
|
|
131
|
-
|
|
137
|
+
You can verify your configuration with:
|
|
138
|
+
gh auth status
|
|
139
|
+
git config --global user.name
|
|
140
|
+
git config --global user.email
|
|
141
|
+
```
|
|
132
142
|
|
|
133
|
-
|
|
143
|
+
### Verifying Configuration
|
|
144
|
+
|
|
145
|
+
You can verify your git identity configuration at any time using:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
gh-setup-git-identity --verify
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Or by running the three verification commands directly:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
gh auth status
|
|
155
|
+
git config --global user.name
|
|
156
|
+
git config --global user.email
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
For local repository configuration, use `--local`:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
gh-setup-git-identity --verify --local
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Or:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
gh auth status
|
|
169
|
+
git config --local user.name
|
|
170
|
+
git config --local user.email
|
|
134
171
|
```
|
|
135
172
|
|
|
136
173
|
## Library Usage
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { makeConfig } from 'lino-arguments';
|
|
10
|
-
import { setupGitIdentity, isGhAuthenticated, runGhAuthLogin } from './index.js';
|
|
10
|
+
import { setupGitIdentity, isGhAuthenticated, runGhAuthLogin, verifyGitIdentity } from './index.js';
|
|
11
11
|
|
|
12
12
|
// Parse command-line arguments with environment variable and .lenv support
|
|
13
13
|
const config = makeConfig({
|
|
@@ -38,6 +38,11 @@ const config = makeConfig({
|
|
|
38
38
|
description: 'Dry run mode - show what would be done without making changes',
|
|
39
39
|
default: getenv('GH_SETUP_GIT_IDENTITY_DRY_RUN', false)
|
|
40
40
|
})
|
|
41
|
+
.option('verify', {
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
description: 'Verify current git identity configuration',
|
|
44
|
+
default: false
|
|
45
|
+
})
|
|
41
46
|
.check((argv) => {
|
|
42
47
|
// --global and --local are mutually exclusive
|
|
43
48
|
if (argv.global && argv.local) {
|
|
@@ -48,12 +53,68 @@ const config = makeConfig({
|
|
|
48
53
|
.example('$0', 'Setup git identity globally using GitHub user')
|
|
49
54
|
.example('$0 --local', 'Setup git identity for current repository only')
|
|
50
55
|
.example('$0 --dry-run', 'Show what would be configured without making changes')
|
|
56
|
+
.example('$0 --verify', 'Verify current git identity configuration')
|
|
51
57
|
.help('h')
|
|
52
58
|
.alias('h', 'help')
|
|
53
59
|
.version('0.1.0')
|
|
54
60
|
.strict(),
|
|
55
61
|
});
|
|
56
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Run verification commands and display results
|
|
65
|
+
* @param {string} scope - 'global' or 'local'
|
|
66
|
+
* @param {boolean} verbose - Enable verbose logging
|
|
67
|
+
*/
|
|
68
|
+
async function runVerify(scope, verbose) {
|
|
69
|
+
const scopeFlag = scope === 'local' ? '--local' : '--global';
|
|
70
|
+
|
|
71
|
+
console.log('Verifying git identity configuration...');
|
|
72
|
+
console.log('');
|
|
73
|
+
|
|
74
|
+
// 1. Run gh auth status
|
|
75
|
+
console.log('1. GitHub CLI authentication status:');
|
|
76
|
+
console.log(' $ gh auth status');
|
|
77
|
+
console.log('');
|
|
78
|
+
|
|
79
|
+
const { spawn } = await import('node:child_process');
|
|
80
|
+
|
|
81
|
+
// Run gh auth status interactively to show full output
|
|
82
|
+
await new Promise((resolve) => {
|
|
83
|
+
const child = spawn('gh', ['auth', 'status'], { stdio: 'inherit' });
|
|
84
|
+
child.on('close', resolve);
|
|
85
|
+
child.on('error', resolve);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
console.log('');
|
|
89
|
+
|
|
90
|
+
// 2. Get git config user.name
|
|
91
|
+
console.log(`2. Git user.name (${scope}):`);
|
|
92
|
+
console.log(` $ git config ${scopeFlag} user.name`);
|
|
93
|
+
|
|
94
|
+
const identity = await verifyGitIdentity({ scope, verbose });
|
|
95
|
+
|
|
96
|
+
if (identity.username) {
|
|
97
|
+
console.log(` ${identity.username}`);
|
|
98
|
+
} else {
|
|
99
|
+
console.log(' (not set)');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
console.log('');
|
|
103
|
+
|
|
104
|
+
// 3. Get git config user.email
|
|
105
|
+
console.log(`3. Git user.email (${scope}):`);
|
|
106
|
+
console.log(` $ git config ${scopeFlag} user.email`);
|
|
107
|
+
|
|
108
|
+
if (identity.email) {
|
|
109
|
+
console.log(` ${identity.email}`);
|
|
110
|
+
} else {
|
|
111
|
+
console.log(' (not set)');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
console.log('');
|
|
115
|
+
console.log('Verification complete!');
|
|
116
|
+
}
|
|
117
|
+
|
|
57
118
|
/**
|
|
58
119
|
* Main CLI function
|
|
59
120
|
*/
|
|
@@ -62,6 +123,12 @@ async function main() {
|
|
|
62
123
|
// Determine scope
|
|
63
124
|
const scope = config.local ? 'local' : 'global';
|
|
64
125
|
|
|
126
|
+
// Handle --verify mode
|
|
127
|
+
if (config.verify) {
|
|
128
|
+
await runVerify(scope, config.verbose);
|
|
129
|
+
process.exit(0);
|
|
130
|
+
}
|
|
131
|
+
|
|
65
132
|
// Check if gh is authenticated
|
|
66
133
|
const authenticated = await isGhAuthenticated({ verbose: config.verbose });
|
|
67
134
|
|
|
@@ -100,14 +167,19 @@ async function main() {
|
|
|
100
167
|
|
|
101
168
|
// Display results
|
|
102
169
|
console.log('');
|
|
103
|
-
console.log(
|
|
104
|
-
console.log(`
|
|
105
|
-
console.log(`
|
|
106
|
-
console.log(`Scope: ${scope === 'global' ? 'global (--global)' : 'local (--local)'}`);
|
|
107
|
-
console.log('');
|
|
170
|
+
console.log(` ${options.dryRun ? '[DRY MODE] Would configure' : 'Git configured'}:`);
|
|
171
|
+
console.log(` user.name: ${result.username}`);
|
|
172
|
+
console.log(` user.email: ${result.email}`);
|
|
173
|
+
console.log(` Scope: ${scope === 'global' ? 'global (--global)' : 'local (--local)'}`);
|
|
108
174
|
|
|
109
175
|
if (!options.dryRun) {
|
|
176
|
+
console.log('');
|
|
110
177
|
console.log('Git identity setup complete!');
|
|
178
|
+
console.log('');
|
|
179
|
+
console.log('You can verify your configuration with:');
|
|
180
|
+
console.log(' gh auth status');
|
|
181
|
+
console.log(` git config ${scope === 'global' ? '--global' : '--local'} user.name`);
|
|
182
|
+
console.log(` git config ${scope === 'global' ? '--global' : '--local'} user.email`);
|
|
111
183
|
}
|
|
112
184
|
|
|
113
185
|
process.exit(0);
|
package/src/index.js
CHANGED
|
@@ -141,7 +141,7 @@ export async function runGhAuthLogin(options = {}) {
|
|
|
141
141
|
return false;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
log(() => '
|
|
144
|
+
log(() => '\nGitHub CLI authentication successful!');
|
|
145
145
|
return true;
|
|
146
146
|
}
|
|
147
147
|
|
|
@@ -323,13 +323,13 @@ export async function setupGitIdentity(options = {}) {
|
|
|
323
323
|
|
|
324
324
|
const log = createDefaultLogger({ verbose, logger });
|
|
325
325
|
|
|
326
|
-
log(() => '
|
|
326
|
+
log(() => '\nFetching GitHub user information...');
|
|
327
327
|
|
|
328
328
|
// Get GitHub user info
|
|
329
329
|
const { username, email } = await getGitHubUserInfo({ verbose, logger });
|
|
330
330
|
|
|
331
|
-
log(() => `GitHub user: ${username}`);
|
|
332
|
-
log(() => `GitHub email: ${email}`);
|
|
331
|
+
log(() => ` GitHub user: ${username}`);
|
|
332
|
+
log(() => ` GitHub email: ${email}`);
|
|
333
333
|
|
|
334
334
|
if (dryRun) {
|
|
335
335
|
log(() => 'DRY MODE: Would configure the following:');
|
|
@@ -339,12 +339,12 @@ export async function setupGitIdentity(options = {}) {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
// Set git config
|
|
342
|
-
log(() =>
|
|
342
|
+
log(() => `\nConfiguring git (${scope})...`);
|
|
343
343
|
|
|
344
344
|
await setGitConfig('user.name', username, { scope, verbose, logger });
|
|
345
345
|
await setGitConfig('user.email', email, { scope, verbose, logger });
|
|
346
346
|
|
|
347
|
-
log(() => 'Git identity configured successfully!');
|
|
347
|
+
log(() => ' Git identity configured successfully!');
|
|
348
348
|
|
|
349
349
|
return { username, email };
|
|
350
350
|
}
|