From 4e36061ced77e691a39eff70395db2b90b6ceea7 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com> Date: Tue, 18 Mar 2025 15:19:11 +0100 Subject: [PATCH] Add Latest Change Date to Frontend (#3231) * Updated Logic for Versions * Update logic, add date --- .github/workflows/crawl-versions.yaml | 5 +++-- frontend/src/app/api/versions/route.ts | 5 ++--- .../app/scripts/_components/ScriptItem.tsx | 21 ++++++++++++++++++- frontend/src/lib/types.ts | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/crawl-versions.yaml b/.github/workflows/crawl-versions.yaml index b908d1f4d..0c25c839d 100644 --- a/.github/workflows/crawl-versions.yaml +++ b/.github/workflows/crawl-versions.yaml @@ -63,9 +63,10 @@ jobs: jq -r '.projects[] | "\(.id) \(.name)"' "$projects_file" | while read -r id name; do version=$(curl -s -H "X-Key: $token" "https://api.newreleases.io/v1/projects/$id/latest-release") version_data=$(echo "$version" | jq -r '.version // empty') + date=$(echo "$version" | jq -r '.date // empty') if [ -n "$version_data" ]; then - jq --arg name "$name" --arg version "$version_data" \ - '. += [{"name": $name, "version": $version}]' "$output_file" > "$output_file.tmp" && mv "$output_file.tmp" "$output_file" + jq --arg name "$name" --arg version "$version_data" --arg date "$date" \ + '. += [{"name": $name, "version": $version, "date": $date}]' "$output_file" > "$output_file.tmp" && mv "$output_file.tmp" "$output_file" fi done ((page++)) diff --git a/frontend/src/app/api/versions/route.ts b/frontend/src/app/api/versions/route.ts index 6adfd7fd6..db891600f 100644 --- a/frontend/src/app/api/versions/route.ts +++ b/frontend/src/app/api/versions/route.ts @@ -17,9 +17,8 @@ const getVersions = async () => { const versions: AppVersion[] = JSON.parse(fileContent); const modifiedVersions = versions.map(version => { - const nameParts = version.name.split('/'); - let newName = nameParts[nameParts.length - 1]; - newName = newName.toLowerCase().replace(/[^a-z0-9]/g, ''); + let newName = version.name; + newName = newName.toLowerCase().replace(/[^a-z0-9/]/g, ''); return { ...version, name: newName }; }); diff --git a/frontend/src/app/scripts/_components/ScriptItem.tsx b/frontend/src/app/scripts/_components/ScriptItem.tsx index 7199b808d..8d3a50039 100644 --- a/frontend/src/app/scripts/_components/ScriptItem.tsx +++ b/frontend/src/app/scripts/_components/ScriptItem.tsx @@ -95,7 +95,26 @@ function ScriptItem({
Loading versions...
) : (<>Version:
-{versions.find((v) => v.name === item.slug.replace(/[^a-z0-9]/g, ''))?.version || "No Version Information found"}
+{versions.find((v) => + v.name === item.slug.replace(/[^a-z0-9]/g, '') || + v.name.includes(item.slug.replace(/[^a-z0-9]/g, '')) || + v.name.replace(/[^a-z0-9]/g, '') === item.slug.replace(/[^a-z0-9]/g, '') + + )?.version || "No Version information found" + }
+Latest changes:
++ {(() => { + const matchedVersion = versions.find((v) => + v.name === item.slug.replace(/[^a-z0-9]/g, '') || + v.name.includes(item.slug.replace(/[^a-z0-9]/g, '')) || + v.name.replace(/[^a-z0-9]/g, '') === item.slug.replace(/[^a-z0-9]/g, '') + ); + return matchedVersion?.date ? + extractDate(matchedVersion.date as unknown as string) : + "No date information found" + })()} +
>) }