grafana-datasource/.config/AGENTS/skills/build-plugin.md
/build-plugin
Run this from the root of your plugin directory.
Detect the package manager. Check the packageManager field in package.json first, then fall back to lock file detection:
PKG_MANAGER=$(
if grep -q '"packageManager"' package.json 2>/dev/null; then
grep '"packageManager"' package.json | sed -E 's/.*"packageManager" *: *"([^@]+).*/\1/'
elif [ -f "pnpm-lock.yaml" ]; then
echo "pnpm"
elif [ -f "yarn.lock" ]; then
echo "yarn"
else
echo "npm"
fi
)
Check if the plugin has a backend:
HAS_BACKEND=$(grep -c '"backend" *: *true' src/plugin.json || true)
Build the frontend following the build instructions in .config/AGENTS/instructions.md. For detailed packaging steps refer to the packaging documentation linked there:
${PKG_MANAGER} run build
If the build fails, stop and report the error to the user.
If HAS_BACKEND is non-zero (backend plugin detected), build the backend following the build instructions and packaging documentation linked in .config/AGENTS/instructions.md:
mage with the build targets provided by the Grafana plugin Go SDK:
mage -v
mage is not installed, stop and tell the user: "mage is required to build the backend. Install it from https://magefile.org or run: go install github.com/magefile/mage@latest"dist/ have execute permissions:
chmod 0755 dist/gpx_*