From 85de908276c12a9c17f6a2c2c4b1ea500a9d381e Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Tue, 17 Dec 2024 18:49:15 +0100 Subject: [PATCH] bugfix: Fix release notes --- packages/metals-vscode/package.json | 4 +++- .../metals-vscode/src/releaseNotesProvider.ts | 23 +++++++++++++++---- packages/metals-vscode/yarn.lock | 7 +++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/packages/metals-vscode/package.json b/packages/metals-vscode/package.json index 20960297e..4666ce99f 100644 --- a/packages/metals-vscode/package.json +++ b/packages/metals-vscode/package.json @@ -1122,6 +1122,7 @@ "@types/semver": "^7.3.13", "@types/sinon": "^10.0.13", "@types/vscode": "1.59.0", + "@types/js-yaml": "4.0.9", "@typescript-eslint/eslint-plugin": "^5.56.0", "@typescript-eslint/parser": "^5.56.0", "@vscode/test-electron": "^2.3.0", @@ -1146,7 +1147,8 @@ "metals-languageclient": "file:../metals-languageclient", "promisify-child-process": "4.1.1", "semver": "^7.5.2", - "vscode-languageclient": "8.1.0" + "vscode-languageclient": "8.1.0", + "js-yaml": "4.1.0" }, "extensionPack": [ "scala-lang.scala" diff --git a/packages/metals-vscode/src/releaseNotesProvider.ts b/packages/metals-vscode/src/releaseNotesProvider.ts index b1a823631..df3eef142 100644 --- a/packages/metals-vscode/src/releaseNotesProvider.ts +++ b/packages/metals-vscode/src/releaseNotesProvider.ts @@ -5,6 +5,7 @@ import path from "path"; import { fetchFrom } from "./util"; import { Either, makeLeft, makeRight } from "./types"; import { marked } from "marked"; +import { load } from "js-yaml"; const versionKey = "metals-server-version"; type CalledOn = "onExtensionStart" | "onUserDemand"; @@ -182,6 +183,16 @@ async function getMarkdownLink( } } +interface Author { + name: string; + url: string; + image_url: string[]; +} + +interface Authors { + [key: string]: Author; +} + /** * * @param releaseNotesUrl Url which server markdown with release notes @@ -199,6 +210,10 @@ async function getReleaseNotesMarkdown( asWebviewUri: (_: vscode.Uri) => vscode.Uri ): Promise { const text = await fetchFrom(releaseNotesUrl); + const authorsYaml = await fetchFrom( + "https://raw.githubusercontent.com/scalameta/metals/main/website/blog/authors.yml" + ); + const authors = load(authorsYaml) as Authors; // every release notes starts with metadata format const tripleDash = "---"; const firstTripleDash = text.indexOf(tripleDash); @@ -213,9 +228,9 @@ async function getReleaseNotesMarkdown( .replace(tripleDash, "") .trim() .split("\n"); - const author = metadata[0].slice("author: ".length); + const authorLogin = metadata[0].slice("authors: ".length); + const currentAuthor = authors[authorLogin]; const title = metadata[1].slice("title: ".length); - const authorUrl = metadata[2].slice("authorURL: ".length); const renderedNotes = marked.parse(releaseNotes); // Uri with additional styles for webview @@ -250,8 +265,8 @@ async function getReleaseNotesMarkdown(


-


diff --git a/packages/metals-vscode/yarn.lock b/packages/metals-vscode/yarn.lock index c0caacf93..73be30096 100644 --- a/packages/metals-vscode/yarn.lock +++ b/packages/metals-vscode/yarn.lock @@ -130,6 +130,11 @@ resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.4.tgz#e913e8175db8307d78b4e8fa690408ba6b65dee4" integrity sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw== +"@types/js-yaml@4.0.9": + version "4.0.9" + resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.9.tgz#cd82382c4f902fed9691a2ed79ec68c5898af4c2" + integrity sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg== + "@types/json-schema@^7.0.9": version "7.0.11" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" @@ -1379,7 +1384,7 @@ js-sdsl@^4.1.4: resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.1.4.tgz#78793c90f80e8430b7d8dc94515b6c77d98a26a6" integrity sha512-Y2/yD55y5jteOAmY50JbUZYwk3CP3wnLPEZnlR1w9oKhITrBEtAxwuWKebFf8hMrPMgbYwFoWK/lH2sBkErELw== -js-yaml@4.1.0, js-yaml@^4.1.0: +js-yaml@4.0.9, js-yaml@4.1.0, js-yaml@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==