# The one forced copy inside every product's deployment/build-image.sh: the
# bootstrap that locates this package before it can source anything from it.
# check-drift.ts extracts the find_dev_kit function below and requires it
# verbatim in each product's script (which must also `source` a script from
# this package's build/). The surrounding wrapper is per-product: tag, port,
# and — for studio's sanctioned bespoke build — which build/ script it sources.
find_dev_kit() {
  local dir="$1"
  while [ "${dir}" != "/" ]; do
    if [ -d "${dir}/node_modules/@norskvideo/ctl-dev-kit" ]; then
      printf '%s' "${dir}/node_modules/@norskvideo/ctl-dev-kit"
      return 0
    fi
    dir="$(dirname "${dir}")"
  done
  echo "could not find @norskvideo/ctl-dev-kit — run bun install" >&2
  return 1
}
