feat(CodeFeed): Enhance commit results with human-readable time

This commit is contained in:
2024-12-13 22:15:33 +01:00
parent d23a27eb66
commit 46bd0a2486
6 changed files with 108 additions and 68 deletions

View File

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

View File

@ -2,9 +2,11 @@
import * as qenv from '@push.rocks/qenv';
import * as smartnpm from '@push.rocks/smartnpm';
import * as smartxml from '@push.rocks/smartxml';
import * as smarttime from '@push.rocks/smarttime';
export {
qenv,
smartnpm,
smartxml,
smarttime,
}

View File

@ -42,6 +42,7 @@ export interface CommitResult {
commitMessage: string;
tagged: boolean;
publishedOnNpm: boolean;
prettyAgoTime: string;
}
export class CodeFeed {
@ -282,16 +283,20 @@ export class CodeFeed {
const taggedCommitShas = await this.fetchTags(org, repo);
const commits = await this.fetchRecentCommitsForRepo(org, repo);
const commitResults = commits.map((c) => ({
baseUrl: this.baseUrl,
org,
repo,
timestamp: c.commit.author.date,
hash: c.sha,
commitMessage: c.commit.message,
tagged: taggedCommitShas.has(c.sha),
publishedOnNpm: false,
}));
const commitResults = commits.map((c) => {
const commit: CommitResult = {
baseUrl: this.baseUrl,
org,
repo,
timestamp: c.commit.author.date,
prettyAgoTime: plugins.smarttime.getMilliSecondsAsHumanReadableAgoTime(new Date(c.commit.author.date).getTime()),
hash: c.sha,
commitMessage: c.commit.message,
tagged: taggedCommitShas.has(c.sha),
publishedOnNpm: false,
}
return commit;
});
if (commitResults.length > 0) {
try {
@ -319,6 +324,8 @@ export class CodeFeed {
console.log(`Processed ${allCommits.length} commits in total.`);
for (const c of allCommits) {
console.log(`______________________________________________________
${c.prettyAgoTime}
${c.timestamp}
Commit ${c.hash} by ${c.org}/${c.repo} at ${c.timestamp}
${c.commitMessage}
Published on npm: ${c.publishedOnNpm}