#!/usr/bin/env bash # Build the deployable release directory. The native executable embeds the JS # and npm dependencies; the web SPA and Tree-sitter grammars remain data files. set -euo pipefail ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) cd "$ROOT" bun run web:build bun run build:native rm -rf release mkdir -p release/shard cp dist/shard release/shard/shard cp -R build release/shard/build mkdir -p release/shard/tree-sitter find node_modules/tree-sitter-wasms/out -maxdepth 1 -type f -name '*.wasm' -exec cp {} release/shard/tree-sitter/ \; # The web-tree-sitter RUNTIME wasm (emscripten glue) is distinct from the # tree-sitter-.wasm grammars above. Ship it beside the binary so # Parser.init()'s locateFile can read it on a host without node_modules; # otherwise a bun --compile binary's baked-in __dirname makes agents ENOENT. cp node_modules/web-tree-sitter/tree-sitter.wasm release/shard/tree-sitter/tree-sitter.wasm # Keep release layout deterministic and make the artifact self-describing. printf '%s\n' "$(bun -e "console.log(require('./package.json').version)")" > release/shard/VERSION ( cd release && tar -czf "shard-$(cat shard/VERSION)-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m).tar.gz" shard ) echo "release written to release/"