From c621ab9db125ad73fb8817f6dc1f37a0c2451e38 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Tue, 23 Apr 2024 19:20:02 +0200 Subject: [PATCH] fix: correct upcoming release date after patch releases (#557) fix: correct next release date after patch releases --- src/_data/stats.json | 8 ++++---- tools/fetch-stats.js | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/_data/stats.json b/src/_data/stats.json index 55d2e0862..c80ca06cb 100644 --- a/src/_data/stats.json +++ b/src/_data/stats.json @@ -4,10 +4,10 @@ "currentVersion": "v9.1.1", "currentVersionDate": "2024-04-22T19:23:14Z", "currentVersionIsPrerelease": false, - "stars": 24270, - "lastCommitDate": "2024-04-23T02:08:58Z", - "projectDependents": 19255405, + "stars": 24271, + "lastCommitDate": "2024-04-23T10:56:02Z", + "projectDependents": 19264226, "weeklyDownloads": 38275199, "nextVersion": "v9.2.0", - "nextVersionDate": "2024-05-10" + "nextVersionDate": "2024-05-03" } \ No newline at end of file diff --git a/tools/fetch-stats.js b/tools/fetch-stats.js index cdedde57d..574dd5b0d 100644 --- a/tools/fetch-stats.js +++ b/tools/fetch-stats.js @@ -194,9 +194,21 @@ async function fetchGitHubNetworkStats() { stats.nextVersion = `v${nextVersion}`; - // approximate next release date - stats.nextVersionDate = DateTime.fromISO(stats.currentVersionDate) - .plus({ weeks: 2 }).endOf("week").minus({ days: 2 }).toISODate(); + /* + * Calculate next release date. + * We do scheduled releases every two weeks, on Fridays. + * One of the scheduled release dates was Friday, 2024-01-12. We'll use that date as the baseline. + * So, all planned releases are expected to be on 2024-01-12 + n * 14 days. + * Now we'll find the first such day after the current version date. + */ + const baseDate = DateTime.fromISO("2024-01-12"); + const currentVersionDate = DateTime.fromISO(stats.currentVersionDate); + + stats.nextVersionDate = currentVersionDate + .plus({ + days: 14 - currentVersionDate.diff(baseDate, "days").days % 14 + }) + .toISODate(); await fs.writeFile(statsFilePath, JSON.stringify(stats, null, 4), { encoding: "utf8" });