feat(CodeFeed): Enhance commit results with human-readable time
This commit is contained in:
@ -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'
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
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