From 512b7ec9f16e4527f1830585c946e6094bb34cb3 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Wed, 20 May 2020 20:15:50 +0200 Subject: [PATCH 1/7] feat: support virtual database entries for npm and github --- util/registry_utils.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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]; } From 2a055095b119b87960b76c0096b5cbda5ca0d811 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Wed, 20 May 2020 20:15:57 +0200 Subject: [PATCH 2/7] test: add test for virtual entries --- util/registry_utils.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/util/registry_utils.test.ts b/util/registry_utils.test.ts index 57a61e0d8..a3c4557c7 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", + }) + ); +}); From 56fed217457acae464353d42e8337d6a92ed8bd6 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Wed, 20 May 2020 20:18:50 +0200 Subject: [PATCH 3/7] docs: add virtual package doc --- pages/x/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pages/x/index.tsx b/pages/x/index.tsx index 16539df77..2ec14ce08 100644 --- a/pages/x/index.tsx +++ b/pages/x/index.tsx @@ -52,7 +52,9 @@ const ThirdPartyRegistryList = () => { https://deno.land/x/MODULE_NAME@BRANCH/SCRIPT.ts . If you leave out the branch, it will default to the module’s - default branch, usually master. + default branch, usually master. You can + 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 From 0a280df589d686eb9892fa71e4c37fcba6962774 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Wed, 20 May 2020 20:27:59 +0200 Subject: [PATCH 4/7] chore: format with prettier --- pages/x/index.tsx | 3 ++- util/registry_utils.test.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pages/x/index.tsx b/pages/x/index.tsx index 2ec14ce08..25c5e39c6 100644 --- a/pages/x/index.tsx +++ b/pages/x/index.tsx @@ -54,7 +54,8 @@ const ThirdPartyRegistryList = () => { . If you leave out the branch, it will default to the module’s default branch, usually master. You can use npm:[package] or - gh:[owner]:[repo] as module name to resolve any artibrary repository or npm package. + 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 diff --git a/util/registry_utils.test.ts b/util/registry_utils.test.ts index a3c4557c7..ddce403a6 100644 --- a/util/registry_utils.test.ts +++ b/util/registry_utils.test.ts @@ -20,7 +20,7 @@ test("Resolve virtual 'gh:owner:repo'", () => { type: "github", desc: "owner/repo", owner: "owner", - repo: 'repo' + repo: "repo", }) ); }); From dee88cab9d12d4ddad57fed3ac72cd15cf5a2ecd Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 28 May 2020 08:36:07 -0400 Subject: [PATCH 5/7] fmt --- database.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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", From 8d90a5d8a157b84086042986e39808a092bd72e5 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 28 May 2020 08:41:24 -0400 Subject: [PATCH 6/7] mark experimental --- pages/x/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pages/x/index.tsx b/pages/x/index.tsx index 92cee56cf..aa885e15b 100644 --- a/pages/x/index.tsx +++ b/pages/x/index.tsx @@ -52,11 +52,15 @@ const ThirdPartyRegistryList = () => { https://deno.land/x/MODULE_NAME@BRANCH/SCRIPT.ts . If you leave out the branch, it will default to the module’s - default branch, usually master. You can - use npm:[package] or + 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{" "} From 8765e915cb22f858f1785199298fb417d08964f9 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 28 May 2020 08:46:27 -0400 Subject: [PATCH 7/7] edit --- pages/x/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pages/x/index.tsx b/pages/x/index.tsx index aa885e15b..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{" "} @@ -55,7 +55,7 @@ const ThirdPartyRegistryList = () => { default branch, usually master.

-

+

Experimental: Use npm:[package] or gh:[owner]:[repo] as module name to resolve any artibrary repository or npm package. @@ -85,7 +85,9 @@ const ThirdPartyRegistryList = () => { > database.json - . + {". "} + Run the tests and formatting before submitting a patch - the PR + must be green to be considered.