Skip to content

Commit c38945d

Browse files
committed
Update README.md for improved clarity and add usage examples; bump version to 2.4.0 in package.json; export additional types in index.ts
1 parent b80b1d7 commit c38945d

3 files changed

Lines changed: 79 additions & 13 deletions

File tree

README.md

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,91 @@
1-
# Github Usage Report Library
1+
# GitHub Usage Report Library
22

3-
A simple library to parse a Github usage report.
3+
A TypeScript library to read and process GitHub usage data from CSV files.
44

5-
See [Viewing your GitHub Actions usage](https://docs.github.com/en/billing/managing-billing-for-github-actions/viewing-your-github-actions-usage) for instructions on how to generate a Github usage report.
5+
## Features
66

7-
## 🔨 Build
7+
- Parse GitHub Actions usage reports from CSV files
8+
- Support for both streaming (async) and direct (sync) file reading
9+
- TypeScript support with full type definitions
10+
- Optional line-by-line processing callbacks
11+
12+
## Installation
13+
14+
```bash
15+
npm install
816
```
9-
npm run build
17+
18+
## Usage
19+
20+
### Reading a Usage Report (Async)
21+
22+
```typescript
23+
import { readGithubUsageReportFile } from './src/index';
24+
25+
// Basic usage
26+
const report = await readGithubUsageReportFile('path/to/usage-report.csv');
27+
console.log(`Report covers ${report.days} days from ${report.startDate} to ${report.endDate}`);
28+
29+
// With line-by-line callback
30+
const report = await readGithubUsageReportFile('path/to/usage-report.csv', (line) => {
31+
console.log(`Processing: ${line.date} - ${line.product}`);
32+
});
1033
```
1134

12-
## 🧪 Test
35+
### Reading a Usage Report (Sync)
36+
37+
```typescript
38+
import { readGithubUsageReportFileSync } from './src/index';
39+
40+
const report = await readGithubUsageReportFileSync('path/to/usage-report.csv');
41+
console.log(`Total lines: ${report.lines.length}`);
1342
```
14-
npm test
43+
44+
### Report Structure
45+
46+
The library returns a `UsageReport` object with the following structure:
47+
48+
```typescript
49+
{
50+
startDate: Date, // First date in the report
51+
endDate: Date, // Last date in the report
52+
days: number, // Number of days covered
53+
lines: UsageReportLine[] // Array of parsed usage data
54+
}
1555
```
1656

17-
## 🏃 Run
57+
## Getting Your GitHub Usage Report
58+
59+
To generate a GitHub usage report:
60+
61+
1. Go to your GitHub organization or personal account settings
62+
2. Navigate to "Billing and plans" → "Actions"
63+
3. Click "Usage" and export your data as CSV
64+
65+
See [Viewing your GitHub Actions usage](https://docs.github.com/en/billing/managing-billing-for-github-actions/viewing-your-github-actions-usage) for detailed instructions.
66+
67+
## Development
68+
69+
### 🔨 Build
70+
```bash
71+
npm run build
1872
```
73+
74+
### 🧪 Test
75+
```bash
76+
npm test
77+
```
78+
79+
### 🏃 Run
80+
```bash
1981
npm start
2082
```
2183

22-
## 🧹 Lint
84+
### 🧹 Lint
85+
```bash
86+
npm run lint
2387
```
24-
npm lint
25-
```
88+
89+
## License
90+
91+
This project is open source.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-usage-report",
3-
"version": "2.0.0",
3+
"version": "2.4.0",
44
"description": "Parse github usage report",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ const readGithubUsageReportFile = async (fileName: string, newLine?: (line?: Usa
4848
});
4949
}
5050

51-
export { readGithubUsageReportFile, readGithubUsageReportFileSync };
51+
export { readGithubUsageReportFile, readGithubUsageReportFileSync, readGithubUsageReport, UsageReport, UsageReportLine };

0 commit comments

Comments
 (0)