Skip to content

Lint_workspace_config

FieldValue
TypeSkill Resource
Source~/.copilot/skills/architecture/scripts/lint_workspace_config.sh
DescriptionNot specified

Source Content

#!/usr/bin/env bash
# Validate a monorepo workspace config: the JSON parses, and every workspace
# glob/path it declares resolves to a real directory on disk. Pure python3
# stdlib (json module, no external CLI/deps) — there is no off-the-shelf tool
# for "does this workspace glob actually resolve", so this check is 100%
# custom parsing, honestly labeled as such below.
#
# Usage:
# lint_workspace_config.sh [config-file]
#
# With no argument, auto-detects by searching the CWD in this order and using
# whichever is found first: package.json (workspaces field), turbo.json,
# nx.json.
#
# Example:
# scripts/lint_workspace_config.sh ./package.json
# cd my-monorepo && /path/to/lint_workspace_config.sh # auto-detect
set -uo pipefail
fail=0
warn() { printf '⚠️ %s\n' "$1"; }
error() { printf '❌ %s\n' "$1"; fail=1; }
ok() { printf '✅ %s\n' "$1"; }
CONFIG="${1:-}"
if [[ -z "$CONFIG" ]]; then
echo "== auto-detecting workspace config in $(pwd) =="
if [[ -f "package.json" ]]; then
CONFIG="package.json"
elif [[ -f "turbo.json" ]]; then
CONFIG="turbo.json"
elif [[ -f "nx.json" ]]; then
CONFIG="nx.json"
else
echo "Usage: $0 [config-file]" >&2
echo "No package.json, turbo.json, or nx.json found in $(pwd)." >&2
exit 2
fi
ok "auto-detected $CONFIG"
fi
if [[ ! -f "$CONFIG" ]]; then
echo "Usage: $0 [config-file]" >&2
echo "Config file not found: $CONFIG" >&2
exit 2
fi
echo
echo "== JSON validity + workspace path resolution (python3 stdlib json — no external CLI exists for this) =="
py_out=$(python3 "$(dirname "$0")/lint_workspace_config.py" "$CONFIG")
py_status=$?
while IFS= read -r line; do
case "$line" in
OK::*) ok "${line#OK::}" ;;
ERROR::*) error "${line#ERROR::}" ;;
*) [[ -n "$line" ]] && echo "$line" ;;
esac
done <<< "$py_out"
if [[ "$py_status" -ne 0 ]]; then
fail=1
fi
echo
if [[ "$fail" -eq 0 ]]; then
echo "All checks passed."
else
echo "One or more checks failed — see ❌ lines above."
fi
exit "$fail"