pixalynx/esp32-usb-ducky
A compact ESP32‑S3 USB‑C stick with native USB HID, 4‑bit microSD storage, 3.3V LDO power regulation, ESD protection, boot/reset controls, addressable RGB status LED, decoupling, and test pads.
- Version
- 1.2.8
- License
- unset
- Stars
- 0
scripts/make-jlc-bundle.sh
#!/usr/bin/env bash
# Build the JLCPCB upload bundle: Gerbers + bom.csv + pick_and_place.csv with
# the bare test pads stripped.
#
# `tsci export -f gerbers` (0.0.2561) leaves doNotPlace parts out of bom.csv but
# still lists them in pick_and_place.csv, so TP1-TP8 reach JLC as placements
# with no part and the order gets a query. Remove those rows here, then check
# that every remaining designator has a BOM line.
#
# Everything is assembled in a temp dir and only copied in at the end: `tsci
# dev`'s file watcher crashes (ENOENT, server exits) when a file it has seen
# inside the project disappears, which a build directory does constantly.
#
# Usage: npm run fab [output dir] (default: dist/jlc)
set -euo pipefail
cd "$(dirname "$0")/.."
OUT="${1:-dist/jlc}"
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
tsci export index.circuit.tsx -f gerbers -o "$work/raw.zip"
unzip -oq "$work/raw.zip" -d "$work/bundle"
cpl="$work/bundle/pick_and_place.csv"
bom="$work/bundle/bom.csv"
before=$(($(wc -l < "$cpl") - 1))
grep -vE '^TP[0-9]+,' "$cpl" > "$cpl.tmp"
mv "$cpl.tmp" "$cpl"
after=$(($(wc -l < "$cpl") - 1))
echo "pick_and_place.csv: $before -> $after placements ($((before - after)) test pads removed)"
missing=0
while IFS=, read -r des _rest; do
[ "$des" = "Designator" ] && continue
[ -z "$des" ] && continue
if ! grep -q "\"$des\"" "$bom"; then
echo " WARNING: $des is placed but has no bom.csv line"
missing=$((missing + 1))
fi
done < "$cpl"
[ "$missing" -eq 0 ] && echo "every placement has a BOM line"
(cd "$work/bundle" && zip -qr -b "$work" ../jlcpcb-bundle.zip .)
mkdir -p "$OUT/bundle"
cp "$work/bundle"/* "$OUT/bundle/"
cp "$work/jlcpcb-bundle.zip" "$OUT/"
echo "wrote $OUT/jlcpcb-bundle.zip (upload this) and $OUT/bundle/ (same files, unpacked)"