Path: blob/main/src/command/dev-call/typst-gather/cmd.ts
6451 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 = architectureToolsPath(binaryName);40if (!existsSync(typstGatherBinary)) {41error(42`typst-gather binary not found.\n` +43"Run ./configure.sh to build and install it.",44);45Deno.exit(1);46}4748info(`Quarto root: ${quartoRoot}`);49info(`Config: ${tomlPath}`);50info(`Running typst-gather...`);5152// Run typst-gather from the quarto root directory53const command = new Deno.Command(typstGatherBinary, {54args: [tomlPath],55cwd: quartoRoot,56stdout: "inherit",57stderr: "inherit",58});5960const result = await command.output();6162if (!result.success) {63error(`typst-gather failed with exit code ${result.code}`);64Deno.exit(result.code);65}6667info("Done!");68});697071