From ccd97f228bfd67054286713a0355cd7a41e0a735 Mon Sep 17 00:00:00 2001 From: Tobias Ludwig Maier Date: Tue, 30 Sep 2025 11:37:29 +0000 Subject: [PATCH 1/2] Add typst feature Adds a new devcontainer feature for Typst, a markup-based typesetting system. The feature supports configurable version installation with "latest" as the default, allowing users to pin specific versions when needed. Files added: - Feature definition with version option - Installation script using GitHub releases - Documentation and test scenarios - Test scripts for default and specific version scenarios Updates: - Added typst to CLAUDE.md and README.md - Added typst to both CI test matrices --- .github/workflows/test.yaml | 2 ++ CLAUDE.md | 1 + README.md | 1 + src/typst/NOTES.md | 7 ++++ src/typst/devcontainer-feature.json | 14 ++++++++ src/typst/install.sh | 49 ++++++++++++++++++++++++++++ test/typst/scenarios.json | 16 +++++++++ test/typst/test.sh | 36 ++++++++++++++++++++ test/typst/typst_default.sh | 17 ++++++++++ test/typst/typst_specific_version.sh | 17 ++++++++++ 10 files changed, 160 insertions(+) create mode 100644 src/typst/NOTES.md create mode 100644 src/typst/devcontainer-feature.json create mode 100755 src/typst/install.sh create mode 100644 test/typst/scenarios.json create mode 100755 test/typst/test.sh create mode 100755 test/typst/typst_default.sh create mode 100755 test/typst/typst_specific_version.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f6c50f2..e92ab15 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,6 +19,7 @@ jobs: - hello - imagemagick - mc + - typst - yek - yq baseImage: @@ -48,6 +49,7 @@ jobs: - imagemagick - mc - mcp-language-server + - typst - yek - yq steps: diff --git a/CLAUDE.md b/CLAUDE.md index d11a811..a1f9a0e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -35,6 +35,7 @@ This is Tobias Maier's Dev Container Features collection - a repository for crea - `imagemagick` - ImageMagick image processing tools - `mc` - MinIO Client for object storage - `mcp-language-server` - MCP Language Server for semantic code navigation +- `typst` - Typst markup-based typesetting system - `yek` - Repository serialization tool for LLMs - `yq` - YAML processing tool diff --git a/README.md b/README.md index 9a8615e..286135c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ A collection of custom [Dev Container Features](https://containers.dev/implement | [imagemagick](https://github.com/tmaier/devcontainer-features/tree/main/src/imagemagick) | ImageMagick image processing library with PDF support | `ghcr.io/tmaier/devcontainer-features/imagemagick` | | [mc](https://github.com/tmaier/devcontainer-features/tree/main/src/mc) | MinIO Client for object storage operations | `ghcr.io/tmaier/devcontainer-features/mc` | | [mcp-language-server](https://github.com/tmaier/devcontainer-features/tree/main/src/mcp-language-server) | MCP Language Server for semantic code navigation | `ghcr.io/tmaier/devcontainer-features/mcp-language-server` | +| [typst](https://github.com/tmaier/devcontainer-features/tree/main/src/typst) | Typst markup-based typesetting system | `ghcr.io/tmaier/devcontainer-features/typst` | | [yek](https://github.com/tmaier/devcontainer-features/tree/main/src/yek) | Repository file serialization tool for LLM consumption | `ghcr.io/tmaier/devcontainer-features/yek` | | [yq](https://github.com/tmaier/devcontainer-features/tree/main/src/yq) | YAML, JSON, XML, and CSV processor | `ghcr.io/tmaier/devcontainer-features/yq` | diff --git a/src/typst/NOTES.md b/src/typst/NOTES.md new file mode 100644 index 0000000..2b28331 --- /dev/null +++ b/src/typst/NOTES.md @@ -0,0 +1,7 @@ +## What This Feature Installs + +This feature installs [Typst](https://github.com/typst/typst), a new markup-based typesetting system that is powerful and easy to learn. Typst is designed to be an alternative to LaTeX, with a focus on simplicity and modern features. + +## Documentation + +For complete usage instructions and documentation, visit the official Typst website: https://typst.app/docs \ No newline at end of file diff --git a/src/typst/devcontainer-feature.json b/src/typst/devcontainer-feature.json new file mode 100644 index 0000000..924769a --- /dev/null +++ b/src/typst/devcontainer-feature.json @@ -0,0 +1,14 @@ +{ + "id": "typst", + "version": "1.0.0", + "name": "Typst", + "description": "Installs Typst - a markup-based typesetting system that is powerful and easy to learn", + "options": { + "version": { + "type": "string", + "default": "latest", + "description": "Version of Typst to install. Use 'latest' for the latest version, or specify a version like '0.13.1'." + } + }, + "installsAfter": [] +} \ No newline at end of file diff --git a/src/typst/install.sh b/src/typst/install.sh new file mode 100755 index 0000000..2884106 --- /dev/null +++ b/src/typst/install.sh @@ -0,0 +1,49 @@ +#!/bin/sh +set -e + +echo "Installing Typst..." + +# Get version from options (capitalized by devcontainer spec) +TYPST_VERSION="${VERSION:-latest}" + +# Update package list and install dependencies if not available +if ! command -v curl >/dev/null 2>&1; then + apt-get update + apt-get install -y --no-install-recommends curl ca-certificates +fi + +if ! command -v tar >/dev/null 2>&1 || ! command -v xz >/dev/null 2>&1; then + apt-get update + apt-get install -y --no-install-recommends tar xz-utils +fi + +# Construct download URL based on version +if [ "$TYPST_VERSION" = "latest" ]; then + echo "Installing latest version of Typst..." + DOWNLOAD_URL="https://github.com/typst/typst/releases/latest/download/typst-x86_64-unknown-linux-musl.tar.xz" +else + echo "Installing Typst version: $TYPST_VERSION" + DOWNLOAD_URL="https://github.com/typst/typst/releases/download/v${TYPST_VERSION}/typst-x86_64-unknown-linux-musl.tar.xz" +fi + +# Download and extract Typst +echo "Downloading from: $DOWNLOAD_URL" +curl -fsSL -o /tmp/typst.tar.xz "$DOWNLOAD_URL" +cd /tmp +tar -xf typst.tar.xz + +# Move binary to /usr/bin +mv typst-x86_64-unknown-linux-musl/typst /usr/bin/typst +chmod +x /usr/bin/typst + +# Clean up +rm -rf /tmp/typst.tar.xz /tmp/typst-x86_64-unknown-linux-musl + +# Verify installation +if ! command -v typst >/dev/null 2>&1; then + echo "Error: Typst installation failed" + exit 1 +fi + +INSTALLED_VERSION=$(typst --version) +echo "Typst installed successfully: $INSTALLED_VERSION" \ No newline at end of file diff --git a/test/typst/scenarios.json b/test/typst/scenarios.json new file mode 100644 index 0000000..2a5cf0b --- /dev/null +++ b/test/typst/scenarios.json @@ -0,0 +1,16 @@ +{ + "typst_default": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "typst": {} + } + }, + "typst_specific_version": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "typst": { + "version": "0.13.1" + } + } + } +} \ No newline at end of file diff --git a/test/typst/test.sh b/test/typst/test.sh new file mode 100755 index 0000000..8a40930 --- /dev/null +++ b/test/typst/test.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# This test file will be executed against auto-generated devcontainer.json files +# that include the 'typst' Feature with various options. +# +# For more information, see: https://github.com/devcontainers/cli/blob/main/docs/features/test.md +# +# These scripts are run as 'root' by default. Although that can be changed +# with the '--remote-user' flag. +# +# This test can be run with the following command: +# +# devcontainer features test \ +# --features typst \ +# --remote-user root \ +# --skip-scenarios \ +# --base-image mcr.microsoft.com/devcontainers/base:ubuntu \ +# /path/to/this/repo + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib +# Provides the 'check' and 'reportResults' commands. +source dev-container-features-test-lib + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. Syntax is... +# check