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