Path: blob/main/package/src/common/dependencies/typst-gather.ts
12922 views
1import { join, dirname } from "../../../../src/deno_ral/path.ts"2import { ensureDirSync, existsSync } from "../../../../src/deno_ral/fs.ts"34import { Configuration } from "../config.ts";5import { Dependency } from "./dependencies.ts";6import { which } from "../../../../src/core/path.ts";7import { unTar } from "../../util/tar.ts";89export function typstGather(version: string): Dependency {10const typstGatherRelease = (filename: string) => {11return {12filename,13url: `https://github.com/quarto-dev/typst-gather/releases/download/v${version}/${filename}`,14configure: async (config: Configuration, path: string) => {15const file = config.os === "windows" ? "typst-gather.exe" : "typst-gather";16const vendor = Deno.env.get("QUARTO_VENDOR_BINARIES");17if (vendor === undefined || vendor === "true") {18const dir = dirname(path);19const targetDir = join(dir, config.arch);20ensureDirSync(targetDir);2122// expand23await unTar(path);2425// move the binary and cleanup26const extractedPath = join(dir, file);27Deno.renameSync(extractedPath, join(targetDir, file));28} else {29// verify that the binary is on PATH, but otherwise don't do anything30if (which(file) === undefined) {31throw new Error(32`${file} is not on PATH. Please install it and add it to PATH.`,33);34}35}36}37}38}3940return {41name: "typst-gather",42bucket: "typst-gather",43version,44architectureDependencies: {45"x86_64": {46"windows": typstGatherRelease("typst-gather-x86_64-pc-windows-msvc.zip"),47"linux": typstGatherRelease("typst-gather-x86_64-unknown-linux-gnu.tar.gz"),48"darwin": typstGatherRelease("typst-gather-x86_64-apple-darwin.tar.gz"),49},50"aarch64": {51"linux": typstGatherRelease("typst-gather-aarch64-unknown-linux-gnu.tar.gz"),52"darwin": typstGatherRelease("typst-gather-aarch64-apple-darwin.tar.gz"),53}54}55}56}575859