From aa49e61e82c13bdb1437af95e895431e0accbf16 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 3 Oct 2026 18:57:15 -0400 Subject: [PATCH] add a displayName to every info.json entry and show it on the homepage --- homeView.test.ts | 10 ++++------ homeView.tsx | 15 ++------------- info.json | 34 ++++++++++++++++++++++++++++++++++ plugins.test.ts | 3 ++- plugins.ts | 3 ++- readInfoFile.ts | 5 ++++- 6 files changed, 48 insertions(+), 22 deletions(-) diff --git a/homeView.test.ts b/homeView.test.ts index fc99b10..da65229 100644 --- a/homeView.test.ts +++ b/homeView.test.ts @@ -91,14 +91,12 @@ it("should keep the url searchable when a specifier replaced it", () => { expect(search).toContain("npm:@dprint/json@1.2.3"); }); -it("should list plugins by repo without the dprint org or plugin prefix", () => { +it("should list plugins by their display name", () => { const { html } = renderReferences([ - createPlugin({ name: "dprint-plugin-json", repo: "dprint/dprint-plugin-json" }), - createPlugin({ name: "dprint_plugin_malva", repo: "g-plane/malva" }), - createPlugin({ name: "dprint-plugin-kdl", repo: "kachick/dprint-plugin-kdl" }), - // data cached before info.json declared the repo + createPlugin({ name: "dprint_plugin_malva", displayName: "g-plane/malva" }), + // data cached before info.json declared the display name createPlugin({ name: "dprint-plugin-cached" }), ]); const names = [...html.matchAll(/([^<]*)<\/span>/g)].map((m) => m[1]); - expect(names).toEqual(["dprint-plugin-json", "g-plane/malva", "kachick/kdl", "dprint-plugin-cached"]); + expect(names).toEqual(["g-plane/malva", "dprint-plugin-cached"]); }); diff --git a/homeView.tsx b/homeView.tsx index dcee7bb..606a1e8 100644 --- a/homeView.tsx +++ b/homeView.tsx @@ -103,6 +103,7 @@ function renderPage(pluginsData: PluginsData) { function pluginSearchText(plugin: PluginData) { const parts: (string | undefined)[] = [ plugin.name, + plugin.displayName, plugin.repo, // the url stays searchable even when the npm specifier is what's shown plugin.url, @@ -167,7 +168,7 @@ function renderPlugin(plugin: PluginData) {
- {displayName(plugin)} + {plugin.displayName ?? plugin.name} {plugin.version ? {plugin.version} : null}
{renderPluginLinks(plugin)} @@ -213,18 +214,6 @@ function latestReference(plugin: PluginData) { // the repo and docs links shown beneath a plugin's name. both are optional: the // repo url is derived during the build and docs only exist for plugins with a // dprint.dev page. -// plugins are listed by the repo they're published from: the dprint org is -// left off its own plugins and the `dprint-plugin-` prefix off everyone else's -// (ex. `dprint-plugin-json` and `kachick/kdl`) -function displayName(plugin: PluginData) { - if (plugin.repo == null) { - return plugin.name; - } - return plugin.repo.startsWith("dprint/") - ? plugin.repo.slice("dprint/".length) - : plugin.repo.replace("/dprint-plugin-", "/"); -} - function renderPluginLinks(plugin: PluginData) { if (plugin.repoUrl == null && plugin.website == null) { return null; diff --git a/info.json b/info.json index 0347308..b8836a9 100644 --- a/info.json +++ b/info.json @@ -4,6 +4,7 @@ "latest": [ { "name": "dprint-plugin-typescript", + "displayName": "dprint-plugin-typescript", "repo": "dprint/dprint-plugin-typescript", "description": "TypeScript/JavaScript code formatter.", "website": "https://dprint.dev/plugins/typescript/", @@ -35,6 +36,7 @@ }, { "name": "dprint-plugin-json", + "displayName": "dprint-plugin-json", "repo": "dprint/dprint-plugin-json", "description": "JSON/JSONC code formatter.", "website": "https://dprint.dev/plugins/json/", @@ -57,6 +59,7 @@ }, { "name": "dprint-plugin-markdown", + "displayName": "dprint-plugin-markdown", "repo": "dprint/dprint-plugin-markdown", "description": "Markdown code formatter.", "website": "https://dprint.dev/plugins/markdown/", @@ -82,6 +85,7 @@ }, { "name": "dprint-plugin-toml", + "displayName": "dprint-plugin-toml", "repo": "dprint/dprint-plugin-toml", "description": "TOML code formatter.", "website": "https://dprint.dev/plugins/toml/", @@ -101,6 +105,7 @@ }, { "name": "dprint-plugin-dockerfile", + "displayName": "dprint-plugin-dockerfile", "repo": "dprint/dprint-plugin-dockerfile", "description": "Dockerfile code formatter.", "website": "https://dprint.dev/plugins/dockerfile/", @@ -124,6 +129,7 @@ }, { "name": "dprint-plugin-biome", + "displayName": "dprint-plugin-biome", "repo": "dprint/dprint-plugin-biome", "description": "Biome (JS/TS/JSON) wrapper plugin.", "website": "https://dprint.dev/plugins/biome/", @@ -157,6 +163,7 @@ }, { "name": "dprint-plugin-mago", + "displayName": "dprint-plugin-mago", "repo": "dprint/dprint-plugin-mago", "description": "Mago (PHP) wrapper plugin.", "website": "https://dprint.dev/plugins/mago/", @@ -177,6 +184,7 @@ }, { "name": "dprint-plugin-ruff", + "displayName": "dprint-plugin-ruff", "repo": "dprint/dprint-plugin-ruff", "description": "Ruff (Python) wrapper plugin.", "website": "https://dprint.dev/plugins/ruff/", @@ -199,6 +207,7 @@ }, { "name": "dprint-plugin-jupyter", + "displayName": "dprint-plugin-jupyter", "repo": "dprint/dprint-plugin-jupyter", "description": "Jupyter notebook code block formatter.", "website": "https://dprint.dev/plugins/jupyter/", @@ -220,6 +229,7 @@ }, { "name": "dprint-plugin-gofumpt", + "displayName": "jakebailey/gofumpt", "repo": "jakebailey/dprint-plugin-gofumpt", "description": "Gofumpt (Go) wrapper plugin.", "website": "https://dprint.dev/plugins/gofumpt/", @@ -241,6 +251,7 @@ }, { "name": "dprint-plugin-kdl", + "displayName": "kachick/kdl", "repo": "kachick/dprint-plugin-kdl", "description": "KDL crate wrapper plugin.", "npm": { @@ -258,6 +269,7 @@ }, { "name": "dprint-plugin-nix", + "displayName": "kachick/nix", "repo": "kachick/dprint-plugin-nix", "description": "Nixfmt-rs (Nix) wrapper plugin.", "npm": { @@ -276,6 +288,7 @@ }, { "name": "dprint-plugin-sh", + "displayName": "kachick/sh", "repo": "kachick/dprint-plugin-sh", "description": "Shuck-formatter (shell script) wrapper plugin.", "npm": { @@ -318,6 +331,7 @@ }, { "name": "kachick/typstyle", + "displayName": "kachick/typstyle", "repo": "kachick/dprint-plugin-typstyle", "description": "Typstyle (Typst) wrapper plugin.", "npm": { @@ -336,6 +350,7 @@ }, { "name": "dprint_plugin_malva", + "displayName": "g-plane/malva", "repo": "g-plane/malva", "description": "CSS, SCSS, Sass and Less formatter.", "website": "https://dprint.dev/plugins/malva/", @@ -363,6 +378,7 @@ }, { "name": "dprint_plugin_markup", + "displayName": "g-plane/markup_fmt", "repo": "g-plane/markup_fmt", "description": "HTML, Vue, Svelte, Astro, Angular, Jinja, Twig, Nunjucks, and Vento formatter.", "website": "https://dprint.dev/plugins/markup_fmt/", @@ -413,6 +429,7 @@ }, { "name": "dprint_plugin_yaml", + "displayName": "g-plane/pretty_yaml", "repo": "g-plane/pretty_yaml", "description": "YAML formatter.", "website": "https://dprint.dev/plugins/pretty_yaml/", @@ -435,6 +452,7 @@ }, { "name": "dprint_plugin_graphql", + "displayName": "g-plane/pretty_graphql", "repo": "g-plane/pretty_graphql", "description": "GraphQL formatter.", "website": "https://dprint.dev/plugins/pretty_graphql/", @@ -456,6 +474,7 @@ }, { "name": "dprint-plugin-oxc", + "displayName": "dprint-plugin-oxc", "repo": "dprint/dprint-plugin-oxc", "description": "Oxc (JS/TS/JSON/CSS/SCSS/Less/GraphQL/YAML/TOML) wrapper plugin.", "website": "https://dprint.dev/plugins/oxc/", @@ -506,6 +525,7 @@ }, { "name": "dprint-plugin-bibtex-tidy", + "displayName": "apcamargo/bibtex-tidy", "repo": "apcamargo/dprint-plugin-bibtex-tidy", "description": "Tidy bibtex files.", "selected": false, @@ -521,6 +541,7 @@ }, { "name": "apcamargo/typstyle", + "displayName": "apcamargo/typstyle", "repo": "apcamargo/dprint-plugin-typstyle", "description": "A beautiful and reliable code formatter for Typst.", "selected": false, @@ -537,6 +558,7 @@ }, { "name": "lax-css", + "displayName": "bartlomieju/lax-css", "repo": "bartlomieju/lax-css", "description": "CSS, SCSS, and Less formatter that never reinterprets your styles.", "npm": { @@ -561,6 +583,7 @@ }, { "name": "lax-markup", + "displayName": "bartlomieju/lax-markup", "repo": "bartlomieju/lax-markup", "description": "HTML, XML, SVG, Vue, Svelte, and Astro formatter that preserves rendering-critical whitespace.", "npm": { @@ -590,6 +613,7 @@ }, { "name": "lax-sql", + "displayName": "bartlomieju/lax-sql", "repo": "bartlomieju/lax-sql", "description": "Dialect-agnostic SQL formatter.", "npm": { @@ -612,6 +636,7 @@ }, { "name": "dprint-plugin-panache", + "displayName": "jolars/panache", "repo": "jolars/dprint-plugin-panache", "description": "Quarto, Pandoc, R Markdown, and Markdown formatter.", "selected": false, @@ -637,6 +662,7 @@ }, { "name": "dprint-plugin-swift", + "displayName": "drluckyspin/swift", "repo": "drluckyspin/dprint-plugin-swift", "description": "Swift code formatter (SwiftFormat wrapper).", "selected": false, @@ -656,6 +682,7 @@ }, { "name": "dprint-plugin-prettier", + "displayName": "dprint-plugin-prettier", "repo": "dprint/dprint-plugin-prettier", "description": "Prettier wrapper plugin (consider faster dedicated plugins for JS/TS, CSS, etc.).", "website": "https://dprint.dev/plugins/prettier/", @@ -705,6 +732,7 @@ }, { "name": "dprint-plugin-roslyn", + "displayName": "dprint-plugin-roslyn", "repo": "dprint/dprint-plugin-roslyn", "description": "C# and Visual Basic code formatter (Roslyn).", "website": "https://dprint.dev/plugins/roslyn/", @@ -730,6 +758,7 @@ }, { "name": "dprint-plugin-exec", + "displayName": "dprint-plugin-exec", "repo": "dprint/dprint-plugin-exec", "description": "Formats code using formatting CLIs installed on the host machine (rustfmt, clang-format, shfmt, etc.).", "website": "https://dprint.dev/plugins/exec/", @@ -848,6 +877,7 @@ }, { "name": "dprint-plugin-clang-format", + "displayName": "sargunv/dprint-clang-format", "repo": "sargunv/dprint-clang-format", "description": "C, C++, and Objective-C code formatter (clang-format).", "selected": false, @@ -877,6 +907,7 @@ }, { "name": "dprint-cmakefmt", + "displayName": "sargunv/dprint-cmakefmt", "repo": "sargunv/dprint-cmakefmt", "description": "CMake code formatter (cmakefmt).", "selected": false, @@ -897,6 +928,7 @@ }, { "name": "dprint-plugin-arity", + "displayName": "jolars/arity", "repo": "jolars/dprint-plugin-arity", "description": "R code formatter (arity).", "selected": false, @@ -915,6 +947,7 @@ }, { "name": "dprint-plugin-fatou", + "displayName": "jolars/fatou", "repo": "jolars/dprint-plugin-fatou", "description": "Julia code formatter (fatou).", "selected": false, @@ -930,6 +963,7 @@ }, { "name": "dprint-plugin-badness", + "displayName": "jolars/badness", "repo": "jolars/dprint-plugin-badness", "description": "LaTeX and BibTeX code formatter (badness).", "selected": false, diff --git a/plugins.test.ts b/plugins.test.ts index db88573..de49caf 100644 --- a/plugins.test.ts +++ b/plugins.test.ts @@ -15,8 +15,9 @@ it("getPluginRepo", () => { expect(getPluginRepo({ repo: "g-plane/malva" })).toEqual({ username: "g-plane", repoName: "malva" }); }); -it("info.json entries should say what repo they're published from", () => { +it("info.json entries should have a display name and say what repo they're published from", () => { for (const plugin of infoJson.latest) { + expect(plugin.displayName, plugin.name).toBeTruthy(); expect(plugin.repo, plugin.name).toMatch(/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/); } }); diff --git a/plugins.ts b/plugins.ts index 57d3039..d65fdeb 100644 --- a/plugins.ts +++ b/plugins.ts @@ -88,7 +88,8 @@ const reposByPluginName = buildReposByPluginName(); /** * The GitHub repo an info.json entry is published from. An entry's `name` is * the name the plugin reports about itself, which the cli matches against the - * plugins in a config file, so `repo` is what says where it's published from. + * plugins in a config file, so it only identifies the plugin: `repo` says where + * it's published from and `displayName` is what's shown for it. */ export function getPluginRepo(plugin: { repo: string }) { const slashIndex = plugin.repo.indexOf("/"); diff --git a/readInfoFile.ts b/readInfoFile.ts index a83f270..e3f0d0a 100644 --- a/readInfoFile.ts +++ b/readInfoFile.ts @@ -10,8 +10,11 @@ export interface PluginsData { } export interface PluginData { - // the name the plugin reports about itself + // the name the plugin reports about itself, which is what identifies it name: string; + // the name to show for the plugin. carried over from info.json, so it's + // absent from data cached before info.json declared it + displayName?: string; // the `username/repo` the plugin is published from. carried over from // info.json, so it's absent from data cached before info.json declared it repo?: string;