@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.
@@ -17,6 +17,7 @@ export interface ICommit {
17
17
  commit: ICommitDetail;
18
18
  }
19
19
  export interface ITag {
20
+ name?: string;
20
21
  commit?: {
21
22
  sha?: string;
22
23
  };
@@ -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.6.4",
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.1.25",
15
- "@git.zone/tsbundle": "^2.0.5",
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": "^1.0.44",
18
- "@push.rocks/tapbundle": "^5.0.15",
19
- "@types/node": "^22.10.2"
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/qenv": "^6.1.0",
23
- "@push.rocks/smartnpm": "^2.0.4",
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",
@@ -58,7 +59,7 @@
58
59
  "version control"
59
60
  ],
60
61
  "scripts": {
61
- "test": "(tstest test/ --web)",
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
- 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
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
- npm install @foss.global/codefeed
8
+ pnpm add @foss.global/codefeed
9
+ # or
10
+ npm i @foss.global/codefeed
12
11
  ```
13
12
 
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.
19
-
20
- ### Setting Up CodeFeed
13
+ Requires Node.js 18+ (global fetch/Request/Response) and ESM.
21
14
 
22
- To get started, import the `CodeFeed` class from the module:
15
+ ## Quick Start
23
16
 
24
- ```typescript
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
- ```typescript
31
- const codeFeed = new CodeFeed('https://your-gitea-instance-url.com', 'your-api-token');
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
- 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
- })();
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
- 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.
52
-
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)
64
-
65
- ### Understanding the Data Fetch Process
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
- This method interacts with the Gitea API to pull organization names, aiding further requests that require organization context.
65
+ ## Features
77
66
 
78
- #### Fetching Repositories
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
- Repositories under these organizations can be retrieved using `fetchAllRepositories`:
76
+ ## Environment
81
77
 
82
- ```typescript
83
- const repositories = await codeFeed.fetchAllRepositories();
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
- - `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.
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
- ### Changelog Integration
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
- Loading changelog content from a repository is integrated into the flow with `loadChangelogFromRepo`. This can be accessed when processing specific commits:
87
+ Run tests:
108
88
 
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
- ```
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
- ### Conclusion
93
+ For the integration test, ensure `GITEA_TOKEN` is provided (e.g., via `.nogit/` as used in `test/test.ts`).
125
94
 
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.
95
+ ## Notes
127
96
 
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
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.
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@foss.global/codefeed',
6
- version: '1.6.4',
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
  }