bananareporter 0.2.1 → 0.3.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/README.md +6 -4
- package/dist/commands/run/index.js +22 -4
- package/dist/integrations/base.d.ts +6 -1
- package/dist/integrations/github.js +8 -1
- package/dist/integrations/gitlab.js +7 -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
@@ -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.0 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.0/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()) {
|
@@ -98,18 +99,35 @@ class Run extends core_1.Command {
|
|
98
99
|
}
|
99
100
|
const fileExt = `.${validatedConfig.format}`;
|
100
101
|
let outFile = validatedConfig.out;
|
102
|
+
logger_1.logger.debug(`Run.flags.out.default ${Run.flags.out.default}`);
|
103
|
+
logger_1.logger.debug(`fileExt ${fileExt}`);
|
104
|
+
logger_1.logger.debug(`outFile ${outFile}`);
|
105
|
+
// if --out was provided and it's a directory
|
106
|
+
// use the default file name
|
107
|
+
try {
|
108
|
+
if ((0, node_fs_1.statSync)(outFile).isDirectory()) {
|
109
|
+
outFile = (0, node_path_1.resolve)(outFile, Run.flags.out.default);
|
110
|
+
logger_1.logger.debug(`outFile is a directory, updated to ${outFile}`);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
catch (error) {
|
114
|
+
logger_1.logger.debug('statSync error', error);
|
115
|
+
}
|
101
116
|
// add file extension
|
102
117
|
if (!outFile.endsWith(fileExt)) {
|
103
118
|
if (outFile === Run.flags.out.default) {
|
104
119
|
outFile = outFile
|
105
|
-
.replace(`.${Run.flags.format.default}`, fileExt)
|
106
|
-
.replace('$FROM', validatedConfig.from)
|
107
|
-
.replace('$TO', validatedConfig.to);
|
120
|
+
.replace(`.${Run.flags.format.default}`, fileExt);
|
108
121
|
}
|
109
122
|
else {
|
110
123
|
outFile += fileExt;
|
111
124
|
}
|
112
125
|
}
|
126
|
+
if (outFile.includes('$FROM') || outFile.includes('$TO')) {
|
127
|
+
outFile = outFile
|
128
|
+
.replace('$FROM', validatedConfig.from)
|
129
|
+
.replace('$TO', validatedConfig.to);
|
130
|
+
}
|
113
131
|
logger_1.logger.debug(`run saving to ${outFile} with file content of size ${outputStr.length}`);
|
114
132
|
(0, node_fs_1.writeFileSync)(outFile, outputStr);
|
115
133
|
this.log(`report with ${reportList.length} entries saved to ${outFile}`);
|
@@ -151,7 +169,7 @@ Run.flags = {
|
|
151
169
|
out: core_1.Flags.file({
|
152
170
|
char: 'o',
|
153
171
|
aliases: ['output'],
|
154
|
-
description: 'file path to save the output',
|
172
|
+
description: 'file path or directory to save the output',
|
155
173
|
required: true,
|
156
174
|
default: './bananareporter_$FROM__$TO.json',
|
157
175
|
}),
|
@@ -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;
|
@@ -65,6 +65,7 @@ class GithubIntegration extends base_1.IntegrationBase {
|
|
65
65
|
async fetchData() {
|
66
66
|
let page = 1;
|
67
67
|
let commitList = [];
|
68
|
+
const commitShaList = new Set();
|
68
69
|
while (page > 0) {
|
69
70
|
logger_1.logger.debug(`github integration working on ${page}`);
|
70
71
|
/* eslint-disable no-await-in-loop */
|
@@ -79,7 +80,12 @@ class GithubIntegration extends base_1.IntegrationBase {
|
|
79
80
|
break;
|
80
81
|
}
|
81
82
|
// eslint-disable-next-line unicorn/prefer-spread
|
82
|
-
commitList = commitList.concat(
|
83
|
+
commitList = commitList.concat(
|
84
|
+
// remove duplicate items
|
85
|
+
commits.items.filter(c => !commitShaList.has(c.sha)));
|
86
|
+
for (const c of commits.items) {
|
87
|
+
commitShaList.add(c.sha);
|
88
|
+
}
|
83
89
|
logger_1.logger.debug(`github integration commitList ${commitList.length} (added ${commits.items.length} commits)`);
|
84
90
|
page += 1;
|
85
91
|
await (0, common_1.delay)(this.delayToUse);
|
@@ -126,6 +132,7 @@ class GithubIntegration extends base_1.IntegrationBase {
|
|
126
132
|
const projectName = rawData.repository.name;
|
127
133
|
const description = `${rawData.commit.message} git:${rawData.sha.slice(0, 7)}`;
|
128
134
|
return {
|
135
|
+
id: rawData.sha,
|
129
136
|
date: rawData.commit.committer.date,
|
130
137
|
username: rawData.commit.committer.name,
|
131
138
|
description,
|
@@ -88,6 +88,7 @@ class GitlabIntegration extends base_1.IntegrationBase {
|
|
88
88
|
let page = 1;
|
89
89
|
let eventList = [];
|
90
90
|
const projectIds = new Set();
|
91
|
+
const commitShaList = new Set();
|
91
92
|
while (page > 0) {
|
92
93
|
logger_1.logger.debug(`gitlab integration working on ${page}`);
|
93
94
|
/* eslint-disable no-await-in-loop */
|
@@ -101,11 +102,14 @@ class GitlabIntegration extends base_1.IntegrationBase {
|
|
101
102
|
logger_1.logger.debug('gitlab integration no more events to process');
|
102
103
|
break;
|
103
104
|
}
|
105
|
+
// eslint-disable-next-line unicorn/prefer-spread
|
106
|
+
eventList = eventList.concat(
|
107
|
+
// remove duplicated commits
|
108
|
+
events.filter(e => !commitShaList.has(e.push_data.commit_to)));
|
104
109
|
for (const e of events) {
|
110
|
+
commitShaList.add(e.push_data.commit_to);
|
105
111
|
projectIds.add(e.project_id);
|
106
112
|
}
|
107
|
-
// eslint-disable-next-line unicorn/prefer-spread
|
108
|
-
eventList = eventList.concat(events);
|
109
113
|
logger_1.logger.debug(`gitlab integration eventList ${eventList.length} (added ${events.length} events)`);
|
110
114
|
page += 1;
|
111
115
|
await (0, common_1.delay)(this.delayToUse);
|
@@ -240,6 +244,7 @@ class GitlabIntegration extends base_1.IntegrationBase {
|
|
240
244
|
const projectName = projectDetails === null || projectDetails === void 0 ? void 0 : projectDetails.path;
|
241
245
|
const description = `${rawData.push_data.commit_title} branch:${rawData.push_data.ref} git:${rawData.push_data.commit_to.slice(0, 7)}`;
|
242
246
|
return {
|
247
|
+
id: `${String(rawData.push_data.commit_to)}`,
|
243
248
|
date: rawData.created_at,
|
244
249
|
username: rawData.author_username,
|
245
250
|
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: `${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.0",
|
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.0",
|
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",
|