Files
grafana/scripts/validate-npm-packages.sh
Jack Westbrook 23a51ec9c5 CI: Fix frontend package validation (#116104)
* ci(frontend-lint): add frontend package change detection and add validate packed packages lint step

* ci(change-detection): add validate-npm-packages.sh to frontend-packages list

* ci(gh-workflows): add actions globs to frontend-packages detection

* ci(gh-workflows): fix typo - > _

* ci(frontend-lint): add missing needs

* chore(i18n): fix publint erroring for custom condition pointing to .cjs file

* ci(validate-npm-packages): make profile node16 default

* chore(validate-npm-packages): remove shellcheck disable comment
2026-01-12 16:08:32 +01:00

38 lines
1009 B
Bash
Executable File

#!/usr/bin/env bash
set -e
# This script is used to validate the npm packages that are published to npmjs.org are in the correct format.
# It won't catch things like malformed JS or Types but it will assert that the package has
# the correct files and package.json properties.
ARTIFACTS_DIR="./npm-artifacts"
failed_checks=()
for file in "$ARTIFACTS_DIR"/*.tgz; do
echo "🔍 Checking NPM package: $file"
if ! NODE_OPTIONS="-C @grafana-app/source" yarn attw "$file" --ignore-rules "false-cjs" --profile "node16"; then
echo "attw check failed for $file"
echo ""
failed_checks+=("$file - yarn attw")
fi
if ! yarn publint "$file"; then
echo "publint check failed for $file"
echo ""
failed_checks+=("$file - yarn publint")
fi
done
if (( ${#failed_checks[@]} > 0 )); then
echo ""
echo "❌ The following NPM package checks failed:"
for check in "${failed_checks[@]}"; do
echo " - $check"
done
exit 1
fi
echo "🚀 All NPM package checks passed! 🚀"
exit 0