gh-setup-git-identity 0.4.2 → 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 +11 -0
- package/README.md +34 -0
- package/package.json +1 -1
- package/src/cli.js +68 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
|
|
3
14
|
## 0.4.2
|
|
4
15
|
|
|
5
16
|
### 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
|
|
@@ -136,6 +140,36 @@ You can verify your configuration with:
|
|
|
136
140
|
git config --global user.email
|
|
137
141
|
```
|
|
138
142
|
|
|
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
|
|
171
|
+
```
|
|
172
|
+
|
|
139
173
|
## Library Usage
|
|
140
174
|
|
|
141
175
|
### Basic Example
|
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
|
|