#!/bin/sh

# ==============================================
# Ad-Hoc Code Sign Plugin Script
#
# This script performs **ad-hoc** signing of a macOS plugin 
# using the `codesign` command-line tool.
#
# Usage:
#   ./sign_plugin.sh /path/to/YourPlugin.plugin
#
# Notes:
# - This is for **ad-hoc signing only** (not for distribution).
# - No valid Developer ID certificate is required.
# - Ad-hoc signing is useful for local development, testing, or 
#   satisfying Gatekeeper requirements in some scenarios.
#
# Flags used:
# - -s -            : Performs ad-hoc signing.
# - --timestamp       : Adds a secure timestamp to the signature.
# - --force           : Forces re-signing if the plugin is already signed.
# - --deep            : Recursively signs nested code (e.g., frameworks inside the plugin).
# ==============================================

if [ "$#" -ne 1 ]; then
  echo "Error: No plugin file provided."
  echo "Usage: $0 /path/to/YourPlugin.plugin"
  exit 1
fi

codesign -s - "$1" --timestamp --force --deep
