@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.
@@ -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
- baseUrl: string;
29
- org: string;
30
- repo: string;
31
- timestamp: string;
32
- hash: string;
33
- commitMessage: string;
34
- tagged: boolean;
35
- publishedOnNpm: boolean;
36
- prettyAgoTime: string;
37
- changelog: string | undefined;
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.6.5",
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": "^2.1.25",
15
- "@git.zone/tsbundle": "^2.0.5",
16
- "@git.zone/tsrun": "^1.2.46",
17
- "@git.zone/tstest": "^1.0.44",
18
- "@push.rocks/tapbundle": "^5.0.15",
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
- "@push.rocks/qenv": "^6.1.0",
23
- "@push.rocks/smartnpm": "^2.0.4",
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.0.8"
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
- "npmextra.json",
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/ --web)",
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
- A module for creating feeds for code development.
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
- ## Install
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
- To install the `@foss.global/codefeed` package, you can run the following npm command in your project directory:
9
+ ## Install
9
10
 
10
11
  ```bash
11
- npm install @foss.global/codefeed
12
+ pnpm add @foss.global/codefeed
12
13
  ```
13
14
 
14
- Ensure that you have a compatible version of Node.js installed and that your project is set up to support ECMAScript modules. The `@foss.global/codefeed` module uses ESM syntax.
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
- ### Setting Up CodeFeed
17
+ ## Quick Start
21
18
 
22
- To get started, import the `CodeFeed` class from the module:
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
- ```typescript
31
- const codeFeed = new CodeFeed('https://your-gitea-instance-url.com', 'your-api-token');
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
- The constructor can also accept a `lastRunTimestamp` which indicates the last time a sync was performed. If not provided, it defaults to 24 hours prior to the current time.
35
-
36
- ### Fetching Commits
37
-
38
- One of the core functionalities of CodeFeed is fetching commits from a Gitea instance. By calling `fetchAllCommitsFromInstance`, you can retrieve commits across multiple repositories:
39
-
40
- ```typescript
41
- (async () => {
42
- try {
43
- const commits = await codeFeed.fetchAllCommitsFromInstance();
44
- console.log(commits);
45
- } catch (error) {
46
- console.error('An error occurred while fetching commits:', error);
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
- This method scans all organizations and repositories, filters commits tagged within the last 24 hours, and enriches them with metadata like changelogs or npm publication status.
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
- Each commit object in the resulting array conforms to the `ICommitResult` interface, containing details such as:
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
- ### Understanding the Data Fetch Process
71
+ ## Features
66
72
 
67
- #### Fetching Organizations
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
- The `fetchAllOrganizations` method collects all organizations within the Gitea instance:
82
+ ## Environment
70
83
 
71
- ```typescript
72
- const organizations = await codeFeed.fetchAllOrganizations();
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
- This method interacts with the Gitea API to pull organization names, aiding further requests that require organization context.
87
+ ## Testing
77
88
 
78
- #### Fetching Repositories
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
- Repositories under these organizations can be retrieved using `fetchAllRepositories`:
93
+ Run tests:
81
94
 
82
- ```typescript
83
- const repositories = await codeFeed.fetchAllRepositories();
84
- console.log('Repositories:', repositories);
95
+ ```bash
96
+ pnpm test
85
97
  ```
86
98
 
87
- Here, filtering by organization can help narrow down the scope further when dealing with large instances.
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
- To handle repository-specific details, use:
101
+ ## Notes
92
102
 
93
- - `fetchTags(owner: string, repo: string)`: Appropriately handles paginated tag data within a repository.
94
-
95
- - `fetchRecentCommitsForRepo(owner: string, repo: string)`: Gathers commit data specific to the past 24 hours for a given repository.
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
- ```typescript
98
- const tags = await codeFeed.fetchTags('orgName', 'repoName');
99
- const recentCommits = await codeFeed.fetchRecentCommitsForRepo('orgName', 'repoName');
107
+ ## License and Legal Information
100
108
 
101
- console.log('Tags:', tags);
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
- ### Changelog Integration
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
- Loading changelog content from a repository is integrated into the flow with `loadChangelogFromRepo`. This can be accessed when processing specific commits:
113
+ ### Trademarks
108
114
 
109
- ```typescript
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
- ### Reacting to Repository Activity
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
- 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:
119
+ ### Company Information
118
120
 
119
- ```typescript
120
- const hasActivity = await codeFeed.hasNewActivity({ orgName: 'orgName', repoName: 'repoName' });
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
- ### Conclusion
124
+ For any legal inquiries or further information, please contact us via email at hello@task.vc.
125
125
 
126
- The `@foss.global/codefeed` module provides robust capabilities for extracting and managing feed data related to code developments in Gitea environments. Through systematic setup and leveraging API-driven methods, it becomes a valuable tool for developers aiming to keep track of software progress and changes efficiently. The integration hooks like changelog and npm verification further enrich its utility, offering consolidated insights into each commit's journey from codebase to published package.
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.
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@foss.global/codefeed',
6
- version: '1.6.5',
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
  }