#!/usr/bin/env bash
# Lints the project's CSS with design_system_api's drupal-ds rules (tokens only,
# logical properties, known custom properties), the rules that gate the
# provider's own CSS. They live in the provider's tooling/stylelint.
#
#   scripts/drupal-ds-lint [path to a design_system_api checkout]
#
# Default path: ../design_system_api (the workspace's apps/ layout). CI clones
# the provider and passes its path. No finding is allowed; an exception is one
# declaration with a reason:
#   /* stylelint-disable-next-line drupal-ds/<rule> -- <why> */
set -euo pipefail

here="$(cd "$(dirname "$0")/.." && pwd)"
provider="$(cd "${1:-$here/../design_system_api}" && pwd)"
tooling="$provider/tooling/stylelint"
[ -d "$tooling/node_modules" ] || (cd "$tooling" && npm ci --no-audit --no-fund --silent)
cd "$tooling"
exec npx stylelint --config-basedir "$tooling" --config "$here/.stylelintrc.drupal-ds.json" \
  "$here/css/**/*.css"
