From d181a7ae5df0189171d70e3cbcf5e82c6e2b64e7 Mon Sep 17 00:00:00 2001 From: Omochice <44566328+Omochice@users.noreply.github.com> Date: Sun, 9 Jun 2024 06:35:53 +0900 Subject: [PATCH] feat: support `https://jsr.io` (#85) --- deno/jsr.json | 6 ++++-- test/deno/jsr.test.ts | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/deno/jsr.json b/deno/jsr.json index 46f889d..443b3ab 100644 --- a/deno/jsr.json +++ b/deno/jsr.json @@ -5,7 +5,8 @@ "customType": "regex", "fileMatch": ["(?:^|/)import_map.json$", "(?:^|/)deno.jsonc?$"], "matchStrings": [ - "['\"].+?['\"]\\s*:\\s*['\"]jsr:(?@(?.+?)/(?.+?))@[\\^~]?(?(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)?)?)[/\"']" + "['\"].+?['\"]\\s*:\\s*['\"]jsr:(?@(?.+?)/(?.+?))@[\\^~]?(?(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)?)?)[/\"']", + "['\"].+?['\"]\\s*:\\s*['\"]https://jsr.io/(?@(?.+?)/(?.+?))/(?(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)?)?)[/\"']" ], "datasourceTemplate": "npm", "packageNameTemplate": "@jsr/{{namespace}}__{{package}}" @@ -14,7 +15,8 @@ "customType": "regex", "fileMatch": ["\\.[jt]sx?$"], "matchStrings": [ - "((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"]jsr:(?@(?.+?)/(?.+?))@[\\^~]?(?(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)?)?)[/'\"]" + "((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"]jsr:(?@(?.+?)/(?.+?))@[\\^~]?(?(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)?)?)[/'\"]", + "((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"]https://jsr.io/(?@(?.+?)/(?.+?))/(?(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:\\.(?:0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)?)?)[/'\"]" ], "datasourceTemplate": "npm", "packageNameTemplate": "@jsr/{{namespace}}__{{package}}" diff --git a/test/deno/jsr.test.ts b/test/deno/jsr.test.ts index 05ace7d..f54557e 100644 --- a/test/deno/jsr.test.ts +++ b/test/deno/jsr.test.ts @@ -34,6 +34,16 @@ describe("jsr for import map", () => { currentValue: "1.0.1", depName: "@luca/flag", }, + { + title: "should accept https://jsr.io", + input: `{ + "imports": { + "@luca/flag": "https://jsr.io/@luca/flag/1.0.1/main.ts" + } + }`, + currentValue: "1.0.1", + depName: "@luca/flag", + }, ] as const; it.each(testCases)("$title", ({ input, currentValue, depName }) => { @@ -56,6 +66,12 @@ describe("jsr for js file", () => { currentValue: "1.0.1", depName: "@luca/flag", }, + { + title: "should accept https://jsr.io", + input: `import { printProgress } from "https://jsr.io/@luca/flag/1.0.1/main.ts";`, + currentValue: "1.0.1", + depName: "@luca/flag", + }, { title: "should accept version pinning(^)", input: `import { printProgress } from "jsr:@luca/flag@^1.0.1";`,