From d932c9ad98879569ba13c1fc8d7776afaf555b8c Mon Sep 17 00:00:00 2001 From: Lexus Drumgold Date: Sat, 4 Nov 2023 23:18:48 -0400 Subject: [PATCH] fix(changelog): current date Signed-off-by: Lexus Drumgold --- .github/workflows/release-branch.yml | 2 ++ .github/workflows/release.yml | 2 ++ __fixtures__/changelog/today.ts | 2 +- .../models/__tests__/changelog-entry.model.spec.ts | 2 +- .../changelog/models/changelog-entry.model.ts | 14 +++++++++++++- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-branch.yml b/.github/workflows/release-branch.yml index 091795b7..5f8f5775 100644 --- a/.github/workflows/release-branch.yml +++ b/.github/workflows/release-branch.yml @@ -105,6 +105,8 @@ jobs: run: node ./dist/cli.mjs bump -w ${{ needs.preflight.outputs.version }} - id: changelog name: Add CHANGELOG entry for ${{ needs.preflight.outputs.tag }} + env: + TZ: ${{ vars.TZ }} run: | echo "$(node ./dist/cli.mjs changelog)" >>$GITHUB_STEP_SUMMARY node ./dist/cli.mjs changelog -sw diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16f4d73f..270c16da 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -117,6 +117,8 @@ jobs: run: yarn pack -o %s-%v.tgz - id: release-notes name: Generate release notes + env: + TZ: ${{ vars.TZ }} run: | node ./dist/cli.mjs changelog -wo $NOTES_FILE echo "$(cat $NOTES_FILE)" >>$GITHUB_STEP_SUMMARY diff --git a/__fixtures__/changelog/today.ts b/__fixtures__/changelog/today.ts index b01585dc..cf577be1 100644 --- a/__fixtures__/changelog/today.ts +++ b/__fixtures__/changelog/today.ts @@ -3,4 +3,4 @@ * @module tests/fixtures/changelog/today */ -export default '2023-09-25' +export default '2023-09-25T00:00:00-04:00' diff --git a/src/subdomains/changelog/models/__tests__/changelog-entry.model.spec.ts b/src/subdomains/changelog/models/__tests__/changelog-entry.model.spec.ts index 1e5bb5ac..9caf5ac6 100644 --- a/src/subdomains/changelog/models/__tests__/changelog-entry.model.spec.ts +++ b/src/subdomains/changelog/models/__tests__/changelog-entry.model.spec.ts @@ -58,7 +58,7 @@ describe('unit:changelog/models/ChangelogEntry', () => { }) it('should set #date', () => { - expect(subject).to.have.property('date', today) + expect(subject).to.have.property('date', today.replace(/T.+/, '')) }) it('should set #groups', () => { diff --git a/src/subdomains/changelog/models/changelog-entry.model.ts b/src/subdomains/changelog/models/changelog-entry.model.ts index 5867e971..6f39b2c0 100644 --- a/src/subdomains/changelog/models/changelog-entry.model.ts +++ b/src/subdomains/changelog/models/changelog-entry.model.ts @@ -236,8 +236,20 @@ class ChangelogEntry implements IChangelogEntry { */ const key: Optional = commits.find(c => c.version === release) + /** + * Current date. + * + * @const {string} today + */ + const today: string = new Intl.DateTimeFormat('fr-ca', { + day: '2-digit', + month: '2-digit', + timeZone: process.env.TZ, + year: 'numeric' + }).format(new Date()) + // set entry date - this.date = get(key, 'date', new Date().toJSON()).replace(/T.+/, '') + this.date = get(key, 'date', today).replace(/T.+/, '') this.key = fallback(key, at(commits, 0)) // throw if key commit was not found