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
12926 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 = Deno.env.get("QUARTO_TYPST_GATHER") ||
41
architectureToolsPath(binaryName);
42
if (!existsSync(typstGatherBinary)) {
43
error(
44
`typst-gather binary not found.\n` +
45
"Run ./configure.sh to build and install it.",
46
);
47
Deno.exit(1);
48
}
49
50
info(`Quarto root: ${quartoRoot}`);
51
info(`Config: ${tomlPath}`);
52
info(`Running typst-gather...`);
53
54
// Run typst-gather from the quarto root directory
55
const command = new Deno.Command(typstGatherBinary, {
56
args: ["gather", tomlPath],
57
cwd: quartoRoot,
58
stdout: "inherit",
59
stderr: "inherit",
60
});
61
62
const result = await command.output();
63
64
if (!result.success) {
65
error(`typst-gather failed with exit code ${result.code}`);
66
Deno.exit(result.code);
67
}
68
69
info("Done!");
70
});
71
72