6 Commits

Author SHA1 Message Date
d103778a75 1.5.2
Some checks failed
Default (tags) / security (push) Successful in 43s
Default (tags) / test (push) Successful in 2m19s
Default (tags) / release (push) Failing after 1m32s
Default (tags) / metadata (push) Successful in 1m58s
2024-12-14 00:33:58 +01:00
9b1b91eb31 fix(core): Ensure stability of core functionalities. 2024-12-14 00:33:58 +01:00
25b2519324 1.5.1
Some checks failed
Default (tags) / security (push) Successful in 39s
Default (tags) / test (push) Successful in 2m22s
Default (tags) / release (push) Failing after 1m42s
Default (tags) / metadata (push) Successful in 2m6s
2024-12-14 00:32:34 +01:00
166b289eb2 fix(core): Refine logging format in CodeFeed class 2024-12-14 00:32:34 +01:00
6ca6b37b1d 1.5.0
Some checks failed
Default (tags) / security (push) Successful in 53s
Default (tags) / test (push) Successful in 2m13s
Default (tags) / release (push) Failing after 1m50s
Default (tags) / metadata (push) Successful in 2m7s
2024-12-14 00:30:35 +01:00
5d0d125e43 feat(core): Refactor TypeScript interfaces and improve module exports 2024-12-14 00:30:35 +01:00
7 changed files with 88 additions and 62 deletions

View File

@ -1,5 +1,21 @@
# Changelog
## 2024-12-14 - 1.5.2 - fix(core)
Ensure stability of core functionalities.
## 2024-12-14 - 1.5.1 - fix(core)
Refine logging format in CodeFeed class
- Modified console log format in fetchAllCommitsFromInstance method for better readability.
## 2024-12-14 - 1.5.0 - feat(core)
Refactor TypeScript interfaces and improve module exports
- Moved TypeScript interfaces to a dedicated file (ts/interfaces/index.ts).
- Updated import/export structure to improve code readability and maintainability.
- Enhanced the package.json to utilize a module exports field for better resolution.
## 2024-12-13 - 1.4.1 - fix(core)
Corrected log formatting for commit information output in CodeFeed

View File

@ -1,10 +1,12 @@
{
"name": "@foss.global/codefeed",
"version": "1.4.1",
"version": "1.5.2",
"private": false,
"description": "a module for creating feeds for code development",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"exports": {
".": "./dist_ts/index.js",
"./interfaces": "./dist_ts/interfaces/index.js"
},
"type": "module",
"author": "Task Venture Capital GmbH",
"license": "MIT",

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@foss.global/codefeed',
version: '1.4.1',
version: '1.5.2',
description: 'a module for creating feeds for code development'
}

View File

@ -1,3 +1,10 @@
// module
import * as interfaces from './interfaces/index.js';
export {
interfaces,
}
// @push.rocks
import * as qenv from '@push.rocks/qenv';
import * as smartnpm from '@push.rocks/smartnpm';

View File

@ -1,49 +1,5 @@
import * as plugins from './codefeed.plugins.js';
interface RepositoryOwner {
login: string;
}
interface Repository {
owner: RepositoryOwner;
name: string;
}
interface CommitAuthor {
date: string;
}
interface CommitDetail {
message: string;
author: CommitAuthor;
}
interface Commit {
sha: string;
commit: CommitDetail;
}
interface Tag {
commit?: {
sha?: string;
};
}
interface RepoSearchResponse {
data: Repository[];
}
export interface CommitResult {
baseUrl: string;
org: string;
repo: string;
timestamp: string;
hash: string;
commitMessage: string;
tagged: boolean;
publishedOnNpm: boolean;
prettyAgoTime: string;
}
export class CodeFeed {
private baseUrl: string;
@ -123,9 +79,9 @@ export class CodeFeed {
/**
* Fetch all repositories accessible to the token/user.
*/
private async fetchAllRepositories(): Promise<Repository[]> {
private async fetchAllRepositories(): Promise<plugins.interfaces.Repository[]> {
let page = 1;
const allRepos: Repository[] = [];
const allRepos: plugins.interfaces.Repository[] = [];
while (true) {
const url = new URL(`${this.baseUrl}/api/v1/repos/search`);
@ -140,7 +96,7 @@ export class CodeFeed {
throw new Error(`Failed to fetch repositories: ${resp.statusText}`);
}
const data: RepoSearchResponse = await resp.json();
const data: plugins.interfaces.RepoSearchResponse = await resp.json();
allRepos.push(...data.data);
if (data.data.length < 50) {
@ -157,7 +113,7 @@ export class CodeFeed {
*/
private async fetchTags(owner: string, repo: string): Promise<Set<string>> {
let page = 1;
const tags: Tag[] = [];
const tags: plugins.interfaces.Tag[] = [];
while (true) {
const url = new URL(`${this.baseUrl}/api/v1/repos/${owner}/${repo}/tags`);
@ -173,7 +129,7 @@ export class CodeFeed {
throw new Error(`Failed to fetch tags for ${owner}/${repo}: ${resp.statusText}`);
}
const data: Tag[] = await resp.json();
const data: plugins.interfaces.Tag[] = await resp.json();
tags.push(...data);
if (data.length < 50) {
@ -195,10 +151,10 @@ export class CodeFeed {
/**
* Fetch commits from the last 24 hours for a repository.
*/
private async fetchRecentCommitsForRepo(owner: string, repo: string): Promise<Commit[]> {
private async fetchRecentCommitsForRepo(owner: string, repo: string): Promise<plugins.interfaces.Commit[]> {
const twentyFourHoursAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);
let page = 1;
const recentCommits: Commit[] = [];
const recentCommits: plugins.interfaces.Commit[] = [];
while (true) {
const url = new URL(`${this.baseUrl}/api/v1/repos/${owner}/${repo}/commits`);
@ -214,7 +170,7 @@ export class CodeFeed {
throw new Error(`Failed to fetch commits for ${owner}/${repo}: ${resp.statusText}`);
}
const data: Commit[] = await resp.json();
const data: plugins.interfaces.Commit[] = await resp.json();
if (data.length === 0) {
break;
}
@ -237,10 +193,10 @@ export class CodeFeed {
/**
* Fetch all commits by querying all organizations.
*/
public async fetchAllCommitsFromInstance(): Promise<CommitResult[]> {
public async fetchAllCommitsFromInstance(): Promise<plugins.interfaces.CommitResult[]> {
const orgs = await this.fetchAllOrganizations();
console.log(`Found ${orgs.length} organizations`);
let allCommits: CommitResult[] = [];
let allCommits: plugins.interfaces.CommitResult[] = [];
for (const orgName of orgs) {
console.log(`Checking activity for organization: ${orgName}`);
@ -284,7 +240,7 @@ export class CodeFeed {
const commits = await this.fetchRecentCommitsForRepo(org, repo);
const commitResults = commits.map((c) => {
const commit: CommitResult = {
const commit: plugins.interfaces.CommitResult = {
baseUrl: this.baseUrl,
org,
repo,
@ -323,9 +279,9 @@ export class CodeFeed {
console.log(`Processed ${allCommits.length} commits in total.`);
for (const c of allCommits) {
console.log(`______________________________________________________
console.log(` ==========================================================================
${c.prettyAgoTime} ago:
Commit ${c.hash} by ${c.org}/${c.repo} at ${c.timestamp}
${c.org}/${c.repo}
${c.commitMessage}
Published on npm: ${c.publishedOnNpm}
`);

44
ts/interfaces/index.ts Normal file
View File

@ -0,0 +1,44 @@
export interface RepositoryOwner {
login: string;
}
export interface Repository {
owner: RepositoryOwner;
name: string;
}
export interface CommitAuthor {
date: string;
}
export interface CommitDetail {
message: string;
author: CommitAuthor;
}
export interface Commit {
sha: string;
commit: CommitDetail;
}
export interface Tag {
commit?: {
sha?: string;
};
}
export interface RepoSearchResponse {
data: Repository[];
}
export interface CommitResult {
baseUrl: string;
org: string;
repo: string;
timestamp: string;
hash: string;
commitMessage: string;
tagged: boolean;
publishedOnNpm: boolean;
prettyAgoTime: string;
}

View File

@ -8,7 +8,8 @@
"esModuleInterop": true,
"verbatimModuleSyntax": true,
"baseUrl": ".",
"paths": {}
"paths": {
}
},
"exclude": [
"dist_*/**/*.d.ts"