@foss.global/codefeed 1.6.4 → 1.7.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/index.d.ts +36 -10
- package/dist_ts/index.js +309 -211
- package/dist_ts/interfaces/index.d.ts +1 -0
- package/dist_ts/plugins.d.ts +8 -0
- package/dist_ts/plugins.js +11 -0
- package/package.json +11 -10
- package/readme.md +70 -101
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/index.ts +358 -276
- package/ts/interfaces/index.ts +1 -0
- package/ts/{codefeed.plugins.ts → plugins.ts} +2 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as interfaces from './interfaces/index.js';
|
|
2
|
+
export { interfaces, };
|
|
3
|
+
import * as qenv from '@push.rocks/qenv';
|
|
4
|
+
import * as smartnpm from '@push.rocks/smartnpm';
|
|
5
|
+
import * as smartxml from '@push.rocks/smartxml';
|
|
6
|
+
import * as smarttime from '@push.rocks/smarttime';
|
|
7
|
+
import * as lik from '@push.rocks/lik';
|
|
8
|
+
export { qenv, smartnpm, smartxml, smarttime, lik, };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// module
|
|
2
|
+
import * as interfaces from './interfaces/index.js';
|
|
3
|
+
export { interfaces, };
|
|
4
|
+
// @push.rocks
|
|
5
|
+
import * as qenv from '@push.rocks/qenv';
|
|
6
|
+
import * as smartnpm from '@push.rocks/smartnpm';
|
|
7
|
+
import * as smartxml from '@push.rocks/smartxml';
|
|
8
|
+
import * as smarttime from '@push.rocks/smarttime';
|
|
9
|
+
import * as lik from '@push.rocks/lik';
|
|
10
|
+
export { qenv, smartnpm, smartxml, smarttime, lik, };
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3BsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsU0FBUztBQUNULE9BQU8sS0FBSyxVQUFVLE1BQU0sdUJBQXVCLENBQUM7QUFFcEQsT0FBTyxFQUNMLFVBQVUsR0FDWCxDQUFBO0FBRUQsY0FBYztBQUNkLE9BQU8sS0FBSyxJQUFJLE1BQU0sa0JBQWtCLENBQUM7QUFDekMsT0FBTyxLQUFLLFFBQVEsTUFBTSxzQkFBc0IsQ0FBQztBQUNqRCxPQUFPLEtBQUssUUFBUSxNQUFNLHNCQUFzQixDQUFDO0FBQ2pELE9BQU8sS0FBSyxTQUFTLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxLQUFLLEdBQUcsTUFBTSxpQkFBaUIsQ0FBQztBQUV2QyxPQUFPLEVBQ0wsSUFBSSxFQUNKLFFBQVEsRUFDUixRQUFRLEVBQ1IsU0FBUyxFQUNULEdBQUcsR0FDSixDQUFBIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foss.global/codefeed",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The @foss.global/codefeed module is designed for generating feeds from Gitea repositories, enhancing development workflows by processing commit data and repository activities.",
|
|
6
6
|
"exports": {
|
|
@@ -11,18 +11,19 @@
|
|
|
11
11
|
"author": "Task Venture Capital GmbH",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@git.zone/tsbuild": "^2.
|
|
15
|
-
"@git.zone/tsbundle": "^2.
|
|
14
|
+
"@git.zone/tsbuild": "^2.6.8",
|
|
15
|
+
"@git.zone/tsbundle": "^2.5.1",
|
|
16
16
|
"@git.zone/tsrun": "^1.2.46",
|
|
17
|
-
"@git.zone/tstest": "^
|
|
18
|
-
"@push.rocks/tapbundle": "^
|
|
19
|
-
"@types/node": "^22.
|
|
17
|
+
"@git.zone/tstest": "^2.3.8",
|
|
18
|
+
"@push.rocks/tapbundle": "^6.0.3",
|
|
19
|
+
"@types/node": "^22.15.2"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@push.rocks/
|
|
23
|
-
"@push.rocks/
|
|
22
|
+
"@push.rocks/lik": "^6.2.2",
|
|
23
|
+
"@push.rocks/qenv": "^6.1.3",
|
|
24
|
+
"@push.rocks/smartnpm": "^2.0.6",
|
|
24
25
|
"@push.rocks/smarttime": "^4.1.1",
|
|
25
|
-
"@push.rocks/smartxml": "^1.
|
|
26
|
+
"@push.rocks/smartxml": "^1.1.1"
|
|
26
27
|
},
|
|
27
28
|
"repository": {
|
|
28
29
|
"type": "git",
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"version control"
|
|
59
60
|
],
|
|
60
61
|
"scripts": {
|
|
61
|
-
"test": "(tstest test/ --
|
|
62
|
+
"test": "(tstest test/ --verbose)",
|
|
62
63
|
"build": "(tsbuild tsfolders --web --allowimplicitany)",
|
|
63
64
|
"buildDocs": "(tsdoc)"
|
|
64
65
|
}
|
package/readme.md
CHANGED
|
@@ -1,130 +1,99 @@
|
|
|
1
|
-
```markdown
|
|
2
1
|
# @foss.global/codefeed
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
Generate an activity feed from a Gitea instance. Scans orgs and repos, retrieves commits since a configurable timestamp, enriches with tags, optional npm publish detection, and CHANGELOG snippets.
|
|
5
4
|
|
|
6
5
|
## Install
|
|
7
6
|
|
|
8
|
-
To install the `@foss.global/codefeed` package, you can run the following npm command in your project directory:
|
|
9
|
-
|
|
10
7
|
```bash
|
|
11
|
-
|
|
8
|
+
pnpm add @foss.global/codefeed
|
|
9
|
+
# or
|
|
10
|
+
npm i @foss.global/codefeed
|
|
12
11
|
```
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
The `@foss.global/codefeed` package is designed to help developers generate feeds for code developments, specifically targeting Gitea repositories. It fetches and processes commit data, changelogs, and repository activities for further analysis or visualization. Here, we'll delve into how you can utilize the different features of the `CodeFeed` class.
|
|
19
|
-
|
|
20
|
-
### Setting Up CodeFeed
|
|
13
|
+
Requires Node.js 18+ (global fetch/Request/Response) and ESM.
|
|
21
14
|
|
|
22
|
-
|
|
15
|
+
## Quick Start
|
|
23
16
|
|
|
24
|
-
```
|
|
17
|
+
```ts
|
|
25
18
|
import { CodeFeed } from '@foss.global/codefeed';
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Then, create an instance of `CodeFeed`. You'll need the base URL of your Gitea instance and optionally an API token if your repositories require authentication:
|
|
29
19
|
|
|
30
|
-
|
|
31
|
-
const
|
|
20
|
+
// Fetch commits since one week ago (default), no caching
|
|
21
|
+
const feed = new CodeFeed('https://code.example.com', 'gitea_token');
|
|
22
|
+
const commits = await feed.fetchAllCommitsFromInstance();
|
|
23
|
+
console.log(commits);
|
|
32
24
|
```
|
|
33
25
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
26
|
+
### With options
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
const thirtyDays = 30 * 24 * 60 * 60 * 1000;
|
|
30
|
+
const since = new Date(Date.now() - thirtyDays).toISOString();
|
|
31
|
+
|
|
32
|
+
const feed = new CodeFeed('https://code.example.com', 'gitea_token', since, {
|
|
33
|
+
enableCache: true, // keep results in memory
|
|
34
|
+
cacheWindowMs: thirtyDays, // trim cache to this window
|
|
35
|
+
enableNpmCheck: true, // check npm for published versions
|
|
36
|
+
taggedOnly: false, // return all commits (or only tagged)
|
|
37
|
+
orgAllowlist: ['myorg'], // only scan these orgs
|
|
38
|
+
orgDenylist: ['archive'], // skip these orgs
|
|
39
|
+
repoAllowlist: ['myorg/app1', 'myorg/app2'], // only these repos
|
|
40
|
+
repoDenylist: ['myorg/old-repo'], // skip these repos
|
|
41
|
+
untilTimestamp: new Date().toISOString(), // optional upper bound
|
|
42
|
+
verbose: true, // print a short metrics summary
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const commits = await feed.fetchAllCommitsFromInstance();
|
|
49
46
|
```
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
#### Fetching Organizations
|
|
68
|
-
|
|
69
|
-
The `fetchAllOrganizations` method collects all organizations within the Gitea instance:
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
const organizations = await codeFeed.fetchAllOrganizations();
|
|
73
|
-
console.log('Organizations:', organizations);
|
|
48
|
+
Each returned item follows this shape:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
interface ICommitResult {
|
|
52
|
+
baseUrl: string;
|
|
53
|
+
org: string;
|
|
54
|
+
repo: string;
|
|
55
|
+
timestamp: string; // ISO date
|
|
56
|
+
hash: string; // commit SHA
|
|
57
|
+
commitMessage: string;
|
|
58
|
+
tagged: boolean; // commit is pointed to by a tag
|
|
59
|
+
publishedOnNpm: boolean; // only when npm check enabled and tag matches
|
|
60
|
+
prettyAgoTime: string; // human-readable diff
|
|
61
|
+
changelog: string | undefined; // snippet for matching tag version
|
|
62
|
+
}
|
|
74
63
|
```
|
|
75
64
|
|
|
76
|
-
|
|
65
|
+
## Features
|
|
77
66
|
|
|
78
|
-
|
|
67
|
+
- Pagination for orgs, repos, commits, and tags (no missing pages)
|
|
68
|
+
- Retries with exponential backoff for 429/5xx and network errors
|
|
69
|
+
- CHANGELOG discovery with case variants (`CHANGELOG.md`, `changelog.md`, `docs/CHANGELOG.md`)
|
|
70
|
+
- Tag-to-version mapping based on tag names (`vX.Y.Z` → `X.Y.Z`)
|
|
71
|
+
- Optional npm publish detection via `@org/repo` package versions
|
|
72
|
+
- In-memory caching with window trimming and stable sorting
|
|
73
|
+
- Allow/deny filters for orgs and repos, optional time upper bound
|
|
74
|
+
- One-line metrics summary when `verbose: true`
|
|
79
75
|
|
|
80
|
-
|
|
76
|
+
## Environment
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
console.log('Repositories:', repositories);
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Here, filtering by organization can help narrow down the scope further when dealing with large instances.
|
|
88
|
-
|
|
89
|
-
#### Fetching Tags and Commits
|
|
90
|
-
|
|
91
|
-
To handle repository-specific details, use:
|
|
78
|
+
- Gitea base URL and an optional token with read access
|
|
79
|
+
- Node.js 18+ (global fetch)
|
|
92
80
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
- `fetchRecentCommitsForRepo(owner: string, repo: string)`: Gathers commit data specific to the past 24 hours for a given repository.
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
const tags = await codeFeed.fetchTags('orgName', 'repoName');
|
|
99
|
-
const recentCommits = await codeFeed.fetchRecentCommitsForRepo('orgName', 'repoName');
|
|
100
|
-
|
|
101
|
-
console.log('Tags:', tags);
|
|
102
|
-
console.log('Recent Commits:', recentCommits);
|
|
103
|
-
```
|
|
81
|
+
## Testing
|
|
104
82
|
|
|
105
|
-
|
|
83
|
+
The repo contains:
|
|
84
|
+
- An integration test using a `GITEA_TOKEN` from `.nogit/` via `@push.rocks/qenv`.
|
|
85
|
+
- A mocked pagination test that does not require network.
|
|
106
86
|
|
|
107
|
-
|
|
87
|
+
Run tests:
|
|
108
88
|
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
const changelog = codeFeed.getChangelogForVersion('1.0.0');
|
|
112
|
-
console.log('Changelog for version 1.0.0:', changelog);
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Reacting to Repository Activity
|
|
116
|
-
|
|
117
|
-
The method `hasNewActivity` checks for recent changes within an organization or a repository. This is particularly useful for setting up alerting systems or continuous integration triggers:
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
const hasActivity = await codeFeed.hasNewActivity({ orgName: 'orgName', repoName: 'repoName' });
|
|
121
|
-
console.log('New activity detected:', hasActivity);
|
|
89
|
+
```bash
|
|
90
|
+
pnpm test
|
|
122
91
|
```
|
|
123
92
|
|
|
124
|
-
|
|
93
|
+
For the integration test, ensure `GITEA_TOKEN` is provided (e.g., via `.nogit/` as used in `test/test.ts`).
|
|
125
94
|
|
|
126
|
-
|
|
95
|
+
## Notes
|
|
127
96
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
97
|
+
- When `taggedOnly` is enabled, the feed includes only commits associated with tags.
|
|
98
|
+
- `publishedOnNpm` is computed by matching the tag-derived version against the npm registry for `@org/repo`.
|
|
99
|
+
- For very large instances, consider using allowlists/denylists and enabling caching for incremental runs.
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@foss.global/codefeed',
|
|
6
|
-
version: '1.
|
|
6
|
+
version: '1.7.2',
|
|
7
7
|
description: 'The @foss.global/codefeed module is designed for generating feeds from Gitea repositories, enhancing development workflows by processing commit data and repository activities.'
|
|
8
8
|
}
|