From 2160c8631527f619f246b444a08a2e3026c6bccc Mon Sep 17 00:00:00 2001 From: MikuroXina Date: Mon, 4 Sep 2023 21:18:02 +0900 Subject: [PATCH 1/6] Update type validation --- src/lib/member-fetch.ts | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/lib/member-fetch.ts b/src/lib/member-fetch.ts index 24654ee0..8c49b2d3 100644 --- a/src/lib/member-fetch.ts +++ b/src/lib/member-fetch.ts @@ -1,6 +1,6 @@ import YAML from "yaml"; -export type SNSLinkInfo = { type: "twitter"; url: string } | { type: "github"; url: string }; +export type SNSLinkInfo = { type: "twitter"; name: string } | { type: "github"; name: string }; function validateSNSLink(obj: unknown): obj is SNSLinkInfo { if (typeof obj !== "object" || obj == null) { @@ -12,7 +12,7 @@ function validateSNSLink(obj: unknown): obj is SNSLinkInfo { console.error("unknown type from: ", obj); return false; } - if (!("url" in obj && typeof (obj as SNSLinkInfo).url === "string")) { + if (!("url" in obj && typeof (obj as SNSLinkInfo).name === "string")) { console.error("`url` not in: ", obj); return false; } @@ -28,10 +28,8 @@ function validateSNSLinks(links: unknown): links is readonly SNSLinkInfo[] { } export type Member = { - avatar: string; - name: string; - role: string; - links: readonly SNSLinkInfo[]; + username: string; + associatedLinks: readonly SNSLinkInfo[]; }; function validateMember(obj: unknown): obj is Member { @@ -40,19 +38,11 @@ function validateMember(obj: unknown): obj is Member { return false; } - if (typeof (obj as Member).avatar !== "string") { + if (typeof (obj as Member).username !== "string") { console.error("`avatar` not in: ", obj); return false; } - if (typeof (obj as Member).name !== "string") { - console.error("`name` not in: ", obj); - return false; - } - if (typeof (obj as Member).role !== "string") { - console.error("`role` not in: ", obj); - return false; - } - if (!validateSNSLinks((obj as Member).links)) { + if (!validateSNSLinks((obj as Member).associatedLinks)) { console.error("`links` not in: ", obj); return false; } @@ -68,13 +58,16 @@ function validateMembers(obj: unknown): obj is readonly Member[] { ); } -const membersUrl = "https://github.com/approvers/site-data/raw/master/data/members/list.yaml"; +const membersUrl = "https://members.approvers.dev/members"; export async function getMembers(): Promise { const res = await fetch(membersUrl); - const parsed = YAML.parse(await res.text()); + if (!res.ok) { + throw new Error("members-assoc unavailable"); + } + const parsed = await res.json(); if (!validateMembers(parsed)) { - throw "invalid list format"; + throw new Error("invalid list format"); } return parsed; } From fdb3736c163e0a05a9ac9e619e89110d66679d05 Mon Sep 17 00:00:00 2001 From: MikuroXina Date: Mon, 4 Sep 2023 21:18:12 +0900 Subject: [PATCH 2/6] Support new format --- src/components/sns-link.tsx | 10 +++++++-- src/pages/member.tsx | 41 ++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/components/sns-link.tsx b/src/components/sns-link.tsx index cdc8c953..be9b48d0 100644 --- a/src/components/sns-link.tsx +++ b/src/components/sns-link.tsx @@ -14,10 +14,16 @@ const icons: Record = { }, }; -export const SNSLink = ({ type, url }: SNSLinkInfo): JSX.Element => { +export const SNSLink = ({ type, name }: SNSLinkInfo): JSX.Element => { const { icon } = icons[type]; return ( - + ); diff --git a/src/pages/member.tsx b/src/pages/member.tsx index 5478b687..2dd9b71c 100644 --- a/src/pages/member.tsx +++ b/src/pages/member.tsx @@ -17,22 +17,29 @@ import { Title } from "../components/title"; const alternative = "/alternative.png"; -const MemberCard = ({ name, role, links, avatar }: Member): JSX.Element => ( - - - - - {name} - - {role} - - {links.map((link, i) => ( - - ))} - - - -); +const MemberCard = ({ username, associatedLinks }: Member): JSX.Element => { + const githubIndex = associatedLinks.findIndex(({ type }) => type === "github"); + const avatar = + githubIndex === -1 + ? alternative + : `https://github.com/${associatedLinks[githubIndex].name}.png`; + + return ( + + + + + {username} + + + {associatedLinks.map((link, i) => ( + + ))} + + + + ); +}; type MembersPageProps = { members: readonly Member[]; @@ -46,7 +53,7 @@ const MembersPage: NextPage = ({ members }) => { メンバー紹介 {members.map((member) => ( - + ))} From 524b46004e1ead66dbf8ef9fca4b20284a3f8b36 Mon Sep 17 00:00:00 2001 From: MikuroXina Date: Mon, 4 Sep 2023 21:20:47 +0900 Subject: [PATCH 3/6] Fix validation bug --- src/lib/member-fetch.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib/member-fetch.ts b/src/lib/member-fetch.ts index 8c49b2d3..244ac734 100644 --- a/src/lib/member-fetch.ts +++ b/src/lib/member-fetch.ts @@ -1,5 +1,3 @@ -import YAML from "yaml"; - export type SNSLinkInfo = { type: "twitter"; name: string } | { type: "github"; name: string }; function validateSNSLink(obj: unknown): obj is SNSLinkInfo { @@ -12,8 +10,8 @@ function validateSNSLink(obj: unknown): obj is SNSLinkInfo { console.error("unknown type from: ", obj); return false; } - if (!("url" in obj && typeof (obj as SNSLinkInfo).name === "string")) { - console.error("`url` not in: ", obj); + if (!("name" in obj && typeof (obj as SNSLinkInfo).name === "string")) { + console.error("`name` not in: ", obj); return false; } return true; @@ -43,7 +41,7 @@ function validateMember(obj: unknown): obj is Member { return false; } if (!validateSNSLinks((obj as Member).associatedLinks)) { - console.error("`links` not in: ", obj); + console.error("`associatedLinks` not in: ", obj); return false; } From e2998059279d1003f8d83dc134778d306221c94e Mon Sep 17 00:00:00 2001 From: MikuroXina Date: Tue, 3 Oct 2023 00:11:52 +0900 Subject: [PATCH 4/6] Sort with type --- src/pages/member.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/member.tsx b/src/pages/member.tsx index 2dd9b71c..28e32e46 100644 --- a/src/pages/member.tsx +++ b/src/pages/member.tsx @@ -18,11 +18,13 @@ import { Title } from "../components/title"; const alternative = "/alternative.png"; const MemberCard = ({ username, associatedLinks }: Member): JSX.Element => { - const githubIndex = associatedLinks.findIndex(({ type }) => type === "github"); + const sortedAssociatedLinks = [...associatedLinks]; + sortedAssociatedLinks.sort((a, b) => a.type.localeCompare(b.type)); + const githubIndex = sortedAssociatedLinks.findIndex(({ type }) => type === "github"); const avatar = githubIndex === -1 ? alternative - : `https://github.com/${associatedLinks[githubIndex].name}.png`; + : `https://github.com/${sortedAssociatedLinks[githubIndex].name}.png`; return ( @@ -32,7 +34,7 @@ const MemberCard = ({ username, associatedLinks }: Member): JSX.Element => { {username} - {associatedLinks.map((link, i) => ( + {sortedAssociatedLinks.map((link, i) => ( ))} From 4828e4b648a634455bc7720d52e16dd716e542c7 Mon Sep 17 00:00:00 2001 From: MikuroXina Date: Tue, 3 Oct 2023 00:12:00 +0900 Subject: [PATCH 5/6] Update sdk --- .yarn/sdks/eslint/package.json | 2 +- .yarn/sdks/prettier/index.js | 12 +- .yarn/sdks/prettier/package.json | 2 +- .yarn/sdks/typescript/lib/tsserver.js | 181 ++++++++++++------- .yarn/sdks/typescript/lib/tsserverlibrary.js | 181 ++++++++++++------- .yarn/sdks/typescript/package.json | 2 +- 6 files changed, 233 insertions(+), 147 deletions(-) diff --git a/.yarn/sdks/eslint/package.json b/.yarn/sdks/eslint/package.json index 395a56c6..a244033a 100644 --- a/.yarn/sdks/eslint/package.json +++ b/.yarn/sdks/eslint/package.json @@ -1,6 +1,6 @@ { "name": "eslint", - "version": "8.20.0-sdk", + "version": "8.37.0-sdk", "main": "./lib/api.js", "type": "commonjs" } diff --git a/.yarn/sdks/prettier/index.js b/.yarn/sdks/prettier/index.js index 81f9bec5..25c97854 100755 --- a/.yarn/sdks/prettier/index.js +++ b/.yarn/sdks/prettier/index.js @@ -1,8 +1,8 @@ #!/usr/bin/env node -const {existsSync} = require(`fs`); -const {createRequire} = require(`module`); -const {resolve} = require(`path`); +const { existsSync } = require(`fs`); +const { createRequire } = require(`module`); +const { resolve } = require(`path`); const relPnpApiPath = "../../../.pnp.cjs"; @@ -11,10 +11,10 @@ const absRequire = createRequire(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { - // Setup the environment to be able to require prettier/index.js + // Setup the environment to be able to require prettier require(absPnpApiPath).setup(); } } -// Defer to the real prettier/index.js your application uses -module.exports = absRequire(`prettier/index.js`); +// Defer to the real prettier your application uses +module.exports = absRequire(`prettier`); diff --git a/.yarn/sdks/prettier/package.json b/.yarn/sdks/prettier/package.json index b61805ce..40e3c2e4 100644 --- a/.yarn/sdks/prettier/package.json +++ b/.yarn/sdks/prettier/package.json @@ -1,6 +1,6 @@ { "name": "prettier", - "version": "2.7.1-sdk", + "version": "2.8.8-sdk", "main": "./index.js", "type": "commonjs" } diff --git a/.yarn/sdks/typescript/lib/tsserver.js b/.yarn/sdks/typescript/lib/tsserver.js index 0fb2ac10..5af71232 100644 --- a/.yarn/sdks/typescript/lib/tsserver.js +++ b/.yarn/sdks/typescript/lib/tsserver.js @@ -1,29 +1,31 @@ #!/usr/bin/env node -const {existsSync} = require(`fs`); -const {createRequire} = require(`module`); -const {resolve} = require(`path`); +const { existsSync } = require(`fs`); +const { createRequire } = require(`module`); +const { resolve } = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absRequire = createRequire(absPnpApiPath); -const moduleWrapper = tsserver => { +const moduleWrapper = (tsserver) => { if (!process.versions.pnp) { return tsserver; } - const {isAbsolute} = require(`path`); + const { isAbsolute } = require(`path`); const pnpApi = require(`pnpapi`); - const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//); - const isPortal = str => str.startsWith("portal:/"); - const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`); + const isVirtual = (str) => str.match(/\/(\$\$virtual|__virtual__)\//); + const isPortal = (str) => str.startsWith("portal:/"); + const normalize = (str) => str.replace(/\\/g, `/`).replace(/^\/?/, `/`); - const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => { - return `${locator.name}@${locator.reference}`; - })); + const dependencyTreeRoots = new Set( + pnpApi.getDependencyTreeRoots().map((locator) => { + return `${locator.name}@${locator.reference}`; + }), + ); // VSCode sends the zip paths to TS using the "zip://" prefix, that TS // doesn't understand. This layer makes sure to remove the protocol @@ -31,7 +33,11 @@ const moduleWrapper = tsserver => { function toEditorPath(str) { // We add the `zip:` prefix to both `.zip/` paths and virtual paths - if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) { + if ( + isAbsolute(str) && + !str.match(/^\^?(zip:|\/zip\/)/) && + (str.match(/\.zip\//) || isVirtual(str)) + ) { // We also take the opportunity to turn virtual paths into physical ones; // this makes it much easier to work with workspaces that list peer // dependencies, since otherwise Ctrl+Click would bring us to the virtual @@ -45,7 +51,11 @@ const moduleWrapper = tsserver => { const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str; if (resolved) { const locator = pnpApi.findPackageLocator(resolved); - if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) { + if ( + locator && + (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || + isPortal(locator.reference)) + ) { str = resolved; } } @@ -73,42 +83,58 @@ const moduleWrapper = tsserver => { // Before | ^/zip/c:/foo/bar.zip/package.json // After | ^/zip//c:/foo/bar.zip/package.json // - case `vscode <1.61`: { - str = `^zip:${str}`; - } break; + case `vscode <1.61`: + { + str = `^zip:${str}`; + } + break; - case `vscode <1.66`: { - str = `^/zip/${str}`; - } break; + case `vscode <1.66`: + { + str = `^/zip/${str}`; + } + break; - case `vscode <1.68`: { - str = `^/zip${str}`; - } break; + case `vscode <1.68`: + { + str = `^/zip${str}`; + } + break; - case `vscode`: { - str = `^/zip/${str}`; - } break; + case `vscode`: + { + str = `^/zip/${str}`; + } + break; // To make "go to definition" work, // We have to resolve the actual file system path from virtual path // and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip) - case `coc-nvim`: { - str = normalize(resolved).replace(/\.zip\//, `.zip::`); - str = resolve(`zipfile:${str}`); - } break; + case `coc-nvim`: + { + str = normalize(resolved).replace(/\.zip\//, `.zip::`); + str = resolve(`zipfile:${str}`); + } + break; // Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server) // We have to resolve the actual file system path from virtual path, // everything else is up to neovim - case `neovim`: { - str = normalize(resolved).replace(/\.zip\//, `.zip::`); - str = `zipfile://${str}`; - } break; - - default: { - str = `zip:${str}`; - } break; + case `neovim`: + { + str = normalize(resolved).replace(/\.zip\//, `.zip::`); + str = `zipfile://${str}`; + } + break; + + default: + { + str = `zip:${str}`; + } + break; } + } else { + str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`); } } @@ -117,26 +143,35 @@ const moduleWrapper = tsserver => { function fromEditorPath(str) { switch (hostInfo) { - case `coc-nvim`: { - str = str.replace(/\.zip::/, `.zip/`); - // The path for coc-nvim is in format of //zipfile://.yarn/... - // So in order to convert it back, we use .* to match all the thing - // before `zipfile:` - return process.platform === `win32` - ? str.replace(/^.*zipfile:\//, ``) - : str.replace(/^.*zipfile:/, ``); - } break; - - case `neovim`: { - str = str.replace(/\.zip::/, `.zip/`); - // The path for neovim is in format of zipfile:////.yarn/... - return str.replace(/^zipfile:\/\//, ``); - } break; + case `coc-nvim`: + { + str = str.replace(/\.zip::/, `.zip/`); + // The path for coc-nvim is in format of //zipfile://.yarn/... + // So in order to convert it back, we use .* to match all the thing + // before `zipfile:` + return process.platform === `win32` + ? str.replace(/^.*zipfile:\//, ``) + : str.replace(/^.*zipfile:/, ``); + } + break; + + case `neovim`: + { + str = str.replace(/\.zip::/, `.zip/`); + // The path for neovim is in format of zipfile:////.yarn/... + return str.replace(/^zipfile:\/\//, ``); + } + break; case `vscode`: - default: { - return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`) - } break; + default: + { + return str.replace( + /^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, + process.platform === `win32` ? `` : `/`, + ); + } + break; } } @@ -148,8 +183,9 @@ const moduleWrapper = tsserver => { // TypeScript already does local loads and if this code is running the user trusts the workspace // https://github.com/microsoft/vscode/issues/45856 const ConfiguredProject = tsserver.server.ConfiguredProject; - const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype; - ConfiguredProject.prototype.enablePluginsWithOptions = function() { + const { enablePluginsWithOptions: originalEnablePluginsWithOptions } = + ConfiguredProject.prototype; + ConfiguredProject.prototype.enablePluginsWithOptions = function () { this.projectService.allowLocalPluginLoads = true; return originalEnablePluginsWithOptions.apply(this, arguments); }; @@ -159,12 +195,12 @@ const moduleWrapper = tsserver => { // like an absolute path of ours and normalize it. const Session = tsserver.server.Session; - const {onMessage: originalOnMessage, send: originalSend} = Session.prototype; + const { onMessage: originalOnMessage, send: originalSend } = Session.prototype; let hostInfo = `unknown`; Object.assign(Session.prototype, { onMessage(/** @type {string | object} */ message) { - const isStringMessage = typeof message === 'string'; + const isStringMessage = typeof message === "string"; const parsedMessage = isStringMessage ? JSON.parse(message) : message; if ( @@ -175,10 +211,12 @@ const moduleWrapper = tsserver => { ) { hostInfo = parsedMessage.arguments.hostInfo; if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) { - const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match( - // The RegExp from https://semver.org/ but without the caret at the start - /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ - ) ?? []).map(Number) + const [, major, minor] = ( + process.env.VSCODE_IPC_HOOK.match( + // The RegExp from https://semver.org/ but without the caret at the start + /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/, + ) ?? [] + ).map(Number); if (major === 1) { if (minor < 61) { @@ -193,20 +231,25 @@ const moduleWrapper = tsserver => { } const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => { - return typeof value === 'string' ? fromEditorPath(value) : value; + return typeof value === "string" ? fromEditorPath(value) : value; }); return originalOnMessage.call( this, - isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON) + isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON), ); }, send(/** @type {any} */ msg) { - return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => { - return typeof value === `string` ? toEditorPath(value) : value; - }))); - } + return originalSend.call( + this, + JSON.parse( + JSON.stringify(msg, (key, value) => { + return typeof value === `string` ? toEditorPath(value) : value; + }), + ), + ); + }, }); return tsserver; diff --git a/.yarn/sdks/typescript/lib/tsserverlibrary.js b/.yarn/sdks/typescript/lib/tsserverlibrary.js index e7033a81..fb3c08d5 100644 --- a/.yarn/sdks/typescript/lib/tsserverlibrary.js +++ b/.yarn/sdks/typescript/lib/tsserverlibrary.js @@ -1,29 +1,31 @@ #!/usr/bin/env node -const {existsSync} = require(`fs`); -const {createRequire} = require(`module`); -const {resolve} = require(`path`); +const { existsSync } = require(`fs`); +const { createRequire } = require(`module`); +const { resolve } = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absRequire = createRequire(absPnpApiPath); -const moduleWrapper = tsserver => { +const moduleWrapper = (tsserver) => { if (!process.versions.pnp) { return tsserver; } - const {isAbsolute} = require(`path`); + const { isAbsolute } = require(`path`); const pnpApi = require(`pnpapi`); - const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//); - const isPortal = str => str.startsWith("portal:/"); - const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`); + const isVirtual = (str) => str.match(/\/(\$\$virtual|__virtual__)\//); + const isPortal = (str) => str.startsWith("portal:/"); + const normalize = (str) => str.replace(/\\/g, `/`).replace(/^\/?/, `/`); - const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => { - return `${locator.name}@${locator.reference}`; - })); + const dependencyTreeRoots = new Set( + pnpApi.getDependencyTreeRoots().map((locator) => { + return `${locator.name}@${locator.reference}`; + }), + ); // VSCode sends the zip paths to TS using the "zip://" prefix, that TS // doesn't understand. This layer makes sure to remove the protocol @@ -31,7 +33,11 @@ const moduleWrapper = tsserver => { function toEditorPath(str) { // We add the `zip:` prefix to both `.zip/` paths and virtual paths - if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) { + if ( + isAbsolute(str) && + !str.match(/^\^?(zip:|\/zip\/)/) && + (str.match(/\.zip\//) || isVirtual(str)) + ) { // We also take the opportunity to turn virtual paths into physical ones; // this makes it much easier to work with workspaces that list peer // dependencies, since otherwise Ctrl+Click would bring us to the virtual @@ -45,7 +51,11 @@ const moduleWrapper = tsserver => { const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str; if (resolved) { const locator = pnpApi.findPackageLocator(resolved); - if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) { + if ( + locator && + (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || + isPortal(locator.reference)) + ) { str = resolved; } } @@ -73,42 +83,58 @@ const moduleWrapper = tsserver => { // Before | ^/zip/c:/foo/bar.zip/package.json // After | ^/zip//c:/foo/bar.zip/package.json // - case `vscode <1.61`: { - str = `^zip:${str}`; - } break; + case `vscode <1.61`: + { + str = `^zip:${str}`; + } + break; - case `vscode <1.66`: { - str = `^/zip/${str}`; - } break; + case `vscode <1.66`: + { + str = `^/zip/${str}`; + } + break; - case `vscode <1.68`: { - str = `^/zip${str}`; - } break; + case `vscode <1.68`: + { + str = `^/zip${str}`; + } + break; - case `vscode`: { - str = `^/zip/${str}`; - } break; + case `vscode`: + { + str = `^/zip/${str}`; + } + break; // To make "go to definition" work, // We have to resolve the actual file system path from virtual path // and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip) - case `coc-nvim`: { - str = normalize(resolved).replace(/\.zip\//, `.zip::`); - str = resolve(`zipfile:${str}`); - } break; + case `coc-nvim`: + { + str = normalize(resolved).replace(/\.zip\//, `.zip::`); + str = resolve(`zipfile:${str}`); + } + break; // Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server) // We have to resolve the actual file system path from virtual path, // everything else is up to neovim - case `neovim`: { - str = normalize(resolved).replace(/\.zip\//, `.zip::`); - str = `zipfile://${str}`; - } break; - - default: { - str = `zip:${str}`; - } break; + case `neovim`: + { + str = normalize(resolved).replace(/\.zip\//, `.zip::`); + str = `zipfile://${str}`; + } + break; + + default: + { + str = `zip:${str}`; + } + break; } + } else { + str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`); } } @@ -117,26 +143,35 @@ const moduleWrapper = tsserver => { function fromEditorPath(str) { switch (hostInfo) { - case `coc-nvim`: { - str = str.replace(/\.zip::/, `.zip/`); - // The path for coc-nvim is in format of //zipfile://.yarn/... - // So in order to convert it back, we use .* to match all the thing - // before `zipfile:` - return process.platform === `win32` - ? str.replace(/^.*zipfile:\//, ``) - : str.replace(/^.*zipfile:/, ``); - } break; - - case `neovim`: { - str = str.replace(/\.zip::/, `.zip/`); - // The path for neovim is in format of zipfile:////.yarn/... - return str.replace(/^zipfile:\/\//, ``); - } break; + case `coc-nvim`: + { + str = str.replace(/\.zip::/, `.zip/`); + // The path for coc-nvim is in format of //zipfile://.yarn/... + // So in order to convert it back, we use .* to match all the thing + // before `zipfile:` + return process.platform === `win32` + ? str.replace(/^.*zipfile:\//, ``) + : str.replace(/^.*zipfile:/, ``); + } + break; + + case `neovim`: + { + str = str.replace(/\.zip::/, `.zip/`); + // The path for neovim is in format of zipfile:////.yarn/... + return str.replace(/^zipfile:\/\//, ``); + } + break; case `vscode`: - default: { - return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`) - } break; + default: + { + return str.replace( + /^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, + process.platform === `win32` ? `` : `/`, + ); + } + break; } } @@ -148,8 +183,9 @@ const moduleWrapper = tsserver => { // TypeScript already does local loads and if this code is running the user trusts the workspace // https://github.com/microsoft/vscode/issues/45856 const ConfiguredProject = tsserver.server.ConfiguredProject; - const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype; - ConfiguredProject.prototype.enablePluginsWithOptions = function() { + const { enablePluginsWithOptions: originalEnablePluginsWithOptions } = + ConfiguredProject.prototype; + ConfiguredProject.prototype.enablePluginsWithOptions = function () { this.projectService.allowLocalPluginLoads = true; return originalEnablePluginsWithOptions.apply(this, arguments); }; @@ -159,12 +195,12 @@ const moduleWrapper = tsserver => { // like an absolute path of ours and normalize it. const Session = tsserver.server.Session; - const {onMessage: originalOnMessage, send: originalSend} = Session.prototype; + const { onMessage: originalOnMessage, send: originalSend } = Session.prototype; let hostInfo = `unknown`; Object.assign(Session.prototype, { onMessage(/** @type {string | object} */ message) { - const isStringMessage = typeof message === 'string'; + const isStringMessage = typeof message === "string"; const parsedMessage = isStringMessage ? JSON.parse(message) : message; if ( @@ -175,10 +211,12 @@ const moduleWrapper = tsserver => { ) { hostInfo = parsedMessage.arguments.hostInfo; if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) { - const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match( - // The RegExp from https://semver.org/ but without the caret at the start - /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ - ) ?? []).map(Number) + const [, major, minor] = ( + process.env.VSCODE_IPC_HOOK.match( + // The RegExp from https://semver.org/ but without the caret at the start + /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/, + ) ?? [] + ).map(Number); if (major === 1) { if (minor < 61) { @@ -193,20 +231,25 @@ const moduleWrapper = tsserver => { } const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => { - return typeof value === 'string' ? fromEditorPath(value) : value; + return typeof value === "string" ? fromEditorPath(value) : value; }); return originalOnMessage.call( this, - isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON) + isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON), ); }, send(/** @type {any} */ msg) { - return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => { - return typeof value === `string` ? toEditorPath(value) : value; - }))); - } + return originalSend.call( + this, + JSON.parse( + JSON.stringify(msg, (key, value) => { + return typeof value === `string` ? toEditorPath(value) : value; + }), + ), + ); + }, }); return tsserver; diff --git a/.yarn/sdks/typescript/package.json b/.yarn/sdks/typescript/package.json index 15466d20..0bfa4eb2 100644 --- a/.yarn/sdks/typescript/package.json +++ b/.yarn/sdks/typescript/package.json @@ -1,6 +1,6 @@ { "name": "typescript", - "version": "4.8.4-sdk", + "version": "5.2.2-sdk", "main": "./lib/typescript.js", "type": "commonjs" } From 23153d678706f1973d6df0f52969388aa7cee908 Mon Sep 17 00:00:00 2001 From: MikuroXina Date: Tue, 3 Oct 2023 00:18:42 +0900 Subject: [PATCH 6/6] Use discordId as key --- src/lib/member-fetch.ts | 7 ++++++- src/pages/member.tsx | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/member-fetch.ts b/src/lib/member-fetch.ts index 244ac734..622100ec 100644 --- a/src/lib/member-fetch.ts +++ b/src/lib/member-fetch.ts @@ -27,6 +27,7 @@ function validateSNSLinks(links: unknown): links is readonly SNSLinkInfo[] { export type Member = { username: string; + discordId: string; associatedLinks: readonly SNSLinkInfo[]; }; @@ -37,7 +38,11 @@ function validateMember(obj: unknown): obj is Member { } if (typeof (obj as Member).username !== "string") { - console.error("`avatar` not in: ", obj); + console.error("`username` not in: ", obj); + return false; + } + if (typeof (obj as Member).discordId !== "string") { + console.error("`discordId` not in: ", obj); return false; } if (!validateSNSLinks((obj as Member).associatedLinks)) { diff --git a/src/pages/member.tsx b/src/pages/member.tsx index 28e32e46..4bf3f30d 100644 --- a/src/pages/member.tsx +++ b/src/pages/member.tsx @@ -55,7 +55,7 @@ const MembersPage: NextPage = ({ members }) => { メンバー紹介 {members.map((member) => ( - + ))}