@foss.global/codefeed 1.6.5 → 1.8.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/{npmextra.json → .smartconfig.json} +15 -7
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/index.d.ts +30 -10
- package/dist_ts/index.js +336 -211
- package/dist_ts/interfaces/index.d.ts +29 -11
- package/dist_ts/plugins.d.ts +7 -0
- package/dist_ts/plugins.js +9 -0
- package/license.md +21 -0
- package/package.json +15 -13
- package/readme.md +87 -91
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/index.ts +378 -275
- package/ts/interfaces/index.ts +33 -11
- package/ts/plugins.ts +19 -0
- package/dist_ts/codefeed.plugins.d.ts +0 -7
- package/dist_ts/codefeed.plugins.js +0 -10
- package/ts/codefeed.plugins.ts +0 -19
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ICodefeedCommitResult } from '@foss.global/interfaces';
|
|
2
|
+
export type { ICodefeedCommitResult } from '@foss.global/interfaces';
|
|
1
3
|
export interface IRepositoryOwner {
|
|
2
4
|
login: string;
|
|
3
5
|
}
|
|
@@ -17,6 +19,7 @@ export interface ICommit {
|
|
|
17
19
|
commit: ICommitDetail;
|
|
18
20
|
}
|
|
19
21
|
export interface ITag {
|
|
22
|
+
name?: string;
|
|
20
23
|
commit?: {
|
|
21
24
|
sha?: string;
|
|
22
25
|
};
|
|
@@ -24,15 +27,30 @@ export interface ITag {
|
|
|
24
27
|
export interface IRepoSearchResponse {
|
|
25
28
|
data: IRepository[];
|
|
26
29
|
}
|
|
27
|
-
export interface ICommitResult {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
export interface ICommitResult extends ICodefeedCommitResult {
|
|
31
|
+
}
|
|
32
|
+
export interface ICodeFeedTagInfo {
|
|
33
|
+
shas: Set<string>;
|
|
34
|
+
map: Map<string, string>;
|
|
35
|
+
}
|
|
36
|
+
export interface ICodeFeedProvider {
|
|
37
|
+
listOrganizations(): Promise<string[]>;
|
|
38
|
+
listRepositoriesForOrg(org: string): Promise<IRepository[]>;
|
|
39
|
+
getLatestCommitForRepo(owner: string, repo: string): Promise<ICommit | undefined>;
|
|
40
|
+
listCommitsForRepo(owner: string, repo: string, sinceTimestamp?: string): Promise<ICommit[]>;
|
|
41
|
+
listTagsForRepo(owner: string, repo: string): Promise<ICodeFeedTagInfo>;
|
|
42
|
+
readChangelogForRepo(owner: string, repo: string): Promise<string>;
|
|
43
|
+
}
|
|
44
|
+
export interface ICodeFeedOptions {
|
|
45
|
+
enableCache?: boolean;
|
|
46
|
+
cacheWindowMs?: number;
|
|
47
|
+
enableNpmCheck?: boolean;
|
|
48
|
+
taggedOnly?: boolean;
|
|
49
|
+
orgAllowlist?: string[];
|
|
50
|
+
orgDenylist?: string[];
|
|
51
|
+
repoAllowlist?: string[];
|
|
52
|
+
repoDenylist?: string[];
|
|
53
|
+
untilTimestamp?: string;
|
|
54
|
+
verbose?: boolean;
|
|
55
|
+
provider?: ICodeFeedProvider;
|
|
38
56
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as interfaces from './interfaces/index.js';
|
|
2
|
+
export { interfaces, };
|
|
3
|
+
import * as smarttime from '@push.rocks/smarttime';
|
|
4
|
+
import * as lik from '@push.rocks/lik';
|
|
5
|
+
export type TNpmRegistry = import('@push.rocks/smartnpm').NpmRegistry;
|
|
6
|
+
export declare const getSmartnpm: () => Promise<typeof import("@push.rocks/smartnpm")>;
|
|
7
|
+
export { smarttime, lik, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// module
|
|
2
|
+
import * as interfaces from './interfaces/index.js';
|
|
3
|
+
export { interfaces, };
|
|
4
|
+
// @push.rocks
|
|
5
|
+
import * as smarttime from '@push.rocks/smarttime';
|
|
6
|
+
import * as lik from '@push.rocks/lik';
|
|
7
|
+
export const getSmartnpm = async () => import('@push.rocks/smartnpm');
|
|
8
|
+
export { smarttime, lik, };
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3BsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsU0FBUztBQUNULE9BQU8sS0FBSyxVQUFVLE1BQU0sdUJBQXVCLENBQUM7QUFFcEQsT0FBTyxFQUNMLFVBQVUsR0FDWCxDQUFBO0FBRUQsY0FBYztBQUNkLE9BQU8sS0FBSyxTQUFTLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxLQUFLLEdBQUcsTUFBTSxpQkFBaUIsQ0FBQztBQUl2QyxNQUFNLENBQUMsTUFBTSxXQUFXLEdBQUcsS0FBSyxJQUFJLEVBQUUsQ0FBQyxNQUFNLENBQUMsc0JBQXNCLENBQUMsQ0FBQztBQUV0RSxPQUFPLEVBQ0wsU0FBUyxFQUNULEdBQUcsR0FDSixDQUFBIn0=
|
package/license.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Task Venture Capital GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foss.global/codefeed",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
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": "^
|
|
15
|
-
"@git.zone/tsbundle": "^2.0
|
|
16
|
-
"@git.zone/tsrun": "^
|
|
17
|
-
"@git.zone/tstest": "^
|
|
18
|
-
"@
|
|
19
|
-
"@types/node": "^22.10.2"
|
|
14
|
+
"@git.zone/tsbuild": "^4.4.2",
|
|
15
|
+
"@git.zone/tsbundle": "^2.11.0",
|
|
16
|
+
"@git.zone/tsrun": "^2.0.4",
|
|
17
|
+
"@git.zone/tstest": "^3.6.6",
|
|
18
|
+
"@types/node": "^26.0.0"
|
|
20
19
|
},
|
|
21
20
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@push.rocks/
|
|
21
|
+
"@foss.global/interfaces": "^0.2.0",
|
|
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",
|
|
@@ -41,8 +42,9 @@
|
|
|
41
42
|
"dist_ts_web/**/*",
|
|
42
43
|
"assets/**/*",
|
|
43
44
|
"cli.js",
|
|
44
|
-
"
|
|
45
|
-
"readme.md"
|
|
45
|
+
".smartconfig.json",
|
|
46
|
+
"readme.md",
|
|
47
|
+
"license.md"
|
|
46
48
|
],
|
|
47
49
|
"keywords": [
|
|
48
50
|
"codefeed",
|
|
@@ -58,7 +60,7 @@
|
|
|
58
60
|
"version control"
|
|
59
61
|
],
|
|
60
62
|
"scripts": {
|
|
61
|
-
"test": "(tstest test/ --
|
|
63
|
+
"test": "(tstest test/ --verbose)",
|
|
62
64
|
"build": "(tsbuild tsfolders --web --allowimplicitany)",
|
|
63
65
|
"buildDocs": "(tsdoc)"
|
|
64
66
|
}
|
package/readme.md
CHANGED
|
@@ -1,130 +1,126 @@
|
|
|
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
|
+
## Issue Reporting and Security
|
|
6
|
+
|
|
7
|
+
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## Install
|
|
9
10
|
|
|
10
11
|
```bash
|
|
11
|
-
|
|
12
|
+
pnpm add @foss.global/codefeed
|
|
12
13
|
```
|
|
13
14
|
|
|
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.
|
|
15
|
+
Requires Node.js 18+ (global fetch/Request/Response) and ESM.
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
## Quick Start
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
19
|
+
```ts
|
|
25
20
|
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
21
|
|
|
30
|
-
|
|
31
|
-
const
|
|
22
|
+
// Fetch commits since one week ago (default), no caching
|
|
23
|
+
const feed = new CodeFeed('https://code.example.com', 'gitea_token');
|
|
24
|
+
const commits = await feed.fetchAllCommitsFromInstance();
|
|
25
|
+
console.log(commits);
|
|
32
26
|
```
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
28
|
+
### With options
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const thirtyDays = 30 * 24 * 60 * 60 * 1000;
|
|
32
|
+
const since = new Date(Date.now() - thirtyDays).toISOString();
|
|
33
|
+
|
|
34
|
+
const feed = new CodeFeed('https://code.example.com', 'gitea_token', since, {
|
|
35
|
+
enableCache: true, // keep results in memory
|
|
36
|
+
cacheWindowMs: thirtyDays, // trim cache to this window
|
|
37
|
+
enableNpmCheck: true, // check npm for published versions
|
|
38
|
+
taggedOnly: false, // return all commits (or only tagged)
|
|
39
|
+
orgAllowlist: ['myorg'], // only scan these orgs
|
|
40
|
+
orgDenylist: ['archive'], // skip these orgs
|
|
41
|
+
repoAllowlist: ['myorg/app1', 'myorg/app2'], // only these repos
|
|
42
|
+
repoDenylist: ['myorg/old-repo'], // skip these repos
|
|
43
|
+
untilTimestamp: new Date().toISOString(), // optional upper bound
|
|
44
|
+
verbose: true, // print a short metrics summary
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const commits = await feed.fetchAllCommitsFromInstance();
|
|
49
48
|
```
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
Advanced callers can provide a custom `ICodeFeedProvider` through the constructor options. The default provider keeps the existing Gitea HTTP behavior, while the provider contract lets adapters supply organizations, repositories, commits, tags, and changelog content from another backend.
|
|
51
|
+
|
|
52
|
+
Each returned item follows this shape:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
interface ICommitResult {
|
|
56
|
+
baseUrl: string;
|
|
57
|
+
org: string;
|
|
58
|
+
repo: string;
|
|
59
|
+
timestamp: string; // ISO date
|
|
60
|
+
hash: string; // commit SHA
|
|
61
|
+
commitMessage: string;
|
|
62
|
+
tagged: boolean; // commit is pointed to by a tag
|
|
63
|
+
publishedOnNpm: boolean; // only when npm check enabled and tag matches
|
|
64
|
+
prettyAgoTime: string; // human-readable diff
|
|
65
|
+
changelog: string | undefined; // snippet for matching tag version
|
|
66
|
+
}
|
|
67
|
+
```
|
|
52
68
|
|
|
53
|
-
|
|
54
|
-
- `baseUrl`
|
|
55
|
-
- `org`
|
|
56
|
-
- `repo`
|
|
57
|
-
- `timestamp`
|
|
58
|
-
- `hash`
|
|
59
|
-
- `commitMessage`
|
|
60
|
-
- `tagged` (boolean)
|
|
61
|
-
- `publishedOnNpm` (boolean)
|
|
62
|
-
- `prettyAgoTime` (human-readable relative time)
|
|
63
|
-
- `changelog` (text from the `changelog.md` associated with a commit)
|
|
69
|
+
The canonical public result contract is exported as `ICodefeedCommitResult` from `@foss.global/interfaces`. `@foss.global/codefeed/interfaces` keeps `ICommitResult` as a package-local alias for that contract.
|
|
64
70
|
|
|
65
|
-
|
|
71
|
+
## Features
|
|
66
72
|
|
|
67
|
-
|
|
73
|
+
- Pagination for orgs, repos, commits, and tags (no missing pages)
|
|
74
|
+
- Retries with exponential backoff for 429/5xx and network errors
|
|
75
|
+
- CHANGELOG discovery with case variants (`CHANGELOG.md`, `changelog.md`, `docs/CHANGELOG.md`)
|
|
76
|
+
- Tag-to-version mapping based on tag names (`vX.Y.Z` → `X.Y.Z`)
|
|
77
|
+
- Optional npm publish detection via `@org/repo` package versions
|
|
78
|
+
- In-memory caching with window trimming and stable sorting
|
|
79
|
+
- Allow/deny filters for orgs and repos, optional time upper bound
|
|
80
|
+
- One-line metrics summary when `verbose: true`
|
|
68
81
|
|
|
69
|
-
|
|
82
|
+
## Environment
|
|
70
83
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
console.log('Organizations:', organizations);
|
|
74
|
-
```
|
|
84
|
+
- Gitea base URL and an optional token with read access
|
|
85
|
+
- Node.js 18+ (global fetch)
|
|
75
86
|
|
|
76
|
-
|
|
87
|
+
## Testing
|
|
77
88
|
|
|
78
|
-
|
|
89
|
+
The repo contains:
|
|
90
|
+
- An opt-in integration test using a `GITEA_TOKEN` from `.nogit/` via `@push.rocks/qenv`.
|
|
91
|
+
- A mocked pagination test that does not require network.
|
|
79
92
|
|
|
80
|
-
|
|
93
|
+
Run tests:
|
|
81
94
|
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
console.log('Repositories:', repositories);
|
|
95
|
+
```bash
|
|
96
|
+
pnpm test
|
|
85
97
|
```
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
#### Fetching Tags and Commits
|
|
99
|
+
For the integration test, set `CODEFEED_RUN_LIVE=true` and ensure `GITEA_TOKEN` is provided, e.g. via `.nogit/` as used by `test/test.live.node.ts`.
|
|
90
100
|
|
|
91
|
-
|
|
101
|
+
## Notes
|
|
92
102
|
|
|
93
|
-
- `
|
|
94
|
-
|
|
95
|
-
-
|
|
103
|
+
- When `taggedOnly` is enabled, the feed includes only commits associated with tags.
|
|
104
|
+
- `publishedOnNpm` is computed by matching the tag-derived version against the npm registry for `@org/repo`.
|
|
105
|
+
- For very large instances, consider using allowlists/denylists and enabling caching for incremental runs.
|
|
96
106
|
|
|
97
|
-
|
|
98
|
-
const tags = await codeFeed.fetchTags('orgName', 'repoName');
|
|
99
|
-
const recentCommits = await codeFeed.fetchRecentCommitsForRepo('orgName', 'repoName');
|
|
107
|
+
## License and Legal Information
|
|
100
108
|
|
|
101
|
-
|
|
102
|
-
console.log('Recent Commits:', recentCommits);
|
|
103
|
-
```
|
|
109
|
+
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the repository license file.
|
|
104
110
|
|
|
105
|
-
|
|
111
|
+
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
|
106
112
|
|
|
107
|
-
|
|
113
|
+
### Trademarks
|
|
108
114
|
|
|
109
|
-
|
|
110
|
-
await codeFeed.loadChangelogFromRepo('org', 'repo');
|
|
111
|
-
const changelog = codeFeed.getChangelogForVersion('1.0.0');
|
|
112
|
-
console.log('Changelog for version 1.0.0:', changelog);
|
|
113
|
-
```
|
|
115
|
+
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
|
|
114
116
|
|
|
115
|
-
|
|
117
|
+
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
|
|
116
118
|
|
|
117
|
-
|
|
119
|
+
### Company Information
|
|
118
120
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
console.log('New activity detected:', hasActivity);
|
|
122
|
-
```
|
|
121
|
+
Task Venture Capital GmbH<br>
|
|
122
|
+
Registered at District Court Bremen HRB 35230 HB, Germany
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
Explore integrating these capabilities into your development workflows to enhance tracking, deployment pipelines, or analytics systems within your projects. Remember to always handle API tokens securely and adhere to best practices when managing access to repository resources. Stay updated on any changes or enhancements to this module for further feature exposures or bug fixes. Happy coding!
|
|
129
|
-
```
|
|
130
|
-
undefined
|
|
126
|
+
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
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.8.0',
|
|
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
|
}
|