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

@@ -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}