Skip to content

Commit

Permalink
feat: support https://jsr.io` (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
Omochice authored Jun 8, 2024
1 parent 1435706 commit d181a7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions deno/jsr.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"customType": "regex",
"fileMatch": ["(?:^|/)import_map.json$", "(?:^|/)deno.jsonc?$"],
"matchStrings": [
"['\"].+?['\"]\\s*:\\s*['\"]jsr:(?<depName>@(?<namespace>.+?)/(?<package>.+?))@[\\^~]?(?<currentValue>(?: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:(?<depName>@(?<namespace>.+?)/(?<package>.+?))@[\\^~]?(?<currentValue>(?: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/(?<depName>@(?<namespace>.+?)/(?<package>.+?))/(?<currentValue>(?: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}}"
Expand All @@ -14,7 +15,8 @@
"customType": "regex",
"fileMatch": ["\\.[jt]sx?$"],
"matchStrings": [
"((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"]jsr:(?<depName>@(?<namespace>.+?)/(?<package>.+?))@[\\^~]?(?<currentValue>(?: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:(?<depName>@(?<namespace>.+?)/(?<package>.+?))@[\\^~]?(?<currentValue>(?: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/(?<depName>@(?<namespace>.+?)/(?<package>.+?))/(?<currentValue>(?: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}}"
Expand Down
16 changes: 16 additions & 0 deletions test/deno/jsr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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";`,
Expand Down

0 comments on commit d181a7a

Please sign in to comment.