Files
skillshare/.devcontainer/setup.sh
T
Willie 474bf3e4c1 feat(devcontainer): standalone lifecycle without VS Code dependency
`make devc` now builds, initialises, and enters the devcontainer in one
step — no VS Code required. A unified `scripts/devc.sh` replaces the old
`devcontainer_shell.sh` with full lifecycle subcommands (up/shell/down/
restart/reset/status).

Key changes:
- Dockerfile Stage 2 copies node+pnpm from ui-builder (removes need for
  devcontainer feature, benefits sandbox playground too)
- profile.d scripts moved from setup.sh → start-dev.sh so they survive
  container recreation (down → up) without re-running full setup
- Volume-based sentinel (~/.devcontainer-initialized) lets devc.sh skip
  setup.sh when volumes persist, cutting restart to ~2s
- Go toolchain PATH added to profile.d (login shell was losing it)
- Makefile/mise.toml gain devc-up/-down/-restart/-reset/-status targets
- Website docs updated with terminal-first flow and CLI path in diagrams
2026-03-03 16:08:11 +08:00

79 lines
4.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Devcontainer post-create setup — mirrors sandbox_playground_up.sh
# for an out-of-the-box demo experience inside VS Code / Codespaces.
#
# Environment assumptions (from docker-compose.yml + devcontainer.json):
# HOME=/tmp | binary at /workspace/bin/skillshare | PATH includes /workspace/bin
set -euo pipefail
if [[ "${HOME:-}" != "/tmp" && "${HOME:-}" != "/home/developer" ]] || [ ! -d /workspace ] || [ ! -f /workspace/go.mod ]; then
echo "Refusing to run: expected devcontainer context (HOME=/tmp or /home/developer, /workspace mounted)." >&2
exit 1
fi
cd /workspace
# ── 0. Container-level setup (profile.d, shortcuts) ──────────────────
# Delegate to start-dev.sh which handles per-start container init.
# This ensures profile.d scripts exist before any login-shell steps below.
/workspace/.devcontainer/start-dev.sh
# ── 1. Build CLI ────────────────────────────────────────────────────
echo "▸ Building skillshare binary …"
make build
# ── 1b. Ensure Linux binary + stable command symlinks ─────────────
echo "▸ Verifying skillshare command targets …"
./.devcontainer/ensure-skillshare-linux-binary.sh
# ── 1c. Install frontend dependencies ─────────────────────────────
echo "▸ Installing UI dependencies …"
(cd /workspace/ui && pnpm install --frozen-lockfile)
echo "▸ Installing website dependencies …"
(cd /workspace/website && pnpm install --frozen-lockfile)
# ── 2. Global mode init ────────────────────────────────────────────
echo "▸ Initializing global mode …"
mkdir -p "$HOME/.claude/skills"
GLOBAL_CFG="$HOME/.config/skillshare/config.yaml"
if [ -f "$GLOBAL_CFG" ]; then
echo " ✓ Already initialized ($GLOBAL_CFG), skipping init"
elif skillshare status -g >/dev/null 2>&1; then
echo " ✓ Already initialized (detected via 'skillshare status -g'), skipping init"
else
skillshare init -g --no-copy --all-targets --no-git --skill
fi
# ── 3. Create demo content (shared with sandbox playground) ───────
echo "▸ Creating demo content …"
SKILLS="$HOME/.config/skillshare/skills"
CFG="$HOME/.config/skillshare"
DEMO="$HOME/demo-project"
/workspace/scripts/create-demo-content.sh "$SKILLS" "$CFG" "$DEMO"
# ── Mark initialisation complete (sentinel on persistent volume) ─────
touch "$HOME/.devcontainer-initialized"
# ── Done ────────────────────────────────────────────────────────────
echo ""
echo "══════════════════════════════════════════════════════════"
echo " Devcontainer ready!"
echo "══════════════════════════════════════════════════════════"
echo ""
echo "Quick start:"
echo " ss status # check current state"
echo " ss list # see all skills"
echo " ui # global-mode dashboard → :5173"
echo " ui -p # project-mode dashboard → :5173"
echo " ui stop # stop dashboard"
echo " docs # documentation site → :3000"
echo " docs stop # stop docs"
echo ""
echo "Private repos:"
echo " credential-helper status # check auth state"
echo " eval \"\$(credential-helper --eval off)\" # disable all auth"
echo " eval \"\$(credential-helper --eval on)\" # restore all auth"
echo ""
echo "Audit playground:"
echo " ss audit # scan all skills, see findings"
echo " cd ~/demo-project && ss audit # project-level scan"