#!/bin/bash
# make_vsix.sh — package the Klammertext VS Code extension as klammertext.vsix.
#
# Modern VS Code loads only REGISTERED extensions: a folder merely copied
# into ~/.vscode/extensions/ is ignored (and flagged in its .obsolete file),
# so the extension must be installed as a .vsix:
#
# ./make_vsix.sh
# code --install-extension klammertext.vsix
#
# A .vsix is a zip holding a two-file manifest plus the extension payload
# under extension/. This script builds it with bash + python3 only — no
# npm, no vsce — matching the extension's no-dependency design. The shared
# core and language server are vendored into the payload: from this folder
# if present (the editing-zip layout), else from ../shared (the repository
# layout).
set -e
cd "$(dirname "$0")"
OUT="$PWD/klammertext.vsix"
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
mkdir -p "$STAGE/extension/syntaxes"
cp package.json extension.js language-configuration.json README.md "$STAGE/extension/"
cp syntaxes/klammertext.tmLanguage.json "$STAGE/extension/syntaxes/"
for f in klammertext_edit.py klammertext_ls.py; do
if [ -f "$f" ]; then
cp "$f" "$STAGE/extension/"
elif [ -f "../shared/$f" ]; then
cp "../shared/$f" "$STAGE/extension/"
else
echo "make_vsix.sh: cannot find $f (looked here and in ../shared)" >&2
exit 1
fi
done
VERSION=$(python3 -c "import json; print(json.load(open('package.json'))['version'])")
cat > "$STAGE/[Content_Types].xml" <<'EOF'
EOF
cat > "$STAGE/extension.vsixmanifest" <
Klammertext
Klammertext language support: syntax highlighting, delimiter matching, structural reindentation, table alignment, and delimiter diagnostics.
Programming Languages
EOF
python3 - "$STAGE" "$OUT" <<'EOF'
import os, sys, zipfile
stage, out = sys.argv[1], sys.argv[2]
with zipfile.ZipFile(out, 'w', zipfile.ZIP_DEFLATED) as z:
for root, _dirs, files in os.walk(stage):
for f in sorted(files):
full = os.path.join(root, f)
z.write(full, os.path.relpath(full, stage))
EOF
echo "Created $OUT"
echo "Install with: code --install-extension $OUT"