mirror of
https://github.com/JimLiu/baoyu-skills.git
synced 2026-07-13 06:19:46 +08:00
refactor(codex-imagegen): extract backend to packages/baoyu-codex-imagegen workspace
Move the codex-imagegen wrapper out of scripts/ into its own workspace package alongside baoyu-md, baoyu-chrome-cdp, and baoyu-fetch. Drop the bash shim — src/main.ts now carries a `#\!/usr/bin/env bun` shebang and serves as the sole entrypoint. Add scripts/sync-codex-imagegen.sh so skills/baoyu-image-gen/scripts/codex-imagegen/ can be regenerated from packages/baoyu-codex-imagegen/src/ for skill self-containment. Update CLAUDE.md, docs/codex-imagegen-backend.md, and the CI workflow paths accordingly.
This commit is contained in:
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
# Sync packages/baoyu-codex-imagegen/src/*.ts (excluding tests) into
|
||||
# skills/baoyu-image-gen/scripts/codex-imagegen/ so the skill stays
|
||||
# self-contained (no `../../../../packages/...` lookups at runtime).
|
||||
#
|
||||
# Run this whenever packages/baoyu-codex-imagegen/src/ changes,
|
||||
# and always before tagging a release.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
SRC_DIR="$REPO_ROOT/packages/baoyu-codex-imagegen/src"
|
||||
DST_DIR="$REPO_ROOT/skills/baoyu-image-gen/scripts/codex-imagegen"
|
||||
|
||||
if [[ ! -d "$SRC_DIR" ]]; then
|
||||
echo "Error: source dir missing: $SRC_DIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$DST_DIR"
|
||||
|
||||
changed=0
|
||||
for f in cache.ts logger.ts main.ts parser.ts spawn.ts types.ts validator.ts; do
|
||||
src="$SRC_DIR/$f"
|
||||
dst="$DST_DIR/$f"
|
||||
if [[ ! -f "$src" ]]; then
|
||||
echo "Error: missing source file: $src" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "$dst" ]] || ! cmp -s "$src" "$dst"; then
|
||||
cp "$src" "$dst"
|
||||
echo "synced: $f"
|
||||
changed=$((changed + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
chmod +x "$DST_DIR/main.ts"
|
||||
|
||||
# Drop any stale .ts files in DST that don't exist in SRC.
|
||||
for dst in "$DST_DIR"/*.ts; do
|
||||
[[ -e "$dst" ]] || continue
|
||||
name="$(basename "$dst")"
|
||||
case "$name" in
|
||||
*.test.ts) rm -f "$dst"; echo "removed test artifact: $name" ;;
|
||||
*)
|
||||
if [[ ! -f "$SRC_DIR/$name" ]]; then
|
||||
rm -f "$dst"
|
||||
echo "removed stale: $name"
|
||||
changed=$((changed + 1))
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "$changed" -eq 0 ]]; then
|
||||
echo "codex-imagegen sync: up to date"
|
||||
else
|
||||
echo "codex-imagegen sync: $changed file(s) updated"
|
||||
fi
|
||||
Reference in New Issue
Block a user