Files
menu/deploy.sh
T
tanshu e64f65642f Add ESLint and Prettier
Prettier owns formatting: .prettierrc.json, format and format:check scripts, and
a one-off pass over the repo so the check is green from the start. Embedded
language formatting is off deliberately - the renderers build HTML in html
tagged templates and letting Prettier reflow those would change the markup
customers receive. docs/ is excluded because it is hand-wrapped prose, and shell
scripts have no Prettier parser.

ESLint covers the JavaScript: the two browser scripts, the build and check
scripts, and its own config. no-var is scoped out for the browser scripts on
purpose; they are plain ES5-shaped IIFEs and a hoisting difference would only
show up in a browser.

ESLint cannot lint the TypeScript here: typescript@7 is the native port with no
JavaScript compiler API, and typescript-eslint requires a 4.8-6.1 peer, so it
refuses to install and forcing it through would leave a parser that cannot read
the compiler. tsc --noEmit stays the TypeScript gate; README records the two
ways to change that.

lint and format:check now run in deploy.sh, and VS Code formats on save with
Prettier and surfaces ESLint findings.
2026-09-22 23:15:08 +05:30

48 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Builds the image, runs the tests and pushes it to the private registry.
#
# ./deploy.sh 2026-09-22
#
# Then deploy with the printed ansible-playbook command, or with the cutover
# flags from deploy/ansible/readme.md.
set -euo pipefail
TAG="${1:-}"
if [[ -z "$TAG" ]]; then
echo "usage: deploy.sh <tag> (e.g. $(date +%Y-%m-%d) or a git short sha)" >&2
exit 1
fi
IMAGE="registry.tanshu.com/menu-admin:${TAG}"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT"
if [[ -z "${SKIP_TESTS:-}" ]]; then
echo "==> lint, format and tests"
npm run lint
npm run format:check
npm run typecheck
npm test
fi
echo "==> building ${IMAGE}"
docker build -t "$IMAGE" .
echo "==> pushing ${IMAGE}"
docker push "$IMAGE"
cat <<EOF
pushed ${IMAGE}
parallel run:
ansible-playbook -l monoco -e site=hopsngrains -e tag=${TAG} playbook.yml
cutover:
ansible-playbook -l monoco -e site=hopsngrains -e tag=${TAG} \\
-e vhost=menu.hopsngrains.com -e retire_nginx_snippet=true \\
-e retire_nginx_container=true playbook.yml
EOF