diff --git a/configuration b/configuration index 0621b6e065..2792099dd6 100644 --- a/configuration +++ b/configuration @@ -17,6 +17,7 @@ export PANDOC=3.8.3 export DARTSASS=1.87.0 export ESBUILD=0.25.10 export TYPST=0.14.2 +export TYPST_GATHER=0.2.2 export VERAPDF=1.28.2 diff --git a/package/src/common/dependencies/dependencies.ts b/package/src/common/dependencies/dependencies.ts index 55be2feef5..d001e09037 100644 --- a/package/src/common/dependencies/dependencies.ts +++ b/package/src/common/dependencies/dependencies.ts @@ -15,6 +15,7 @@ import { esBuild } from "./esbuild.ts"; import { pandoc } from "./pandoc.ts"; import { archiveUrl } from "../archive-binary-dependencies.ts"; import { typst } from "./typst.ts"; +import { typstGather } from "./typst-gather.ts"; import { verapdf } from "./verapdf.ts"; // The list of binary dependencies for Quarto @@ -24,6 +25,7 @@ export const kDependencies = [ dartSass(version("DARTSASS")), esBuild(version("ESBUILD")), typst(version("TYPST")), + typstGather(version("TYPST_GATHER")), verapdf(version("VERAPDF")), ]; diff --git a/package/src/common/dependencies/typst-gather.ts b/package/src/common/dependencies/typst-gather.ts new file mode 100644 index 0000000000..f0f192ec55 --- /dev/null +++ b/package/src/common/dependencies/typst-gather.ts @@ -0,0 +1,58 @@ + +import { join, dirname } from "../../../../src/deno_ral/path.ts" +import { ensureDirSync, existsSync } from "../../../../src/deno_ral/fs.ts" + +import { Configuration } from "../config.ts"; +import { Dependency } from "./dependencies.ts"; +import { which } from "../../../../src/core/path.ts"; +import { unTar } from "../../util/tar.ts"; + +export function typstGather(version: string): Dependency { + const typstGatherRelease = (filename: string) => { + return { + filename, + url: `https://github.com/quarto-dev/typst-gather/releases/download/v${version}/${filename}`, + configure: async (config: Configuration, path: string) => { + const file = config.os === "windows" ? "typst-gather.exe" : "typst-gather"; + const vendor = Deno.env.get("QUARTO_VENDOR_BINARIES"); + if (vendor === undefined || vendor === "true") { + const dir = dirname(path); + const targetDir = join(dir, config.arch); + ensureDirSync(targetDir); + + // expand + await unTar(path); + + // move the binary and cleanup + const extractedPath = join(dir, file); + Deno.renameSync(extractedPath, join(targetDir, file)); + } else { + // verify that the binary is on PATH, but otherwise don't do anything + if (which(file) === undefined) { + throw new Error( + `${file} is not on PATH. Please install it and add it to PATH.`, + ); + } + } + } + } + } + + return { + name: "typst-gather", + bucket: "typst-gather", + version, + archiveOnly: true, + architectureDependencies: { + "x86_64": { + "windows": typstGatherRelease("typst-gather-x86_64-pc-windows-msvc.zip"), + "linux": typstGatherRelease("typst-gather-x86_64-unknown-linux-gnu.tar.gz"), + "darwin": typstGatherRelease("typst-gather-x86_64-apple-darwin.tar.gz"), + }, + "aarch64": { + "linux": typstGatherRelease("typst-gather-aarch64-unknown-linux-gnu.tar.gz"), + "darwin": typstGatherRelease("typst-gather-aarch64-apple-darwin.tar.gz"), + } + } + } +}