Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions homeView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 class="name-text">([^<]*)<\/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"]);
});
15 changes: 2 additions & 13 deletions homeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -167,7 +168,7 @@ function renderPlugin(plugin: PluginData) {
<span class="swatch"></span>
<div class="name-block">
<div class="name-line">
<span class="name-text">{displayName(plugin)}</span>
<span class="name-text">{plugin.displayName ?? plugin.name}</span>
{plugin.version ? <span class="version-tag">{plugin.version}</span> : null}
</div>
{renderPluginLinks(plugin)}
Expand Down Expand Up @@ -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;
Expand Down
34 changes: 34 additions & 0 deletions info.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down Expand Up @@ -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/",
Expand All @@ -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/",
Expand All @@ -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/",
Expand All @@ -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/",
Expand All @@ -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/",
Expand Down Expand Up @@ -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/",
Expand All @@ -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/",
Expand All @@ -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/",
Expand All @@ -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/",
Expand All @@ -241,6 +251,7 @@
},
{
"name": "dprint-plugin-kdl",
"displayName": "kachick/kdl",
"repo": "kachick/dprint-plugin-kdl",
"description": "KDL crate wrapper plugin.",
"npm": {
Expand All @@ -258,6 +269,7 @@
},
{
"name": "dprint-plugin-nix",
"displayName": "kachick/nix",
"repo": "kachick/dprint-plugin-nix",
"description": "Nixfmt-rs (Nix) wrapper plugin.",
"npm": {
Expand All @@ -276,6 +288,7 @@
},
{
"name": "dprint-plugin-sh",
"displayName": "kachick/sh",
"repo": "kachick/dprint-plugin-sh",
"description": "Shuck-formatter (shell script) wrapper plugin.",
"npm": {
Expand Down Expand Up @@ -318,6 +331,7 @@
},
{
"name": "kachick/typstyle",
"displayName": "kachick/typstyle",
"repo": "kachick/dprint-plugin-typstyle",
"description": "Typstyle (Typst) wrapper plugin.",
"npm": {
Expand All @@ -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/",
Expand Down Expand Up @@ -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/",
Expand Down Expand Up @@ -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/",
Expand All @@ -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/",
Expand All @@ -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/",
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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": {
Expand All @@ -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": {
Expand Down Expand Up @@ -590,6 +613,7 @@
},
{
"name": "lax-sql",
"displayName": "bartlomieju/lax-sql",
"repo": "bartlomieju/lax-sql",
"description": "Dialect-agnostic SQL formatter.",
"npm": {
Expand All @@ -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,
Expand All @@ -637,6 +662,7 @@
},
{
"name": "dprint-plugin-swift",
"displayName": "drluckyspin/swift",
"repo": "drluckyspin/dprint-plugin-swift",
"description": "Swift code formatter (SwiftFormat wrapper).",
"selected": false,
Expand All @@ -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/",
Expand Down Expand Up @@ -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/",
Expand All @@ -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/",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -877,6 +907,7 @@
},
{
"name": "dprint-cmakefmt",
"displayName": "sargunv/dprint-cmakefmt",
"repo": "sargunv/dprint-cmakefmt",
"description": "CMake code formatter (cmakefmt).",
"selected": false,
Expand All @@ -897,6 +928,7 @@
},
{
"name": "dprint-plugin-arity",
"displayName": "jolars/arity",
"repo": "jolars/dprint-plugin-arity",
"description": "R code formatter (arity).",
"selected": false,
Expand All @@ -915,6 +947,7 @@
},
{
"name": "dprint-plugin-fatou",
"displayName": "jolars/fatou",
"repo": "jolars/dprint-plugin-fatou",
"description": "Julia code formatter (fatou).",
"selected": false,
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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._-]+$/);
}
});
Expand Down
3 changes: 2 additions & 1 deletion plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("/");
Expand Down
5 changes: 4 additions & 1 deletion readInfoFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading