fuzzyworld-tools / files / vscode-web / install.sh
install.sh
| 1 | #!/bin/bash |
| 2 | # Install VS Code in the browser at apps.fuzzyworld.net/vscode/. Run from the laptop: |
| 3 | # |
| 4 | # vscode-web/install.sh build, then upload to dh:apps.fuzzyworld.net/vscode/ |
| 5 | # vscode-web/install.sh --out DIR only build into DIR (for trying it locally) |
| 6 | # |
| 7 | # The editor is the vscode-web npm package (VS Code's open-source web build, MIT), pinned below; |
| 8 | # npm checks the download against the registry's integrity hash. Beside it go index.html and |
| 9 | # fw-fs/, our read-only file system for code.fuzzyworld.net. The app has no .fuzzyworld.json, so |
| 10 | # it isn't listed on the apps index; repo pages link to it. |
| 11 | set -euo pipefail |
| 12 | cd "$(dirname "$0")" |
| 13 | VERSION=1.91.1 |
| 14 | HOST=${FW_HOST:-dh} |
| 15 | out="" |
| 16 | [ "${1:-}" = --out ] && out=${2:?--out needs a directory} |
| 17 | |
| 18 | tmp=$(mktemp -d) |
| 19 | trap 'rm -rf "$tmp"' EXIT |
| 20 | ( cd "$tmp" && npm pack --silent "vscode-web@$VERSION" >/dev/null && tar xzf "vscode-web-$VERSION.tgz" ) |
| 21 | build=${out:-$tmp/build} |
| 22 | mkdir -p "$build" |
| 23 | rsync -a --delete "$tmp/package/dist/" "$build/dist/" |
| 24 | rsync -a --delete fw-fs/ "$build/fw-fs/" |
| 25 | cp index.html "$build/index.html" |
| 26 | echo "built VS Code web $VERSION in $build" |
| 27 | |
| 28 | if [ -z "$out" ]; then |
| 29 | ssh "$HOST" 'mkdir -p apps.fuzzyworld.net/vscode' |
| 30 | rsync -az --delete "$build/" "$HOST:apps.fuzzyworld.net/vscode/" |
| 31 | echo "installed: https://apps.fuzzyworld.net/vscode/?repo=<name>" |
| 32 | fi |