diff --git a/database.json b/database.json index e9df329fe..1e4f21b48 100644 --- a/database.json +++ b/database.json @@ -836,13 +836,13 @@ "type": "github", "owner": "viandwi24", "repo": "denova", - "desc": "A Typescript Framework For Deno - Framework Looks Like Laravel." + "desc": "A Typescript Framework For Deno - Framework Looks Like Laravel." }, "denovel": { "type": "github", "owner": "fauzan121002", "repo": "denovel", - "desc": "A Deno Framework for Web Artisan - Inspired by Laravel." + "desc": "A Deno Framework for Web Artisan - Inspired by Laravel." }, "denoversion": { "type": "github", @@ -2232,7 +2232,7 @@ "repo": "router", "desc": "A high-performance basic router works everywhere." }, - "rsocket": { + "rsocket": { "type": "github", "owner": "linux-china", "repo": "rsocket-deno", diff --git a/pages/x/index.tsx b/pages/x/index.tsx index 4dfc99e92..e5d46973d 100644 --- a/pages/x/index.tsx +++ b/pages/x/index.tsx @@ -44,7 +44,7 @@ const ThirdPartyRegistryList = () => {
-

+

deno.land/x is a URL rewriting service for Deno scripts. The basic format of code URLs is{" "} @@ -54,6 +54,13 @@ const ThirdPartyRegistryList = () => { . If you leave out the branch, it will default to the module’s default branch, usually master.

+ +

+ Experimental: Use npm:[package] or + gh:[owner]:[repo] as module name to + resolve any artibrary repository or npm package. +

+

Functionality built-in to Deno is not listed here. The built-in runtime is documented on{" "} @@ -78,7 +85,9 @@ const ThirdPartyRegistryList = () => { > database.json - . + {". "} + Run the tests and formatting before submitting a patch - the PR + must be green to be considered.

diff --git a/util/registry_utils.test.ts b/util/registry_utils.test.ts index 57a61e0d8..ddce403a6 100644 --- a/util/registry_utils.test.ts +++ b/util/registry_utils.test.ts @@ -1,5 +1,7 @@ import { findEntry } from "./registry_utils"; import { DenoStdEntry } from "./registries/deno_std"; +import { NPMEntry } from "./registries/npm"; +import { GithubEntry } from "./registries/github"; /* eslint-env jest */ @@ -11,3 +13,24 @@ test("find 'std' in database", () => { }) ); }); + +test("Resolve virtual 'gh:owner:repo'", () => { + expect(findEntry("gh:owner:repo")).toEqual( + new GithubEntry({ + type: "github", + desc: "owner/repo", + owner: "owner", + repo: "repo", + }) + ); +}); + +test("Resolve virtual 'npm:package'", () => { + expect(findEntry("npm:package")).toEqual( + new NPMEntry({ + type: "npm", + desc: "package", + package: "package", + }) + ); +}); diff --git a/util/registry_utils.ts b/util/registry_utils.ts index 21f192fb3..f0d3642fc 100644 --- a/util/registry_utils.ts +++ b/util/registry_utils.ts @@ -15,6 +15,27 @@ function findDatabaseEntry( | URLDatabaseEntry | NPMDatabaseEntry | undefined { + if (name.startsWith("npm:")) { + const [_, packageName] = name.split(":"); + const entry: NPMDatabaseEntry = { + desc: packageName, + package: packageName, + type: "npm", + }; + return entry; + } + + if (name.startsWith("gh:")) { + const [_, owner, repo] = name.split(":"); + const entry: GithubDatabaseEntry = { + desc: `${owner}/${repo}`, + owner, + repo, + type: "github", + }; + return entry; + } + // @ts-ignore return DATABASE[name]; }