Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128#!/bin/bashset -euo pipefailcd "$(dirname "$0")/../.."unset BASH_ENVroot=$PWDif [[ -z ${PARCEL_DEV_BINARY:-} ]]; then PARCEL_DEV_BINARY=$(Scripts/parcel-dev.sh --path); fiPARCEL_DEV_BINARY=$(realpath "$PARCEL_DEV_BINARY")export PARCEL_DEV_BINARYmkdir -p "$root/.build"work=$(mktemp -d "$root/.build/app-icons-fixture.XXXXXX")trap 'rm -rf "$work"' EXITcount=0check() { if ! "$@"; then printf 'App icon test failed: %s\n' "$*" >&2; exit 1; fi count=$((count + 1))}fails() { if "$@" > "$work/failure.log" 2>&1; then printf 'Expected failure: %s\n' "$*" >&2; return 1; fi}checker="$root/Scripts/check-app-icons.sh"source_icons="$root/Sources/ParcelUI/Resources/AppIcons"check "$checker" --resources "$source_icons"check "$checker" --catalog "$root/Resources/Assets.xcassets/AppIcon.appiconset"check cmp "$source_icons/AppIcon-classic-light.png" "$root/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png"check fails "$checker"check fails "$checker" --resourcescheck fails "$checker" --unknowncheck fails "$checker" --resources "$work/absent"check grep -q 'resource directory missing' "$work/failure.log"mkdir "$work/empty"check fails "$checker" --resources "$work/empty"check grep -q 'App icon missing: AppIcon-classic-light.png' "$work/failure.log"icons="$work/icons with spaces"ditto "$source_icons" "$icons"cp "$icons/AppIcon-classic-light.png" "$icons/AppIcon-retired-light.png"check fails "$checker" --resources "$icons"check grep -q 'Unexpected app icon resource: AppIcon-retired-light.png' "$work/failure.log"rm "$icons/AppIcon-retired-light.png"for name in classic night sunrise patchwork sprout orbit confetti blueprint; do for appearance in light dark tinted; do filename="AppIcon-$name-$appearance.png" mv "$icons/$filename" "$work/held.png" check fails "$checker" --resources "$icons" check grep -Fq "App icon missing: $filename" "$work/failure.log" mv "$work/held.png" "$icons/$filename" donedonefor appearance in light dark tinted; do filename="AppIcon-sprout-$appearance.png" cp "$icons/$filename" "$work/held.png" printf 'not an image\n' > "$icons/$filename" check fails "$checker" --resources "$icons" check grep -Fq "Invalid app icon $filename: not a PNG" "$work/failure.log" cp "$work/held.png" "$icons/$filename" # Keep the real PNG signature and IHDR, but truncate the remaining chunk payload. dd if="$work/held.png" of="$icons/$filename" bs=1 count=40 2>/dev/null check fails "$checker" --resources "$icons" check grep -q 'truncated chunk' "$work/failure.log" cp "$work/held.png" "$icons/$filename" printf '\377' | dd of="$icons/$filename" bs=1 seek=29 conv=notrunc 2>/dev/null check fails "$checker" --resources "$icons" check grep -q 'bad IHDR checksum' "$work/failure.log" cp "$work/held.png" "$icons/$filename"donefilename=AppIcon-orbit-tinted.pngcp "$icons/$filename" "$work/held.png"printf 'trailing bytes' >> "$icons/$filename"check fails "$checker" --resources "$icons"check grep -q 'trailing data' "$work/failure.log"cp "$work/held.png" "$icons/$filename"cp "$icons/AppIcon-classic-light.png" "$icons/$filename"check fails "$checker" --resources "$icons"check grep -q 'Duplicate app icon artwork' "$work/failure.log"cp "$work/held.png" "$icons/$filename"cp "$icons/AppIcon-orbit-light.png" "$icons/$filename"check fails "$checker" --resources "$icons"check grep -q 'Duplicate app icon artwork' "$work/failure.log"cp "$work/held.png" "$icons/$filename"sips -z 128 128 "$work/held.png" --out "$icons/$filename" >/dev/nullcheck fails "$checker" --resources "$icons"check grep -q 'expected a 512px or 1024px square' "$work/failure.log"sips -z 512 1024 "$work/held.png" --out "$icons/$filename" >/dev/nullcheck fails "$checker" --resources "$icons"check grep -q 'expected a 512px or 1024px square' "$work/failure.log"sips -z 512 512 "$work/held.png" --out "$icons/$filename" >/dev/nullcheck "$checker" --resources "$icons"sips -s format jpeg "$work/held.png" --out "$icons/$filename" >/dev/nullcheck fails "$checker" --resources "$icons"check grep -q 'not a PNG' "$work/failure.log"sips -s format png "$icons/$filename" --out "$work/opaque.png" >/dev/nullcp "$work/opaque.png" "$icons/$filename"check fails "$checker" --resources "$icons"check grep -q 'expected rounded corners and a transparent margin' "$work/failure.log"cp "$work/held.png" "$icons/$filename"
# Exercise both SwiftPM layouts, without launching an app or mocking PNG decoding.mkdir -p "$work/project/Scripts" "$work/project/Packaging/AlternateIcons"cp Scripts/product.env Scripts/version.sh Scripts/packaging-paths.sh Scripts/parcel-dev.sh \ Scripts/bundle-preflight.sh Scripts/check-bundle.sh Scripts/check-app-icons.sh "$work/project/Scripts/"cp Packaging/AlternateIcons/IconTool.swift "$work/project/Packaging/AlternateIcons/"app="$work/project/build/Parcel.app"mkdir -p "$app/Contents/Resources"check fails "$checker" "$app"check grep -q 'UI resource bundle missing' "$work/failure.log"bundle="$app/Contents/Resources/Parcel_ParcelUI.bundle"ditto "$icons" "$bundle"check "$checker" "$app"check "$root/Scripts/bundle-preflight.sh" "$app"mv "$bundle" "$work/flat-icons"mkdir -p "$bundle/Contents"mv "$work/flat-icons" "$bundle/Contents/Resources"check "$checker" "$app"check "$root/Scripts/bundle-preflight.sh" "$app"mv "$bundle/Contents/Resources/AppIcon-blueprint-dark.png" "$work/held.png"# Old versions remain safe to replace even though the new release preflight rejects missing artwork.check "$root/Scripts/parcel-dev.sh" bundle-preflight "$app"check fails "$root/Scripts/bundle-preflight.sh" "$app"check grep -q 'App icon missing: AppIcon-blueprint-dark.png' "$work/failure.log"check fails "$work/project/Scripts/check-bundle.sh" --no-launch "$app"check grep -q 'App icon missing: AppIcon-blueprint-dark.png' "$work/failure.log"mv "$work/held.png" "$bundle/Contents/Resources/AppIcon-blueprint-dark.png"# Nested-only icons must not pass: Bundle.module expects flattened filename stems.mkdir "$bundle/Contents/Resources/AppIcons"mv "$bundle/Contents/Resources/AppIcon-night-light.png" "$bundle/Contents/Resources/AppIcons/"check fails "$checker" "$app"check grep -q 'App icon missing: AppIcon-night-light.png' "$work/failure.log"printf 'App icon checks passed: %s\n' "$count"