Something went wrong. Try again.
Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol.
Something went wrong. Try again.
1.6 kB · 48 lines
Shell
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849#!/usr/bin/env bash## Type-check the Komodo Actions.## An Action file is not a module — Komodo pastes its contents inside an# `async function main()` and supplies `ARGS`, `komodo`, `Types`, `YAML` and# `TOML` around it. Checking the files as-is therefore reports noise that is# not real (top-level await "errors", and every Action colliding with every# other at global scope) while hiding what matters.## So each Action is wrapped exactly the way Komodo wraps it and the wrapper# is what gets checked. Line numbers are shifted by the wrapper preamble;# subtract 2 to map a reported line back to the source file.## Types under komodo/vendor are fetched from a running Komodo by# fetch-komodo-types.sh (needs KOMODO_ADDRESS) and are not committed. They# are fetched here when missing; delete the directory to refresh.
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
[ -f "$here/komodo/vendor/types.d.ts" ] || "$here/fetch-komodo-types.sh"
work="$(mktemp -d)"trap 'rm -rf "$work"' EXIT
mkdir -p "$work/komodo"cp -R "$here/komodo/vendor" "$work/komodo/vendor"cp "$here"/komodo/*.d.ts "$work/komodo/"
for action in "$here"/komodo/*.ts; do name="$(basename "$action")" # declaration files describe the wrapper; they must not be wrapped by it case "$name" in *.d.ts) continue ;; esac { echo "export {}" echo "async function main() {" cat "$action" echo "}" echo "void main" } > "$work/komodo/$name"done
cp "$here/tsconfig.json" "$work/tsconfig.json"
bunx tsc -p "$work/tsconfig.json"echo "actions type-check clean"