diff --git a/homeView.tsx b/homeView.tsx index 606a1e8..f00f594 100644 --- a/homeView.tsx +++ b/homeView.tsx @@ -104,7 +104,6 @@ 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, latestReference(plugin), diff --git a/info.json b/info.json index b8836a9..a15876b 100644 --- a/info.json +++ b/info.json @@ -5,7 +5,7 @@ { "name": "dprint-plugin-typescript", "displayName": "dprint-plugin-typescript", - "repo": "dprint/dprint-plugin-typescript", + "repoUrl": "https://github.com/dprint/dprint-plugin-typescript", "description": "TypeScript/JavaScript code formatter.", "website": "https://dprint.dev/plugins/typescript/", "npm": { @@ -37,7 +37,7 @@ { "name": "dprint-plugin-json", "displayName": "dprint-plugin-json", - "repo": "dprint/dprint-plugin-json", + "repoUrl": "https://github.com/dprint/dprint-plugin-json", "description": "JSON/JSONC code formatter.", "website": "https://dprint.dev/plugins/json/", "npm": { @@ -60,7 +60,7 @@ { "name": "dprint-plugin-markdown", "displayName": "dprint-plugin-markdown", - "repo": "dprint/dprint-plugin-markdown", + "repoUrl": "https://github.com/dprint/dprint-plugin-markdown", "description": "Markdown code formatter.", "website": "https://dprint.dev/plugins/markdown/", "npm": { @@ -86,7 +86,7 @@ { "name": "dprint-plugin-toml", "displayName": "dprint-plugin-toml", - "repo": "dprint/dprint-plugin-toml", + "repoUrl": "https://github.com/dprint/dprint-plugin-toml", "description": "TOML code formatter.", "website": "https://dprint.dev/plugins/toml/", "npm": { @@ -106,7 +106,7 @@ { "name": "dprint-plugin-dockerfile", "displayName": "dprint-plugin-dockerfile", - "repo": "dprint/dprint-plugin-dockerfile", + "repoUrl": "https://github.com/dprint/dprint-plugin-dockerfile", "description": "Dockerfile code formatter.", "website": "https://dprint.dev/plugins/dockerfile/", "npm": { @@ -130,7 +130,7 @@ { "name": "dprint-plugin-biome", "displayName": "dprint-plugin-biome", - "repo": "dprint/dprint-plugin-biome", + "repoUrl": "https://github.com/dprint/dprint-plugin-biome", "description": "Biome (JS/TS/JSON) wrapper plugin.", "website": "https://dprint.dev/plugins/biome/", "npm": { @@ -164,7 +164,7 @@ { "name": "dprint-plugin-mago", "displayName": "dprint-plugin-mago", - "repo": "dprint/dprint-plugin-mago", + "repoUrl": "https://github.com/dprint/dprint-plugin-mago", "description": "Mago (PHP) wrapper plugin.", "website": "https://dprint.dev/plugins/mago/", "npm": { @@ -185,7 +185,7 @@ { "name": "dprint-plugin-ruff", "displayName": "dprint-plugin-ruff", - "repo": "dprint/dprint-plugin-ruff", + "repoUrl": "https://github.com/dprint/dprint-plugin-ruff", "description": "Ruff (Python) wrapper plugin.", "website": "https://dprint.dev/plugins/ruff/", "npm": { @@ -208,7 +208,7 @@ { "name": "dprint-plugin-jupyter", "displayName": "dprint-plugin-jupyter", - "repo": "dprint/dprint-plugin-jupyter", + "repoUrl": "https://github.com/dprint/dprint-plugin-jupyter", "description": "Jupyter notebook code block formatter.", "website": "https://dprint.dev/plugins/jupyter/", "npm": { @@ -230,7 +230,7 @@ { "name": "dprint-plugin-gofumpt", "displayName": "jakebailey/gofumpt", - "repo": "jakebailey/dprint-plugin-gofumpt", + "repoUrl": "https://github.com/jakebailey/dprint-plugin-gofumpt", "description": "Gofumpt (Go) wrapper plugin.", "website": "https://dprint.dev/plugins/gofumpt/", "npm": { @@ -249,109 +249,10 @@ ], "configExcludes": [] }, - { - "name": "dprint-plugin-kdl", - "displayName": "kachick/kdl", - "repo": "kachick/dprint-plugin-kdl", - "description": "KDL crate wrapper plugin.", - "npm": { - "name": "@kachick/dprint-plugin-kdl" - }, - "selected": false, - "configKey": "kdl", - "keywords": [ - "kdl" - ], - "fileExtensions": [ - "kdl" - ], - "configExcludes": [] - }, - { - "name": "dprint-plugin-nix", - "displayName": "kachick/nix", - "repo": "kachick/dprint-plugin-nix", - "description": "Nixfmt-rs (Nix) wrapper plugin.", - "npm": { - "name": "@kachick/dprint-plugin-nix" - }, - "selected": false, - "configKey": "nix", - "keywords": [ - "nix", - "nixfmt-rs" - ], - "fileExtensions": [ - "nix" - ], - "configExcludes": [] - }, - { - "name": "dprint-plugin-sh", - "displayName": "kachick/sh", - "repo": "kachick/dprint-plugin-sh", - "description": "Shuck-formatter (shell script) wrapper plugin.", - "npm": { - "name": "@kachick/dprint-plugin-sh" - }, - "selected": false, - "configKey": "sh", - "keywords": [ - "sh", - "shell-script", - "shuck-formatter", - "bash", - "zsh", - "envrc" - ], - "fileExtensions": [ - "sh", - "bash", - "zsh", - "ksh", - "mksh", - "dash", - "bats" - ], - "fileNames": [ - ".envrc", - ".bashrc", - ".bash_profile", - ".bash_aliases", - ".bash_login", - ".bash_logout", - ".profile", - ".zshrc", - ".zshenv", - ".zprofile", - ".zlogin", - ".zlogout" - ], - "configExcludes": [] - }, - { - "name": "kachick/typstyle", - "displayName": "kachick/typstyle", - "repo": "kachick/dprint-plugin-typstyle", - "description": "Typstyle (Typst) wrapper plugin.", - "npm": { - "name": "@kachick/dprint-plugin-typstyle" - }, - "selected": false, - "configKey": "typst", - "keywords": [ - "typst", - "typstyle" - ], - "fileExtensions": [ - "typ" - ], - "configExcludes": [] - }, { "name": "dprint_plugin_malva", "displayName": "g-plane/malva", - "repo": "g-plane/malva", + "repoUrl": "https://github.com/g-plane/malva", "description": "CSS, SCSS, Sass and Less formatter.", "website": "https://dprint.dev/plugins/malva/", "npm": { @@ -379,7 +280,7 @@ { "name": "dprint_plugin_markup", "displayName": "g-plane/markup_fmt", - "repo": "g-plane/markup_fmt", + "repoUrl": "https://github.com/g-plane/markup_fmt", "description": "HTML, Vue, Svelte, Astro, Angular, Jinja, Twig, Nunjucks, and Vento formatter.", "website": "https://dprint.dev/plugins/markup_fmt/", "npm": { @@ -430,7 +331,7 @@ { "name": "dprint_plugin_yaml", "displayName": "g-plane/pretty_yaml", - "repo": "g-plane/pretty_yaml", + "repoUrl": "https://github.com/g-plane/pretty_yaml", "description": "YAML formatter.", "website": "https://dprint.dev/plugins/pretty_yaml/", "npm": { @@ -453,7 +354,7 @@ { "name": "dprint_plugin_graphql", "displayName": "g-plane/pretty_graphql", - "repo": "g-plane/pretty_graphql", + "repoUrl": "https://github.com/g-plane/pretty_graphql", "description": "GraphQL formatter.", "website": "https://dprint.dev/plugins/pretty_graphql/", "npm": { @@ -475,7 +376,7 @@ { "name": "dprint-plugin-oxc", "displayName": "dprint-plugin-oxc", - "repo": "dprint/dprint-plugin-oxc", + "repoUrl": "https://github.com/dprint/dprint-plugin-oxc", "description": "Oxc (JS/TS/JSON/CSS/SCSS/Less/GraphQL/YAML/TOML) wrapper plugin.", "website": "https://dprint.dev/plugins/oxc/", "npm": { @@ -523,10 +424,109 @@ "**/*-lock.json" ] }, + { + "name": "dprint-plugin-kdl", + "displayName": "kachick/kdl", + "repoUrl": "https://github.com/kachick/dprint-plugin-kdl", + "description": "KDL crate wrapper plugin.", + "npm": { + "name": "@kachick/dprint-plugin-kdl" + }, + "selected": false, + "configKey": "kdl", + "keywords": [ + "kdl" + ], + "fileExtensions": [ + "kdl" + ], + "configExcludes": [] + }, + { + "name": "dprint-plugin-nix", + "displayName": "kachick/nix", + "repoUrl": "https://github.com/kachick/dprint-plugin-nix", + "description": "Nixfmt-rs (Nix) wrapper plugin.", + "npm": { + "name": "@kachick/dprint-plugin-nix" + }, + "selected": false, + "configKey": "nix", + "keywords": [ + "nix", + "nixfmt-rs" + ], + "fileExtensions": [ + "nix" + ], + "configExcludes": [] + }, + { + "name": "dprint-plugin-sh", + "displayName": "kachick/sh", + "repoUrl": "https://github.com/kachick/dprint-plugin-sh", + "description": "Shuck-formatter (shell script) wrapper plugin.", + "npm": { + "name": "@kachick/dprint-plugin-sh" + }, + "selected": false, + "configKey": "sh", + "keywords": [ + "sh", + "shell-script", + "shuck-formatter", + "bash", + "zsh", + "envrc" + ], + "fileExtensions": [ + "sh", + "bash", + "zsh", + "ksh", + "mksh", + "dash", + "bats" + ], + "fileNames": [ + ".envrc", + ".bashrc", + ".bash_profile", + ".bash_aliases", + ".bash_login", + ".bash_logout", + ".profile", + ".zshrc", + ".zshenv", + ".zprofile", + ".zlogin", + ".zlogout" + ], + "configExcludes": [] + }, + { + "name": "kachick/typstyle", + "displayName": "kachick/typstyle", + "repoUrl": "https://github.com/kachick/dprint-plugin-typstyle", + "description": "Typstyle (Typst) wrapper plugin.", + "npm": { + "name": "@kachick/dprint-plugin-typstyle" + }, + "selected": false, + "configKey": "typst", + "keywords": [ + "typst", + "typstyle" + ], + "fileExtensions": [ + "typ" + ], + "configExcludes": [] + }, { "name": "dprint-plugin-bibtex-tidy", "displayName": "apcamargo/bibtex-tidy", - "repo": "apcamargo/dprint-plugin-bibtex-tidy", + "repoUrl": "https://github.com/apcamargo/dprint-plugin-bibtex-tidy", "description": "Tidy bibtex files.", "selected": false, "configKey": "bibtex-tidy", @@ -542,7 +542,7 @@ { "name": "apcamargo/typstyle", "displayName": "apcamargo/typstyle", - "repo": "apcamargo/dprint-plugin-typstyle", + "repoUrl": "https://github.com/apcamargo/dprint-plugin-typstyle", "description": "A beautiful and reliable code formatter for Typst.", "selected": false, "configKey": "typstyle", @@ -559,7 +559,7 @@ { "name": "lax-css", "displayName": "bartlomieju/lax-css", - "repo": "bartlomieju/lax-css", + "repoUrl": "https://github.com/bartlomieju/lax-css", "description": "CSS, SCSS, and Less formatter that never reinterprets your styles.", "npm": { "name": "lax-css" @@ -584,7 +584,7 @@ { "name": "lax-markup", "displayName": "bartlomieju/lax-markup", - "repo": "bartlomieju/lax-markup", + "repoUrl": "https://github.com/bartlomieju/lax-markup", "description": "HTML, XML, SVG, Vue, Svelte, and Astro formatter that preserves rendering-critical whitespace.", "npm": { "name": "lax-markup" @@ -614,7 +614,7 @@ { "name": "lax-sql", "displayName": "bartlomieju/lax-sql", - "repo": "bartlomieju/lax-sql", + "repoUrl": "https://github.com/bartlomieju/lax-sql", "description": "Dialect-agnostic SQL formatter.", "npm": { "name": "lax-sql" @@ -637,7 +637,7 @@ { "name": "dprint-plugin-panache", "displayName": "jolars/panache", - "repo": "jolars/dprint-plugin-panache", + "repoUrl": "https://github.com/jolars/dprint-plugin-panache", "description": "Quarto, Pandoc, R Markdown, and Markdown formatter.", "selected": false, "configKey": "panache", @@ -663,7 +663,7 @@ { "name": "dprint-plugin-swift", "displayName": "drluckyspin/swift", - "repo": "drluckyspin/dprint-plugin-swift", + "repoUrl": "https://github.com/drluckyspin/dprint-plugin-swift", "description": "Swift code formatter (SwiftFormat wrapper).", "selected": false, "configKey": "swiftformat", @@ -683,7 +683,7 @@ { "name": "dprint-plugin-prettier", "displayName": "dprint-plugin-prettier", - "repo": "dprint/dprint-plugin-prettier", + "repoUrl": "https://github.com/dprint/dprint-plugin-prettier", "description": "Prettier wrapper plugin (consider faster dedicated plugins for JS/TS, CSS, etc.).", "website": "https://dprint.dev/plugins/prettier/", "npm": { @@ -733,7 +733,7 @@ { "name": "dprint-plugin-roslyn", "displayName": "dprint-plugin-roslyn", - "repo": "dprint/dprint-plugin-roslyn", + "repoUrl": "https://github.com/dprint/dprint-plugin-roslyn", "description": "C# and Visual Basic code formatter (Roslyn).", "website": "https://dprint.dev/plugins/roslyn/", "npm": { @@ -759,7 +759,7 @@ { "name": "dprint-plugin-exec", "displayName": "dprint-plugin-exec", - "repo": "dprint/dprint-plugin-exec", + "repoUrl": "https://github.com/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/", "npm": { @@ -878,7 +878,7 @@ { "name": "dprint-plugin-clang-format", "displayName": "sargunv/dprint-clang-format", - "repo": "sargunv/dprint-clang-format", + "repoUrl": "https://github.com/sargunv/dprint-clang-format", "description": "C, C++, and Objective-C code formatter (clang-format).", "selected": false, "configKey": "clangFormat", @@ -908,7 +908,7 @@ { "name": "dprint-cmakefmt", "displayName": "sargunv/dprint-cmakefmt", - "repo": "sargunv/dprint-cmakefmt", + "repoUrl": "https://github.com/sargunv/dprint-cmakefmt", "description": "CMake code formatter (cmakefmt).", "selected": false, "configKey": "cmakefmt", @@ -929,7 +929,7 @@ { "name": "dprint-plugin-arity", "displayName": "jolars/arity", - "repo": "jolars/dprint-plugin-arity", + "repoUrl": "https://github.com/jolars/dprint-plugin-arity", "description": "R code formatter (arity).", "selected": false, "configKey": "arity", @@ -948,7 +948,7 @@ { "name": "dprint-plugin-fatou", "displayName": "jolars/fatou", - "repo": "jolars/dprint-plugin-fatou", + "repoUrl": "https://github.com/jolars/dprint-plugin-fatou", "description": "Julia code formatter (fatou).", "selected": false, "configKey": "fatou", @@ -964,7 +964,7 @@ { "name": "dprint-plugin-badness", "displayName": "jolars/badness", - "repo": "jolars/dprint-plugin-badness", + "repoUrl": "https://github.com/jolars/dprint-plugin-badness", "description": "LaTeX and BibTeX code formatter (badness).", "selected": false, "configKey": "badness", diff --git a/plugins.test.ts b/plugins.test.ts index de49caf..1a5229b 100644 --- a/plugins.test.ts +++ b/plugins.test.ts @@ -8,17 +8,20 @@ function resolveAsset(url: string) { } it("getPluginRepo", () => { - expect(getPluginRepo({ repo: "dprint/dprint-plugin-typescript" })).toEqual({ + expect(getPluginRepo({ repoUrl: "https://github.com/dprint/dprint-plugin-typescript" })).toEqual({ username: "dprint", repoName: "dprint-plugin-typescript", }); - expect(getPluginRepo({ repo: "g-plane/malva" })).toEqual({ username: "g-plane", repoName: "malva" }); + expect(getPluginRepo({ repoUrl: "https://github.com/g-plane/malva" })).toEqual({ + username: "g-plane", + repoName: "malva", + }); }); 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._-]+$/); + expect(plugin.repoUrl, plugin.name).toMatch(/^https:\/\/github\.com\/[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/); } }); diff --git a/plugins.ts b/plugins.ts index d65fdeb..fe3a1f9 100644 --- a/plugins.ts +++ b/plugins.ts @@ -88,12 +88,12 @@ 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 it only identifies the plugin: `repo` says where - * it's published from and `displayName` is what's shown for it. + * plugins in a config file, so it only identifies the plugin: `repoUrl` 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("/"); - return { username: plugin.repo.slice(0, slashIndex), repoName: plugin.repo.slice(slashIndex + 1) }; +export function getPluginRepo(plugin: { repoUrl: string }) { + const [username, repoName] = new URL(plugin.repoUrl).pathname.slice(1).split("/"); + return { username: username!, repoName: repoName! }; } const APPROVED_ASSET_REPOS = new Set([ @@ -254,7 +254,7 @@ async function userRepoTagPatternMapper( function buildNpmPackagesByRepo() { const result = new Map(); - for (const plugin of infoJson.latest as { repo: string; npm?: PluginNpmInfo }[]) { + for (const plugin of infoJson.latest as { repoUrl: string; npm?: PluginNpmInfo }[]) { if (plugin.npm == null) { continue; } diff --git a/readInfoFile.ts b/readInfoFile.ts index e3f0d0a..0b575e9 100644 --- a/readInfoFile.ts +++ b/readInfoFile.ts @@ -15,9 +15,6 @@ export interface PluginData { // 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; url: string; version: string; downloadCount: {