diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cb754f0..c54e72de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,9 +19,11 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: task: test:unit + submodules: true integration: name: Integration uses: hasundue/actions/.github/workflows/integration-deno.yml@main with: task: test:integration + submodules: true diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..cbe0e3a0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "core/import_map"] + path = core/import_map + url = https://github.com/hasundue/import_map.git diff --git a/cli/cli_test.ts b/cli/cli_test.ts index 4ba20261..c586221f 100644 --- a/cli/cli_test.ts +++ b/cli/cli_test.ts @@ -56,6 +56,10 @@ molt( // --no-resolve molt("mod.ts --no-resolve", { dir: "multiple_modules" }); +// jsr import with path +molt("mod.ts", { dir: "jsr_with_path_in_import_map" }); +molt("deno.json", { dir: "jsr_with_path_in_import_map" }); + //----------------------- // Test implementation //----------------------- diff --git a/core/deno.json b/core/deno.json index a3742b9a..81d01173 100644 --- a/core/deno.json +++ b/core/deno.json @@ -21,12 +21,6 @@ "@std/jsonc": "jsr:@std/jsonc@^0.222.1", "@std/path": "jsr:@std/path@^0.222.1", "@std/semver": "jsr:@std/semver@^0.222.1", - "@std/testing": "jsr:@std/testing@^0.222.1", - "x/import_map": "./vendor/deno.land/x/import_map@v0.19.1/mod.ts" - }, - "scopes": { - "./vendor/": { - "https://deno.land/": "./vendor/deno.land/" - } + "@std/testing": "jsr:@std/testing@^0.222.1" } } diff --git a/core/dependency.ts b/core/dependency.ts index 5527406a..2ac3531b 100644 --- a/core/dependency.ts +++ b/core/dependency.ts @@ -123,11 +123,18 @@ function addSeparator(protocol: string): string { * // -> "https://deno.land/std@1.0.0/fs/mod.ts" * ``` */ -export function stringify(dependency: Dependency, includePath = true): string { - const header = addSeparator(dependency.protocol); +export function stringify( + dependency: Dependency, + include: { protocol?: boolean; path?: boolean } = {}, +): string { + include.protocol ??= true; + const header = include.protocol ? addSeparator(dependency.protocol) : ""; + const version = dependency.version ? "@" + dependency.version : ""; const path = dependency.path; - return `${header}${dependency.name}${version}` + (includePath ? path : ""); + + include.path ??= true; + return `${header}${dependency.name}${version}` + (include.path ? path : ""); } export function hasVersionRange( diff --git a/core/import_map b/core/import_map new file mode 160000 index 00000000..3c8d55da --- /dev/null +++ b/core/import_map @@ -0,0 +1 @@ +Subproject commit 3c8d55da6a111641dd5273e1dd161a5c66aeff10 diff --git a/core/import_map.ts b/core/import_map.ts index 7fc2c930..e98b7895 100644 --- a/core/import_map.ts +++ b/core/import_map.ts @@ -3,7 +3,8 @@ import { maxBy } from "@std/collections"; import { parse as parseJsonc } from "@std/jsonc"; import { ensure, is } from "@core/unknownutil"; import { toPath } from "@molt/lib/path"; -import { type ImportMapJson, parseFromJson } from "x/import_map"; +import { type ImportMapJson, parseFromJson } from "./import_map/js/mod.ts"; +import { parse, stringify } from "./dependency.ts"; export type { ImportMapJson }; @@ -98,13 +99,22 @@ export async function readFromJson( return; } const url = new URL(resolved); - // Find which key is used for the resolution. - // This is ridiculously inefficient, but we prefer not to reimplement - // the whole import_map module. Maybe we should rather contribute to - // the original import_map module. + // Find which key is used for the resolution. This is ridiculously + // inefficient, but we prefer not to reimplement the whole + // import_map module. + // TODO: migrate to our own import_map wasm const replacement = maxBy( Object.entries(json.imports) - .filter(([, value]) => resolved.includes(value)) + .filter(([, value]) => + resolved.includes( + // We need this because import_map adds a heading slash to the + // dependency when a jsr import has a path. + // e.g. jsr:/@std/testing@0.210.0/ + value.startsWith("jsr:") + ? stringify(parse(value), { protocol: false, path: true }) + : value, + ) + ) .map(([key, value]) => ({ key, value })), ({ value }) => value.length, ); diff --git a/core/import_map_test.ts b/core/import_map_test.ts index 0fe7ea50..2fbfa98d 100644 --- a/core/import_map_test.ts +++ b/core/import_map_test.ts @@ -77,6 +77,7 @@ describe("resolve()", () => { }, ); }); + it("do not resolve an url", async () => { const importMap = await readFromJson( new URL( @@ -97,6 +98,7 @@ describe("resolve()", () => { undefined, ); }); + it("resolve specifiers in a referred import map", async () => { const importMap = await readFromJson( new URL( @@ -118,6 +120,23 @@ describe("resolve()", () => { }, ); }); + + it("resolve a jsr specifier with path", async () => { + const dir = "../test/cases/jsr_with_path_in_import_map"; + const importMap = await readFromJson( + new URL(`${dir}/deno.json`, import.meta.url), + ); + assertExists(importMap); + const referrer = new URL(`${dir}/mod.ts`, import.meta.url); + assertEquals( + importMap.resolve("@std/testing/bdd", referrer), + { + resolved: "jsr:/@std/testing@0.210.0/bdd", + key: "@std/testing", + value: "jsr:@std/testing@0.210.0", + }, + ); + }); }); Deno.test("resolveInner", async () => { @@ -129,8 +148,4 @@ Deno.test("resolveInner", async () => { resolveInner("/lib.ts", referrer), new URL("../test/cases/import_map/lib.ts", import.meta.url).href, ); - assertEquals( - resolveInner("@std/testing/bdd", referrer), - "jsr:/@std/testing@0.200.0/bdd", - ); }); diff --git a/deno.json b/deno.json index da29a90a..06410023 100644 --- a/deno.json +++ b/deno.json @@ -9,8 +9,7 @@ "pre-commit": "deno fmt && deno lint && deno task -q check && deno task -q test", "run": "deno run -A --unstable-kv --config ./deno.json ./cli/main.ts", "update": "deno run --unstable-kv --config ./deno.json --allow-env --allow-read --allow-write --allow-net --allow-run=git,deno ./cli/main.ts ./deno.json ./*/deno.json --changelog", - "update:commit": "deno task -q update --commit --prefix 'build(deps):'", - "vendor": "deno vendor -qf --no-config --output ./core/vendor https://deno.land/x/import_map/mod.ts && curl -fsSL -o ./core/vendor/deno.land/x/import_map@v0.19.1/import_map_bg.wasm https://deno.land/x/import_map@v0.19.1/import_map_bg.wasm" + "update:commit": "deno task -q update --commit --prefix 'build(deps):'" }, "imports": { "@cliffy/ansi": "jsr:@cliffy/ansi@1.0.0-rc.4", @@ -30,8 +29,7 @@ "@std/jsonc": "jsr:@std/jsonc@^0.222.1", "@std/path": "jsr:@std/path@^0.222.1", "@std/semver": "jsr:@std/semver@^0.222.1", - "@std/testing": "jsr:@std/testing@^0.222.1", - "x/import_map": "https://deno.land/x/import_map@v0.19.1/mod.ts" + "@std/testing": "jsr:@std/testing@^0.222.1" }, "scopes": { ".": { @@ -46,11 +44,6 @@ "@molt/integration/repository": "./integration/repository.ts" } }, - "fmt": { - "exclude": [ - "CHANGELOG.md" - ] - }, "lint": { "exclude": [ "test/cases", @@ -61,5 +54,8 @@ "no-sync-fn-in-async-fn" ] } - } + }, + "exclude": [ + "core/import_map" + ] } diff --git a/deno.lock b/deno.lock index e1fc9c6e..996723c5 100644 --- a/deno.lock +++ b/deno.lock @@ -11,29 +11,40 @@ "jsr:@david/dax@^0.40.0": "jsr:@david/dax@0.40.1", "jsr:@david/which@0.3": "jsr:@david/which@0.3.0", "jsr:@deno/graph@^0.73.1": "jsr:@deno/graph@0.73.1", + "jsr:@deno/wasmbuild@0.15.6": "jsr:@deno/wasmbuild@0.15.6", "jsr:@lambdalisue/async@^2.1.1": "jsr:@lambdalisue/async@2.1.1", + "jsr:@std/archive@^0.218.2": "jsr:@std/archive@0.218.2", + "jsr:@std/assert@^0.218.2": "jsr:@std/assert@0.218.2", "jsr:@std/assert@^0.221.0": "jsr:@std/assert@0.221.0", "jsr:@std/assert@^0.222.1": "jsr:@std/assert@0.222.1", + "jsr:@std/bytes@^0.218.2": "jsr:@std/bytes@0.218.2", "jsr:@std/bytes@^0.221.0": "jsr:@std/bytes@0.221.0", + "jsr:@std/cli@^0.218.2": "jsr:@std/cli@0.218.2", "jsr:@std/collections@^0.222.1": "jsr:@std/collections@0.222.1", "jsr:@std/console@0.221": "jsr:@std/console@0.221.0", "jsr:@std/dotenv@^0.222.1": "jsr:@std/dotenv@0.222.1", "jsr:@std/encoding@0.221": "jsr:@std/encoding@0.221.0", + "jsr:@std/encoding@^0.218.2": "jsr:@std/encoding@0.218.2", "jsr:@std/fmt@0.221": "jsr:@std/fmt@0.221.0", + "jsr:@std/fmt@^0.218.2": "jsr:@std/fmt@0.218.2", "jsr:@std/fmt@^0.221.0": "jsr:@std/fmt@0.221.0", "jsr:@std/fmt@^0.222.1": "jsr:@std/fmt@0.222.1", "jsr:@std/fs@0.221.0": "jsr:@std/fs@0.221.0", + "jsr:@std/fs@^0.218.2": "jsr:@std/fs@0.218.2", "jsr:@std/fs@^0.222.1": "jsr:@std/fs@0.222.1", "jsr:@std/io@0.221": "jsr:@std/io@0.221.0", "jsr:@std/io@0.221.0": "jsr:@std/io@0.221.0", + "jsr:@std/io@^0.218.2": "jsr:@std/io@0.218.2", "jsr:@std/io@^0.221.0": "jsr:@std/io@0.221.0", "jsr:@std/json@^0.222.1": "jsr:@std/json@0.222.1", "jsr:@std/jsonc@^0.222.1": "jsr:@std/jsonc@0.222.1", "jsr:@std/path@0.221.0": "jsr:@std/path@0.221.0", + "jsr:@std/path@^0.218.2": "jsr:@std/path@0.218.2", "jsr:@std/path@^0.221.0": "jsr:@std/path@0.221.0", "jsr:@std/path@^0.222.1": "jsr:@std/path@0.222.1", "jsr:@std/semver@^0.222.1": "jsr:@std/semver@0.222.1", "jsr:@std/streams@0.221.0": "jsr:@std/streams@0.221.0", + "jsr:@std/streams@^0.218.2": "jsr:@std/streams@0.218.2", "jsr:@std/testing@^0.222.1": "jsr:@std/testing@0.222.1", "jsr:@std/text@0.221": "jsr:@std/text@0.221.0", "npm:@conventional-commits/parser@^0.4.1": "npm:@conventional-commits/parser@0.4.1", @@ -93,9 +104,31 @@ "@deno/graph@0.73.1": { "integrity": "cd69639d2709d479037d5ce191a422eabe8d71bb68b0098344f6b07411c84d41" }, + "@deno/wasmbuild@0.15.6": { + "integrity": "d55c16d33543b016126ea7d0def259b6bca451249e7c2dac2f7e5ed8ac003c2e", + "dependencies": [ + "jsr:@std/archive@^0.218.2", + "jsr:@std/cli@^0.218.2", + "jsr:@std/encoding@^0.218.2", + "jsr:@std/fmt@^0.218.2", + "jsr:@std/fs@^0.218.2", + "jsr:@std/io@^0.218.2", + "jsr:@std/path@^0.218.2", + "jsr:@std/streams@^0.218.2" + ] + }, "@lambdalisue/async@2.1.1": { "integrity": "1fc9bc6f4ed50215cd2f7217842b18cea80f81c25744f88f8c5eb4be5a1c9ab4" }, + "@std/archive@0.218.2": { + "integrity": "bcf2a51953ebb14816d66170a50e1ac8805dd7c31e1b822887708211f5398c37", + "dependencies": [ + "jsr:@std/io@^0.218.2" + ] + }, + "@std/assert@0.218.2": { + "integrity": "7f0a5a1a8cf86607cd6c2c030584096e1ffad27fc9271429a8cb48cfbdee5eaf" + }, "@std/assert@0.221.0": { "integrity": "a5f1aa6e7909dbea271754fd4ab3f4e687aeff4873b4cef9a320af813adb489a" }, @@ -105,9 +138,18 @@ "jsr:@std/fmt@^0.222.1" ] }, + "@std/bytes@0.218.2": { + "integrity": "91fe54b232dcca73856b79a817247f4a651dbb60d51baafafb6408c137241670" + }, "@std/bytes@0.221.0": { "integrity": "64a047011cf833890a4a2ab7293ac55a1b4f5a050624ebc6a0159c357de91966" }, + "@std/cli@0.218.2": { + "integrity": "7877f41b4369f51b2ee06132b678ceee703051671c0fcea9058c1c0242652098", + "dependencies": [ + "jsr:@std/assert@^0.218.2" + ] + }, "@std/collections@0.222.1": { "integrity": "234099e08eead6a87e59f4f1abdcba35df5503cfb0e852e77a19f79359ed5760" }, @@ -117,15 +159,28 @@ "@std/dotenv@0.222.1": { "integrity": "61c75269cfd569033d580d9341597eb1cd4b2796323c5823033bb6d60c66d619" }, + "@std/encoding@0.218.2": { + "integrity": "da55a763c29bf0dbf06fd286430b358266eb99c28789d89fe9a3e28edecb8d8e" + }, "@std/encoding@0.221.0": { "integrity": "d1dd76ef0dc5d14088411e6dc1dede53bf8308c95d1537df1214c97137208e45" }, + "@std/fmt@0.218.2": { + "integrity": "99526449d2505aa758b6cbef81e7dd471d8b28ec0dcb1491d122b284c548788a" + }, "@std/fmt@0.221.0": { "integrity": "379fed69bdd9731110f26b9085aeb740606b20428ce6af31ef6bd45ef8efa62a" }, "@std/fmt@0.222.1": { "integrity": "ec3382f9b0261c1ab1a5c804aa355d816515fa984cdd827ed32edfb187c0a722" }, + "@std/fs@0.218.2": { + "integrity": "dd9431453f7282e8c577cc22c9e6d036055a9a980b5549f887d6012969fabcca", + "dependencies": [ + "jsr:@std/assert@^0.218.2", + "jsr:@std/path@^0.218.2" + ] + }, "@std/fs@0.221.0": { "integrity": "028044450299de8ed5a716ade4e6d524399f035513b85913794f4e81f07da286", "dependencies": [ @@ -140,6 +195,13 @@ "jsr:@std/path@^0.222.1" ] }, + "@std/io@0.218.2": { + "integrity": "c64fbfa087b7c9d4d386c5672f291f607d88cb7d44fc299c20c713e345f2785f", + "dependencies": [ + "jsr:@std/assert@^0.218.2", + "jsr:@std/bytes@^0.218.2" + ] + }, "@std/io@0.221.0": { "integrity": "faf7f8700d46ab527fa05cc6167f4b97701a06c413024431c6b4d207caa010da", "dependencies": [ @@ -157,6 +219,12 @@ "jsr:@std/json@^0.222.1" ] }, + "@std/path@0.218.2": { + "integrity": "b568fd923d9e53ad76d17c513e7310bda8e755a3e825e6289a0ce536404e2662", + "dependencies": [ + "jsr:@std/assert@^0.218.2" + ] + }, "@std/path@0.221.0": { "integrity": "0a36f6b17314ef653a3a1649740cc8db51b25a133ecfe838f20b79a56ebe0095", "dependencies": [ @@ -172,6 +240,14 @@ "@std/semver@0.222.1": { "integrity": "43c5b526423f48f6f75375c77226646803776fdc678b331f243b0bd667d54c18" }, + "@std/streams@0.218.2": { + "integrity": "2af3cab7bb4364575e8616fd36e8df69c5b2ff49b25c5b865c26178e7da2c096", + "dependencies": [ + "jsr:@std/assert@^0.218.2", + "jsr:@std/bytes@^0.218.2", + "jsr:@std/io@^0.218.2" + ] + }, "@std/streams@0.221.0": { "integrity": "47f2f74634b47449277c0ee79fe878da4424b66bd8975c032e3afdca88986e61", "dependencies": [ @@ -351,6 +427,38 @@ } }, "remote": { + "https://deno.land/std@0.205.0/assert/_constants.ts": "8a9da298c26750b28b326b297316cdde860bc237533b07e1337c021379e6b2a9", + "https://deno.land/std@0.205.0/assert/_diff.ts": "58e1461cc61d8eb1eacbf2a010932bf6a05b79344b02ca38095f9b805795dc48", + "https://deno.land/std@0.205.0/assert/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7", + "https://deno.land/std@0.205.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", + "https://deno.land/std@0.205.0/assert/assert_almost_equals.ts": "e15ca1f34d0d5e0afae63b3f5d975cbd18335a132e42b0c747d282f62ad2cd6c", + "https://deno.land/std@0.205.0/assert/assert_array_includes.ts": "6856d7f2c3544bc6e62fb4646dfefa3d1df5ff14744d1bca19f0cbaf3b0d66c9", + "https://deno.land/std@0.205.0/assert/assert_equals.ts": "d8ec8a22447fbaf2fc9d7c3ed2e66790fdb74beae3e482855d75782218d68227", + "https://deno.land/std@0.205.0/assert/assert_exists.ts": "407cb6b9fb23a835cd8d5ad804e2e2edbbbf3870e322d53f79e1c7a512e2efd7", + "https://deno.land/std@0.205.0/assert/assert_false.ts": "0ccbcaae910f52c857192ff16ea08bda40fdc79de80846c206bfc061e8c851c6", + "https://deno.land/std@0.205.0/assert/assert_greater.ts": "ae2158a2d19313bf675bf7251d31c6dc52973edb12ac64ac8fc7064152af3e63", + "https://deno.land/std@0.205.0/assert/assert_greater_or_equal.ts": "1439da5ebbe20855446cac50097ac78b9742abe8e9a43e7de1ce1426d556e89c", + "https://deno.land/std@0.205.0/assert/assert_instance_of.ts": "3aedb3d8186e120812d2b3a5dea66a6e42bf8c57a8bd927645770bd21eea554c", + "https://deno.land/std@0.205.0/assert/assert_is_error.ts": "c21113094a51a296ffaf036767d616a78a2ae5f9f7bbd464cd0197476498b94b", + "https://deno.land/std@0.205.0/assert/assert_less.ts": "aec695db57db42ec3e2b62e97e1e93db0063f5a6ec133326cc290ff4b71b47e4", + "https://deno.land/std@0.205.0/assert/assert_less_or_equal.ts": "5fa8b6a3ffa20fd0a05032fe7257bf985d207b85685fdbcd23651b70f928c848", + "https://deno.land/std@0.205.0/assert/assert_match.ts": "c4083f80600bc190309903c95e397a7c9257ff8b5ae5c7ef91e834704e672e9b", + "https://deno.land/std@0.205.0/assert/assert_not_equals.ts": "9f1acab95bd1f5fc9a1b17b8027d894509a745d91bac1718fdab51dc76831754", + "https://deno.land/std@0.205.0/assert/assert_not_instance_of.ts": "0c14d3dfd9ab7a5276ed8ed0b18c703d79a3d106102077ec437bfe7ed912bd22", + "https://deno.land/std@0.205.0/assert/assert_not_match.ts": "3796a5b0c57a1ce6c1c57883dd4286be13a26f715ea662318ab43a8491a13ab0", + "https://deno.land/std@0.205.0/assert/assert_not_strict_equals.ts": "ca6c6d645e95fbc873d25320efeb8c4c6089a9a5e09f92d7c1c4b6e935c2a6ad", + "https://deno.land/std@0.205.0/assert/assert_object_match.ts": "d8fc2867cfd92eeacf9cea621e10336b666de1874a6767b5ec48988838370b54", + "https://deno.land/std@0.205.0/assert/assert_rejects.ts": "45c59724de2701e3b1f67c391d6c71c392363635aad3f68a1b3408f9efca0057", + "https://deno.land/std@0.205.0/assert/assert_strict_equals.ts": "b1f538a7ea5f8348aeca261d4f9ca603127c665e0f2bbfeb91fa272787c87265", + "https://deno.land/std@0.205.0/assert/assert_string_includes.ts": "b821d39ebf5cb0200a348863c86d8c4c4b398e02012ce74ad15666fc4b631b0c", + "https://deno.land/std@0.205.0/assert/assert_throws.ts": "63784e951475cb7bdfd59878cd25a0931e18f6dc32a6077c454b2cd94f4f4bcd", + "https://deno.land/std@0.205.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", + "https://deno.land/std@0.205.0/assert/equal.ts": "9f1a46d5993966d2596c44e5858eec821859b45f783a5ee2f7a695dfc12d8ece", + "https://deno.land/std@0.205.0/assert/fail.ts": "c36353d7ae6e1f7933d45f8ea51e358c8c4b67d7e7502028598fe1fea062e278", + "https://deno.land/std@0.205.0/assert/mod.ts": "37c49a26aae2b254bbe25723434dc28cd7532e444cf0b481a97c045d110ec085", + "https://deno.land/std@0.205.0/assert/unimplemented.ts": "d56fbeecb1f108331a380f72e3e010a1f161baa6956fd0f7cf3e095ae1a4c75a", + "https://deno.land/std@0.205.0/assert/unreachable.ts": "4600dc0baf7d9c15a7f7d234f00c23bca8f3eba8b140286aaca7aa998cf9a536", + "https://deno.land/std@0.205.0/fmt/colors.ts": "c51c4642678eb690dcf5ffee5918b675bf01a33fba82acf303701ae1a4f8c8d9", "https://deno.land/x/dir@1.5.1/data_local_dir/mod.ts": "91eb1c4bfadfbeda30171007bac6d85aadacd43224a5ed721bbe56bc64e9eb66", "https://deno.land/x/import_map@v0.19.1/import_map.generated.js": "c46023bef881ccecc740740962331f98decbfe72d88644396bf674145c20dd1e", "https://deno.land/x/import_map@v0.19.1/mod.ts": "dd4c4e20639dcfd720a6d41f47bea250db86137901a08988102094678c6b7859", diff --git a/test/snapshots/cli_test.ts.snap b/test/snapshots/cli_test.ts.snap index ed15f4d6..6ebc5edb 100644 --- a/test/snapshots/cli_test.ts.snap +++ b/test/snapshots/cli_test.ts.snap @@ -434,3 +434,23 @@ snapshot[`cli - multiple_modules - "molt mod.ts --no-resolve" 2`] = ` "Checking for updates " `; + +snapshot[`cli - jsr_with_path_in_import_map - "molt mod.ts" 1`] = ` +"📦 @std/testing 0.210.0 => 0.218.2 +" +`; + +snapshot[`cli - jsr_with_path_in_import_map - "molt mod.ts" 2`] = ` +"Checking for updates +" +`; + +snapshot[`cli - jsr_with_path_in_import_map - "molt deno.json" 1`] = ` +"📦 @std/testing 0.210.0 => 0.218.2 +" +`; + +snapshot[`cli - jsr_with_path_in_import_map - "molt deno.json" 2`] = ` +"Checking for updates +" +`; diff --git a/test/snapshots/file_test.ts.snap b/test/snapshots/file_test.ts.snap index f9913ead..c1f53793 100644 --- a/test/snapshots/file_test.ts.snap +++ b/test/snapshots/file_test.ts.snap @@ -128,6 +128,101 @@ snapshot[`write - lockfile_not_importable/mod.ts 2`] = ` ] `; +snapshot[`write - jsr_with_path_in_import_map/deno.json 1`] = ` +[ + { + dependencies: [ + { + code: { + span: undefined, + specifier: "jsr:@std/testing@0.210.0", + }, + from: { + name: "@std/testing", + path: "", + protocol: "jsr:", + version: "0.210.0", + }, + map: { + key: "@std/testing", + resolved: "jsr:@std/testing@0.210.0", + }, + to: { + name: "@std/testing", + path: "", + protocol: "jsr:", + version: "123.456.789", + }, + }, + ], + kind: "import_map", + }, +] +`; + +snapshot[`write - jsr_with_path_in_import_map/deno.json 2`] = ` +[ + '{ + "imports": { + "@std/testing": "jsr:@std/testing@123.456.789" + } +} +', +] +`; + +snapshot[`write - jsr_with_path_in_import_map/mod.ts 1`] = ` +[ + { + dependencies: [ + { + code: { + span: { + end: { + character: 43, + line: 0, + }, + start: { + character: 25, + line: 0, + }, + }, + specifier: "@std/testing/bdd", + }, + from: { + name: "@std/testing", + path: "", + protocol: "jsr:", + version: "0.210.0", + }, + map: { + key: "@std/testing", + resolved: "jsr:/@std/testing@0.210.0/bdd", + }, + to: { + name: "@std/testing", + path: "", + protocol: "jsr:", + version: "123.456.789", + }, + }, + ], + kind: "import_map", + }, +] +`; + +snapshot[`write - jsr_with_path_in_import_map/mod.ts 2`] = ` +[ + '{ + "imports": { + "@std/testing": "jsr:@std/testing@123.456.789" + } +} +', +] +`; + snapshot[`write - multiple_imports.ts 1`] = ` [ { diff --git a/test/snapshots/update_test.ts.snap b/test/snapshots/update_test.ts.snap index a35323a0..741af181 100644 --- a/test/snapshots/update_test.ts.snap +++ b/test/snapshots/update_test.ts.snap @@ -119,6 +119,38 @@ snapshot[`collect - jsr_with_path_in_import_map - deno.json 1`] = ` ] `; +snapshot[`collect - jsr_with_path_in_import_map - mod.ts 1`] = ` +[ + { + code: { + span: { + end: { + character: 43, + line: 0, + }, + start: { + character: 25, + line: 0, + }, + }, + specifier: "@std/testing/bdd", + }, + from: { + name: "@std/testing", + path: "", + protocol: "jsr:", + version: "0.210.0", + }, + to: { + name: "@std/testing", + path: "", + protocol: "jsr:", + version: "123.456.789", + }, + }, +] +`; + snapshot[`collect - multiple_imports.ts 1`] = ` [ {