bananareporter 0.1.0 → 0.1.2

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 CHANGED
@@ -1,13 +1,17 @@
1
- Banana Reporter
2
- =================
3
1
 
4
- Create a report in CSV, JSON/L from multiple sources (e.g. GitLab, GitHub, todo.txt etc.)
2
+ <p align="center">
3
+ <img src="docs/assets/banana-reporter-logo.png" alt="Banana Reporter Logo" height="70px"/>
4
+ </p>
5
+ <h1 align="center">Banana Reporter</h1>
6
+ <p align="center">Create a report in CSV, JSON and JSONL from multiple sources (e.g. GitLab, GitHub, todo.txt etc.)</p>
5
7
 
6
- [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7
- [![Version](https://img.shields.io/npm/v/bananareporter.svg)](https://npmjs.org/package/bananareporter)
8
- [![CircleCI](https://circleci.com/gh/oclif/hello-world/tree/main.svg?style=shield)](https://circleci.com/gh/oclif/hello-world/tree/main)
9
- [![Downloads/week](https://img.shields.io/npm/dw/bananareporter.svg)](https://npmjs.org/package/bananareporter)
10
- [![License](https://img.shields.io/npm/l/bananareporter.svg)](https://github.com/oclif/hello-world/blob/main/package.json)
8
+ <p align="center">
9
+ <a href="https://oclif.io"><img src="https://img.shields.io/badge/cli-oclif-brightgreen.svg" alt="oclif"/></a>
10
+ <a href="https://npmjs.org/package/bananareporter"><img src="https://img.shields.io/npm/v/bananareporter.svg" alt="Version"/></a>
11
+ <a href="https://github.com/nya1/bananareporter/actions/workflows/test.yml"><img src="https://github.com/nya1/bananareporter/actions/workflows/test.yml/badge.svg" alt="Github"/></a>
12
+ <a href="https://npmjs.org/package/bananareporter"><img src="https://img.shields.io/npm/dw/bananareporter.svg" alt="Downloads/week"/></a>
13
+ <a href="https://github.com/nya1/bananareporter/blob/main/package.json"><img src="https://img.shields.io/npm/l/bananareporter.svg" alt="License"/></a>
14
+ </p>
11
15
 
12
16
  <!-- toc -->
13
17
  * [Features](#features)
@@ -21,7 +25,16 @@ Create a report in CSV, JSON/L from multiple sources (e.g. GitLab, GitHub, todo.
21
25
  - **Easy to use**: provide a `--from` and `--to` date range and a config file, all data will be fetched automatically
22
26
  - **Multiple output formats**: output file can be a JSON, JSONL or CSV (via `--format`) _more coming soon_
23
27
  - **Configurable**: data to be imported can be filtered using the configuration file and each option can be overridden per source
24
- - **Sources Supported**: GitLab, GitHub and todo.txt files, _more coming soon_
28
+ - **Sources Supported**
29
+ - GitLab: commits
30
+ - GitHub: commits
31
+ - todo.txt: tasks
32
+ - **[Request a new source](https://github.com/nya1/bananareporter/issues/new?assignees=&labels=enhancement&template=new-source-request.md&title=)**
33
+
34
+ ## Use cases
35
+
36
+ - create a PDF work report based on commits and tasks
37
+ - get insights on your activity
25
38
 
26
39
  # Quickstart
27
40
 
@@ -48,13 +61,13 @@ sources:
48
61
  # file: './todo.txt'
49
62
  ```
50
63
 
51
- 2. Run the reporter with a date range
64
+ 2. Run the reporter with a date range (ISO8601 date)
52
65
 
53
66
  ```sh
54
67
  bananareporter --from 2023-01-01 --to 2023-03-01 -c bananareporter.yaml
55
68
  ```
56
69
 
57
- In the current directory you can find the `bananareporter.json` output
70
+ In the current directory you will find the output as `bananareporter_$FROM__$TO.json`, can be changed with `--out`
58
71
 
59
72
 
60
73
  # Usage
@@ -64,7 +77,7 @@ $ npm install -g bananareporter
64
77
  $ bananareporter COMMAND
65
78
  running command...
66
79
  $ bananareporter (--version)
67
- bananareporter/0.1.0 linux-x64 node-v18.14.2
80
+ bananareporter/0.1.2 linux-x64 node-v18.14.2
68
81
  $ bananareporter --help [COMMAND]
69
82
  USAGE
70
83
  $ bananareporter COMMAND
@@ -107,7 +120,7 @@ USAGE
107
120
 
108
121
  FLAGS
109
122
  -c, --config=<value> config file location, by default ~/.config/bananareporter/config.yaml
110
- -o, --out=<value> (required) [default: ./bananareporter.json] file path to save the output
123
+ -o, --out=<value> (required) [default: ./bananareporter_$FROM__$TO.json] file path to save the output
111
124
  --delay=<value> [default: 300] global delay in millisecons between http requests
112
125
  --format=<option> (required) [default: json] output file format
113
126
  <options: json|jsonl|csv>
@@ -123,5 +136,5 @@ EXAMPLES
123
136
  report with 138 entries saved to ./bananareporter.json
124
137
  ```
125
138
 
126
- _See code: [dist/commands/run/index.ts](https://github.com/nya1/bananareporter/blob/v0.1.0/dist/commands/run/index.ts)_
139
+ _See code: [dist/commands/run/index.ts](https://github.com/nya1/bananareporter/blob/v0.1.2/dist/commands/run/index.ts)_
127
140
  <!-- commandsstop -->
@@ -96,7 +96,10 @@ class Run extends core_1.Command {
96
96
  // add file extension
97
97
  if (!outFile.endsWith(fileExt)) {
98
98
  if (outFile === Run.flags.out.default) {
99
- outFile = outFile.replace(`.${Run.flags.format.default}`, fileExt);
99
+ outFile = outFile
100
+ .replace(`.${Run.flags.format.default}`, fileExt)
101
+ .replace('$FROM', validatedConfig.from)
102
+ .replace('$TO', validatedConfig.to);
100
103
  }
101
104
  else {
102
105
  outFile += fileExt;
@@ -138,7 +141,7 @@ Run.flags = {
138
141
  aliases: ['output'],
139
142
  description: 'file path to save the output',
140
143
  required: true,
141
- default: './bananareporter.json',
144
+ default: './bananareporter_$FROM__$TO.json',
142
145
  }),
143
146
  format: core_1.Flags.string({
144
147
  description: 'output file format',
@@ -8,6 +8,7 @@ const zod_1 = require("zod");
8
8
  const axios_1 = require("axios");
9
9
  const dayjs = require("dayjs");
10
10
  const logger_1 = require("../util/logger");
11
+ const objectPath = require("object-path");
11
12
  exports.GitlabConfig = zod_1.z.object({
12
13
  committerUsername: zod_1.z.string().min(1),
13
14
  userId: zod_1.z.number().optional(),
@@ -120,7 +121,13 @@ class GitlabIntegration extends base_1.IntegrationBase {
120
121
  });
121
122
  // format data to common obj
122
123
  let filteredData = eventList
123
- .filter(e => e.action_name.startsWith('pushed'));
124
+ .filter(e => {
125
+ var _a;
126
+ return (e.action_name
127
+ .startsWith('pushed') &&
128
+ ((_a = e === null || e === void 0 ? void 0 : e.push_data) === null || _a === void 0 ? void 0 : _a.commit_title) &&
129
+ !e.push_data.commit_title.startsWith('Merge branch'));
130
+ });
124
131
  const projectsToRemove = new Set();
125
132
  for (const filter of this.config.filters || []) {
126
133
  const targetKey = filter.on;
@@ -148,12 +155,13 @@ class GitlabIntegration extends base_1.IntegrationBase {
148
155
  return true;
149
156
  }
150
157
  const regex = new RegExp(filter.regex);
151
- if (!(targetKey in e)) {
158
+ const value = objectPath.get(e, targetKey);
159
+ if (typeof value === 'undefined') {
152
160
  const errorMsg = `while filtering event id ${e.id} unable to find the key ${targetKey} in the event's object (available keys: ${Object.keys(e).join(',')})`;
153
161
  logger_1.logger.error(errorMsg);
154
162
  throw new Error(errorMsg);
155
163
  }
156
- return regex.test(e[targetKey]);
164
+ return regex.test(value);
157
165
  });
158
166
  }
159
167
  if (projectsToRemove.size > 0) {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.0",
2
+ "version": "0.1.2",
3
3
  "commands": {
4
4
  "run": {
5
5
  "id": "run",
@@ -47,7 +47,7 @@
47
47
  "description": "file path to save the output",
48
48
  "required": true,
49
49
  "multiple": false,
50
- "default": "./bananareporter.json",
50
+ "default": "./bananareporter_$FROM__$TO.json",
51
51
  "aliases": [
52
52
  "output"
53
53
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bananareporter",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Easily generate a report from multiple sources",
5
5
  "author": "nya1",
6
6
  "bin": {