diff --git a/changelog.md b/changelog.md index 129ec4d..cda82b9 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2024-12-13 - 1.4.0 - feat(CodeFeed) +Enhance commit results with human-readable time + +- Integrated smarttime plugin to calculate and format timestamps into human-readable time. +- Updated dependencies in package.json to include smarttime and adjusted versions for existing packages. +- Improved fetchAllCommitsFromInstance method to display formatted time ago information for each commit. + ## 2024-12-13 - 1.3.0 - feat(core) Export CommitResult interface for external use. diff --git a/package.json b/package.json index 4be141b..98f7ede 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "license": "MIT", "scripts": { "test": "(tstest test/ --web)", - "build": "(tsbuild --web --allowimplicitany)", + "build": "(tsbuild tsfolders --web --allowimplicitany)", "buildDocs": "(tsdoc)" }, "devDependencies": { @@ -19,11 +19,12 @@ "@git.zone/tsrun": "^1.2.46", "@git.zone/tstest": "^1.0.44", "@push.rocks/tapbundle": "^5.0.15", - "@types/node": "^20.8.7" + "@types/node": "^22.10.2" }, "dependencies": { "@push.rocks/qenv": "^6.1.0", "@push.rocks/smartnpm": "^2.0.4", + "@push.rocks/smarttime": "^4.1.1", "@push.rocks/smartxml": "^1.0.8" }, "repository": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3cd4622..e19a843 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: '@push.rocks/smartnpm': specifier: ^2.0.4 version: 2.0.4 + '@push.rocks/smarttime': + specifier: ^4.1.1 + version: 4.1.1 '@push.rocks/smartxml': specifier: ^1.0.8 version: 1.0.8 @@ -34,8 +37,8 @@ importers: specifier: ^5.0.15 version: 5.5.3(@aws-sdk/client-sso-oidc@3.709.0(@aws-sdk/client-sts@3.709.0))(@aws-sdk/credential-providers@3.709.0(@aws-sdk/client-sso-oidc@3.709.0(@aws-sdk/client-sts@3.709.0)))(socks@2.8.3) '@types/node': - specifier: ^20.8.7 - version: 20.17.10 + specifier: ^22.10.2 + version: 22.10.2 packages: @@ -842,8 +845,8 @@ packages: '@push.rocks/smartstring@4.0.15': resolution: {integrity: sha512-NTNeOjWyg+aHtBTiQEyXamr7oTvYZ3wS1fudHo9ua7CLrykpK+i+RxFyJaLg1zB5x9xQF3NLEQecB14HPFX8Cg==} - '@push.rocks/smarttime@4.0.8': - resolution: {integrity: sha512-He+1ebBowVd8rW+VHZMFmz407xVMQf/JbyKr3s1ozoIlJS1AhZpDvlkzyqLV2tNMP1/cEBeo25ImJN2x1pksBA==} + '@push.rocks/smarttime@4.1.1': + resolution: {integrity: sha512-Ha/3J/G+zfTl4ahpZgF6oUOZnUjpLhrBja0OQ2cloFxF9sKT8I1COaSqIfBGDtoK2Nly4UD4aTJ3JcJNOg/kgA==} '@push.rocks/smartunique@3.0.9': resolution: {integrity: sha512-q6DYQgT7/dqdWi9HusvtWCjdsFzLFXY9LTtaZV6IYNJt6teZOonoygxTdNt9XLn6niBSbLYrHSKvJNTRH/uK+g==} @@ -1391,8 +1394,8 @@ packages: '@types/node-forge@1.3.11': resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==} - '@types/node@20.17.10': - resolution: {integrity: sha512-/jrvh5h6NXhEauFFexRin69nA0uHJ5gwk4iDivp/DeoEua3uwCUto6PC86IpRITBOs4+6i2I56K5x5b6WYGXHA==} + '@types/node@22.10.2': + resolution: {integrity: sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==} '@types/parse5@6.0.3': resolution: {integrity: sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==} @@ -1862,9 +1865,9 @@ packages: resolution: {integrity: sha512-9pSLe+tDJnmNak2JeMkz6ZmTCXP5p6vCxSd4kvDqrTJkqAP62j2uAEIZjf8cPDZIakStujqVzh5Y5MIWH3yYAw==} engines: {node: '>=6.0'} - croner@7.0.8: - resolution: {integrity: sha512-4E27J9ZQV9prM9ggU18QGPYPMSblbA9JuGv4Ff3Gk6supX4RszNGQxBgiFBL6wb/L9HuSMpFbQpduMiDRo+z5Q==} - engines: {node: '>=6.0'} + croner@9.0.0: + resolution: {integrity: sha512-onMB0OkDjkXunhdW9htFjEhqrD54+M94i6ackoUkjHKbRnXdyEyKRelp4nJ1kAz32+s27jP1FsebpJCVl0BsvA==} + engines: {node: '>=18.0'} cross-fetch@3.1.5: resolution: {integrity: sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==} @@ -1880,6 +1883,9 @@ packages: resolution: {integrity: sha512-KWjTXWwxFd6a94m5CdRGW/t82Tr8DoBc9dNnPCAbFI1EBweN6v1tv8y4Y1m7ndkp/nkIBRxUxAzpaBnR2k3bcQ==} engines: {node: '>=14.16'} + date-fns@4.1.0: + resolution: {integrity: sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==} + dayjs@1.11.13: resolution: {integrity: sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==} @@ -3231,6 +3237,10 @@ packages: resolution: {integrity: sha512-Tpb8Z7r7XbbtBTrM9UhpkzzaMrqA2VXMT3YChzYltwV3P3pM6t8wl7TvpMnSTosz1aQAdVib7kdoys7vYOPerw==} engines: {node: '>=12'} + parse-ms@4.0.0: + resolution: {integrity: sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==} + engines: {node: '>=18'} + parse5@6.0.1: resolution: {integrity: sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==} @@ -3322,6 +3332,10 @@ packages: resolution: {integrity: sha512-ASJqOugUF1bbzI35STMBUpZqdfYKlJugy6JBziGi2EE+AL5JPJGSzvpeVXojxrr0ViUYoToUjb5kjSEGf7Y83Q==} engines: {node: '>=14.16'} + pretty-ms@9.2.0: + resolution: {integrity: sha512-4yf0QO/sllf/1zbZWYnvWw3NxCQwLXKzIj0G849LSufP15BXKM0rbD2Z3wVnkMfjdn/CB0Dpp444gYAACdsplg==} + engines: {node: '>=18'} + process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} @@ -3841,8 +3855,8 @@ packages: unbzip2-stream@1.4.3: resolution: {integrity: sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==} - undici-types@6.19.8: - resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} + undici-types@6.20.0: + resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} unified@11.0.5: resolution: {integrity: sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==} @@ -4110,7 +4124,7 @@ snapshots: '@push.rocks/smartrx': 3.0.7 '@push.rocks/smartsitemap': 2.0.3 '@push.rocks/smartstream': 3.2.5 - '@push.rocks/smarttime': 4.0.8 + '@push.rocks/smarttime': 4.1.1 '@push.rocks/taskbuffer': 3.1.7 '@push.rocks/webrequest': 3.0.37 '@push.rocks/webstore': 2.0.20 @@ -5051,7 +5065,7 @@ snapshots: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/yargs': 17.0.33 chalk: 4.1.2 @@ -5189,7 +5203,7 @@ snapshots: '@push.rocks/smartmatch': 2.0.0 '@push.rocks/smartpromise': 4.0.4 '@push.rocks/smartrx': 3.0.7 - '@push.rocks/smarttime': 4.0.8 + '@push.rocks/smarttime': 4.1.1 '@types/minimatch': 5.1.2 '@types/symbol-tree': 3.2.5 symbol-tree: 3.2.4 @@ -5299,7 +5313,7 @@ snapshots: '@push.rocks/smartpromise': 4.0.4 '@push.rocks/smartrx': 3.0.7 '@push.rocks/smartstring': 4.0.15 - '@push.rocks/smarttime': 4.0.8 + '@push.rocks/smarttime': 4.1.1 '@push.rocks/smartunique': 3.0.9 '@push.rocks/taskbuffer': 3.1.7 '@tsclass/tsclass': 4.2.0 @@ -5492,7 +5506,7 @@ snapshots: '@push.rocks/smartpath': 5.0.18 '@push.rocks/smartpromise': 4.0.4 '@push.rocks/smartrequest': 2.0.23 - '@push.rocks/smarttime': 4.0.8 + '@push.rocks/smarttime': 4.1.1 '@push.rocks/smartversion': 3.0.5 package-json: 8.1.1 transitivePeerDependencies: @@ -5615,7 +5629,7 @@ snapshots: '@push.rocks/smartlog': 3.0.7 '@push.rocks/smartpromise': 4.0.4 '@push.rocks/smartrx': 3.0.7 - '@push.rocks/smarttime': 4.0.8 + '@push.rocks/smarttime': 4.1.1 engine.io: 6.5.4 socket.io: 4.7.5 socket.io-client: 4.7.5 @@ -5669,15 +5683,16 @@ snapshots: strip-indent: 4.0.0 url: 0.11.4 - '@push.rocks/smarttime@4.0.8': + '@push.rocks/smarttime@4.1.1': dependencies: '@push.rocks/lik': 6.1.0 '@push.rocks/smartdelay': 3.0.5 '@push.rocks/smartpromise': 4.0.4 - croner: 7.0.8 + croner: 9.0.0 + date-fns: 4.1.0 dayjs: 1.11.13 is-nan: 1.3.2 - pretty-ms: 8.0.0 + pretty-ms: 9.2.0 '@push.rocks/smartunique@3.0.9': dependencies: @@ -5718,7 +5733,7 @@ snapshots: '@push.rocks/smartrequest': 2.0.23 '@push.rocks/smarts3': 2.2.5 '@push.rocks/smartshell': 3.2.0 - '@push.rocks/smarttime': 4.0.8 + '@push.rocks/smarttime': 4.1.1 expect: 29.7.0 transitivePeerDependencies: - '@aws-sdk/client-sso-oidc' @@ -5741,7 +5756,7 @@ snapshots: '@push.rocks/smartlog': 3.0.7 '@push.rocks/smartpromise': 4.0.4 '@push.rocks/smartrx': 3.0.7 - '@push.rocks/smarttime': 4.0.8 + '@push.rocks/smarttime': 4.1.1 '@push.rocks/smartunique': 3.0.9 '@push.rocks/webrequest@3.0.37': @@ -6326,14 +6341,14 @@ snapshots: '@types/accepts@1.3.7': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/babel__code-frame@7.0.6': {} '@types/body-parser@1.19.5': dependencies: '@types/connect': 3.4.38 - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/buffer-json@2.0.3': {} @@ -6349,17 +6364,17 @@ snapshots: '@types/clean-css@4.2.11': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 source-map: 0.6.1 '@types/co-body@6.1.3': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/qs': 6.9.17 '@types/connect@3.4.38': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/content-disposition@0.5.8': {} @@ -6372,11 +6387,11 @@ snapshots: '@types/connect': 3.4.38 '@types/express': 5.0.0 '@types/keygrip': 1.0.6 - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/cors@2.8.17': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/debounce@1.2.4': {} @@ -6390,14 +6405,14 @@ snapshots: '@types/express-serve-static-core@4.19.6': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/qs': 6.9.17 '@types/range-parser': 1.2.7 '@types/send': 0.17.4 '@types/express-serve-static-core@5.0.2': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/qs': 6.9.17 '@types/range-parser': 1.2.7 '@types/send': 0.17.4 @@ -6422,30 +6437,30 @@ snapshots: '@types/from2@2.3.5': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/fs-extra@11.0.4': dependencies: '@types/jsonfile': 6.1.4 - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/fs-extra@9.0.13': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/glob@7.2.0': dependencies: '@types/minimatch': 5.1.2 - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/glob@8.1.0': dependencies: '@types/minimatch': 5.1.2 - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/gunzip-maybe@1.4.2': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/hast@3.0.4': dependencies: @@ -6479,7 +6494,7 @@ snapshots: '@types/jsonfile@6.1.4': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/keygrip@1.0.6': {} @@ -6496,7 +6511,7 @@ snapshots: '@types/http-errors': 2.0.4 '@types/keygrip': 1.0.6 '@types/koa-compose': 3.2.8 - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/mdast@4.0.4': dependencies: @@ -6514,11 +6529,11 @@ snapshots: '@types/node-forge@1.3.11': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 - '@types/node@20.17.10': + '@types/node@22.10.2': dependencies: - undici-types: 6.19.8 + undici-types: 6.20.0 '@types/parse5@6.0.3': {} @@ -6534,19 +6549,19 @@ snapshots: '@types/s3rver@3.7.4': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/semver@7.5.8': {} '@types/send@0.17.4': dependencies: '@types/mime': 1.3.5 - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/serve-static@1.15.7': dependencies: '@types/http-errors': 2.0.4 - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/send': 0.17.4 '@types/sinon-chai@3.2.12': @@ -6566,11 +6581,11 @@ snapshots: '@types/tar-stream@2.2.3': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/through2@2.0.41': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/triple-beam@1.3.5': {} @@ -6594,7 +6609,7 @@ snapshots: '@types/whatwg-url@8.2.2': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/webidl-conversions': 7.0.3 '@types/which@2.0.2': {} @@ -6603,11 +6618,11 @@ snapshots: '@types/ws@7.4.7': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/ws@8.5.13': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 '@types/yargs-parser@21.0.3': {} @@ -6617,7 +6632,7 @@ snapshots: '@types/yauzl@2.10.3': dependencies: - '@types/node': 20.17.10 + '@types/node': 22.10.2 optional: true '@ungap/structured-clone@1.2.1': {} @@ -7034,7 +7049,7 @@ snapshots: croner@5.7.0: {} - croner@7.0.8: {} + croner@9.0.0: {} cross-fetch@3.1.5: dependencies: @@ -7057,6 +7072,8 @@ snapshots: dependencies: type-fest: 2.19.0 + date-fns@4.1.0: {} + dayjs@1.11.13: {} debounce@1.2.1: {} @@ -7200,7 +7217,7 @@ snapshots: dependencies: '@types/cookie': 0.4.1 '@types/cors': 2.8.17 - '@types/node': 20.17.10 + '@types/node': 22.10.2 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.4.2 @@ -7892,7 +7909,7 @@ snapshots: jest-util@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 20.17.10 + '@types/node': 22.10.2 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -8689,6 +8706,8 @@ snapshots: parse-ms@3.0.0: {} + parse-ms@4.0.0: {} + parse5@6.0.1: {} parseurl@1.3.3: {} @@ -8763,6 +8782,10 @@ snapshots: dependencies: parse-ms: 3.0.0 + pretty-ms@9.2.0: + dependencies: + parse-ms: 4.0.0 + process-nextick-args@2.0.1: {} progress@2.0.3: {} @@ -9386,7 +9409,7 @@ snapshots: buffer: 5.7.1 through: 2.3.8 - undici-types@6.19.8: {} + undici-types@6.20.0: {} unified@11.0.5: dependencies: diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 77e28c4..4243bd5 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -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' } diff --git a/ts/codefeed.plugins.ts b/ts/codefeed.plugins.ts index bdb6cc3..0ad4b25 100644 --- a/ts/codefeed.plugins.ts +++ b/ts/codefeed.plugins.ts @@ -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, } \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts index 51d8bfc..4612c42 100644 --- a/ts/index.ts +++ b/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}