Path: blob/main/src/command/dev-call/typst-gather/cmd.ts
12926 views
/*1* cmd.ts2*3* Copyright (C) 2025 Posit Software, PBC4*/56import { Command } from "cliffy/command/mod.ts";7import { existsSync } from "../../../deno_ral/fs.ts";8import { error, info } from "../../../deno_ral/log.ts";9import { join } from "../../../deno_ral/path.ts";10import { isWindows } from "../../../deno_ral/platform.ts";11import { architectureToolsPath } from "../../../core/resources.ts";1213export const typstGatherCommand = new Command()14.name("typst-gather")15.hidden()16.description(17"Gather Typst packages for offline/hermetic builds.\n\n" +18"This command runs the typst-gather tool to download @preview packages " +19"and copy @local packages to a local directory for use during Quarto builds.",20)21.action(async () => {22// Get quarto root directory23const quartoRoot = Deno.env.get("QUARTO_ROOT");24if (!quartoRoot) {25error(26"QUARTO_ROOT environment variable not set. This command requires a development version of Quarto.",27);28Deno.exit(1);29}3031// Path to the TOML config file (relative to this source file's location in the repo)32const tomlPath = join(33quartoRoot,34"src/command/dev-call/typst-gather/typst-gather.toml",35);3637// Find typst-gather binary in standard tools location38const binaryName = isWindows ? "typst-gather.exe" : "typst-gather";39const typstGatherBinary = Deno.env.get("QUARTO_TYPST_GATHER") ||40architectureToolsPath(binaryName);41if (!existsSync(typstGatherBinary)) {42error(43`typst-gather binary not found.\n` +44"Run ./configure.sh to build and install it.",45);46Deno.exit(1);47}4849info(`Quarto root: ${quartoRoot}`);50info(`Config: ${tomlPath}`);51info(`Running typst-gather...`);5253// Run typst-gather from the quarto root directory54const command = new Deno.Command(typstGatherBinary, {55args: ["gather", tomlPath],56cwd: quartoRoot,57stdout: "inherit",58stderr: "inherit",59});6061const result = await command.output();6263if (!result.success) {64error(`typst-gather failed with exit code ${result.code}`);65Deno.exit(result.code);66}6768info("Done!");69});707172