#!/bin/sh
# Read-only JSR preflight. No application bootstrap, DB, printer, writes or service control.
set -eu
root=/workspace/wwwroot/zhct_jsr/project
printf 'JSR_PREFLIGHT_BEGIN\n'
hostname
date -u '+%Y-%m-%dT%H:%M:%SZ'
test -d "$root"
test ! -L "$root"
readlink -f "$root"
for relative in application/p/logic/MealOrder.php application/common/enum/ReceiptPrinterTemplate.php application/api/model/meal/Order.php application/api/controller/MealOrder.php composer.json composer.lock thinkphp/library/think/Model.php; do
    if test -f "$root/$relative"; then
        sha256sum "$root/$relative"
    fi
done
printf 'ENV_MARKERS\n'
grep -E "define\('TP_ENV'|define\('BUSINESS'" "$root/env.php"
printf 'RECEIPT_FEATURES\n'
grep -nE 'function orderPrint|function buildAdvancedReceiptContent|function buildCompactReceiptContent|function formatReceiptLabeledLines|function formatReceiptPickupTime' "$root/application/p/logic/MealOrder.php"
printf 'PACKAGE_LIST\n'
find /workspace/wwwroot/zhct_jsr -maxdepth 1 -type f -name 'zhct_*.tgz' -printf '%f %s %TY-%Tm-%TdT%TH:%TM\n'
printf 'CODE_STAT\n'
stat -c '%n %s %a %U:%G %y' "$root/application/p/logic/MealOrder.php"
printf 'JSR_PREFLIGHT_END\n'
