···11+#!/bin/sh
22+# Patches link: paths in package.json to point to vendored copies at
33+# $ROOT/vendor/ so pnpm install can resolve them with --frozen-lockfile.
44+#
55+# Also creates a /riotbyte/project-q/packages/ directory tree that
66+# mirrors the layout pnpm's lockfile expects (relative link: targets
77+# resolve to /riotbyte/... inside Docker because the workspace root
88+# is at /app which is only 1 level deep).
99+#
1010+# Usage: patch-vendor-links.sh [workspace-root]
1111+1212+set -e
1313+1414+ROOT="${1:-.}"
1515+1616+# Step 1: Patch package.json specifiers (link:host-path → link:$ROOT/vendor/*)
1717+# pnpm validates specifiers match package.json during --frozen-lockfile
1818+find "$ROOT" -name 'package.json' -not -path '*/node_modules/*' | while read -r f; do
1919+ if grep -q '"link:.*project-q' "$f" 2>/dev/null; then
2020+ sed -i \
2121+ -e "s|\"link:[^\"]*project-q/packages/core\"|\"link:$ROOT/vendor/project-q-core\"|g" \
2222+ -e "s|\"link:[^\"]*project-q/packages/framework/nest\"|\"link:$ROOT/vendor/project-q-nestjs\"|g" \
2323+ -e "s|\"link:[^\"]*project-q/packages/transport/postgres\"|\"link:$ROOT/vendor/project-q-transport-postgres\"|g" \
2424+ "$f"
2525+ echo "Patched $f"
2626+ fi
2727+done
2828+2929+# Step 2: Patch lockfile specifiers to match the package.json changes
3030+# Only patch absolute specifier lines (link:/...), leave relative
3131+# version lines untouched — they resolve via mount points below.
3232+LOCKFILE="$ROOT/pnpm-lock.yaml"
3333+if [ -f "$LOCKFILE" ] && grep -q 'project-q' "$LOCKFILE" 2>/dev/null; then
3434+ sed -i \
3535+ -e "s|link:/[^ ]*project-q/packages/core|link:$ROOT/vendor/project-q-core|g" \
3636+ -e "s|link:/[^ ]*project-q/packages/framework/nest|link:$ROOT/vendor/project-q-nestjs|g" \
3737+ -e "s|link:/[^ ]*project-q/packages/transport/postgres|link:$ROOT/vendor/project-q-transport-postgres|g" \
3838+ "$LOCKFILE"
3939+ echo "Patched $LOCKFILE"
4040+fi
4141+4242+# Step 3: Create mount points so pnpm's relative symlinks resolve correctly.
4343+# Inside Docker, relative link: paths from the lockfile resolve to
4444+# /riotbyte/project-q/packages/* (because the workspace is at /app).
4545+# We create symlinks there pointing to the vendored copies inside the
4646+# workspace tree (at $ROOT/vendor/).
4747+mkdir -p /riotbyte/project-q/packages/framework /riotbyte/project-q/packages/transport
4848+ln -sfn "$ROOT/vendor/project-q-core" /riotbyte/project-q/packages/core
4949+ln -sfn "$ROOT/vendor/project-q-nestjs" /riotbyte/project-q/packages/framework/nest
5050+ln -sfn "$ROOT/vendor/project-q-transport-postgres" /riotbyte/project-q/packages/transport/postgres
5151+echo "Created mount points at /riotbyte/project-q/packages/"
5252+5353+# Step 4: Create root-level node_modules symlinks so vendored packages
5454+# can resolve each other (e.g. transport-postgres depends on core).
5555+# pnpm only creates per-workspace symlinks for link: deps, not at root.
5656+mkdir -p "$ROOT/node_modules/@riotbyte"
5757+ln -sfn "$ROOT/vendor/project-q-core" "$ROOT/node_modules/@riotbyte/project-q-core"
5858+ln -sfn "$ROOT/vendor/project-q-nestjs" "$ROOT/node_modules/@riotbyte/project-q-nestjs"
5959+ln -sfn "$ROOT/vendor/project-q-transport-postgres" "$ROOT/node_modules/@riotbyte/project-q-transport-postgres"
6060+echo "Created root node_modules symlinks for project-q"
+16
.docker/restore-manifests.sh
···11+#!/bin/sh
22+# Restores encoded package.json files back to their original paths.
33+# Reverses the encoding from copy-manifests.sh (__ → /).
44+#
55+# Usage: restore-manifests.sh <manifests-dir>
66+77+set -e
88+99+DIR="${1:-/tmp/manifests}"
1010+1111+for f in "$DIR"/*; do
1212+ [ -f "$f" ] || continue
1313+ original=$(basename "$f" | sed 's|__|/|g')
1414+ mkdir -p "$(dirname "$original")"
1515+ mv "$f" "$original"
1616+done