scripts(ts-packages): 🔨 Add validation script to verify TypeScript package configurations and dependencies
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
445981179b
commit
a79e09e342
1 changed files with 45 additions and 39 deletions
|
|
@ -380,17 +380,15 @@ run_runtime_checks() {
|
|||
return
|
||||
fi
|
||||
|
||||
local build_pass=0 build_fail=0 build_skip=0
|
||||
local tc_pass=0 tc_fail=0 tc_skip=0
|
||||
local test_pass=0 test_fail=0 test_skip=0
|
||||
local idx=0
|
||||
# --- Phase 2: Build (all packages) ---
|
||||
if [[ "$SKIP_BUILD" == false ]]; then
|
||||
local build_pass=0 build_fail=0 build_skip=0 idx=0
|
||||
log " Phase 2a: Build ($total packages)\n"
|
||||
|
||||
for entry in "${VERIFIED_PACKAGES[@]}"; do
|
||||
IFS='|' read -r pkg_name pkg_dir namespace <<< "$entry"
|
||||
((idx++))
|
||||
for entry in "${VERIFIED_PACKAGES[@]}"; do
|
||||
IFS='|' read -r pkg_name pkg_dir namespace <<< "$entry"
|
||||
((idx++))
|
||||
|
||||
# --- Build ---
|
||||
if [[ "$SKIP_BUILD" == false ]]; then
|
||||
local has_build_script
|
||||
has_build_script=$(jq -r '.scripts.build // empty' "$pkg_dir/package.json" 2>/dev/null)
|
||||
|
||||
|
|
@ -403,10 +401,7 @@ run_runtime_checks() {
|
|||
local exit_code=$?
|
||||
((build_fail++))
|
||||
local detail="Build failed (exit $exit_code)"
|
||||
if [[ $exit_code -eq 124 ]]; then
|
||||
detail="Build timed out after ${BUILD_TIMEOUT}s"
|
||||
fi
|
||||
# Capture last 3 lines of output for context
|
||||
[[ $exit_code -eq 124 ]] && detail="Build timed out after ${BUILD_TIMEOUT}s"
|
||||
local tail_output
|
||||
tail_output=$(echo "$build_output" | tail -3 | tr '\n' ' ' | head -c 200)
|
||||
add_issue "error" "BUILD_FAIL" "$pkg_name" "$namespace" "$detail: $tail_output"
|
||||
|
|
@ -414,10 +409,20 @@ run_runtime_checks() {
|
|||
else
|
||||
((build_skip++))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
progress_done
|
||||
log " Build: $build_pass passed, $build_fail failed, $build_skip skipped (no script)\n"
|
||||
fi
|
||||
|
||||
# --- Phase 3: Typecheck (all packages, after all builds complete) ---
|
||||
if [[ "$SKIP_TYPECHECK" == false ]]; then
|
||||
local tc_pass=0 tc_fail=0 tc_skip=0 idx=0
|
||||
log " Phase 2b: Typecheck ($total packages)\n"
|
||||
|
||||
for entry in "${VERIFIED_PACKAGES[@]}"; do
|
||||
IFS='|' read -r pkg_name pkg_dir namespace <<< "$entry"
|
||||
((idx++))
|
||||
|
||||
# --- Typecheck ---
|
||||
if [[ "$SKIP_TYPECHECK" == false ]]; then
|
||||
local has_tsconfig=false
|
||||
[[ -f "$pkg_dir/tsconfig.json" || -f "$pkg_dir/tsconfig.build.json" ]] && has_tsconfig=true
|
||||
|
||||
|
|
@ -433,9 +438,7 @@ run_runtime_checks() {
|
|||
local exit_code=$?
|
||||
((tc_fail++))
|
||||
local detail="Typecheck failed (exit $exit_code)"
|
||||
if [[ $exit_code -eq 124 ]]; then
|
||||
detail="Typecheck timed out after ${BUILD_TIMEOUT}s"
|
||||
fi
|
||||
[[ $exit_code -eq 124 ]] && detail="Typecheck timed out after ${BUILD_TIMEOUT}s"
|
||||
local error_count
|
||||
error_count=$(echo "$tc_output" | grep -c "error TS" || true)
|
||||
[[ $error_count -gt 0 ]] && detail="$detail — $error_count type errors"
|
||||
|
|
@ -447,10 +450,20 @@ run_runtime_checks() {
|
|||
else
|
||||
((tc_skip++))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
progress_done
|
||||
log " Typecheck: $tc_pass passed, $tc_fail failed, $tc_skip skipped (no tsconfig)\n"
|
||||
fi
|
||||
|
||||
# --- Phase 4: Test (all packages, after builds and typechecks) ---
|
||||
if [[ "$SKIP_TEST" == false ]]; then
|
||||
local test_pass=0 test_fail=0 test_skip=0 idx=0
|
||||
log " Phase 2c: Test ($total packages)\n"
|
||||
|
||||
for entry in "${VERIFIED_PACKAGES[@]}"; do
|
||||
IFS='|' read -r pkg_name pkg_dir namespace <<< "$entry"
|
||||
((idx++))
|
||||
|
||||
# --- Test ---
|
||||
if [[ "$SKIP_TEST" == false ]]; then
|
||||
local has_test_script
|
||||
has_test_script=$(jq -r '.scripts.test // empty' "$pkg_dir/package.json" 2>/dev/null)
|
||||
|
||||
|
|
@ -463,9 +476,7 @@ run_runtime_checks() {
|
|||
local exit_code=$?
|
||||
((test_fail++))
|
||||
local detail="Tests failed (exit $exit_code)"
|
||||
if [[ $exit_code -eq 124 ]]; then
|
||||
detail="Tests timed out after ${BUILD_TIMEOUT}s"
|
||||
fi
|
||||
[[ $exit_code -eq 124 ]] && detail="Tests timed out after ${BUILD_TIMEOUT}s"
|
||||
local tail_output
|
||||
tail_output=$(echo "$test_output" | tail -5 | tr '\n' ' ' | head -c 200)
|
||||
add_issue "error" "TEST_FAIL" "$pkg_name" "$namespace" "$detail: $tail_output"
|
||||
|
|
@ -473,19 +484,9 @@ run_runtime_checks() {
|
|||
else
|
||||
((test_skip++))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
progress_done
|
||||
|
||||
# Log runtime summary
|
||||
if [[ "$SKIP_BUILD" == false ]]; then
|
||||
log " Build: $build_pass passed, $build_fail failed, $build_skip skipped (no script)"
|
||||
fi
|
||||
if [[ "$SKIP_TYPECHECK" == false ]]; then
|
||||
log " Typecheck: $tc_pass passed, $tc_fail failed, $tc_skip skipped (no tsconfig)"
|
||||
fi
|
||||
if [[ "$SKIP_TEST" == false ]]; then
|
||||
log " Test: $test_pass passed, $test_fail failed, $test_skip skipped (no script)"
|
||||
done
|
||||
progress_done
|
||||
log " Test: $test_pass passed, $test_fail failed, $test_skip skipped (no script)\n"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -587,7 +588,7 @@ main() {
|
|||
discover_packages
|
||||
log " $TOTAL_PACKAGES packages scanned, $TOTAL_HEALTHY passed structure checks\n"
|
||||
|
||||
# Phases 2-4: Build, Typecheck, Test
|
||||
# Phases 2-4: Build, Typecheck, Test (run sequentially: all builds → all typechecks → all tests)
|
||||
if [[ "$STRUCTURE_ONLY" == false ]]; then
|
||||
local phases=""
|
||||
[[ "$SKIP_BUILD" == false ]] && phases+="build "
|
||||
|
|
@ -595,6 +596,11 @@ main() {
|
|||
[[ "$SKIP_TEST" == false ]] && phases+="test "
|
||||
|
||||
if [[ -n "$phases" ]]; then
|
||||
# Check dependencies are installed
|
||||
if [[ ! -d "$TS_ROOT/node_modules" ]]; then
|
||||
log " WARNING: node_modules not found. Run 'bun install' in @ts/ first.\n"
|
||||
fi
|
||||
|
||||
log "Phase 2: Runtime checks ($phases)\n"
|
||||
run_runtime_checks
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue