diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index ad5781d..2a6baff 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -15,5 +15,12 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + + - name: Vendor + run: deno task vendor + - name: Publish package - run: npx jsr publish + run: deno 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..6a8bb38 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -9,14 +9,21 @@ }, "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/" + }, + "fmt": { + "exclude": ["vendor/", "node_modules/"] + }, + "lint": { + "exclude": ["vendor/", "node_modules/"] } } 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}`)), + ], + }, + ); +}