#!/bin/sh
# Argos Patchwork Check, Mac collector (read-only).
# Asks macOS for the list of installed apps (name, version, developer) and your macOS version, and saves them
# to patchwork-inventory.json on your Desktop. File locations are blanked out because they can contain your user
# name. It changes nothing, makes no network calls and does not record your computer name or files.
# Open the file in TextEdit to see exactly what it holds. Source and checksum: https://patchwork.intelamation.net/computer/
f="$HOME/Desktop/patchwork-inventory.json"
{
  printf '{"schema":1,"collector":"mac","osVersion":"%s","arch":"%s","at":"%s","profiler":' \
    "$(sw_vers -productVersion)" "$(uname -m)" "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
  system_profiler SPApplicationsDataType -json | sed 's#"path" *: *"[^"]*"#"path" : ""#'
  printf '}'
} > "$f"
echo "Saved patchwork-inventory.json to your Desktop. Drop it on the Patchwork Check page."
