bananareporter 0.2.1 → 0.3.1
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 +7 -5
- package/dist/commands/run/index.js +24 -4
- package/dist/integrations/base.d.ts +6 -1
- package/dist/integrations/github.js +1 -0
- package/dist/integrations/gitlab.js +3 -2
- package/dist/integrations/todotxt.d.ts +1 -1
- package/dist/integrations/todotxt.js +3 -2
- package/oclif.manifest.json +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
<a href="https://oclif.io"><img src="https://img.shields.io/badge/cli-oclif-brightgreen.svg" alt="oclif"/></a>
|
10
10
|
<a href="https://npmjs.org/package/bananareporter"><img src="https://img.shields.io/npm/v/bananareporter.svg" alt="Version"/></a>
|
11
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/
|
12
|
+
<a href="https://npmjs.org/package/bananareporter"><img src="https://img.shields.io/npm/dt/bananareporter.svg" alt="Total Downloads"/></a>
|
13
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
14
|
</p>
|
15
15
|
|
@@ -74,6 +74,7 @@ Example of output (json) with gitlab and github sources:
|
|
74
74
|
```json
|
75
75
|
[
|
76
76
|
{
|
77
|
+
"id": "c12ba180bfecf45fcdcc40d6104d1f1b7ad409dc",
|
77
78
|
"date": "2023-01-13T07:51:21.730Z",
|
78
79
|
"username": "johndoe",
|
79
80
|
"description": "chore: update changelog and swagger branch:work git:aa33b04",
|
@@ -82,8 +83,9 @@ Example of output (json) with gitlab and github sources:
|
|
82
83
|
"type": "gitlab"
|
83
84
|
},
|
84
85
|
{
|
86
|
+
"id": "6e1b66a1dea89e957d8c44943f942be4874c0641",
|
85
87
|
"date": "2023-01-14T10:50:10.230Z",
|
86
|
-
"username": "
|
88
|
+
"username": "johndoe",
|
87
89
|
"description": "refactor: compare date function branch:work git:ia1f241",
|
88
90
|
"projectId": "928544",
|
89
91
|
"projectName": "awesome-backend",
|
@@ -100,7 +102,7 @@ $ npm install -g bananareporter
|
|
100
102
|
$ bananareporter COMMAND
|
101
103
|
running command...
|
102
104
|
$ bananareporter (--version)
|
103
|
-
bananareporter/0.
|
105
|
+
bananareporter/0.3.1 linux-x64 node-v18.15.0
|
104
106
|
$ bananareporter --help [COMMAND]
|
105
107
|
USAGE
|
106
108
|
$ bananareporter COMMAND
|
@@ -143,7 +145,7 @@ USAGE
|
|
143
145
|
|
144
146
|
FLAGS
|
145
147
|
-c, --config=<value> config file location, by default ~/.config/bananareporter/config.yaml
|
146
|
-
-o, --out=<value> (required) [default: ./bananareporter_$FROM__$TO.json] file path to save the output
|
148
|
+
-o, --out=<value> (required) [default: ./bananareporter_$FROM__$TO.json] file path or directory to save the output
|
147
149
|
--delay=<value> [default: 300] global delay in millisecons between http requests
|
148
150
|
--format=<option> (required) [default: json] output file format
|
149
151
|
<options: json|jsonl|csv>
|
@@ -159,5 +161,5 @@ EXAMPLES
|
|
159
161
|
report with 138 entries saved to ./bananareporter.json
|
160
162
|
```
|
161
163
|
|
162
|
-
_See code: [dist/commands/run/index.ts](https://github.com/nya1/bananareporter/blob/v0.
|
164
|
+
_See code: [dist/commands/run/index.ts](https://github.com/nya1/bananareporter/blob/v0.3.1/dist/commands/run/index.ts)_
|
163
165
|
<!-- commandsstop -->
|
@@ -14,6 +14,7 @@ const logger_1 = require("../../util/logger");
|
|
14
14
|
const github_1 = require("../../integrations/github");
|
15
15
|
const todotxt_1 = require("../../integrations/todotxt");
|
16
16
|
const zod_1 = require("zod");
|
17
|
+
const node_path_1 = require("node:path");
|
17
18
|
class Run extends core_1.Command {
|
18
19
|
static dateStringValidation(input) {
|
19
20
|
if (!dayjs(input).isValid()) {
|
@@ -69,6 +70,8 @@ class Run extends core_1.Command {
|
|
69
70
|
// eslint-disable-next-line unicorn/prefer-spread
|
70
71
|
reportList = reportList.concat(res);
|
71
72
|
}
|
73
|
+
// remove any duplicates (based on "id")
|
74
|
+
reportList = [...new Map(reportList.map(v => [v.id, v])).values()];
|
72
75
|
if (reportList.length === 0) {
|
73
76
|
this.warn('no entries found, make sure the date range provided and the sources are correct');
|
74
77
|
return;
|
@@ -98,18 +101,35 @@ class Run extends core_1.Command {
|
|
98
101
|
}
|
99
102
|
const fileExt = `.${validatedConfig.format}`;
|
100
103
|
let outFile = validatedConfig.out;
|
104
|
+
logger_1.logger.debug(`Run.flags.out.default ${Run.flags.out.default}`);
|
105
|
+
logger_1.logger.debug(`fileExt ${fileExt}`);
|
106
|
+
logger_1.logger.debug(`outFile ${outFile}`);
|
107
|
+
// if --out was provided and it's a directory
|
108
|
+
// use the default file name
|
109
|
+
try {
|
110
|
+
if ((0, node_fs_1.statSync)(outFile).isDirectory()) {
|
111
|
+
outFile = (0, node_path_1.resolve)(outFile, Run.flags.out.default);
|
112
|
+
logger_1.logger.debug(`outFile is a directory, updated to ${outFile}`);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
catch (error) {
|
116
|
+
logger_1.logger.debug('statSync error', error);
|
117
|
+
}
|
101
118
|
// add file extension
|
102
119
|
if (!outFile.endsWith(fileExt)) {
|
103
120
|
if (outFile === Run.flags.out.default) {
|
104
121
|
outFile = outFile
|
105
|
-
.replace(`.${Run.flags.format.default}`, fileExt)
|
106
|
-
.replace('$FROM', validatedConfig.from)
|
107
|
-
.replace('$TO', validatedConfig.to);
|
122
|
+
.replace(`.${Run.flags.format.default}`, fileExt);
|
108
123
|
}
|
109
124
|
else {
|
110
125
|
outFile += fileExt;
|
111
126
|
}
|
112
127
|
}
|
128
|
+
if (outFile.includes('$FROM') || outFile.includes('$TO')) {
|
129
|
+
outFile = outFile
|
130
|
+
.replace('$FROM', validatedConfig.from)
|
131
|
+
.replace('$TO', validatedConfig.to);
|
132
|
+
}
|
113
133
|
logger_1.logger.debug(`run saving to ${outFile} with file content of size ${outputStr.length}`);
|
114
134
|
(0, node_fs_1.writeFileSync)(outFile, outputStr);
|
115
135
|
this.log(`report with ${reportList.length} entries saved to ${outFile}`);
|
@@ -151,7 +171,7 @@ Run.flags = {
|
|
151
171
|
out: core_1.Flags.file({
|
152
172
|
char: 'o',
|
153
173
|
aliases: ['output'],
|
154
|
-
description: 'file path to save the output',
|
174
|
+
description: 'file path or directory to save the output',
|
155
175
|
required: true,
|
156
176
|
default: './bananareporter_$FROM__$TO.json',
|
157
177
|
}),
|
@@ -3,13 +3,18 @@ import { BananaConfig } from '../core';
|
|
3
3
|
export declare const SourceType: z.ZodEnum<["gitlab", "github", "todo.txt"]>;
|
4
4
|
export type SourceType = z.infer<typeof SourceType>;
|
5
5
|
export interface CommonBananaReporterObj {
|
6
|
+
id: string;
|
6
7
|
date: string;
|
7
8
|
description: string;
|
8
9
|
username?: string;
|
9
10
|
projectId?: string;
|
10
11
|
projectName?: string;
|
11
12
|
type: SourceType;
|
12
|
-
|
13
|
+
/**
|
14
|
+
* the raw source object,
|
15
|
+
* included only when --include-raw-object is provided
|
16
|
+
*/
|
17
|
+
__raw?: any;
|
13
18
|
}
|
14
19
|
export declare abstract class IntegrationBase {
|
15
20
|
static type: SourceType;
|
@@ -126,6 +126,7 @@ class GithubIntegration extends base_1.IntegrationBase {
|
|
126
126
|
const projectName = rawData.repository.name;
|
127
127
|
const description = `${rawData.commit.message} git:${rawData.sha.slice(0, 7)}`;
|
128
128
|
return {
|
129
|
+
id: rawData.sha,
|
129
130
|
date: rawData.commit.committer.date,
|
130
131
|
username: rawData.commit.committer.name,
|
131
132
|
description,
|
@@ -101,11 +101,11 @@ class GitlabIntegration extends base_1.IntegrationBase {
|
|
101
101
|
logger_1.logger.debug('gitlab integration no more events to process');
|
102
102
|
break;
|
103
103
|
}
|
104
|
+
// eslint-disable-next-line unicorn/prefer-spread
|
105
|
+
eventList = eventList.concat(events);
|
104
106
|
for (const e of events) {
|
105
107
|
projectIds.add(e.project_id);
|
106
108
|
}
|
107
|
-
// eslint-disable-next-line unicorn/prefer-spread
|
108
|
-
eventList = eventList.concat(events);
|
109
109
|
logger_1.logger.debug(`gitlab integration eventList ${eventList.length} (added ${events.length} events)`);
|
110
110
|
page += 1;
|
111
111
|
await (0, common_1.delay)(this.delayToUse);
|
@@ -240,6 +240,7 @@ class GitlabIntegration extends base_1.IntegrationBase {
|
|
240
240
|
const projectName = projectDetails === null || projectDetails === void 0 ? void 0 : projectDetails.path;
|
241
241
|
const description = `${rawData.push_data.commit_title} branch:${rawData.push_data.ref} git:${rawData.push_data.commit_to.slice(0, 7)}`;
|
242
242
|
return {
|
243
|
+
id: `${String(rawData.push_data.commit_to)}`,
|
243
244
|
date: rawData.created_at,
|
244
245
|
username: rawData.author_username,
|
245
246
|
description,
|
@@ -47,5 +47,5 @@ export declare class TodoTxtIntegration extends IntegrationBase {
|
|
47
47
|
private bananaReporterConfig;
|
48
48
|
constructor(_rawConfig: unknown, bananaReporterConfig: BananaConfig);
|
49
49
|
fetchData(): Promise<CommonBananaReporterObj[]>;
|
50
|
-
toBananaReporterObj(rawData: Task): CommonBananaReporterObj;
|
50
|
+
toBananaReporterObj(rawData: Task, index?: number): CommonBananaReporterObj;
|
51
51
|
}
|
@@ -73,14 +73,15 @@ class TodoTxtIntegration extends base_1.IntegrationBase {
|
|
73
73
|
return regex.test(value);
|
74
74
|
});
|
75
75
|
}
|
76
|
-
const formattedData = filteredTasks.map(e => this.toBananaReporterObj(e));
|
76
|
+
const formattedData = filteredTasks.map((e, i) => this.toBananaReporterObj(e, i));
|
77
77
|
return formattedData;
|
78
78
|
}
|
79
|
-
toBananaReporterObj(rawData) {
|
79
|
+
toBananaReporterObj(rawData, index) {
|
80
80
|
var _a;
|
81
81
|
const projectName = (_a = rawData.projects) === null || _a === void 0 ? void 0 : _a.map(p => p.replace('+', '')).join(',');
|
82
82
|
const description = `${rawData.description}`;
|
83
83
|
return {
|
84
|
+
id: `${this.config.file}_${index}`,
|
84
85
|
date: rawData.completion || rawData.creation || '',
|
85
86
|
description,
|
86
87
|
projectName,
|
package/oclif.manifest.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "0.
|
2
|
+
"version": "0.3.1",
|
3
3
|
"commands": {
|
4
4
|
"run": {
|
5
5
|
"id": "run",
|
@@ -44,7 +44,7 @@
|
|
44
44
|
"name": "out",
|
45
45
|
"type": "option",
|
46
46
|
"char": "o",
|
47
|
-
"description": "file path to save the output",
|
47
|
+
"description": "file path or directory to save the output",
|
48
48
|
"required": true,
|
49
49
|
"multiple": false,
|
50
50
|
"default": "./bananareporter_$FROM__$TO.json",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "bananareporter",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.3.1",
|
4
4
|
"description": "Easily generate a report from multiple sources",
|
5
5
|
"author": "nya1",
|
6
6
|
"bin": {
|
@@ -34,7 +34,7 @@
|
|
34
34
|
"@types/chai": "^4",
|
35
35
|
"@types/js-yaml": "^4.0.5",
|
36
36
|
"@types/mocha": "^9.1.1",
|
37
|
-
"@types/node": "^18.15.
|
37
|
+
"@types/node": "^18.15.3",
|
38
38
|
"@types/node-fetch": "^2.6.2",
|
39
39
|
"@types/object-path": "^0.11.1",
|
40
40
|
"@types/papaparse": "^5.3.7",
|