gstatx 0.1.2 → 0.1.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 +129 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
📊 Export statistics from git repositories
|
|
4
4
|
|
|
5
|
-
A CLI tool to analyze and export statistics from one or multiple git repositories.
|
|
5
|
+
A CLI tool and library to analyze and export statistics from one or multiple git repositories.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -10,10 +10,10 @@ A CLI tool to analyze and export statistics from one or multiple git repositorie
|
|
|
10
10
|
npm install -g gstatx
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Or
|
|
13
|
+
Or install as a library:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm install
|
|
16
|
+
npm install gstatx
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Quick Start
|
|
@@ -27,6 +27,12 @@ gstatx contributors ./repo1 ./repo2 ./repo3
|
|
|
27
27
|
|
|
28
28
|
# Hide commit counts
|
|
29
29
|
gstatx contributors --no-commits ./my-repo
|
|
30
|
+
|
|
31
|
+
# Generate commit history report
|
|
32
|
+
gstatx hist ./my-repo
|
|
33
|
+
|
|
34
|
+
# Generate history report for last month and save to file
|
|
35
|
+
gstatx hist --since "1 month ago" --out report.json ./my-repo
|
|
30
36
|
```
|
|
31
37
|
|
|
32
38
|
## User Guide
|
|
@@ -39,7 +45,7 @@ List contributors for specified git repositories.
|
|
|
39
45
|
|
|
40
46
|
**Usage:**
|
|
41
47
|
```bash
|
|
42
|
-
gstatx contributors [options]
|
|
48
|
+
gstatx contributors [options] [repo-paths...]
|
|
43
49
|
```
|
|
44
50
|
|
|
45
51
|
**Options:**
|
|
@@ -56,8 +62,49 @@ gstatx contributors --no-commits ./my-repo
|
|
|
56
62
|
|
|
57
63
|
# List contributors for multiple repositories
|
|
58
64
|
gstatx contributors ./repo1 ./repo2 ./repo3
|
|
65
|
+
|
|
66
|
+
# Use repositories from config file
|
|
67
|
+
gstatx contributors
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### `hist`
|
|
71
|
+
|
|
72
|
+
Generate commit history report with detailed statistics.
|
|
73
|
+
|
|
74
|
+
**Usage:**
|
|
75
|
+
```bash
|
|
76
|
+
gstatx hist [options] [repo-paths...]
|
|
59
77
|
```
|
|
60
78
|
|
|
79
|
+
**Options:**
|
|
80
|
+
- `-s, --since <date>` - Start date for the report (e.g., "2024-01-01", "1 month ago")
|
|
81
|
+
- `-u, --until <date>` - End date for the report (e.g., "2024-12-31", "now")
|
|
82
|
+
- `-o, --out <file>` - Output file path (defaults to stdout)
|
|
83
|
+
- `--help, -h` - Show help message
|
|
84
|
+
|
|
85
|
+
**Examples:**
|
|
86
|
+
```bash
|
|
87
|
+
# Generate history for a repository
|
|
88
|
+
gstatx hist ./my-repo
|
|
89
|
+
|
|
90
|
+
# Generate history for last month
|
|
91
|
+
gstatx hist --since "1 month ago" ./my-repo
|
|
92
|
+
|
|
93
|
+
# Generate history for specific period
|
|
94
|
+
gstatx hist --since "2024-01-01" --until "2024-12-31" ./my-repo
|
|
95
|
+
|
|
96
|
+
# Save to file
|
|
97
|
+
gstatx hist --since "1 month ago" --out report.json ./my-repo
|
|
98
|
+
|
|
99
|
+
# Use repositories from config file
|
|
100
|
+
gstatx hist --since "1 month ago" --out report.json
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The report includes:
|
|
104
|
+
- Commit details (hash, author, date, message)
|
|
105
|
+
- File-level statistics (files changed, insertions, deletions)
|
|
106
|
+
- Summary statistics per repository
|
|
107
|
+
|
|
61
108
|
### Configuration File
|
|
62
109
|
|
|
63
110
|
You can create a `.gstatxrc.json` file to set default options and repository paths. The config file is automatically searched in the current directory and parent directories.
|
|
@@ -85,7 +132,6 @@ You can create a `.gstatxrc.json` file to set default options and repository pat
|
|
|
85
132
|
```
|
|
86
133
|
|
|
87
134
|
**Configuration Fields:**
|
|
88
|
-
|
|
89
135
|
- `contributors.no-commits` (boolean, optional): Hide commit counts by default
|
|
90
136
|
- `cloneIfNotExists` (boolean, optional): Automatically clone repositories that don't exist locally
|
|
91
137
|
- `repositories` (array, optional): List of repositories to process
|
|
@@ -97,6 +143,7 @@ You can create a `.gstatxrc.json` file to set default options and repository pat
|
|
|
97
143
|
- Repository paths in the config file are resolved relative to the `.gstatxrc.json` file location, not the current working directory
|
|
98
144
|
- If `cloneIfNotExists: true` and a repository doesn't exist, it will be cloned from the `url`
|
|
99
145
|
- CLI arguments always override config file values
|
|
146
|
+
- Both `contributors` and `hist` commands can use repositories from the config file
|
|
100
147
|
|
|
101
148
|
**Example Config File:**
|
|
102
149
|
|
|
@@ -125,6 +172,7 @@ You can create a `.gstatxrc.json` file to set default options and repository pat
|
|
|
125
172
|
|
|
126
173
|
- `--help, -h` - Show help message
|
|
127
174
|
- `--config, -c <path>` - Specify custom config file path
|
|
175
|
+
- `--version, -V` - Show version number
|
|
128
176
|
|
|
129
177
|
**Examples:**
|
|
130
178
|
```bash
|
|
@@ -133,6 +181,9 @@ gstatx --config ./custom-config.json contributors
|
|
|
133
181
|
|
|
134
182
|
# Short form
|
|
135
183
|
gstatx -c ./custom-config.json contributors
|
|
184
|
+
|
|
185
|
+
# Show version
|
|
186
|
+
gstatx --version
|
|
136
187
|
```
|
|
137
188
|
|
|
138
189
|
### Using Config File Repositories
|
|
@@ -142,6 +193,9 @@ If you have repositories defined in your config file, you can run commands witho
|
|
|
142
193
|
```bash
|
|
143
194
|
# Uses repositories from .gstatxrc.json
|
|
144
195
|
gstatx contributors
|
|
196
|
+
|
|
197
|
+
# Generate history for all config repositories
|
|
198
|
+
gstatx hist --since "1 month ago" --out report.json
|
|
145
199
|
```
|
|
146
200
|
|
|
147
201
|
The tool will automatically use the repositories listed in your config file.
|
|
@@ -171,6 +225,76 @@ When `cloneIfNotExists: true` is set in your config:
|
|
|
171
225
|
|
|
172
226
|
Running `gstatx contributors` will automatically clone the repository if it doesn't exist.
|
|
173
227
|
|
|
228
|
+
## Library Usage
|
|
229
|
+
|
|
230
|
+
gstatx can also be used as a library in your TypeScript/JavaScript projects.
|
|
231
|
+
|
|
232
|
+
### Installation
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
npm install gstatx
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Basic Usage
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
import { Client } from "gstatx";
|
|
242
|
+
|
|
243
|
+
const client = new Client({
|
|
244
|
+
cloneIfNotExists: true,
|
|
245
|
+
repositories: [
|
|
246
|
+
{
|
|
247
|
+
path: "/path/to/repository",
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
contributors: {
|
|
251
|
+
"no-commits": false
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// List contributors
|
|
256
|
+
const contributors = await client.listContributors();
|
|
257
|
+
// Returns: Array<{ path: string; contributors: RepoContributor[] }>
|
|
258
|
+
|
|
259
|
+
// Get commit history
|
|
260
|
+
const history = await client.getHistory(
|
|
261
|
+
undefined, // use config repositories
|
|
262
|
+
"1 month ago", // since
|
|
263
|
+
"now" // until
|
|
264
|
+
);
|
|
265
|
+
// Returns: Array<{ path: string; commits: Commit[] }>
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Available Exports
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
import {
|
|
272
|
+
Client,
|
|
273
|
+
getContributors,
|
|
274
|
+
getCommits,
|
|
275
|
+
isGitRepo,
|
|
276
|
+
ensureRepository,
|
|
277
|
+
loadConfig,
|
|
278
|
+
type RepoContributor,
|
|
279
|
+
type Commit,
|
|
280
|
+
type GstatxConfig,
|
|
281
|
+
type RepositoryConfig,
|
|
282
|
+
} from "gstatx";
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Client Options
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
interface ClientOptions {
|
|
289
|
+
cloneIfNotExists?: boolean;
|
|
290
|
+
repositories?: RepositoryConfig[];
|
|
291
|
+
configPath?: string;
|
|
292
|
+
contributors?: {
|
|
293
|
+
"no-commits"?: boolean;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
174
298
|
## Development
|
|
175
299
|
|
|
176
300
|
### Prerequisites
|