fix: add dep checks (node/npm), auto-install npm deps in all scripts

This commit is contained in:
mirivlad 2026-06-16 12:32:32 +08:00
parent 2883de9792
commit 24d500a7b5
3 changed files with 55 additions and 9 deletions

View File

@ -15,6 +15,24 @@ report() {
echo "=== verstak-sdk build ==="
# ── Dependency checks ──
echo "[deps]"
if ! command -v node &>/dev/null; then
echo " ❌ node: not found"
FAILED=1
else
echo " ✅ node $(node --version)"
fi
if ! command -v npm &>/dev/null; then
echo " ❌ npm: not found"
FAILED=1
fi
if [ "$FAILED" -ne 0 ]; then
echo ""
echo "❌ build failed — missing core dependencies"
exit 1
fi
# Install dependencies if needed
if [ ! -d "$ROOT/node_modules" ]; then
if [ -f "$ROOT/package-lock.json" ]; then

View File

@ -15,6 +15,16 @@ report() {
echo "=== verstak-sdk check ==="
# ── Dependency checks ──
if ! command -v node &>/dev/null; then
echo " ❌ node: not found"
FAILED=1
fi
if ! command -v npm &>/dev/null; then
echo " ❌ npm: not found"
FAILED=1
fi
# Validate that all JSON schemas are valid JSON
echo "[schema validation]"
if command -v python3 &>/dev/null; then
@ -48,17 +58,20 @@ else
fi
# TypeScript check (noEmit)
if [ ! -d "$ROOT/node_modules" ]; then
if [ -f "$ROOT/package-lock.json" ]; then
(cd "$ROOT" && npm ci --no-audit --no-fund)
report "npm ci" $?
else
(cd "$ROOT" && npm install --no-audit --no-fund)
report "npm install" $?
echo "[typescript]"
if [ "$FAILED" -eq 0 ]; then
if [ ! -d "$ROOT/node_modules" ]; then
if [ -f "$ROOT/package-lock.json" ]; then
(cd "$ROOT" && npm ci --no-audit --no-fund)
report "npm ci" $?
else
(cd "$ROOT" && npm install --no-audit --no-fund)
report "npm install" $?
fi
fi
(cd "$ROOT" && npx tsc --noEmit)
report "tsc --noEmit" $?
fi
(cd "$ROOT" && npx tsc --noEmit)
report "tsc --noEmit" $?
echo ""
if [ "$FAILED" -eq 0 ]; then

View File

@ -15,6 +15,21 @@ report() {
echo "=== verstak-sdk test ==="
# ── Dependency checks ──
if ! command -v node &>/dev/null; then
echo " ❌ node: not found"
FAILED=1
fi
if ! command -v npm &>/dev/null; then
echo " ❌ npm: not found"
FAILED=1
fi
if [ "$FAILED" -ne 0 ]; then
echo ""
echo "❌ tests failed — missing core dependencies"
exit 1
fi
# Install deps if missing
if [ ! -d "$ROOT/node_modules" ]; then
if [ -f "$ROOT/package-lock.json" ]; then