Skip to content

Commit 6c261fc

Browse files
claude: Add typst-gather tool for offline package staging
New Rust tool and Quarto command for gathering Typst packages for offline use in format extensions. Features: - Auto-detection from _extension.yml (template and template-partials) - Config file support (typst-gather.toml) with rootdir option - @Preview package downloading from Typst package registry - @Local package copying with exclusion filtering - --init-config flag to generate starter configuration Usage: quarto call typst-gather # Auto-detect or use config quarto call typst-gather --init-config # Generate config file Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3f10174 commit 6c261fc

51 files changed

Lines changed: 7504 additions & 19 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/actions/quarto-dev/action.yml‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ runs:
1212
restore-keys: |
1313
${{ runner.os }}-deno_std-2-
1414
15+
- name: Install Rust for typst-gather
16+
uses: dtolnay/rust-toolchain@master
17+
with:
18+
toolchain: stable
19+
20+
- name: Cache Cargo dependencies
21+
uses: actions/cache@v4
22+
with:
23+
path: |
24+
~/.cargo/registry
25+
~/.cargo/git
26+
package/typst-gather/target
27+
key: ${{ runner.os }}-cargo-typst-gather-${{ hashFiles('package/typst-gather/Cargo.lock') }}
28+
restore-keys: |
29+
${{ runner.os }}-cargo-typst-gather-
30+
1531
- name: Configure Quarto (.sh)
1632
if: runner.os != 'Windows'
1733
shell: bash
@@ -33,13 +49,13 @@ runs:
3349
- name: Basic dev mode sanity check
3450
shell: pwsh
3551
run: |
36-
If ( "$(quarto --version)" -ne "99.9.9") {
52+
If ( "$(quarto --version)" -ne "99.9.9") {
3753
echo "Unexpected version detected: $(quarto --version)"
38-
Exit 1
54+
Exit 1
3955
}
40-
If ( $(quarto --paths | Select-String -Pattern "package[/\\]+dist[/\\]+share") -ne $null ) {
56+
If ( $(quarto --paths | Select-String -Pattern "package[/\\]+dist[/\\]+share") -ne $null ) {
4157
echo "Unexpected package/dist/share path detected: $(quarto --paths)"
42-
Exit 1
58+
Exit 1
4359
}
4460
# check if configure is modifying some files as it should not
4561
$modifiedFiles = git diff --name-only

‎.github/workflows/create-release.yml‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ jobs:
133133
if: ${{ inputs.publish-release }}
134134
uses: ./.github/workflows/actions/prevent-rerun
135135

136+
- name: Install Rust for typst-gather
137+
uses: dtolnay/rust-toolchain@master
138+
with:
139+
toolchain: stable
140+
136141
- name: Configure
137142
run: |
138143
./configure.sh
@@ -261,6 +266,11 @@ jobs:
261266
if: ${{ inputs.publish-release }}
262267
uses: ./.github/workflows/actions/prevent-rerun
263268

269+
- name: Install Rust for typst-gather
270+
uses: dtolnay/rust-toolchain@master
271+
with:
272+
toolchain: stable
273+
264274
- name: Configure
265275
run: |
266276
./configure.sh
@@ -360,10 +370,11 @@ jobs:
360370
if: ${{ inputs.publish-release }}
361371
uses: ./.github/workflows/actions/prevent-rerun
362372

363-
- name: Configure Rust Tools
364-
run: |
365-
rustup.exe toolchain install 1.63.0 --component rustfmt --component clippy --no-self-update
366-
rustup.exe default 1.63.0
373+
- name: Install Rust for typst-gather and launcher
374+
uses: dtolnay/rust-toolchain@master
375+
with:
376+
toolchain: stable
377+
367378
- name: Configure
368379
run: |
369380
.\configure.cmd
@@ -389,6 +400,7 @@ jobs:
389400
./package/pkg-working/bin/tools/x86_64/esbuild.exe
390401
./package/pkg-working/bin/tools/x86_64/dart-sass/src/dart.exe
391402
./package/pkg-working/bin/tools/x86_64/deno_dom/plugin.dll
403+
./package/pkg-working/bin/tools/x86_64/typst-gather.exe
392404
./package/pkg-working/bin/tools/pandoc.exe
393405
./package/pkg-working/bin/quarto.js
394406
env:
@@ -491,6 +503,11 @@ jobs:
491503
if: ${{ inputs.publish-release }}
492504
uses: ./.github/workflows/actions/prevent-rerun
493505

506+
- name: Install Rust for typst-gather
507+
uses: dtolnay/rust-toolchain@master
508+
with:
509+
toolchain: stable
510+
494511
- name: Configure
495512
run: |
496513
./configure.sh

‎configure.cmd‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ 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 if cargo is available
93+
where cargo >nul 2>nul
94+
if %ERRORLEVEL% EQU 0 (
95+
ECHO Building typst-gather...
96+
cargo build --release --manifest-path package\typst-gather\Cargo.toml
97+
) else (
98+
ECHO Note: Rust/cargo not found, skipping typst-gather build
99+
ECHO Install Rust to use 'quarto call typst-gather'
100+
)
101+
92102
endlocal & set QUARTO_BIN_DEV=%QUARTO_BIN_PATH%
93103

94104
GOTO :eof

‎configure.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,12 @@ else
102102
export QUARTO_DENO_EXTRA_OPTIONS="--reload"
103103
quarto --version
104104
fi
105+
106+
# Build typst-gather if cargo is available
107+
if command -v cargo &> /dev/null; then
108+
echo "Building typst-gather..."
109+
cargo build --release --manifest-path package/typst-gather/Cargo.toml
110+
else
111+
echo "Note: Rust/cargo not found, skipping typst-gather build"
112+
echo "Install Rust to use 'quarto call typst-gather'"
113+
fi

‎package/src/common/prepare-dist.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,30 @@ export async function prepareDist(
100100
}
101101
}
102102

103+
// Stage typst-gather binary if it exists (built by configure.sh)
104+
// Only stage if the build machine architecture matches the target architecture
105+
// (cross-compilation is not currently supported)
106+
const buildArch = Deno.build.arch === "aarch64" ? "aarch64" : "x86_64";
107+
if (buildArch === config.arch) {
108+
const typstGatherBinaryName = config.os === "windows" ? "typst-gather.exe" : "typst-gather";
109+
const typstGatherSrc = join(
110+
config.directoryInfo.root,
111+
"package/typst-gather/target/release",
112+
typstGatherBinaryName,
113+
);
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");
122+
}
123+
} else {
124+
info(`\nNote: Skipping typst-gather staging (build arch ${buildArch} != target arch ${config.arch})`);
125+
}
126+
103127
// build quarto-preview.js
104128
info("Building Quarto Web UI");
105129
const result = buildQuartoPreviewJs(config.directoryInfo.src, undefined, true);

‎package/typst-gather/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

0 commit comments

Comments
 (0)