From 4ff94c5435695afece110349cf0a111dc9acc794 Mon Sep 17 00:00:00 2001 From: Ethan Davidson <31261035+EthanThatOneKid@users.noreply.github.com> Date: Sat, 26 Oct 2024 12:00:32 -0700 Subject: [PATCH] add vendor task for https imports - --- .github/workflows/publish.yaml | 3 +++ .gitignore | 2 ++ deno.jsonc | 7 ++++--- vendor.ts | 30 ++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 vendor.ts diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index ad5781d..d6a1e6e 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -15,5 +15,8 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Vendor + run: deno task vendor + - name: Publish package run: npx jsr publish diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..022b988 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +vendor diff --git a/deno.jsonc b/deno.jsonc index 00a0dec..92ce96d 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -9,14 +9,15 @@ }, "lock": false, "tasks": { - "dev": "deno test --watch -A" + "dev": "deno test --watch -A", + "vendor": "deno run -A vendor.ts" }, "imports": { "#/": "./", "@sinclair/typebox": "npm:@sinclair/typebox@^0.33.14", "@sinclair/typebox-codegen": "npm:@sinclair/typebox-codegen@^0.10.5", "@std/assert": "jsr:@std/assert@^1.0.6", - "common-tree-sitter-languages/": "https://github.com/jeff-hykin/common_tree_sitter_languages/raw/e0395e3a6e552b0fa73500d5b724735a52936067/main/", - "deno-tree-sitter/": "https://deno.land/x/deno_tree_sitter@0.2.5.2/" + "deno-tree-sitter/": "./vendor/deno.land/x/tree_sitter/vendor/deno.land/x/deno_tree_sitter@0.2.5.2/", + "common-tree-sitter-languages/": "./vendor/raw.githubusercontent.com/jeff-hykin/common_tree_sitter_languages/#e0395e3a6e552b0fa735_8bb8d/main/" } } diff --git a/vendor.ts b/vendor.ts new file mode 100644 index 0000000..0cad07f --- /dev/null +++ b/vendor.ts @@ -0,0 +1,30 @@ +if (import.meta.main) { + const cacheSubcommand = makeCacheSubcommand({ + "https://deno.land/x/deno_tree_sitter@0.2.5.2/": [ + "tree_sitter.js", + "main.js", + ], + "https://github.com/jeff-hykin/common_tree_sitter_languages/raw/e0395e3a6e552b0fa73500d5b724735a52936067/main/": + ["typescript.js"], + }); + + const cacheSubcommandOutput = await cacheSubcommand.output(); + if (!cacheSubcommandOutput.success) { + Deno.exit(1); + } +} + +export function makeCacheSubcommand( + httpsImports: Record, +): Deno.Command { + return new Deno.Command( + Deno.execPath(), + { + args: [ + "cache", + ...Object.entries(httpsImports) + .flatMap(([url, paths]) => paths.map((path) => `${url}${path}`)), + ], + }, + ); +}