feat(CodeFeed): Enhance commit results with human-readable time
This commit is contained in:
27
ts/index.ts
27
ts/index.ts
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user