From 20eeca9fd1dccc5e78da2b331566fdf16bef484a Mon Sep 17 00:00:00 2001 From: Omochice <44566328+Omochice@users.noreply.github.com> Date: Tue, 31 Dec 2024 23:51:24 +0900 Subject: [PATCH] feat: add support for `ts-types` (#313) * test: remove a duplicated test case * test: add tests for ts-types * feat: add support for ts-types * test: fix test case title --- deno/deno-land.json | 2 +- deno/github-tag.json | 4 ++-- deno/jsr.json | 4 ++-- deno/nest-land.json | 2 +- deno/npm.json | 8 ++++---- test/deno/deno-land.test.ts | 6 ++++++ test/deno/github-tag.test.ts | 6 ++++++ test/deno/jsr.test.ts | 12 ++++++------ test/deno/nest-land.test.ts | 6 ++++++ test/deno/npm.test.ts | 6 ++++++ 10 files changed, 40 insertions(+), 16 deletions(-) diff --git a/deno/deno-land.json b/deno/deno-land.json index 4c94607..7d06cb0 100644 --- a/deno/deno-land.json +++ b/deno/deno-land.json @@ -13,7 +13,7 @@ "customType": "regex", "fileMatch": ["\\.[jt]sx?$"], "matchStrings": [ - "((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"](?https://deno.land/(?:x?.+?|std))@(?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://deno.land/(?:x?.+?|std))@(?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" } diff --git a/deno/github-tag.json b/deno/github-tag.json index 42cd60a..c38b087 100644 --- a/deno/github-tag.json +++ b/deno/github-tag.json @@ -14,8 +14,8 @@ "customType": "regex", "fileMatch": ["\\.[jt]sx?$"], "matchStrings": [ - "((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"]https://pax.deno.dev/(?.+?/.+?)@(?[^/\"']+?)[/\"']", - "((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"]https://raw.githubusercontent.com/(?.+?/.+?)/(?[^'\"]+?)[/'\"]" + "((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=|//\\s*@ts-types=)['\"]https://pax.deno.dev/(?.+?/.+?)@(?[^/\"']+?)[/\"']", + "((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=|//\\s*@ts-types=)['\"]https://raw.githubusercontent.com/(?.+?/.+?)/(?[^'\"]+?)[/'\"]" ], "datasourceTemplate": "github-tags" } diff --git a/deno/jsr.json b/deno/jsr.json index 5284c4f..97c2836 100644 --- a/deno/jsr.json +++ b/deno/jsr.json @@ -16,8 +16,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=)['\"]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-]+)*))?)?)?)[/'\"]" + "((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=|//\\s*@ts-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=|//\\s*@ts-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", "registryUrlTemplate": "https://npm.jsr.io", diff --git a/deno/nest-land.json b/deno/nest-land.json index a0620b6..529e4c6 100644 --- a/deno/nest-land.json +++ b/deno/nest-land.json @@ -13,7 +13,7 @@ "customType": "regex", "fileMatch": ["\\.[jt]sx?$"], "matchStrings": [ - "((?:im|ex)port(?:.|\\s)+?from\\s*|//\\s*@deno-types=)['\"]https://x.nest.land/(?.+?)@(?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/(?.+?)@(?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" } diff --git a/deno/npm.json b/deno/npm.json index b4fa428..143e597 100644 --- a/deno/npm.json +++ b/deno/npm.json @@ -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}/)?(?.+?)@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=)['\"]npm:(?.+?)@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*|\\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:(?.+?)@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?://unpkg.com/(?(?:@[^/\"']*/)?[^/\"']*?)@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?://cdn.skypack.dev/(?(?:@[^/\"']*/)?[^/\"']*?)@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": "npm" } diff --git a/test/deno/deno-land.test.ts b/test/deno/deno-land.test.ts index 9d08c33..79b24c0 100644 --- a/test/deno/deno-land.test.ts +++ b/test/deno/deno-land.test.ts @@ -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 }) => { diff --git a/test/deno/github-tag.test.ts b/test/deno/github-tag.test.ts index 7dc4573..f557a5b 100644 --- a/test/deno/github-tag.test.ts +++ b/test/deno/github-tag.test.ts @@ -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 }) => { diff --git a/test/deno/jsr.test.ts b/test/deno/jsr.test.ts index d66f971..f8090a9 100644 --- a/test/deno/jsr.test.ts +++ b/test/deno/jsr.test.ts @@ -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";`, @@ -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 }) => { diff --git a/test/deno/nest-land.test.ts b/test/deno/nest-land.test.ts index 6e00ccd..eef2d08 100644 --- a/test/deno/nest-land.test.ts +++ b/test/deno/nest-land.test.ts @@ -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 }) => { diff --git a/test/deno/npm.test.ts b/test/deno/npm.test.ts index 57b1a79..d3d6cd8 100644 --- a/test/deno/npm.test.ts +++ b/test/deno/npm.test.ts @@ -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 }) => {