Skip to content

Commit

Permalink
Merge pull request #1564 from tgodzik/fix-release-notes
Browse files Browse the repository at this point in the history
bugfix: Fix release notes
tgodzik authored Dec 17, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 5e97232 + 85de908 commit 90f589a
Showing 3 changed files with 28 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/metals-vscode/package.json
Original file line number Diff line number Diff line change
@@ -1123,6 +1123,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",
@@ -1147,7 +1148,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"
23 changes: 19 additions & 4 deletions packages/metals-vscode/src/releaseNotesProvider.ts
Original file line number Diff line number Diff line change
@@ -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<string> {
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(
</p>
<hr>
<p>
<a href="${authorUrl}" target="_blank" itemprop="url">
<span itemprop="name">${author}</span>
<a href="${currentAuthor.url}" target="_blank" itemprop="url">
<span itemprop="name">${currentAuthor.name}</span>
</a>
</p>
<hr>
7 changes: 6 additions & 1 deletion packages/metals-vscode/yarn.lock
Original file line number Diff line number Diff line change
@@ -130,6 +130,11 @@
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.4.tgz#e913e8175db8307d78b4e8fa690408ba6b65dee4"
integrity sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==

"@types/[email protected]":
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==

[email protected], 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==

0 comments on commit 90f589a

Please sign in to comment.