Skip to content

Commit f1d51ab

Browse files
claude: Install typst-gather to bin/tools/{arch}/ during configure
- configure.sh/cmd: Copy built binary to standard tools location - Simplify cmd.ts files to only use architectureToolsPath() - prepare-dist.ts: Error if typst-gather binary is missing Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent aba9d2b commit f1d51ab

5 files changed

Lines changed: 30 additions & 53 deletions

File tree

configure.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ IF EXIST !QUARTO_BIN_PATH!\quarto.cmd (
8989
ECHO NOTE: To use quarto please use quarto.cmd (located in this folder) or add the following path to your PATH
9090
ECHO !QUARTO_BIN_PATH!
9191

92-
REM Build typst-gather
92+
REM Build typst-gather and install to tools directory
9393
ECHO Building typst-gather...
9494
cargo build --release --manifest-path package\typst-gather\Cargo.toml
95+
COPY package\typst-gather\target\release\typst-gather.exe "!QUARTO_BIN_PATH!\tools\x86_64\"
9596

9697
endlocal & set QUARTO_BIN_DEV=%QUARTO_BIN_PATH%
9798

configure.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ else
103103
quarto --version
104104
fi
105105

106-
# Build typst-gather
106+
# Build typst-gather and install to tools directory
107107
echo "Building typst-gather..."
108108
cargo build --release --manifest-path package/typst-gather/Cargo.toml
109+
cp package/typst-gather/target/release/typst-gather "$QUARTO_BIN_PATH/tools/$DENO_ARCH_DIR/"

package/src/common/prepare-dist.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export async function prepareDist(
100100
}
101101
}
102102

103-
// Stage typst-gather binary if it exists (built by configure.sh)
103+
// Stage typst-gather binary (built by configure.sh)
104104
// Only stage if the build machine architecture matches the target architecture
105105
// (cross-compilation is not currently supported)
106106
const buildArch = Deno.build.arch === "aarch64" ? "aarch64" : "x86_64";
@@ -111,15 +111,17 @@ export async function prepareDist(
111111
"package/typst-gather/target/release",
112112
typstGatherBinaryName,
113113
);
114-
if (existsSync(typstGatherSrc)) {
115-
info("\nStaging typst-gather binary");
116-
const typstGatherDest = join(targetDir, config.arch, typstGatherBinaryName);
117-
ensureDirSync(join(targetDir, config.arch));
118-
copySync(typstGatherSrc, typstGatherDest, { overwrite: true });
119-
info(`Copied ${typstGatherSrc} to ${typstGatherDest}`);
120-
} else {
121-
info("\nNote: typst-gather binary not found, skipping staging");
114+
if (!existsSync(typstGatherSrc)) {
115+
throw new Error(
116+
`typst-gather binary not found at ${typstGatherSrc}\n` +
117+
"Run ./configure.sh to build it.",
118+
);
122119
}
120+
info("\nStaging typst-gather binary");
121+
const typstGatherDest = join(targetDir, config.arch, typstGatherBinaryName);
122+
ensureDirSync(join(targetDir, config.arch));
123+
copySync(typstGatherSrc, typstGatherDest, { overwrite: true });
124+
info(`Copied ${typstGatherSrc} to ${typstGatherDest}`);
123125
} else {
124126
info(`\nNote: Skipping typst-gather staging (build arch ${buildArch} != target arch ${config.arch})`);
125127
}

src/command/call/typst-gather/cmd.ts

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -452,36 +452,15 @@ export const typstGatherCommand = new Command()
452452
Deno.exit(1);
453453
}
454454

455-
// Find typst-gather binary
456-
// First try architecture-specific path, then fall back to PATH
457-
let typstGatherBinary: string;
455+
// Find typst-gather binary in standard tools location
458456
const binaryName = isWindows ? "typst-gather.exe" : "typst-gather";
459-
460-
const archPath = architectureToolsPath(binaryName);
461-
if (existsSync(archPath)) {
462-
typstGatherBinary = archPath;
463-
} else {
464-
// Try to find in PATH or use development location
465-
const quartoRoot = Deno.env.get("QUARTO_ROOT");
466-
if (quartoRoot) {
467-
const devPath = join(
468-
quartoRoot,
469-
"package/typst-gather/target/release",
470-
binaryName,
471-
);
472-
if (existsSync(devPath)) {
473-
typstGatherBinary = devPath;
474-
} else {
475-
console.error(
476-
`typst-gather binary not found.\n` +
477-
`Build it with: cd package/typst-gather && cargo build --release`,
478-
);
479-
Deno.exit(1);
480-
}
481-
} else {
482-
console.error("typst-gather binary not found.");
483-
Deno.exit(1);
484-
}
457+
const typstGatherBinary = architectureToolsPath(binaryName);
458+
if (!existsSync(typstGatherBinary)) {
459+
console.error(
460+
`typst-gather binary not found.\n` +
461+
`Run ./configure.sh to build and install it.`,
462+
);
463+
Deno.exit(1);
485464
}
486465

487466
// Determine config file to use

src/command/dev-call/typst-gather/cmd.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*/
66

77
import { Command } from "cliffy/command/mod.ts";
8+
import { existsSync } from "../../../deno_ral/fs.ts";
89
import { error, info } from "../../../deno_ral/log.ts";
910
import { join } from "../../../deno_ral/path.ts";
1011
import { isWindows } from "../../../deno_ral/platform.ts";
12+
import { architectureToolsPath } from "../../../core/resources.ts";
1113

1214
export const typstGatherCommand = new Command()
1315
.name("typst-gather")
@@ -33,21 +35,13 @@ export const typstGatherCommand = new Command()
3335
"src/command/dev-call/typst-gather/typst-gather.toml",
3436
);
3537

36-
// Path to the typst-gather binary
38+
// Find typst-gather binary in standard tools location
3739
const binaryName = isWindows ? "typst-gather.exe" : "typst-gather";
38-
const typstGatherBinary = join(
39-
quartoRoot,
40-
"package/typst-gather/target/release",
41-
binaryName,
42-
);
43-
44-
// Check if binary exists
45-
try {
46-
await Deno.stat(typstGatherBinary);
47-
} catch {
40+
const typstGatherBinary = architectureToolsPath(binaryName);
41+
if (!existsSync(typstGatherBinary)) {
4842
error(
49-
`typst-gather binary not found at ${typstGatherBinary}\n` +
50-
"Build it with: cd package/typst-gather && cargo build --release",
43+
`typst-gather binary not found.\n` +
44+
"Run ./configure.sh to build and install it.",
5145
);
5246
Deno.exit(1);
5347
}

0 commit comments

Comments
 (0)