Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/src/command/dev-call/typst-gather/cmd.ts
6451 views
1
/*
2
* cmd.ts
3
*
4
* Copyright (C) 2025 Posit Software, PBC
5
*/
6
7
import { Command } from "cliffy/command/mod.ts";
8
import { existsSync } from "../../../deno_ral/fs.ts";
9
import { error, info } from "../../../deno_ral/log.ts";
10
import { join } from "../../../deno_ral/path.ts";
11
import { isWindows } from "../../../deno_ral/platform.ts";
12
import { architectureToolsPath } from "../../../core/resources.ts";
13
14
export const typstGatherCommand = new Command()
15
.name("typst-gather")
16
.hidden()
17
.description(
18
"Gather Typst packages for offline/hermetic builds.\n\n" +
19
"This command runs the typst-gather tool to download @preview packages " +
20
"and copy @local packages to a local directory for use during Quarto builds.",
21
)
22
.action(async () => {
23
// Get quarto root directory
24
const quartoRoot = Deno.env.get("QUARTO_ROOT");
25
if (!quartoRoot) {
26
error(
27
"QUARTO_ROOT environment variable not set. This command requires a development version of Quarto.",
28
);
29
Deno.exit(1);
30
}
31
32
// Path to the TOML config file (relative to this source file's location in the repo)
33
const tomlPath = join(
34
quartoRoot,
35
"src/command/dev-call/typst-gather/typst-gather.toml",
36
);
37
38
// Find typst-gather binary in standard tools location
39
const binaryName = isWindows ? "typst-gather.exe" : "typst-gather";
40
const typstGatherBinary = architectureToolsPath(binaryName);
41
if (!existsSync(typstGatherBinary)) {
42
error(
43
`typst-gather binary not found.\n` +
44
"Run ./configure.sh to build and install it.",
45
);
46
Deno.exit(1);
47
}
48
49
info(`Quarto root: ${quartoRoot}`);
50
info(`Config: ${tomlPath}`);
51
info(`Running typst-gather...`);
52
53
// Run typst-gather from the quarto root directory
54
const command = new Deno.Command(typstGatherBinary, {
55
args: [tomlPath],
56
cwd: quartoRoot,
57
stdout: "inherit",
58
stderr: "inherit",
59
});
60
61
const result = await command.output();
62
63
if (!result.success) {
64
error(`typst-gather failed with exit code ${result.code}`);
65
Deno.exit(result.code);
66
}
67
68
info("Done!");
69
});
70
71