Skip to content

Commit

Permalink
feat: add support for ts-types (#313)
Browse files Browse the repository at this point in the history
* test: remove a duplicated test case

* test: add tests for ts-types

* feat: add support for ts-types

* test: fix test case title
  • Loading branch information
Omochice authored Dec 31, 2024
1 parent 875c49e commit 20eeca9
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 16 deletions.
2 changes: 1 addition & 1 deletion deno/deno-land.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"customType": "regex",
"fileMatch": ["\\.[jt]sx?$"],
"matchStrings": [
"((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"](?<depName>https://deno.land/(?:x?.+?|std))@(?<currentValue>v?(?: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=|//\\s*@ts-types=)['\"](?<depName>https://deno.land/(?:x?.+?|std))@(?<currentValue>v?(?: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": "deno"
}
Expand Down
4 changes: 2 additions & 2 deletions deno/github-tag.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"customType": "regex",
"fileMatch": ["\\.[jt]sx?$"],
"matchStrings": [
"((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"]https://pax.deno.dev/(?<depName>.+?/.+?)@(?<currentValue>[^/\"']+?)[/\"']",
"((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"]https://raw.githubusercontent.com/(?<depName>.+?/.+?)/(?<currentValue>[^'\"]+?)[/'\"]"
"((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=|//\\s*@ts-types=)['\"]https://pax.deno.dev/(?<depName>.+?/.+?)@(?<currentValue>[^/\"']+?)[/\"']",
"((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=|//\\s*@ts-types=)['\"]https://raw.githubusercontent.com/(?<depName>.+?/.+?)/(?<currentValue>[^'\"]+?)[/'\"]"
],
"datasourceTemplate": "github-tags"
}
Expand Down
4 changes: 2 additions & 2 deletions deno/jsr.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,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=)['\"]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-]+)*))?)?)?)[/'\"]"
"((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=|//\\s*@ts-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=|//\\s*@ts-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",
"registryUrlTemplate": "https://npm.jsr.io",
Expand Down
2 changes: 1 addition & 1 deletion deno/nest-land.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"customType": "regex",
"fileMatch": ["\\.[jt]sx?$"],
"matchStrings": [
"((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"]https://x.nest.land/(?<depName>.+?)@(?<currentValue>v?(?: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=|//\\s*@ts-types=)['\"]https://x.nest.land/(?<depName>.+?)@(?<currentValue>v?(?: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": "custom.nest-land"
}
Expand Down
8 changes: 4 additions & 4 deletions deno/npm.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"customType": "regex",
"fileMatch": ["\\.[jt]sx?$"],
"matchStrings": [
"((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"]https://esm.sh/(v\\d{1,3}/)?(?<depName>.+?)@v?(?<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=)['\"]npm:(?<depName>.+?)@v?(?<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?://unpkg.com/(?<depName>(?:@[^/\"']*/)?[^/\"']*?)@v?(?<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?://cdn.skypack.dev/(?<depName>(?:@[^/\"']*/)?[^/\"']*?)@v?(?<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=|//\\s*@ts-types=)['\"]https://esm.sh/(v\\d{1,3}/)?(?<depName>.+?)@v?(?<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=|//\\s*@ts-types=)['\"]npm:(?<depName>.+?)@v?(?<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=|//\\s*@ts-types=)['\"]https?://unpkg.com/(?<depName>(?:@[^/\"']*/)?[^/\"']*?)@v?(?<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=|//\\s*@ts-types=)['\"]https?://cdn.skypack.dev/(?<depName>(?:@[^/\"']*/)?[^/\"']*?)@v?(?<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"
}
Expand Down
6 changes: 6 additions & 0 deletions test/deno/deno-land.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ describe("deno.land for import map", () => {
currentValue: "0.1.0",
depName: "https://deno.land/x/some_module",
},
{
title: "should accept deno.land/x in //@ts-types",
input: `// @ts-types="https://deno.land/x/some_module@1.0.0/some/mod.ts";`,
currentValue: "1.0.0",
depName: "https://deno.land/x/some_module",
},
] as const;

it.each(testCases)("$title", ({ input, currentValue, depName }) => {
Expand Down
6 changes: 6 additions & 0 deletions test/deno/github-tag.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ describe("github tag for js file", () => {
currentValue: "sampleversion",
depName: "user/repo",
},
{
title: "should accept un-semver version in //@ts-types",
input: `// @ts-types="https://raw.githubusercontent.com/user/repo/sampleversion/mod.ts"`,
currentValue: "sampleversion",
depName: "user/repo",
},
];

it.each(testCases)("$title", ({ input, currentValue, depName }) => {
Expand Down
12 changes: 6 additions & 6 deletions test/deno/jsr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ describe("jsr for js file", () => {
currentValue: "1.0.1",
depName: "@luca/flag",
},
{
title: "should accept jsr specifier in //@deno-types",
input: `// @deno-types="jsr:@luca/flag@1.0.1";`,
currentValue: "1.0.1",
depName: "@luca/flag",
},
{
title: "version pinning(^) with //@deno-types",
input: `// @deno-types="jsr:@luca/flag@^1.0.1";`,
Expand Down Expand Up @@ -139,6 +133,12 @@ describe("jsr for js file", () => {
currentValue: "1.0.6",
depName: "@std/assert",
},
{
title: "should accept jsr specifier in //@ts-types",
input: `// @ts-types="jsr:@some/package@0.1.0";`,
currentValue: "0.1.0",
depName: "@some/package",
},
] as const;

it.each(testCases)("$title", ({ input, currentValue, depName }) => {
Expand Down
6 changes: 6 additions & 0 deletions test/deno/nest-land.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ describe("x.nest.land for js file", () => {
currentValue: "v0.0.1",
depName: "sample",
},
{
title: "should accept x.nest.land in //@ts-types",
input: `// @ts-types="https://x.nest.land/sample@0.0.1/mod.ts";`,
currentValue: "0.0.1",
depName: "sample",
},
];

it.each(testCases)("$title", ({ input, currentValue, depName }) => {
Expand Down
6 changes: 6 additions & 0 deletions test/deno/npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ describe("npm for js file", () => {
currentValue: "10.5.5",
depName: "@scope/package",
},
{
title: "should accept npm specifier in //@ts-types",
input: `// @ts-types="npm:some@0.1.0";`,
currentValue: "0.1.0",
depName: "some",
},
] as const;

it.each(testCases)("$title", ({ input, currentValue, depName }) => {
Expand Down

0 comments on commit 20eeca9

Please sign in to comment.