From c457d91b7935bb674b99c30096ed832e3363b8cf Mon Sep 17 00:00:00 2001 From: alekhya-cplace Date: Mon, 12 May 2025 08:52:47 +0200 Subject: [PATCH 1/3] PFM-ISSUE-29885:Updated the timestamp to CET in github comments --- tools/scripts/artifacts/utils.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/scripts/artifacts/utils.ts b/tools/scripts/artifacts/utils.ts index e556dee8..da119916 100644 --- a/tools/scripts/artifacts/utils.ts +++ b/tools/scripts/artifacts/utils.ts @@ -287,6 +287,14 @@ export class Utils { public static writePublishedProjectToGithubCommentsFile(message: string) { const gitHubCommentsFile = Utils.getGitHubCommentsFile(); + const currentDate = new Date(); + const dateString = currentDate.toLocaleDateString("en-GB", { + timeZone: "Europe/Berlin", + }); + const timeString = currentDate.toLocaleTimeString("en-GB", { + timeZone: "Europe/Berlin", + }); + if (!fs.existsSync(gitHubCommentsFile)) { fs.writeFileSync(gitHubCommentsFile, `${message}\n`); } else { @@ -299,13 +307,14 @@ export class Utils { fs.writeFileSync( gitHubCommentsFile, `:tada: Snapshots of the following projects have been published: - Last updated: ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()} \n` + Last updated: ${dateString} ${timeString} (CET/CEST) \n` ); } fs.appendFileSync(gitHubCommentsFile, `${message}\n`); } } + public static parseScopeFromPackageJson(): string { const gitRootDir = Utils.getRootDir(); const pathToRootPackageJson = path.join(gitRootDir, NxProject.PACKAGEJSON); From b1438455d2256264bc01dbfc06cf7447af5aefa6 Mon Sep 17 00:00:00 2001 From: alekhya-cplace Date: Mon, 12 May 2025 08:59:06 +0200 Subject: [PATCH 2/3] PFM-ISSUE-29885:format --- tools/scripts/artifacts/utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/scripts/artifacts/utils.ts b/tools/scripts/artifacts/utils.ts index da119916..803b7fed 100644 --- a/tools/scripts/artifacts/utils.ts +++ b/tools/scripts/artifacts/utils.ts @@ -314,7 +314,6 @@ export class Utils { } } - public static parseScopeFromPackageJson(): string { const gitRootDir = Utils.getRootDir(); const pathToRootPackageJson = path.join(gitRootDir, NxProject.PACKAGEJSON); From 4d2bc076a17ea0d10a3eff1bda79ef2366bf631f Mon Sep 17 00:00:00 2001 From: alekhya-cplace Date: Mon, 12 May 2025 10:55:13 +0200 Subject: [PATCH 3/3] PFM-ISSUE-29885:updated unit test --- tools/scripts/artifacts/utils.test.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/scripts/artifacts/utils.test.ts b/tools/scripts/artifacts/utils.test.ts index 7a7ce5c5..f3d8e1f0 100644 --- a/tools/scripts/artifacts/utils.test.ts +++ b/tools/scripts/artifacts/utils.test.ts @@ -157,8 +157,18 @@ test('can get all versions of a npm package', async () => { expect(snapshots).toHaveLength(3); }); -test('can create comments for github actions', () => { +test('can create comments for github actions with CET/CEST timestamp', () => { jest.spyOn(Utils, 'getRootDir').mockReturnValue(rootDir); + + const fixedDate = new Date('2024-05-10T14:30:00Z'); // UTC + const RealDate = Date; + global.Date = class extends RealDate { + constructor() { + super(); + return fixedDate; + } + } as unknown as DateConstructor; + const gitHubCommentsFile = Utils.GITHUB_COMMENTS_FILE; if (fs.existsSync(gitHubCommentsFile)) fs.rmSync(gitHubCommentsFile); Utils.initGithubActionsFile(); @@ -171,11 +181,17 @@ test('can create comments for github actions', () => { let comments = ''; if (fs.existsSync(gitHubCommentsFile)) comments = fs.readFileSync(gitHubCommentsFile).toString(); + + const expectedDate = fixedDate.toLocaleDateString('en-GB', { timeZone: 'Europe/Berlin' }); + const expectedTime = fixedDate.toLocaleTimeString('en-GB', { timeZone: 'Europe/Berlin' }); + expect(comments).toBe( - ':tada: Snapshots of the following projects have been published: \n' + - '@cplace-next/cf-platform@0.0.0-feat-PFM-ISSUE-10014-Notify-the-developer-about-th-488\n' + - '@cplace-next/cf-platform@0.0.0-SNAPSHOT-l484devc-20220610\n' + `:tada: Snapshots of the following projects have been published: + Last updated: ${expectedDate} ${expectedTime} (CET/CEST) \n` + + `@cplace-next/cf-platform@0.0.0-feat-PFM-ISSUE-10014-Notify-the-developer-about-th-488\n` + + `@cplace-next/cf-platform@0.0.0-SNAPSHOT-l484devc-20220610\n` ); + global.Date = RealDate; }); test('parseScopeFromPackageJson can parse scope from packageJson', () => {